2 * DOM Document Implementation implementation
4 * Copyright 2007 Alistair Leslie-Hughes
6 * This library is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU Lesser General Public
8 * License as published by the Free Software Foundation; either
9 * version 2.1 of the License, or (at your option) any later version.
11 * This library is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * Lesser General Public License for more details.
16 * You should have received a copy of the GNU Lesser General Public
17 * License along with this library; if not, write to the Free Software
18 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
27 # include <libxml/parser.h>
28 # include <libxml/xmlerror.h>
37 #include "msxml_private.h"
39 #include "wine/debug.h"
43 WINE_DEFAULT_DEBUG_CHANNEL(msxml
);
45 typedef struct _domimpl
48 IXMLDOMImplementation IXMLDOMImplementation_iface
;
52 static inline domimpl
*impl_from_IXMLDOMImplementation( IXMLDOMImplementation
*iface
)
54 return CONTAINING_RECORD(iface
, domimpl
, IXMLDOMImplementation_iface
);
57 static HRESULT WINAPI
dimimpl_QueryInterface(
58 IXMLDOMImplementation
*iface
,
62 domimpl
*This
= impl_from_IXMLDOMImplementation( iface
);
63 TRACE("(%p)->(%s %p)\n", This
, debugstr_guid(riid
), ppvObject
);
65 if ( IsEqualGUID( riid
, &IID_IXMLDOMImplementation
) ||
66 IsEqualGUID( riid
, &IID_IDispatch
) ||
67 IsEqualGUID( riid
, &IID_IUnknown
) )
71 else if (dispex_query_interface(&This
->dispex
, riid
, ppvObject
))
73 return *ppvObject
? S_OK
: E_NOINTERFACE
;
77 TRACE("Unsupported interface %s\n", debugstr_guid(riid
));
82 IXMLDOMImplementation_AddRef( iface
);
87 static ULONG WINAPI
dimimpl_AddRef(
88 IXMLDOMImplementation
*iface
)
90 domimpl
*This
= impl_from_IXMLDOMImplementation( iface
);
91 ULONG ref
= InterlockedIncrement( &This
->ref
);
92 TRACE("(%p)->(%d)\n", This
, ref
);
96 static ULONG WINAPI
dimimpl_Release(
97 IXMLDOMImplementation
*iface
)
99 domimpl
*This
= impl_from_IXMLDOMImplementation( iface
);
100 ULONG ref
= InterlockedDecrement( &This
->ref
);
102 TRACE("(%p)->(%d)\n", This
, ref
);
109 static HRESULT WINAPI
dimimpl_GetTypeInfoCount(
110 IXMLDOMImplementation
*iface
,
113 domimpl
*This
= impl_from_IXMLDOMImplementation( iface
);
114 return IDispatchEx_GetTypeInfoCount(&This
->dispex
.IDispatchEx_iface
, pctinfo
);
117 static HRESULT WINAPI
dimimpl_GetTypeInfo(
118 IXMLDOMImplementation
*iface
,
119 UINT iTInfo
, LCID lcid
,
120 ITypeInfo
** ppTInfo
)
122 domimpl
*This
= impl_from_IXMLDOMImplementation( iface
);
123 return IDispatchEx_GetTypeInfo(&This
->dispex
.IDispatchEx_iface
,
124 iTInfo
, lcid
, ppTInfo
);
127 static HRESULT WINAPI
dimimpl_GetIDsOfNames(
128 IXMLDOMImplementation
*iface
,
129 REFIID riid
, LPOLESTR
* rgszNames
,
130 UINT cNames
, LCID lcid
, DISPID
* rgDispId
)
132 domimpl
*This
= impl_from_IXMLDOMImplementation( iface
);
133 return IDispatchEx_GetIDsOfNames(&This
->dispex
.IDispatchEx_iface
,
134 riid
, rgszNames
, cNames
, lcid
, rgDispId
);
137 static HRESULT WINAPI
dimimpl_Invoke(
138 IXMLDOMImplementation
*iface
,
139 DISPID dispIdMember
, REFIID riid
, LCID lcid
,
140 WORD wFlags
, DISPPARAMS
* pDispParams
, VARIANT
* pVarResult
,
141 EXCEPINFO
* pExcepInfo
, UINT
* puArgErr
)
143 domimpl
*This
= impl_from_IXMLDOMImplementation( iface
);
144 return IDispatchEx_Invoke(&This
->dispex
.IDispatchEx_iface
,
145 dispIdMember
, riid
, lcid
, wFlags
, pDispParams
, pVarResult
, pExcepInfo
, puArgErr
);
148 static HRESULT WINAPI
dimimpl_hasFeature(IXMLDOMImplementation
* This
, BSTR feature
, BSTR version
, VARIANT_BOOL
*hasFeature
)
150 static const WCHAR bVersion
[] = {'1','.','0',0};
151 static const WCHAR bXML
[] = {'X','M','L',0};
152 static const WCHAR bDOM
[] = {'D','O','M',0};
153 static const WCHAR bMSDOM
[] = {'M','S','-','D','O','M',0};
154 BOOL bValidFeature
= FALSE
;
155 BOOL bValidVersion
= FALSE
;
157 TRACE("(%p)->(%s %s %p)\n", This
, debugstr_w(feature
), debugstr_w(version
), hasFeature
);
159 if(!feature
|| !hasFeature
)
162 *hasFeature
= VARIANT_FALSE
;
164 if(!version
|| lstrcmpiW(version
, bVersion
) == 0)
165 bValidVersion
= TRUE
;
167 if(lstrcmpiW(feature
, bXML
) == 0 || lstrcmpiW(feature
, bDOM
) == 0 || lstrcmpiW(feature
, bMSDOM
) == 0)
168 bValidFeature
= TRUE
;
170 if(bValidVersion
&& bValidFeature
)
171 *hasFeature
= VARIANT_TRUE
;
176 static const struct IXMLDOMImplementationVtbl dimimpl_vtbl
=
178 dimimpl_QueryInterface
,
181 dimimpl_GetTypeInfoCount
,
183 dimimpl_GetIDsOfNames
,
188 static const tid_t dimimpl_iface_tids
[] = {
189 IXMLDOMImplementation_tid
,
193 static dispex_static_data_t dimimpl_dispex
= {
195 IXMLDOMImplementation_tid
,
200 IUnknown
* create_doc_Implementation(void)
204 This
= heap_alloc( sizeof *This
);
208 This
->IXMLDOMImplementation_iface
.lpVtbl
= &dimimpl_vtbl
;
210 init_dispex(&This
->dispex
, (IUnknown
*)&This
->IXMLDOMImplementation_iface
, &dimimpl_dispex
);
212 return (IUnknown
*)&This
->IXMLDOMImplementation_iface
;