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));
76 IXMLDOMImplementation_AddRef( iface );
81 static ULONG WINAPI dimimpl_AddRef(
82 IXMLDOMImplementation *iface )
84 domimpl *This = impl_from_IXMLDOMImplementation( iface );
85 return InterlockedIncrement( &This->ref );
88 static ULONG WINAPI dimimpl_Release(
89 IXMLDOMImplementation *iface )
91 domimpl *This = impl_from_IXMLDOMImplementation( iface );
94 ref = InterlockedDecrement( &This->ref );
103 static HRESULT WINAPI dimimpl_GetTypeInfoCount(
104 IXMLDOMImplementation *iface,
107 domimpl *This = impl_from_IXMLDOMImplementation( iface );
109 TRACE("(%p)->(%p)\n", This, pctinfo);
116 static HRESULT WINAPI dimimpl_GetTypeInfo(
117 IXMLDOMImplementation *iface,
118 UINT iTInfo, LCID lcid,
119 ITypeInfo** ppTInfo )
121 domimpl *This = impl_from_IXMLDOMImplementation( iface );
124 TRACE("(%p)->(%u %u %p)\n", This, iTInfo, lcid, ppTInfo);
126 hr = get_typeinfo(IXMLDOMImplementation_tid, ppTInfo);
131 static HRESULT WINAPI dimimpl_GetIDsOfNames(
132 IXMLDOMImplementation *iface,
133 REFIID riid, LPOLESTR* rgszNames,
134 UINT cNames, LCID lcid, DISPID* rgDispId )
136 domimpl *This = impl_from_IXMLDOMImplementation( iface );
140 TRACE("(%p)->(%s %p %u %u %p)\n", This, debugstr_guid(riid), rgszNames, cNames,
143 if(!rgszNames || cNames == 0 || !rgDispId)
146 hr = get_typeinfo(IXMLDOMImplementation_tid, &typeinfo);
149 hr = ITypeInfo_GetIDsOfNames(typeinfo, rgszNames, cNames, rgDispId);
150 ITypeInfo_Release(typeinfo);
156 static HRESULT WINAPI dimimpl_Invoke(
157 IXMLDOMImplementation *iface,
158 DISPID dispIdMember, REFIID riid, LCID lcid,
159 WORD wFlags, DISPPARAMS* pDispParams, VARIANT* pVarResult,
160 EXCEPINFO* pExcepInfo, UINT* puArgErr )
162 domimpl *This = impl_from_IXMLDOMImplementation( iface );
166 TRACE("(%p)->(%d %s %d %d %p %p %p %p)\n", This, dispIdMember, debugstr_guid(riid),
167 lcid, wFlags, pDispParams, pVarResult, pExcepInfo, puArgErr);
169 hr = get_typeinfo(IXMLDOMImplementation_tid, &typeinfo);
172 hr = ITypeInfo_Invoke(typeinfo, &This->IXMLDOMImplementation_iface, dispIdMember, wFlags,
173 pDispParams, pVarResult, pExcepInfo, puArgErr);
174 ITypeInfo_Release(typeinfo);
180 static HRESULT WINAPI dimimpl_hasFeature(IXMLDOMImplementation* This, BSTR feature, BSTR version, VARIANT_BOOL *hasFeature)
182 static const WCHAR bVersion[] = {'1','.','0',0};
183 static const WCHAR bXML[] = {'X','M','L',0};
184 static const WCHAR bDOM[] = {'D','O','M',0};
185 static const WCHAR bMSDOM[] = {'M','S','-','D','O','M',0};
186 BOOL bValidFeature = FALSE;
187 BOOL bValidVersion = FALSE;
189 TRACE("(%p)->(%s %s %p)\n", This, debugstr_w(feature), debugstr_w(version), hasFeature);
191 if(!feature || !hasFeature)
194 *hasFeature = VARIANT_FALSE;
196 if(!version || lstrcmpiW(version, bVersion) == 0)
197 bValidVersion = TRUE;
199 if(lstrcmpiW(feature, bXML) == 0 || lstrcmpiW(feature, bDOM) == 0 || lstrcmpiW(feature, bMSDOM) == 0)
200 bValidFeature = TRUE;
202 if(bValidVersion && bValidFeature)
203 *hasFeature = VARIANT_TRUE;
208 static const struct IXMLDOMImplementationVtbl dimimpl_vtbl =
210 dimimpl_QueryInterface,
213 dimimpl_GetTypeInfoCount,
215 dimimpl_GetIDsOfNames,
220 IUnknown* create_doc_Implementation(void)
224 This = heap_alloc( sizeof *This );
228 This->IXMLDOMImplementation_iface.lpVtbl = &dimimpl_vtbl;
231 return (IUnknown*)&This->IXMLDOMImplementation_iface;