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
));
87 static ULONG WINAPI
ClassFactory_AddRef(IClassFactory
*iface
)
92 static ULONG WINAPI
ClassFactory_Release(IClassFactory
*iface
)
97 static HRESULT WINAPI
ClassFactory_CreateInstance(
103 ClassFactory
*This
= (ClassFactory
*)iface
;
107 TRACE("%p %s %p\n", pOuter
, debugstr_guid(riid
), ppobj
);
112 return CLASS_E_NOAGGREGATION
;
114 r
= This
->pCreateInstance( pOuter
, (void**) &punk
);
118 r
= IUnknown_QueryInterface( punk
, riid
, ppobj
);
119 IUnknown_Release( punk
);
123 static HRESULT WINAPI
ClassFactory_LockServer(
124 IClassFactory
*iface
,
127 FIXME("(%p)->(%d),stub!\n",iface
,dolock
);
131 static ULONG WINAPI
DOMClassFactory_AddRef(IClassFactory
*iface
)
133 DOMFactory
*This
= (DOMFactory
*)iface
;
134 ULONG ref
= InterlockedIncrement(&This
->ref
);
135 TRACE("(%p) ref = %u\n", This
, ref
);
139 static ULONG WINAPI
DOMClassFactory_Release(IClassFactory
*iface
)
141 DOMFactory
*This
= (DOMFactory
*)iface
;
142 ULONG ref
= InterlockedDecrement(&This
->ref
);
143 TRACE("(%p) ref = %u\n", This
, ref
);
150 static HRESULT WINAPI
DOMClassFactory_CreateInstance(
151 IClassFactory
*iface
,
156 DOMFactory
*This
= (DOMFactory
*)iface
;
160 TRACE("%p %s %p\n", pOuter
, debugstr_guid(riid
), ppobj
);
165 return CLASS_E_NOAGGREGATION
;
167 r
= This
->pCreateInstance( &This
->clsid
, pOuter
, (void**) &punk
);
171 r
= IUnknown_QueryInterface( punk
, riid
, ppobj
);
172 IUnknown_Release( punk
);
176 static const struct IClassFactoryVtbl ClassFactoryVtbl
=
178 ClassFactory_QueryInterface
,
180 ClassFactory_Release
,
181 ClassFactory_CreateInstance
,
182 ClassFactory_LockServer
185 static const struct IClassFactoryVtbl DOMClassFactoryVtbl
=
187 ClassFactory_QueryInterface
,
188 DOMClassFactory_AddRef
,
189 DOMClassFactory_Release
,
190 DOMClassFactory_CreateInstance
,
191 ClassFactory_LockServer
194 static HRESULT
DOMClassFactory_Create(const GUID
*clsid
, REFIID riid
, void **ppv
, DOMFactoryCreateInstanceFunc fnCreateInstance
)
196 DOMFactory
*ret
= heap_alloc(sizeof(DOMFactory
));
199 ret
->lpVtbl
= &DOMClassFactoryVtbl
;
202 ret
->pCreateInstance
= fnCreateInstance
;
204 hres
= IClassFactory_QueryInterface((IClassFactory
*)ret
, riid
, ppv
);
212 static ClassFactory xmldoccf
= { &ClassFactoryVtbl
, XMLDocument_create
};
213 static ClassFactory saxreadcf
= { &ClassFactoryVtbl
, SAXXMLReader_create
};
214 static ClassFactory httpreqcf
= { &ClassFactoryVtbl
, XMLHTTPRequest_create
};
215 static ClassFactory xsltemplatecf
= { &ClassFactoryVtbl
, XSLTemplate_create
};
216 static ClassFactory mxwritercf
= { &ClassFactoryVtbl
, MXWriter_create
};
218 /******************************************************************
219 * DllGetClassObject (MSXML3.@)
221 HRESULT WINAPI
DllGetClassObject( REFCLSID rclsid
, REFIID riid
, void **ppv
)
223 IClassFactory
*cf
= NULL
;
225 TRACE("%s %s %p\n", debugstr_guid(rclsid
), debugstr_guid(riid
), ppv
);
227 if( IsEqualCLSID( rclsid
, &CLSID_DOMDocument
) || /* Version indep. v 2.x */
228 IsEqualCLSID( rclsid
, &CLSID_DOMDocument2
) || /* Version indep. v 3.0 */
229 IsEqualCLSID( rclsid
, &CLSID_DOMDocument26
)|| /* Version dep. v 2.6 */
230 IsEqualCLSID( rclsid
, &CLSID_DOMDocument30
)|| /* Version dep. v 3.0 */
231 IsEqualCLSID( rclsid
, &CLSID_DOMDocument40
)|| /* Version dep. v 4.0 */
232 IsEqualCLSID( rclsid
, &CLSID_DOMDocument60
)) /* Version dep. v 6.0 */
234 return DOMClassFactory_Create(rclsid
, riid
, ppv
, DOMDocument_create
);
236 else if( IsEqualCLSID( rclsid
, &CLSID_XMLSchemaCache
) ||
237 IsEqualCLSID( rclsid
, &CLSID_XMLSchemaCache26
) ||
238 IsEqualCLSID( rclsid
, &CLSID_XMLSchemaCache30
) ||
239 IsEqualCLSID( rclsid
, &CLSID_XMLSchemaCache40
) ||
240 IsEqualCLSID( rclsid
, &CLSID_XMLSchemaCache60
))
242 return DOMClassFactory_Create(rclsid
, riid
, ppv
, SchemaCache_create
);
244 else if( IsEqualCLSID( rclsid
, &CLSID_XMLDocument
) )
246 cf
= (IClassFactory
*) &xmldoccf
.lpVtbl
;
248 else if( IsEqualCLSID( rclsid
, &CLSID_DOMFreeThreadedDocument
) || /* Version indep. v 2.x */
249 IsEqualCLSID( rclsid
, &CLSID_FreeThreadedDOMDocument
) ||
250 IsEqualCLSID( rclsid
, &CLSID_FreeThreadedDOMDocument26
) ||
251 IsEqualCLSID( rclsid
, &CLSID_FreeThreadedDOMDocument30
) ||
252 IsEqualCLSID( rclsid
, &CLSID_FreeThreadedDOMDocument40
) ||
253 IsEqualCLSID( rclsid
, &CLSID_FreeThreadedDOMDocument60
))
255 return DOMClassFactory_Create(rclsid
, riid
, ppv
, DOMDocument_create
);
257 else if( IsEqualCLSID( rclsid
, &CLSID_SAXXMLReader
) ||
258 IsEqualCLSID( rclsid
, &CLSID_SAXXMLReader30
) ||
259 IsEqualCLSID( rclsid
, &CLSID_SAXXMLReader40
) ||
260 IsEqualCLSID( rclsid
, &CLSID_SAXXMLReader60
))
262 cf
= (IClassFactory
*) &saxreadcf
.lpVtbl
;
264 else if( IsEqualCLSID( rclsid
, &CLSID_XMLHTTPRequest
) ||
265 IsEqualCLSID( rclsid
, &CLSID_XMLHTTP26
) ||
266 IsEqualCLSID( rclsid
, &CLSID_XMLHTTP30
) ||
267 IsEqualCLSID( rclsid
, &CLSID_XMLHTTP40
) ||
268 IsEqualCLSID( rclsid
, &CLSID_XMLHTTP60
))
270 cf
= (IClassFactory
*) &httpreqcf
.lpVtbl
;
272 else if( IsEqualCLSID( rclsid
, &CLSID_XSLTemplate
) ||
273 IsEqualCLSID( rclsid
, &CLSID_XSLTemplate26
) ||
274 IsEqualCLSID( rclsid
, &CLSID_XSLTemplate30
) ||
275 IsEqualCLSID( rclsid
, &CLSID_XSLTemplate40
) ||
276 IsEqualCLSID( rclsid
, &CLSID_XSLTemplate60
))
278 cf
= (IClassFactory
*) &xsltemplatecf
.lpVtbl
;
280 else if( IsEqualCLSID( rclsid
, &CLSID_MXXMLWriter
) ||
281 IsEqualCLSID( rclsid
, &CLSID_MXXMLWriter30
) ||
282 IsEqualCLSID( rclsid
, &CLSID_MXXMLWriter40
) ||
283 IsEqualCLSID( rclsid
, &CLSID_MXXMLWriter60
) )
285 cf
= (IClassFactory
*) &mxwritercf
.lpVtbl
;
289 return CLASS_E_CLASSNOTAVAILABLE
;
291 return IClassFactory_QueryInterface( cf
, riid
, ppv
);