oleaut32: Convert CustData to use standard linked lists.
[wine.git] / dlls / msxml3 / domimpl.c
blob9743cc6a29592236998d8506c7e90f7e3cc0ee61
1 /*
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
21 #define COBJMACROS
23 #include "config.h"
25 #include <stdarg.h>
26 #ifdef HAVE_LIBXML2
27 # include <libxml/parser.h>
28 # include <libxml/xmlerror.h>
29 #endif
31 #include "windef.h"
32 #include "winbase.h"
33 #include "winuser.h"
34 #include "ole2.h"
35 #include "msxml6.h"
37 #include "msxml_private.h"
39 #include "wine/debug.h"
41 WINE_DEFAULT_DEBUG_CHANNEL(msxml);
43 #ifdef HAVE_LIBXML2
45 typedef struct _domimpl
47 IXMLDOMImplementation IXMLDOMImplementation_iface;
48 LONG ref;
49 } domimpl;
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,
58 REFIID riid,
59 void** ppvObject )
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 ) )
68 *ppvObject = iface;
70 else
72 FIXME("Unsupported interface %s\n", debugstr_guid(riid));
73 *ppvObject = NULL;
74 return E_NOINTERFACE;
77 IXMLDOMImplementation_AddRef( iface );
79 return S_OK;
82 static ULONG WINAPI dimimpl_AddRef(
83 IXMLDOMImplementation *iface )
85 domimpl *This = impl_from_IXMLDOMImplementation( iface );
86 ULONG ref = InterlockedIncrement( &This->ref );
87 TRACE("(%p)->(%d)\n", This, ref);
88 return ref;
91 static ULONG WINAPI dimimpl_Release(
92 IXMLDOMImplementation *iface )
94 domimpl *This = impl_from_IXMLDOMImplementation( iface );
95 ULONG ref = InterlockedDecrement( &This->ref );
97 TRACE("(%p)->(%d)\n", This, ref);
98 if ( ref == 0 )
100 heap_free( This );
103 return ref;
106 static HRESULT WINAPI dimimpl_GetTypeInfoCount(
107 IXMLDOMImplementation *iface,
108 UINT* pctinfo )
110 domimpl *This = impl_from_IXMLDOMImplementation( iface );
112 TRACE("(%p)->(%p)\n", This, pctinfo);
114 *pctinfo = 1;
116 return S_OK;
119 static HRESULT WINAPI dimimpl_GetTypeInfo(
120 IXMLDOMImplementation *iface,
121 UINT iTInfo, LCID lcid,
122 ITypeInfo** ppTInfo )
124 domimpl *This = impl_from_IXMLDOMImplementation( iface );
125 HRESULT hr;
127 TRACE("(%p)->(%u %u %p)\n", This, iTInfo, lcid, ppTInfo);
129 hr = get_typeinfo(IXMLDOMImplementation_tid, ppTInfo);
131 return hr;
134 static HRESULT WINAPI dimimpl_GetIDsOfNames(
135 IXMLDOMImplementation *iface,
136 REFIID riid, LPOLESTR* rgszNames,
137 UINT cNames, LCID lcid, DISPID* rgDispId )
139 domimpl *This = impl_from_IXMLDOMImplementation( iface );
140 ITypeInfo *typeinfo;
141 HRESULT hr;
143 TRACE("(%p)->(%s %p %u %u %p)\n", This, debugstr_guid(riid), rgszNames, cNames,
144 lcid, rgDispId);
146 if(!rgszNames || cNames == 0 || !rgDispId)
147 return E_INVALIDARG;
149 hr = get_typeinfo(IXMLDOMImplementation_tid, &typeinfo);
150 if(SUCCEEDED(hr))
152 hr = ITypeInfo_GetIDsOfNames(typeinfo, rgszNames, cNames, rgDispId);
153 ITypeInfo_Release(typeinfo);
156 return hr;
159 static HRESULT WINAPI dimimpl_Invoke(
160 IXMLDOMImplementation *iface,
161 DISPID dispIdMember, REFIID riid, LCID lcid,
162 WORD wFlags, DISPPARAMS* pDispParams, VARIANT* pVarResult,
163 EXCEPINFO* pExcepInfo, UINT* puArgErr )
165 domimpl *This = impl_from_IXMLDOMImplementation( iface );
166 ITypeInfo *typeinfo;
167 HRESULT hr;
169 TRACE("(%p)->(%d %s %d %d %p %p %p %p)\n", This, dispIdMember, debugstr_guid(riid),
170 lcid, wFlags, pDispParams, pVarResult, pExcepInfo, puArgErr);
172 hr = get_typeinfo(IXMLDOMImplementation_tid, &typeinfo);
173 if(SUCCEEDED(hr))
175 hr = ITypeInfo_Invoke(typeinfo, &This->IXMLDOMImplementation_iface, dispIdMember, wFlags,
176 pDispParams, pVarResult, pExcepInfo, puArgErr);
177 ITypeInfo_Release(typeinfo);
180 return hr;
183 static HRESULT WINAPI dimimpl_hasFeature(IXMLDOMImplementation* This, BSTR feature, BSTR version, VARIANT_BOOL *hasFeature)
185 static const WCHAR bVersion[] = {'1','.','0',0};
186 static const WCHAR bXML[] = {'X','M','L',0};
187 static const WCHAR bDOM[] = {'D','O','M',0};
188 static const WCHAR bMSDOM[] = {'M','S','-','D','O','M',0};
189 BOOL bValidFeature = FALSE;
190 BOOL bValidVersion = FALSE;
192 TRACE("(%p)->(%s %s %p)\n", This, debugstr_w(feature), debugstr_w(version), hasFeature);
194 if(!feature || !hasFeature)
195 return E_INVALIDARG;
197 *hasFeature = VARIANT_FALSE;
199 if(!version || lstrcmpiW(version, bVersion) == 0)
200 bValidVersion = TRUE;
202 if(lstrcmpiW(feature, bXML) == 0 || lstrcmpiW(feature, bDOM) == 0 || lstrcmpiW(feature, bMSDOM) == 0)
203 bValidFeature = TRUE;
205 if(bValidVersion && bValidFeature)
206 *hasFeature = VARIANT_TRUE;
208 return S_OK;
211 static const struct IXMLDOMImplementationVtbl dimimpl_vtbl =
213 dimimpl_QueryInterface,
214 dimimpl_AddRef,
215 dimimpl_Release,
216 dimimpl_GetTypeInfoCount,
217 dimimpl_GetTypeInfo,
218 dimimpl_GetIDsOfNames,
219 dimimpl_Invoke,
220 dimimpl_hasFeature
223 IUnknown* create_doc_Implementation(void)
225 domimpl *This;
227 This = heap_alloc( sizeof *This );
228 if ( !This )
229 return NULL;
231 This->IXMLDOMImplementation_iface.lpVtbl = &dimimpl_vtbl;
232 This->ref = 1;
234 return (IUnknown*)&This->IXMLDOMImplementation_iface;
237 #endif