4 * Copyright 2002 Lionel Ulmer
5 * Copyright 2005 Mike McCormack
7 * This library is free software; you can redistribute it and/or
8 * modify it under the terms of the GNU Lesser General Public
9 * License as published by the Free Software Foundation; either
10 * version 2.1 of the License, or (at your option) any later version.
12 * This library is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 * Lesser General Public License for more details.
17 * You should have received a copy of the GNU Lesser General Public
18 * License along with this library; if not, write to the Free Software
19 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
28 # include <libxml/parser.h>
29 # include <libxml/xmlerror.h>
39 /* undef the #define in msxml2 so that we can access the v.2 version
40 independent CLSID as well as the v.3 one. */
41 #undef CLSID_DOMDocument
43 #include "wine/debug.h"
45 #include "msxml_private.h"
47 WINE_DEFAULT_DEBUG_CHANNEL(msxml);
49 typedef HRESULT (*ClassFactoryCreateInstanceFunc)(IUnknown *pUnkOuter, LPVOID *ppObj);
50 typedef HRESULT (*DOMFactoryCreateInstanceFunc)(const GUID *clsid, IUnknown *pUnkOuter, LPVOID *ppObj);
52 /******************************************************************************
57 const struct IClassFactoryVtbl *lpVtbl;
58 ClassFactoryCreateInstanceFunc pCreateInstance;
63 const struct IClassFactoryVtbl *lpVtbl;
65 DOMFactoryCreateInstanceFunc pCreateInstance;
69 static HRESULT WINAPI ClassFactory_QueryInterface(
74 if (IsEqualGUID(riid, &IID_IUnknown) ||
75 IsEqualGUID(riid, &IID_IClassFactory))
77 IClassFactory_AddRef( iface );
82 FIXME("interface %s not implemented\n", debugstr_guid(riid));
86 static ULONG WINAPI ClassFactory_AddRef(IClassFactory *iface )
91 static ULONG WINAPI ClassFactory_Release(IClassFactory *iface )
96 static HRESULT WINAPI ClassFactory_CreateInstance(
102 ClassFactory *This = (ClassFactory*)iface;
106 TRACE("%p %s %p\n", pOuter, debugstr_guid(riid), ppobj );
111 return CLASS_E_NOAGGREGATION;
113 r = This->pCreateInstance( pOuter, (void**) &punk );
117 r = IUnknown_QueryInterface( punk, riid, ppobj );
118 IUnknown_Release( punk );
122 static HRESULT WINAPI ClassFactory_LockServer(
123 IClassFactory *iface,
126 FIXME("(%p)->(%d),stub!\n",iface,dolock);
130 static ULONG WINAPI DOMClassFactory_AddRef(IClassFactory *iface )
132 DOMFactory *This = (DOMFactory*)iface;
133 ULONG ref = InterlockedIncrement(&This->ref);
134 TRACE("(%p) ref = %u\n", This, ref);
138 static ULONG WINAPI DOMClassFactory_Release(IClassFactory *iface )
140 DOMFactory *This = (DOMFactory*)iface;
141 ULONG ref = InterlockedDecrement(&This->ref);
142 TRACE("(%p) ref = %u\n", This, ref);
149 static HRESULT WINAPI DOMClassFactory_CreateInstance(
150 IClassFactory *iface,
155 DOMFactory *This = (DOMFactory*)iface;
159 TRACE("%p %s %p\n", pOuter, debugstr_guid(riid), ppobj );
164 return CLASS_E_NOAGGREGATION;
166 r = This->pCreateInstance( &This->clsid, pOuter, (void**) &punk );
170 r = IUnknown_QueryInterface( punk, riid, ppobj );
171 IUnknown_Release( punk );
175 static const struct IClassFactoryVtbl ClassFactoryVtbl =
177 ClassFactory_QueryInterface,
179 ClassFactory_Release,
180 ClassFactory_CreateInstance,
181 ClassFactory_LockServer
184 static const struct IClassFactoryVtbl DOMClassFactoryVtbl =
186 ClassFactory_QueryInterface,
187 DOMClassFactory_AddRef,
188 DOMClassFactory_Release,
189 DOMClassFactory_CreateInstance,
190 ClassFactory_LockServer
193 static HRESULT DOMClassFactory_Create(const GUID *clsid, REFIID riid, void **ppv, DOMFactoryCreateInstanceFunc fnCreateInstance)
195 DOMFactory *ret = heap_alloc(sizeof(DOMFactory));
198 ret->lpVtbl = &DOMClassFactoryVtbl;
201 ret->pCreateInstance = fnCreateInstance;
203 hres = IClassFactory_QueryInterface((IClassFactory*)ret, riid, ppv);
211 static ClassFactory xmldoccf = { &ClassFactoryVtbl, XMLDocument_create };
212 static ClassFactory saxreadcf = { &ClassFactoryVtbl, SAXXMLReader_create };
213 static ClassFactory httpreqcf = { &ClassFactoryVtbl, XMLHTTPRequest_create };
214 static ClassFactory xsltemplatecf = { &ClassFactoryVtbl, XSLTemplate_create };
216 /******************************************************************
217 * DllGetClassObject (MSXML3.@)
219 HRESULT WINAPI DllGetClassObject( REFCLSID rclsid, REFIID riid, void **ppv )
221 IClassFactory *cf = NULL;
223 TRACE("%s %s %p\n", debugstr_guid(rclsid), debugstr_guid(riid), ppv );
225 if( IsEqualCLSID( rclsid, &CLSID_DOMDocument ) || /* Version indep. v 2.x */
226 IsEqualCLSID( rclsid, &CLSID_DOMDocument2 ) || /* Version indep. v 3.0 */
227 IsEqualCLSID( rclsid, &CLSID_DOMDocument26 )|| /* Version dep. v 2.6 */
228 IsEqualCLSID( rclsid, &CLSID_DOMDocument30 )|| /* Version dep. v 3.0 */
229 IsEqualCLSID( rclsid, &CLSID_DOMDocument40 )|| /* Version dep. v 4.0 */
230 IsEqualCLSID( rclsid, &CLSID_DOMDocument60 )) /* Version dep. v 6.0 */
232 return DOMClassFactory_Create(rclsid, riid, ppv, DOMDocument_create);
234 else if( IsEqualCLSID( rclsid, &CLSID_XMLSchemaCache ) ||
235 IsEqualCLSID( rclsid, &CLSID_XMLSchemaCache26 ) ||
236 IsEqualCLSID( rclsid, &CLSID_XMLSchemaCache30 ) ||
237 IsEqualCLSID( rclsid, &CLSID_XMLSchemaCache40 ) ||
238 IsEqualCLSID( rclsid, &CLSID_XMLSchemaCache60 ))
240 return DOMClassFactory_Create(rclsid, riid, ppv, SchemaCache_create);
242 else if( IsEqualCLSID( rclsid, &CLSID_XMLDocument ) )
244 cf = (IClassFactory*) &xmldoccf.lpVtbl;
246 else if( IsEqualCLSID( rclsid, &CLSID_DOMFreeThreadedDocument ) || /* Version indep. v 2.x */
247 IsEqualCLSID( rclsid, &CLSID_FreeThreadedDOMDocument ) ||
248 IsEqualCLSID( rclsid, &CLSID_FreeThreadedDOMDocument26 ) ||
249 IsEqualCLSID( rclsid, &CLSID_FreeThreadedDOMDocument30 ) ||
250 IsEqualCLSID( rclsid, &CLSID_FreeThreadedDOMDocument40 ) ||
251 IsEqualCLSID( rclsid, &CLSID_FreeThreadedDOMDocument60 ))
253 return DOMClassFactory_Create(rclsid, riid, ppv, DOMDocument_create);
255 else if( IsEqualCLSID( rclsid, &CLSID_SAXXMLReader) ||
256 IsEqualCLSID( rclsid, &CLSID_SAXXMLReader30 ) ||
257 IsEqualCLSID( rclsid, &CLSID_SAXXMLReader40 ) ||
258 IsEqualCLSID( rclsid, &CLSID_SAXXMLReader60 ))
260 cf = (IClassFactory*) &saxreadcf.lpVtbl;
262 else if( IsEqualCLSID( rclsid, &CLSID_XMLHTTPRequest ) ||
263 IsEqualCLSID( rclsid, &CLSID_XMLHTTP26 ) ||
264 IsEqualCLSID( rclsid, &CLSID_XMLHTTP30 ) ||
265 IsEqualCLSID( rclsid, &CLSID_XMLHTTP40 ) ||
266 IsEqualCLSID( rclsid, &CLSID_XMLHTTP60 ))
268 cf = (IClassFactory*) &httpreqcf.lpVtbl;
270 else if( IsEqualCLSID( rclsid, &CLSID_XSLTemplate ) ||
271 IsEqualCLSID( rclsid, &CLSID_XSLTemplate26 ) ||
272 IsEqualCLSID( rclsid, &CLSID_XSLTemplate30 ) ||
273 IsEqualCLSID( rclsid, &CLSID_XSLTemplate40 ) ||
274 IsEqualCLSID( rclsid, &CLSID_XSLTemplate60 ))
276 cf = (IClassFactory*) &xsltemplatecf.lpVtbl;
280 return CLASS_E_CLASSNOTAVAILABLE;
282 return IClassFactory_QueryInterface( cf, riid, ppv );