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"
41 WINE_DEFAULT_DEBUG_CHANNEL(msxml);
45 typedef struct _domimpl
47 IXMLDOMImplementation IXMLDOMImplementation_iface;
51 static inline domimpl *impl_from_IXMLDOMImplementation( IXMLDOMImplementation *iface )
53 return CONTAINING_RECORD(iface, domimpl, IXMLDOMImplementation_iface);
56 static HRESULT WINAPI dimimpl_QueryInterface(
57 IXMLDOMImplementation *iface,
61 domimpl *This = impl_from_IXMLDOMImplementation( iface );
62 TRACE("(%p)->(%s %p)\n", This, debugstr_guid(riid), ppvObject);
64 if ( IsEqualGUID( riid, &IID_IXMLDOMImplementation ) ||
65 IsEqualGUID( riid, &IID_IDispatch ) ||
66 IsEqualGUID( riid, &IID_IUnknown ) )
72 FIXME("Unsupported interface %s\n", debugstr_guid(riid));
77 IXMLDOMImplementation_AddRef( iface );
82 static ULONG WINAPI dimimpl_AddRef(
83 IXMLDOMImplementation *iface )
85 domimpl *This = impl_from_IXMLDOMImplementation( iface );
86 return InterlockedIncrement( &This->ref );
89 static ULONG WINAPI dimimpl_Release(
90 IXMLDOMImplementation *iface )
92 domimpl *This = impl_from_IXMLDOMImplementation( iface );
95 ref = InterlockedDecrement( &This->ref );
104 static HRESULT WINAPI dimimpl_GetTypeInfoCount(
105 IXMLDOMImplementation *iface,
108 domimpl *This = impl_from_IXMLDOMImplementation( iface );
110 TRACE("(%p)->(%p)\n", This, 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 );
125 TRACE("(%p)->(%u %u %p)\n", This, iTInfo, lcid, ppTInfo);
127 hr = get_typeinfo(IXMLDOMImplementation_tid, ppTInfo);
132 static HRESULT WINAPI dimimpl_GetIDsOfNames(
133 IXMLDOMImplementation *iface,
134 REFIID riid, LPOLESTR* rgszNames,
135 UINT cNames, LCID lcid, DISPID* rgDispId )
137 domimpl *This = impl_from_IXMLDOMImplementation( iface );
141 TRACE("(%p)->(%s %p %u %u %p)\n", This, debugstr_guid(riid), rgszNames, cNames,
144 if(!rgszNames || cNames == 0 || !rgDispId)
147 hr = get_typeinfo(IXMLDOMImplementation_tid, &typeinfo);
150 hr = ITypeInfo_GetIDsOfNames(typeinfo, rgszNames, cNames, rgDispId);
151 ITypeInfo_Release(typeinfo);
157 static HRESULT WINAPI dimimpl_Invoke(
158 IXMLDOMImplementation *iface,
159 DISPID dispIdMember, REFIID riid, LCID lcid,
160 WORD wFlags, DISPPARAMS* pDispParams, VARIANT* pVarResult,
161 EXCEPINFO* pExcepInfo, UINT* puArgErr )
163 domimpl *This = impl_from_IXMLDOMImplementation( iface );
167 TRACE("(%p)->(%d %s %d %d %p %p %p %p)\n", This, dispIdMember, debugstr_guid(riid),
168 lcid, wFlags, pDispParams, pVarResult, pExcepInfo, puArgErr);
170 hr = get_typeinfo(IXMLDOMImplementation_tid, &typeinfo);
173 hr = ITypeInfo_Invoke(typeinfo, &This->IXMLDOMImplementation_iface, dispIdMember, wFlags,
174 pDispParams, pVarResult, pExcepInfo, puArgErr);
175 ITypeInfo_Release(typeinfo);
181 static HRESULT WINAPI dimimpl_hasFeature(IXMLDOMImplementation* This, BSTR feature, BSTR version, VARIANT_BOOL *hasFeature)
183 static const WCHAR bVersion[] = {'1','.','0',0};
184 static const WCHAR bXML[] = {'X','M','L',0};
185 static const WCHAR bDOM[] = {'D','O','M',0};
186 static const WCHAR bMSDOM[] = {'M','S','-','D','O','M',0};
187 BOOL bValidFeature = FALSE;
188 BOOL bValidVersion = FALSE;
190 TRACE("(%p)->(%s %s %p)\n", This, debugstr_w(feature), debugstr_w(version), hasFeature);
192 if(!feature || !hasFeature)
195 *hasFeature = VARIANT_FALSE;
197 if(!version || lstrcmpiW(version, bVersion) == 0)
198 bValidVersion = TRUE;
200 if(lstrcmpiW(feature, bXML) == 0 || lstrcmpiW(feature, bDOM) == 0 || lstrcmpiW(feature, bMSDOM) == 0)
201 bValidFeature = TRUE;
203 if(bValidVersion && bValidFeature)
204 *hasFeature = VARIANT_TRUE;
209 static const struct IXMLDOMImplementationVtbl dimimpl_vtbl =
211 dimimpl_QueryInterface,
214 dimimpl_GetTypeInfoCount,
216 dimimpl_GetIDsOfNames,
221 IUnknown* create_doc_Implementation(void)
225 This = heap_alloc( sizeof *This );
229 This->IXMLDOMImplementation_iface.lpVtbl = &dimimpl_vtbl;
232 return (IUnknown*)&This->IXMLDOMImplementation_iface;