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
35 /* undef the #define in msxml2 so that we can access the v.2 version
36 independent CLSID as well as the v.3 one. */
37 #undef CLSID_DOMDocument
39 #include "wine/debug.h"
41 #include "msxml_private.h"
43 WINE_DEFAULT_DEBUG_CHANNEL(msxml);
45 typedef HRESULT (*fnCreateInstance)(IUnknown *pUnkOuter, LPVOID *ppObj);
47 /******************************************************************************
52 const struct IClassFactoryVtbl *lpVtbl;
53 fnCreateInstance pfnCreateInstance;
56 static inline xmlcf *impl_from_IClassFactory( IClassFactory *iface )
58 return (xmlcf *)((char*)iface - FIELD_OFFSET(xmlcf, lpVtbl));
61 static HRESULT WINAPI xmlcf_QueryInterface(
66 if (IsEqualGUID(riid, &IID_IUnknown) ||
67 IsEqualGUID(riid, &IID_IClassFactory))
69 IClassFactory_AddRef( iface );
74 FIXME("interface %s not implemented\n", debugstr_guid(riid));
78 static ULONG WINAPI xmlcf_AddRef(
79 IClassFactory *iface )
84 static ULONG WINAPI xmlcf_Release(
85 IClassFactory *iface )
90 static HRESULT WINAPI xmlcf_CreateInstance(
96 xmlcf *This = impl_from_IClassFactory( iface );
100 TRACE("%p %s %p\n", pOuter, debugstr_guid(riid), ppobj );
105 return CLASS_E_NOAGGREGATION;
107 r = This->pfnCreateInstance( pOuter, (LPVOID*) &punk );
111 r = IUnknown_QueryInterface( punk, riid, ppobj );
112 IUnknown_Release( punk );
116 static HRESULT WINAPI xmlcf_LockServer(
117 IClassFactory *iface,
120 FIXME("(%p)->(%d),stub!\n",iface,dolock);
124 static const struct IClassFactoryVtbl xmlcf_vtbl =
126 xmlcf_QueryInterface,
129 xmlcf_CreateInstance,
133 static xmlcf domdoccf = { &xmlcf_vtbl, DOMDocument_create };
134 static xmlcf schemacf = { &xmlcf_vtbl, SchemaCache_create };
135 static xmlcf xmldoccf = { &xmlcf_vtbl, XMLDocument_create };
136 static xmlcf saxreadcf = { &xmlcf_vtbl, SAXXMLReader_create };
137 static xmlcf httpreqcf = { &xmlcf_vtbl, XMLHTTPRequest_create };
139 /******************************************************************
140 * DllGetClassObject (MSXML3.@)
142 HRESULT WINAPI DllGetClassObject( REFCLSID rclsid, REFIID iid, LPVOID *ppv )
144 IClassFactory *cf = NULL;
146 TRACE("%s %s %p\n", debugstr_guid(rclsid), debugstr_guid(iid), ppv );
148 if( IsEqualCLSID( rclsid, &CLSID_DOMDocument ) || /* Version indep. v 2.x */
149 IsEqualCLSID( rclsid, &CLSID_DOMDocument2 ) || /* Version indep. v 3.0 */
150 IsEqualCLSID( rclsid, &CLSID_DOMDocument30 )|| /* Version dep. v 3.0 */
151 IsEqualCLSID( rclsid, &CLSID_DOMDocument40 )) /* Version dep. v 4.0 */
153 cf = (IClassFactory*) &domdoccf.lpVtbl;
155 else if( IsEqualCLSID( rclsid, &CLSID_XMLSchemaCache ) ||
156 IsEqualCLSID( rclsid, &CLSID_XMLSchemaCache30 ) )
158 cf = (IClassFactory*) &schemacf.lpVtbl;
160 else if( IsEqualCLSID( rclsid, &CLSID_XMLDocument ) )
162 cf = (IClassFactory*) &xmldoccf.lpVtbl;
164 else if( IsEqualCLSID( rclsid, &CLSID_DOMFreeThreadedDocument ) || /* Version indep. v 2.x */
165 IsEqualCLSID( rclsid, &CLSID_FreeThreadedDOMDocument ) ||
166 IsEqualCLSID( rclsid, &CLSID_FreeThreadedDOMDocument30 ))
168 cf = (IClassFactory*) &domdoccf.lpVtbl;
170 else if( IsEqualCLSID( rclsid, &CLSID_SAXXMLReader) ||
171 IsEqualCLSID( rclsid, &CLSID_SAXXMLReader30 ) ||
172 IsEqualCLSID( rclsid, &CLSID_SAXXMLReader40 ))
174 cf = (IClassFactory*) &saxreadcf.lpVtbl;
176 else if( IsEqualCLSID( rclsid, &CLSID_XMLHTTPRequest))
178 cf = (IClassFactory*) &httpreqcf.lpVtbl;
182 return CLASS_E_CLASSNOTAVAILABLE;
184 return IClassFactory_QueryInterface( cf, iid, ppv );