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
34 /* undef the #define in msxml2 so that we can access the v.2 version
35 independent CLSID as well as the v.3 one. */
36 #undef CLSID_DOMDocument
38 #include "wine/debug.h"
40 #include "msxml_private.h"
42 WINE_DEFAULT_DEBUG_CHANNEL(msxml
);
44 typedef HRESULT (*ClassFactoryCreateInstanceFunc
)(IUnknown
*pUnkOuter
, LPVOID
*ppObj
);
45 typedef HRESULT (*DOMFactoryCreateInstanceFunc
)(const GUID
*clsid
, IUnknown
*pUnkOuter
, LPVOID
*ppObj
);
47 /******************************************************************************
52 const struct IClassFactoryVtbl
*lpVtbl
;
53 ClassFactoryCreateInstanceFunc pCreateInstance
;
58 const struct IClassFactoryVtbl
*lpVtbl
;
60 DOMFactoryCreateInstanceFunc pCreateInstance
;
64 static HRESULT WINAPI
ClassFactory_QueryInterface(
69 if (IsEqualGUID(riid
, &IID_IUnknown
) ||
70 IsEqualGUID(riid
, &IID_IClassFactory
))
72 IClassFactory_AddRef( iface
);
77 FIXME("interface %s not implemented\n", debugstr_guid(riid
));
81 static ULONG WINAPI
ClassFactory_AddRef(IClassFactory
*iface
)
86 static ULONG WINAPI
ClassFactory_Release(IClassFactory
*iface
)
91 static HRESULT WINAPI
ClassFactory_CreateInstance(
97 ClassFactory
*This
= (ClassFactory
*)iface
;
101 TRACE("%p %s %p\n", pOuter
, debugstr_guid(riid
), ppobj
);
106 return CLASS_E_NOAGGREGATION
;
108 r
= This
->pCreateInstance( pOuter
, (void**) &punk
);
112 r
= IUnknown_QueryInterface( punk
, riid
, ppobj
);
113 IUnknown_Release( punk
);
117 static HRESULT WINAPI
ClassFactory_LockServer(
118 IClassFactory
*iface
,
121 FIXME("(%p)->(%d),stub!\n",iface
,dolock
);
125 static ULONG WINAPI
DOMClassFactory_AddRef(IClassFactory
*iface
)
127 DOMFactory
*This
= (DOMFactory
*)iface
;
128 ULONG ref
= InterlockedIncrement(&This
->ref
);
129 TRACE("(%p) ref = %u\n", This
, ref
);
133 static ULONG WINAPI
DOMClassFactory_Release(IClassFactory
*iface
)
135 DOMFactory
*This
= (DOMFactory
*)iface
;
136 ULONG ref
= InterlockedDecrement(&This
->ref
);
137 TRACE("(%p) ref = %u\n", This
, ref
);
144 static HRESULT WINAPI
DOMClassFactory_CreateInstance(
145 IClassFactory
*iface
,
150 DOMFactory
*This
= (DOMFactory
*)iface
;
154 TRACE("%p %s %p\n", pOuter
, debugstr_guid(riid
), ppobj
);
159 return CLASS_E_NOAGGREGATION
;
161 r
= This
->pCreateInstance( &This
->clsid
, pOuter
, (void**) &punk
);
165 r
= IUnknown_QueryInterface( punk
, riid
, ppobj
);
166 IUnknown_Release( punk
);
170 static const struct IClassFactoryVtbl ClassFactoryVtbl
=
172 ClassFactory_QueryInterface
,
174 ClassFactory_Release
,
175 ClassFactory_CreateInstance
,
176 ClassFactory_LockServer
179 static const struct IClassFactoryVtbl DOMClassFactoryVtbl
=
181 ClassFactory_QueryInterface
,
182 DOMClassFactory_AddRef
,
183 DOMClassFactory_Release
,
184 DOMClassFactory_CreateInstance
,
185 ClassFactory_LockServer
188 static HRESULT
DOMClassFactory_Create(const GUID
*clsid
, REFIID riid
, void **ppv
, DOMFactoryCreateInstanceFunc fnCreateInstance
)
190 DOMFactory
*ret
= heap_alloc(sizeof(DOMFactory
));
193 ret
->lpVtbl
= &DOMClassFactoryVtbl
;
196 ret
->pCreateInstance
= fnCreateInstance
;
198 hres
= IClassFactory_QueryInterface((IClassFactory
*)ret
, riid
, ppv
);
206 static ClassFactory xmldoccf
= { &ClassFactoryVtbl
, XMLDocument_create
};
207 static ClassFactory saxreadcf
= { &ClassFactoryVtbl
, SAXXMLReader_create
};
208 static ClassFactory httpreqcf
= { &ClassFactoryVtbl
, XMLHTTPRequest_create
};
210 /******************************************************************
211 * DllGetClassObject (MSXML3.@)
213 HRESULT WINAPI
DllGetClassObject( REFCLSID rclsid
, REFIID riid
, void **ppv
)
215 IClassFactory
*cf
= NULL
;
217 TRACE("%s %s %p\n", debugstr_guid(rclsid
), debugstr_guid(riid
), ppv
);
219 if( IsEqualCLSID( rclsid
, &CLSID_DOMDocument
) || /* Version indep. v 2.x */
220 IsEqualCLSID( rclsid
, &CLSID_DOMDocument2
) || /* Version indep. v 3.0 */
221 IsEqualCLSID( rclsid
, &CLSID_DOMDocument26
)|| /* Version dep. v 2.6 */
222 IsEqualCLSID( rclsid
, &CLSID_DOMDocument30
)|| /* Version dep. v 3.0 */
223 IsEqualCLSID( rclsid
, &CLSID_DOMDocument40
)|| /* Version dep. v 4.0 */
224 IsEqualCLSID( rclsid
, &CLSID_DOMDocument60
)) /* Version dep. v 6.0 */
226 return DOMClassFactory_Create(rclsid
, riid
, ppv
, DOMDocument_create
);
228 else if( IsEqualCLSID( rclsid
, &CLSID_XMLSchemaCache
) ||
229 IsEqualCLSID( rclsid
, &CLSID_XMLSchemaCache26
) ||
230 IsEqualCLSID( rclsid
, &CLSID_XMLSchemaCache30
) ||
231 IsEqualCLSID( rclsid
, &CLSID_XMLSchemaCache40
) ||
232 IsEqualCLSID( rclsid
, &CLSID_XMLSchemaCache60
))
234 return DOMClassFactory_Create(rclsid
, riid
, ppv
, SchemaCache_create
);
236 else if( IsEqualCLSID( rclsid
, &CLSID_XMLDocument
) )
238 cf
= (IClassFactory
*) &xmldoccf
.lpVtbl
;
240 else if( IsEqualCLSID( rclsid
, &CLSID_DOMFreeThreadedDocument
) || /* Version indep. v 2.x */
241 IsEqualCLSID( rclsid
, &CLSID_FreeThreadedDOMDocument
) ||
242 IsEqualCLSID( rclsid
, &CLSID_FreeThreadedDOMDocument26
) ||
243 IsEqualCLSID( rclsid
, &CLSID_FreeThreadedDOMDocument30
) ||
244 IsEqualCLSID( rclsid
, &CLSID_FreeThreadedDOMDocument40
) ||
245 IsEqualCLSID( rclsid
, &CLSID_FreeThreadedDOMDocument60
))
247 return DOMClassFactory_Create(rclsid
, riid
, ppv
, DOMDocument_create
);
249 else if( IsEqualCLSID( rclsid
, &CLSID_SAXXMLReader
) ||
250 IsEqualCLSID( rclsid
, &CLSID_SAXXMLReader30
) ||
251 IsEqualCLSID( rclsid
, &CLSID_SAXXMLReader40
) ||
252 IsEqualCLSID( rclsid
, &CLSID_SAXXMLReader60
))
254 cf
= (IClassFactory
*) &saxreadcf
.lpVtbl
;
256 else if( IsEqualCLSID( rclsid
, &CLSID_XMLHTTPRequest
) ||
257 IsEqualCLSID( rclsid
, &CLSID_XMLHTTP26
) ||
258 IsEqualCLSID( rclsid
, &CLSID_XMLHTTP30
) ||
259 IsEqualCLSID( rclsid
, &CLSID_XMLHTTP40
) ||
260 IsEqualCLSID( rclsid
, &CLSID_XMLHTTP60
))
262 cf
= (IClassFactory
*) &httpreqcf
.lpVtbl
;
266 return CLASS_E_CLASSNOTAVAILABLE
;
268 return IClassFactory_QueryInterface( cf
, riid
, ppv
);