ReactOS 0.4.16-dev-2207-geb15453
factory.c
Go to the documentation of this file.
1/*
2 * MSXML Class Factory
3 *
4 * Copyright 2002 Lionel Ulmer
5 * Copyright 2005 Mike McCormack
6 *
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.
11 *
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.
16 *
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
20 */
21
22#define COBJMACROS
23
24#include <stdarg.h>
25#include <libxml/parser.h>
26#include <libxml/xmlerror.h>
27
28#include "windef.h"
29#include "winbase.h"
30#include "winuser.h"
31#include "ole2.h"
32#include "msxml.h"
33#include "msxml2.h"
34#include "xmlparser.h"
35
36/* undef the #define in msxml2 so that we can access the v.2 version
37 independent CLSID as well as the v.3 one. */
38#undef CLSID_DOMDocument
39
40#include "wine/debug.h"
41
42#include "msxml_private.h"
43
45
46#ifndef __REACTOS__
48#endif
49
52
54{
55 const GUID *clsid;
57};
58
60{
62 { &CLSID_DOMDocument2, MSXML2 },
63 { &CLSID_DOMDocument26, MSXML26 },
64 { &CLSID_DOMDocument30, MSXML3 },
65 { &CLSID_DOMDocument40, MSXML4 },
66 { &CLSID_DOMDocument60, MSXML6 },
67
69 { &CLSID_FreeThreadedDOMDocument, MSXML_DEFAULT },
70 { &CLSID_FreeThreadedDOMDocument26, MSXML26 },
71 { &CLSID_FreeThreadedDOMDocument30, MSXML3 },
72 { &CLSID_FreeThreadedDOMDocument40, MSXML4 },
73 { &CLSID_FreeThreadedDOMDocument60, MSXML6 },
74
75 { &CLSID_XMLSchemaCache, MSXML_DEFAULT },
76 { &CLSID_XMLSchemaCache26, MSXML26 },
77 { &CLSID_XMLSchemaCache30, MSXML3 },
78 { &CLSID_XMLSchemaCache40, MSXML4 },
80
81 { &CLSID_MXXMLWriter, MSXML_DEFAULT },
82 { &CLSID_MXXMLWriter30, MSXML3 },
83 { &CLSID_MXXMLWriter40, MSXML4 },
84 { &CLSID_MXXMLWriter60, MSXML6 },
85
86 { &CLSID_SAXXMLReader, MSXML_DEFAULT },
87 { &CLSID_SAXXMLReader30, MSXML3 },
88 { &CLSID_SAXXMLReader40, MSXML4 },
89 { &CLSID_SAXXMLReader60, MSXML6 },
90
91 { &CLSID_SAXAttributes, MSXML_DEFAULT },
92 { &CLSID_SAXAttributes30, MSXML3 },
93 { &CLSID_SAXAttributes40, MSXML4 },
94 { &CLSID_SAXAttributes60, MSXML6 },
95
96 { &CLSID_XMLView, MSXML_DEFAULT }
97};
98
100{
101 unsigned int i;
102
103 for (i = 0; i < ARRAY_SIZE(clsid_versions_table); i++)
106
107 ERR("unknown clsid=%s\n", debugstr_guid(clsid));
108 return MSXML_DEFAULT;
109}
110
111/******************************************************************************
112 * MSXML ClassFactory
113 */
114typedef struct
115{
116 IClassFactory IClassFactory_iface;
119
120typedef struct
121{
126} DOMFactory;
127
129{
130 return CONTAINING_RECORD(iface, ClassFactory, IClassFactory_iface);
131}
132
134 IClassFactory *iface,
135 REFIID riid,
136 void **ppobj )
137{
140 {
141 IClassFactory_AddRef( iface );
142 *ppobj = iface;
143 return S_OK;
144 }
145
146 FIXME("interface %s not implemented\n", debugstr_guid(riid));
147 *ppobj = NULL;
148 return E_NOINTERFACE;
149}
150
152{
153 return 2;
154}
155
157{
158 return 1;
159}
160
162 IClassFactory *iface,
163 IUnknown *pOuter,
164 REFIID riid,
165 void **ppobj )
166{
168 IUnknown *punk;
169 HRESULT r;
170
171 TRACE("%p %s %p\n", pOuter, debugstr_guid(riid), ppobj );
172
173 *ppobj = NULL;
174
175 if (pOuter)
177
178 r = This->pCreateInstance( (void**) &punk );
179 if (FAILED(r))
180 return r;
181
182 r = IUnknown_QueryInterface( punk, riid, ppobj );
183 IUnknown_Release( punk );
184 return r;
185}
186
188 IClassFactory *iface,
189 BOOL dolock)
190{
191 FIXME("(%p)->(%d),stub!\n",iface,dolock);
192 return S_OK;
193}
194
196{
197 return CONTAINING_RECORD(iface, DOMFactory, IClassFactory_iface);
198}
199
201{
204 TRACE("%p, refcount %lu.\n", iface, ref);
205 return ref;
206}
207
209{
212
213 TRACE("%p, refcount %lu.\n", iface, ref);
214
215 if (!ref)
216 free(factory);
217
218 return ref;
219}
220
222 IClassFactory *iface,
223 IUnknown *pOuter,
224 REFIID riid,
225 void **ppobj )
226{
228 IUnknown *punk;
229 HRESULT r;
230
231 TRACE("%p %s %p\n", pOuter, debugstr_guid(riid), ppobj );
232
233 *ppobj = NULL;
234
235 if (pOuter)
237
238 r = This->pCreateInstance( This->version, (void**) &punk );
239 if (FAILED(r))
240 return r;
241
242 r = IUnknown_QueryInterface( punk, riid, ppobj );
243 IUnknown_Release( punk );
244 return r;
245}
246
247static const struct IClassFactoryVtbl ClassFactoryVtbl =
248{
254};
255
256static const struct IClassFactoryVtbl DOMClassFactoryVtbl =
257{
263};
264
266{
267 DOMFactory *ret = malloc(sizeof(DOMFactory));
269
270 ret->IClassFactory_iface.lpVtbl = &DOMClassFactoryVtbl;
271 ret->ref = 0;
272 ret->version = get_msxml_version(clsid);
273 ret->pCreateInstance = fnCreateInstance;
274
275 hres = IClassFactory_QueryInterface(&ret->IClassFactory_iface, riid, ppv);
276 if(FAILED(hres)) {
277 free(ret);
278 *ppv = NULL;
279 }
280 return hres;
281}
282
290
291/******************************************************************
292 * DllGetClassObject (MSXML3.@)
293 */
295{
297
298 TRACE("%s %s %p\n", debugstr_guid(rclsid), debugstr_guid(riid), ppv );
299
300 if( IsEqualCLSID( rclsid, &CLSID_DOMDocument ) || /* Version indep. v 2.x */
301 IsEqualCLSID( rclsid, &CLSID_DOMDocument2 ) || /* Version indep. v 3.0 */
302 IsEqualCLSID( rclsid, &CLSID_DOMDocument26 )|| /* Version dep. v 2.6 */
303 IsEqualCLSID( rclsid, &CLSID_DOMDocument30 )|| /* Version dep. v 3.0 */
304 IsEqualCLSID( rclsid, &CLSID_DOMDocument40 )|| /* Version dep. v 4.0 */
305 IsEqualCLSID( rclsid, &CLSID_DOMDocument60 )) /* Version dep. v 6.0 */
306 {
308 }
309 else if( IsEqualCLSID( rclsid, &CLSID_XMLSchemaCache ) ||
310 IsEqualCLSID( rclsid, &CLSID_XMLSchemaCache26 ) ||
311 IsEqualCLSID( rclsid, &CLSID_XMLSchemaCache30 ) ||
312 IsEqualCLSID( rclsid, &CLSID_XMLSchemaCache40 ) ||
314 {
316 }
317 else if( IsEqualCLSID( rclsid, &CLSID_XMLDocument ) )
318 {
320 }
321 else if( IsEqualCLSID( rclsid, &CLSID_DOMFreeThreadedDocument ) || /* Version indep. v 2.x */
322 IsEqualCLSID( rclsid, &CLSID_FreeThreadedDOMDocument ) ||
323 IsEqualCLSID( rclsid, &CLSID_FreeThreadedDOMDocument26 ) ||
324 IsEqualCLSID( rclsid, &CLSID_FreeThreadedDOMDocument30 ) ||
325 IsEqualCLSID( rclsid, &CLSID_FreeThreadedDOMDocument40 ) ||
326 IsEqualCLSID( rclsid, &CLSID_FreeThreadedDOMDocument60 ))
327 {
329 }
330 else if( IsEqualCLSID( rclsid, &CLSID_SAXXMLReader) ||
331 IsEqualCLSID( rclsid, &CLSID_SAXXMLReader30 ) ||
332 IsEqualCLSID( rclsid, &CLSID_SAXXMLReader40 ) ||
333 IsEqualCLSID( rclsid, &CLSID_SAXXMLReader60 ))
334 {
336 }
337 else if( IsEqualCLSID( rclsid, &CLSID_XMLHTTPRequest ) ||
338 IsEqualCLSID( rclsid, &CLSID_XMLHTTP) ||
339 IsEqualCLSID( rclsid, &CLSID_XMLHTTP26 ) ||
340 IsEqualCLSID( rclsid, &CLSID_XMLHTTP30 ) ||
341 IsEqualCLSID( rclsid, &CLSID_XMLHTTP40 ) ||
342 IsEqualCLSID( rclsid, &CLSID_XMLHTTP60 ))
343 {
345 }
346 else if( IsEqualCLSID( rclsid, &CLSID_ServerXMLHTTP ) ||
347 IsEqualCLSID( rclsid, &CLSID_ServerXMLHTTP30 ) ||
348 IsEqualCLSID( rclsid, &CLSID_ServerXMLHTTP40 ) ||
349 IsEqualCLSID( rclsid, &CLSID_ServerXMLHTTP60 ))
350 {
351 cf = &serverhttp.IClassFactory_iface;
352 }
353 else if( IsEqualCLSID( rclsid, &CLSID_XSLTemplate ) ||
354 IsEqualCLSID( rclsid, &CLSID_XSLTemplate26 ) ||
355 IsEqualCLSID( rclsid, &CLSID_XSLTemplate30 ) ||
356 IsEqualCLSID( rclsid, &CLSID_XSLTemplate40 ) ||
357 IsEqualCLSID( rclsid, &CLSID_XSLTemplate60 ))
358 {
360 }
361 else if( IsEqualCLSID( rclsid, &CLSID_MXXMLWriter ) ||
362 IsEqualCLSID( rclsid, &CLSID_MXXMLWriter30 ) ||
363 IsEqualCLSID( rclsid, &CLSID_MXXMLWriter40 ) ||
364 IsEqualCLSID( rclsid, &CLSID_MXXMLWriter60 ) )
365 {
367 }
368 else if( IsEqualCLSID( rclsid, &CLSID_SAXAttributes) ||
369 IsEqualCLSID( rclsid, &CLSID_SAXAttributes30 ) ||
370 IsEqualCLSID( rclsid, &CLSID_SAXAttributes40 ) ||
371 IsEqualCLSID( rclsid, &CLSID_SAXAttributes60 ))
372 {
374 }
375 else if( IsEqualCLSID( rclsid, &CLSID_MXNamespaceManager ) ||
376 IsEqualCLSID( rclsid, &CLSID_MXNamespaceManager40 ) ||
377 IsEqualCLSID( rclsid, &CLSID_MXNamespaceManager60 ) )
378 {
380 }
381 else if( IsEqualCLSID( rclsid, &CLSID_XMLParser ) ||
382 IsEqualCLSID( rclsid, &CLSID_XMLParser26 ) ||
383 IsEqualCLSID( rclsid, &CLSID_XMLParser30 ) )
384 {
386 }
387 else if( IsEqualCLSID( rclsid, &CLSID_XMLView ) )
388 {
390 }
391
392 if ( !cf )
394
395 return IClassFactory_QueryInterface( cf, riid, ppv );
396}
#define InterlockedIncrement
Definition: armddk.h:53
#define InterlockedDecrement
Definition: armddk.h:52
HRESULT WINAPI DllGetClassObject(REFCLSID pclsid, REFIID piid, LPVOID *ppv)
Definition: factory.c:183
#define WINE_DEFAULT_DEBUG_CHANNEL(t)
Definition: precomp.h:23
#define ARRAY_SIZE(A)
Definition: main.h:20
#define FIXME(fmt,...)
Definition: precomp.h:53
#define ERR(fmt,...)
Definition: precomp.h:57
const GUID IID_IUnknown
const GUID IID_IClassFactory
#define free
Definition: debug_ros.c:5
#define malloc
Definition: debug_ros.c:4
#define NULL
Definition: types.h:112
static const WCHAR version[]
Definition: asmname.c:66
HRESULT dom_document_create(MSXML_VERSION version, void **ppObj)
Definition: domdoc.c:3788
return ret
Definition: mutex.c:146
unsigned int BOOL
Definition: ntddk_ex.h:94
GLdouble GLdouble GLdouble r
Definition: gl.h:2055
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint i
Definition: glfuncs.h:248
HRESULT(* fnCreateInstance)(IUnknown *pUnkOuter, LPVOID *ppObj)
Definition: hnetcfg.c:37
HRESULT ServerXMLHTTP_create(void **obj)
Definition: httprequest.c:2106
HRESULT XMLHTTPRequest_create(void **obj)
Definition: httprequest.c:2088
REFIID riid
Definition: atlbase.h:39
REFIID LPVOID * ppv
Definition: atlbase.h:39
#define S_OK
Definition: intsafe.h:52
#define FAILED(hr)
Definition: intsafe.h:51
#define debugstr_guid
Definition: kernel32.h:35
HRESULT hres
Definition: protocol.c:465
const CLSID * clsid
Definition: msctf.cpp:50
static ClassFactory xmlparsercf
Definition: factory.c:288
static HRESULT WINAPI ClassFactory_CreateInstance(IClassFactory *iface, IUnknown *pOuter, REFIID riid, void **ppobj)
Definition: factory.c:161
static HRESULT WINAPI ClassFactory_LockServer(IClassFactory *iface, BOOL dolock)
Definition: factory.c:187
static const struct IClassFactoryVtbl ClassFactoryVtbl
Definition: factory.c:247
static const struct IClassFactoryVtbl DOMClassFactoryVtbl
Definition: factory.c:256
static ClassFactory * ClassFactory_from_IClassFactory(IClassFactory *iface)
Definition: factory.c:128
HRESULT(* DOMFactoryCreateInstanceFunc)(MSXML_VERSION, void **)
Definition: factory.c:51
static ClassFactory mxnsmanagercf
Definition: factory.c:287
GUID CLSID_XMLSchemaCache60
static ClassFactory xmldoccf
Definition: factory.c:283
static HRESULT WINAPI DOMClassFactory_CreateInstance(IClassFactory *iface, IUnknown *pOuter, REFIID riid, void **ppobj)
Definition: factory.c:221
static ClassFactory xmlviewcf
Definition: factory.c:289
static ULONG WINAPI ClassFactory_Release(IClassFactory *iface)
Definition: factory.c:156
static HRESULT DOMClassFactory_Create(const GUID *clsid, REFIID riid, void **ppv, DOMFactoryCreateInstanceFunc fnCreateInstance)
Definition: factory.c:265
static const struct clsid_version_t clsid_versions_table[]
Definition: factory.c:59
static ULONG WINAPI DOMClassFactory_Release(IClassFactory *iface)
Definition: factory.c:208
HRESULT(* ClassFactoryCreateInstanceFunc)(void **)
Definition: factory.c:50
static DOMFactory * DOMFactory_from_IClassFactory(IClassFactory *iface)
Definition: factory.c:195
static ClassFactory xsltemplatecf
Definition: factory.c:286
static MSXML_VERSION get_msxml_version(const GUID *clsid)
Definition: factory.c:99
static ULONG WINAPI ClassFactory_AddRef(IClassFactory *iface)
Definition: factory.c:151
static HRESULT WINAPI ClassFactory_QueryInterface(IClassFactory *iface, REFIID riid, void **ppobj)
Definition: factory.c:133
static ClassFactory httpreqcf
Definition: factory.c:284
static ULONG WINAPI DOMClassFactory_AddRef(IClassFactory *iface)
Definition: factory.c:200
const struct _GUID CLSID_DOMDocument
const struct _GUID CLSID_DOMFreeThreadedDocument
const struct _GUID CLSID_XMLDocument
const struct _GUID CLSID_XMLHTTPRequest
MSXML_VERSION
Definition: msxml_dispex.h:27
@ MSXML_DEFAULT
Definition: msxml_dispex.h:28
@ MSXML4
Definition: msxml_dispex.h:32
@ MSXML6
Definition: msxml_dispex.h:33
@ MSXML26
Definition: msxml_dispex.h:30
@ MSXML3
Definition: msxml_dispex.h:31
HRESULT MXNamespaceManager_create(void **)
Definition: mxnamespace.c:638
HRESULT SAXXMLReader_create(MSXML_VERSION, void **)
HRESULT XMLView_create(void **)
Definition: xmlview.c:1404
HRESULT SAXAttributes_create(MSXML_VERSION, void **)
Definition: mxwriter.c:3555
HRESULT MXWriter_create(MSXML_VERSION, void **)
Definition: mxwriter.c:2590
HRESULT SchemaCache_create(MSXML_VERSION, void **)
Definition: schema.c:1601
HRESULT XMLParser_create(void **)
Definition: xmlparser.c:414
HRESULT XMLDocument_create(void **)
HRESULT XSLTemplate_create(void **)
Definition: stylesheet.c:264
long LONG
Definition: pedump.c:60
#define IsEqualGUID(rguid1, rguid2)
Definition: guiddef.h:147
#define REFIID
Definition: guiddef.h:118
#define REFCLSID
Definition: guiddef.h:117
#define IsEqualCLSID(rclsid1, rclsid2)
Definition: guiddef.h:96
_In_opt_ IUnknown * punk
Definition: shlwapi.h:158
#define TRACE(s)
Definition: solgame.cpp:4
IClassFactory IClassFactory_iface
Definition: main.c:210
ClassFactoryCreateInstanceFunc pCreateInstance
Definition: factory.c:117
LONG ref
Definition: factory.c:123
DOMFactoryCreateInstanceFunc pCreateInstance
Definition: factory.c:124
IClassFactory IClassFactory_iface
Definition: factory.c:122
MSXML_VERSION version
Definition: factory.c:125
const GUID * clsid
Definition: factory.c:55
MSXML_VERSION version
Definition: factory.c:56
Definition: main.c:439
Definition: send.c:48
#define CONTAINING_RECORD(address, type, field)
Definition: typedefs.h:260
uint32_t ULONG
Definition: typedefs.h:59
#define HRESULT
Definition: msvc.h:7
#define WINAPI
Definition: msvc.h:6
#define E_NOINTERFACE
Definition: winerror.h:3479
#define CLASS_E_NOAGGREGATION
Definition: winerror.h:3771
#define CLASS_E_CLASSNOTAVAILABLE
Definition: winerror.h:3772