1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
/*
* DOM Document Implementation implementation
*
* Copyright 2007 Alistair Leslie-Hughes
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
*/
#define COBJMACROS
#include "config.h"
#include <stdarg.h>
#ifdef HAVE_LIBXML2
# include <libxml/parser.h>
# include <libxml/xmlerror.h>
#endif
#include "windef.h"
#include "winbase.h"
#include "winuser.h"
#include "ole2.h"
#include "msxml6.h"
#include "msxml_private.h"
#include "wine/debug.h"
WINE_DEFAULT_DEBUG_CHANNEL(msxml);
#ifdef HAVE_LIBXML2
typedef struct _domimpl
{
DispatchEx dispex;
IXMLDOMImplementation IXMLDOMImplementation_iface;
LONG ref;
} domimpl;
static inline domimpl *impl_from_IXMLDOMImplementation( IXMLDOMImplementation *iface )
{
return CONTAINING_RECORD(iface, domimpl, IXMLDOMImplementation_iface);
}
static HRESULT WINAPI dimimpl_QueryInterface(
IXMLDOMImplementation *iface,
REFIID riid,
void** ppvObject )
{
domimpl *This = impl_from_IXMLDOMImplementation( iface );
TRACE("(%p)->(%s %p)\n", This, debugstr_guid(riid), ppvObject);
if ( IsEqualGUID( riid, &IID_IXMLDOMImplementation ) ||
IsEqualGUID( riid, &IID_IDispatch ) ||
IsEqualGUID( riid, &IID_IUnknown ) )
{
*ppvObject = iface;
}
else if (dispex_query_interface(&This->dispex, riid, ppvObject))
{
return *ppvObject ? S_OK : E_NOINTERFACE;
}
else
{
TRACE("Unsupported interface %s\n", debugstr_guid(riid));
*ppvObject = NULL;
return E_NOINTERFACE;
}
IXMLDOMImplementation_AddRef( iface );
return S_OK;
}
static ULONG WINAPI dimimpl_AddRef(
IXMLDOMImplementation *iface )
{
domimpl *This = impl_from_IXMLDOMImplementation( iface );
ULONG ref = InterlockedIncrement( &This->ref );
TRACE("(%p)->(%d)\n", This, ref);
return ref;
}
static ULONG WINAPI dimimpl_Release(
IXMLDOMImplementation *iface )
{
domimpl *This = impl_from_IXMLDOMImplementation( iface );
ULONG ref = InterlockedDecrement( &This->ref );
TRACE("(%p)->(%d)\n", This, ref);
if ( ref == 0 )
{
release_dispex(&This->dispex);
heap_free( This );
}
return ref;
}
static HRESULT WINAPI dimimpl_GetTypeInfoCount(
IXMLDOMImplementation *iface,
UINT* pctinfo )
{
domimpl *This = impl_from_IXMLDOMImplementation( iface );
return IDispatchEx_GetTypeInfoCount(&This->dispex.IDispatchEx_iface, pctinfo);
}
static HRESULT WINAPI dimimpl_GetTypeInfo(
IXMLDOMImplementation *iface,
UINT iTInfo, LCID lcid,
ITypeInfo** ppTInfo )
{
domimpl *This = impl_from_IXMLDOMImplementation( iface );
return IDispatchEx_GetTypeInfo(&This->dispex.IDispatchEx_iface,
iTInfo, lcid, ppTInfo);
}
static HRESULT WINAPI dimimpl_GetIDsOfNames(
IXMLDOMImplementation *iface,
REFIID riid, LPOLESTR* rgszNames,
UINT cNames, LCID lcid, DISPID* rgDispId )
{
domimpl *This = impl_from_IXMLDOMImplementation( iface );
return IDispatchEx_GetIDsOfNames(&This->dispex.IDispatchEx_iface,
riid, rgszNames, cNames, lcid, rgDispId);
}
static HRESULT WINAPI dimimpl_Invoke(
IXMLDOMImplementation *iface,
DISPID dispIdMember, REFIID riid, LCID lcid,
WORD wFlags, DISPPARAMS* pDispParams, VARIANT* pVarResult,
EXCEPINFO* pExcepInfo, UINT* puArgErr )
{
domimpl *This = impl_from_IXMLDOMImplementation( iface );
return IDispatchEx_Invoke(&This->dispex.IDispatchEx_iface,
dispIdMember, riid, lcid, wFlags, pDispParams, pVarResult, pExcepInfo, puArgErr);
}
static HRESULT WINAPI dimimpl_hasFeature(IXMLDOMImplementation* This, BSTR feature, BSTR version, VARIANT_BOOL *hasFeature)
{
static const WCHAR bVersion[] = {'1','.','0',0};
static const WCHAR bXML[] = {'X','M','L',0};
static const WCHAR bDOM[] = {'D','O','M',0};
static const WCHAR bMSDOM[] = {'M','S','-','D','O','M',0};
BOOL bValidFeature = FALSE;
BOOL bValidVersion = FALSE;
TRACE("(%p)->(%s %s %p)\n", This, debugstr_w(feature), debugstr_w(version), hasFeature);
if(!feature || !hasFeature)
return E_INVALIDARG;
*hasFeature = VARIANT_FALSE;
if(!version || lstrcmpiW(version, bVersion) == 0)
bValidVersion = TRUE;
if(lstrcmpiW(feature, bXML) == 0 || lstrcmpiW(feature, bDOM) == 0 || lstrcmpiW(feature, bMSDOM) == 0)
bValidFeature = TRUE;
if(bValidVersion && bValidFeature)
*hasFeature = VARIANT_TRUE;
return S_OK;
}
static const struct IXMLDOMImplementationVtbl dimimpl_vtbl =
{
dimimpl_QueryInterface,
dimimpl_AddRef,
dimimpl_Release,
dimimpl_GetTypeInfoCount,
dimimpl_GetTypeInfo,
dimimpl_GetIDsOfNames,
dimimpl_Invoke,
dimimpl_hasFeature
};
static const tid_t dimimpl_iface_tids[] = {
IXMLDOMImplementation_tid,
0
};
static dispex_static_data_t dimimpl_dispex = {
NULL,
IXMLDOMImplementation_tid,
NULL,
dimimpl_iface_tids
};
IUnknown* create_doc_Implementation(void)
{
domimpl *This;
This = heap_alloc( sizeof *This );
if ( !This )
return NULL;
This->IXMLDOMImplementation_iface.lpVtbl = &dimimpl_vtbl;
This->ref = 1;
init_dispex(&This->dispex, (IUnknown*)&This->IXMLDOMImplementation_iface, &dimimpl_dispex);
return (IUnknown*)&This->IXMLDOMImplementation_iface;
}
#endif