2005-08-02 11:29:04 +00:00
|
|
|
/*
|
|
|
|
* MSXML Class Factory
|
|
|
|
*
|
|
|
|
* Copyright 2002 Lionel Ulmer
|
|
|
|
* Copyright 2005 Mike McCormack
|
|
|
|
*
|
|
|
|
* This library is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU Lesser General Public
|
|
|
|
* License as published by the Free Software Foundation; either
|
|
|
|
* version 2.1 of the License, or (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This library is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
|
* Lesser General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU Lesser General Public
|
|
|
|
* License along with this library; if not, write to the Free Software
|
2006-05-18 12:49:52 +00:00
|
|
|
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
|
2005-08-02 11:29:04 +00:00
|
|
|
*/
|
|
|
|
|
|
|
|
#define COBJMACROS
|
|
|
|
|
2007-01-20 08:19:55 +00:00
|
|
|
#include "config.h"
|
|
|
|
|
2005-08-02 11:29:04 +00:00
|
|
|
#include <stdarg.h>
|
|
|
|
#include "windef.h"
|
|
|
|
#include "winbase.h"
|
|
|
|
#include "winuser.h"
|
|
|
|
#include "ole2.h"
|
2006-11-13 15:31:45 +00:00
|
|
|
#include "msxml.h"
|
|
|
|
#include "xmldom.h"
|
2005-11-08 19:59:36 +00:00
|
|
|
#include "msxml2.h"
|
2010-08-29 21:31:07 +00:00
|
|
|
#include "msxml6.h"
|
2005-08-02 11:29:04 +00:00
|
|
|
|
2006-11-13 15:31:45 +00:00
|
|
|
/* undef the #define in msxml2 so that we can access the v.2 version
|
|
|
|
independent CLSID as well as the v.3 one. */
|
|
|
|
#undef CLSID_DOMDocument
|
|
|
|
|
2005-08-02 11:29:04 +00:00
|
|
|
#include "wine/debug.h"
|
|
|
|
|
|
|
|
#include "msxml_private.h"
|
|
|
|
|
|
|
|
WINE_DEFAULT_DEBUG_CHANNEL(msxml);
|
|
|
|
|
2010-09-14 05:15:31 +00:00
|
|
|
typedef HRESULT (*ClassFactoryCreateInstanceFunc)(IUnknown *pUnkOuter, LPVOID *ppObj);
|
|
|
|
typedef HRESULT (*DOMFactoryCreateInstanceFunc)(const GUID *clsid, IUnknown *pUnkOuter, LPVOID *ppObj);
|
2005-08-02 11:29:04 +00:00
|
|
|
|
|
|
|
/******************************************************************************
|
|
|
|
* MSXML ClassFactory
|
|
|
|
*/
|
2010-09-14 05:15:31 +00:00
|
|
|
typedef struct
|
2005-08-02 11:29:04 +00:00
|
|
|
{
|
|
|
|
const struct IClassFactoryVtbl *lpVtbl;
|
2010-09-14 05:15:31 +00:00
|
|
|
ClassFactoryCreateInstanceFunc pCreateInstance;
|
|
|
|
} ClassFactory;
|
2005-08-02 11:29:04 +00:00
|
|
|
|
2010-09-14 05:15:31 +00:00
|
|
|
typedef struct
|
2005-08-02 11:29:04 +00:00
|
|
|
{
|
2010-09-14 05:15:31 +00:00
|
|
|
const struct IClassFactoryVtbl *lpVtbl;
|
|
|
|
LONG ref;
|
|
|
|
DOMFactoryCreateInstanceFunc pCreateInstance;
|
|
|
|
GUID clsid;
|
|
|
|
} DOMFactory;
|
2005-08-02 11:29:04 +00:00
|
|
|
|
2010-09-14 05:15:31 +00:00
|
|
|
static HRESULT WINAPI ClassFactory_QueryInterface(
|
2005-08-02 11:29:04 +00:00
|
|
|
IClassFactory *iface,
|
|
|
|
REFIID riid,
|
2010-09-14 05:15:31 +00:00
|
|
|
void **ppobj )
|
2005-08-02 11:29:04 +00:00
|
|
|
{
|
|
|
|
if (IsEqualGUID(riid, &IID_IUnknown) ||
|
|
|
|
IsEqualGUID(riid, &IID_IClassFactory))
|
|
|
|
{
|
|
|
|
IClassFactory_AddRef( iface );
|
|
|
|
*ppobj = iface;
|
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
|
2006-01-27 18:22:56 +00:00
|
|
|
FIXME("interface %s not implemented\n", debugstr_guid(riid));
|
2005-08-02 11:29:04 +00:00
|
|
|
return E_NOINTERFACE;
|
|
|
|
}
|
|
|
|
|
2010-09-14 05:15:31 +00:00
|
|
|
static ULONG WINAPI ClassFactory_AddRef(IClassFactory *iface )
|
2005-08-02 11:29:04 +00:00
|
|
|
{
|
|
|
|
return 2;
|
|
|
|
}
|
|
|
|
|
2010-09-14 05:15:31 +00:00
|
|
|
static ULONG WINAPI ClassFactory_Release(IClassFactory *iface )
|
2005-08-02 11:29:04 +00:00
|
|
|
{
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
2010-09-14 05:15:31 +00:00
|
|
|
static HRESULT WINAPI ClassFactory_CreateInstance(
|
2005-08-02 11:29:04 +00:00
|
|
|
IClassFactory *iface,
|
2010-09-14 05:15:31 +00:00
|
|
|
IUnknown *pOuter,
|
2005-08-02 11:29:04 +00:00
|
|
|
REFIID riid,
|
2010-09-14 05:15:31 +00:00
|
|
|
void **ppobj )
|
2005-08-02 11:29:04 +00:00
|
|
|
{
|
2010-09-14 05:15:31 +00:00
|
|
|
ClassFactory *This = (ClassFactory*)iface;
|
2005-08-02 11:29:04 +00:00
|
|
|
IUnknown *punk;
|
2010-09-14 05:15:31 +00:00
|
|
|
HRESULT r;
|
|
|
|
|
2005-08-02 11:29:04 +00:00
|
|
|
TRACE("%p %s %p\n", pOuter, debugstr_guid(riid), ppobj );
|
|
|
|
|
|
|
|
*ppobj = NULL;
|
|
|
|
|
|
|
|
if (pOuter)
|
|
|
|
return CLASS_E_NOAGGREGATION;
|
|
|
|
|
2010-09-14 05:15:31 +00:00
|
|
|
r = This->pCreateInstance( pOuter, (void**) &punk );
|
2005-08-02 11:29:04 +00:00
|
|
|
if (FAILED(r))
|
|
|
|
return r;
|
|
|
|
|
|
|
|
r = IUnknown_QueryInterface( punk, riid, ppobj );
|
|
|
|
IUnknown_Release( punk );
|
|
|
|
return r;
|
|
|
|
}
|
|
|
|
|
2010-09-14 05:15:31 +00:00
|
|
|
static HRESULT WINAPI ClassFactory_LockServer(
|
2005-08-02 11:29:04 +00:00
|
|
|
IClassFactory *iface,
|
|
|
|
BOOL dolock)
|
|
|
|
{
|
|
|
|
FIXME("(%p)->(%d),stub!\n",iface,dolock);
|
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
|
2010-09-14 05:15:31 +00:00
|
|
|
static ULONG WINAPI DOMClassFactory_AddRef(IClassFactory *iface )
|
|
|
|
{
|
|
|
|
DOMFactory *This = (DOMFactory*)iface;
|
|
|
|
ULONG ref = InterlockedIncrement(&This->ref);
|
|
|
|
TRACE("(%p) ref = %u\n", This, ref);
|
|
|
|
return ref;
|
|
|
|
}
|
|
|
|
|
|
|
|
static ULONG WINAPI DOMClassFactory_Release(IClassFactory *iface )
|
|
|
|
{
|
|
|
|
DOMFactory *This = (DOMFactory*)iface;
|
|
|
|
ULONG ref = InterlockedDecrement(&This->ref);
|
|
|
|
TRACE("(%p) ref = %u\n", This, ref);
|
|
|
|
if(!ref) {
|
|
|
|
heap_free(This);
|
|
|
|
}
|
|
|
|
return ref;
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI DOMClassFactory_CreateInstance(
|
|
|
|
IClassFactory *iface,
|
|
|
|
IUnknown *pOuter,
|
|
|
|
REFIID riid,
|
|
|
|
void **ppobj )
|
|
|
|
{
|
|
|
|
DOMFactory *This = (DOMFactory*)iface;
|
|
|
|
IUnknown *punk;
|
|
|
|
HRESULT r;
|
|
|
|
|
|
|
|
TRACE("%p %s %p\n", pOuter, debugstr_guid(riid), ppobj );
|
|
|
|
|
|
|
|
*ppobj = NULL;
|
|
|
|
|
|
|
|
if (pOuter)
|
|
|
|
return CLASS_E_NOAGGREGATION;
|
|
|
|
|
|
|
|
r = This->pCreateInstance( &This->clsid, pOuter, (void**) &punk );
|
|
|
|
if (FAILED(r))
|
|
|
|
return r;
|
|
|
|
|
|
|
|
r = IUnknown_QueryInterface( punk, riid, ppobj );
|
|
|
|
IUnknown_Release( punk );
|
|
|
|
return r;
|
|
|
|
}
|
|
|
|
|
|
|
|
static const struct IClassFactoryVtbl ClassFactoryVtbl =
|
2005-08-02 11:29:04 +00:00
|
|
|
{
|
2010-09-14 05:15:31 +00:00
|
|
|
ClassFactory_QueryInterface,
|
|
|
|
ClassFactory_AddRef,
|
|
|
|
ClassFactory_Release,
|
|
|
|
ClassFactory_CreateInstance,
|
|
|
|
ClassFactory_LockServer
|
2005-08-02 11:29:04 +00:00
|
|
|
};
|
|
|
|
|
2010-09-14 05:15:31 +00:00
|
|
|
static const struct IClassFactoryVtbl DOMClassFactoryVtbl =
|
|
|
|
{
|
|
|
|
ClassFactory_QueryInterface,
|
|
|
|
DOMClassFactory_AddRef,
|
|
|
|
DOMClassFactory_Release,
|
|
|
|
DOMClassFactory_CreateInstance,
|
|
|
|
ClassFactory_LockServer
|
|
|
|
};
|
|
|
|
|
|
|
|
static HRESULT DOMClassFactory_Create(const GUID *clsid, REFIID riid, void **ppv, DOMFactoryCreateInstanceFunc fnCreateInstance)
|
|
|
|
{
|
|
|
|
DOMFactory *ret = heap_alloc(sizeof(DOMFactory));
|
|
|
|
HRESULT hres;
|
|
|
|
|
|
|
|
ret->lpVtbl = &DOMClassFactoryVtbl;
|
|
|
|
ret->ref = 0;
|
|
|
|
ret->clsid = *clsid;
|
|
|
|
ret->pCreateInstance = fnCreateInstance;
|
|
|
|
|
|
|
|
hres = IClassFactory_QueryInterface((IClassFactory*)ret, riid, ppv);
|
|
|
|
if(FAILED(hres)) {
|
|
|
|
heap_free(ret);
|
|
|
|
*ppv = NULL;
|
|
|
|
}
|
|
|
|
return hres;
|
|
|
|
}
|
|
|
|
|
|
|
|
static ClassFactory schemacf = { &ClassFactoryVtbl, SchemaCache_create };
|
|
|
|
static ClassFactory xmldoccf = { &ClassFactoryVtbl, XMLDocument_create };
|
|
|
|
static ClassFactory saxreadcf = { &ClassFactoryVtbl, SAXXMLReader_create };
|
|
|
|
static ClassFactory httpreqcf = { &ClassFactoryVtbl, XMLHTTPRequest_create };
|
2005-08-02 11:29:04 +00:00
|
|
|
|
2005-08-10 09:53:47 +00:00
|
|
|
/******************************************************************
|
|
|
|
* DllGetClassObject (MSXML3.@)
|
|
|
|
*/
|
2010-09-14 05:15:31 +00:00
|
|
|
HRESULT WINAPI DllGetClassObject( REFCLSID rclsid, REFIID riid, void **ppv )
|
2005-08-02 11:29:04 +00:00
|
|
|
{
|
|
|
|
IClassFactory *cf = NULL;
|
|
|
|
|
2010-09-14 05:15:31 +00:00
|
|
|
TRACE("%s %s %p\n", debugstr_guid(rclsid), debugstr_guid(riid), ppv );
|
2005-08-02 11:29:04 +00:00
|
|
|
|
2010-08-29 21:31:07 +00:00
|
|
|
if( IsEqualCLSID( rclsid, &CLSID_DOMDocument ) || /* Version indep. v 2.x */
|
2007-02-27 12:32:02 +00:00
|
|
|
IsEqualCLSID( rclsid, &CLSID_DOMDocument2 ) || /* Version indep. v 3.0 */
|
2010-02-03 19:34:45 +00:00
|
|
|
IsEqualCLSID( rclsid, &CLSID_DOMDocument30 )|| /* Version dep. v 3.0 */
|
2010-08-29 21:31:07 +00:00
|
|
|
IsEqualCLSID( rclsid, &CLSID_DOMDocument40 )|| /* Version dep. v 4.0 */
|
|
|
|
IsEqualCLSID( rclsid, &CLSID_DOMDocument60 )) /* Version dep. v 6.0 */
|
2007-05-24 18:13:06 +00:00
|
|
|
{
|
2010-09-14 05:15:31 +00:00
|
|
|
return DOMClassFactory_Create(rclsid, riid, ppv, DOMDocument_create);
|
2007-05-24 18:13:06 +00:00
|
|
|
}
|
2010-09-09 10:21:21 +00:00
|
|
|
else if( IsEqualCLSID( rclsid, &CLSID_XMLSchemaCache ) ||
|
|
|
|
IsEqualCLSID( rclsid, &CLSID_XMLSchemaCache30 ) ||
|
|
|
|
IsEqualCLSID( rclsid, &CLSID_XMLSchemaCache40 ) ||
|
|
|
|
IsEqualCLSID( rclsid, &CLSID_XMLSchemaCache60 ))
|
2007-05-24 18:13:06 +00:00
|
|
|
{
|
2007-02-27 12:32:02 +00:00
|
|
|
cf = (IClassFactory*) &schemacf.lpVtbl;
|
2007-05-24 18:13:06 +00:00
|
|
|
}
|
|
|
|
else if( IsEqualCLSID( rclsid, &CLSID_XMLDocument ) )
|
|
|
|
{
|
|
|
|
cf = (IClassFactory*) &xmldoccf.lpVtbl;
|
|
|
|
}
|
2010-08-29 21:31:07 +00:00
|
|
|
else if( IsEqualCLSID( rclsid, &CLSID_DOMFreeThreadedDocument ) || /* Version indep. v 2.x */
|
|
|
|
IsEqualCLSID( rclsid, &CLSID_FreeThreadedDOMDocument ) ||
|
|
|
|
IsEqualCLSID( rclsid, &CLSID_FreeThreadedDOMDocument30 ) ||
|
2010-08-29 21:33:04 +00:00
|
|
|
IsEqualCLSID( rclsid, &CLSID_FreeThreadedDOMDocument40 ) ||
|
2010-08-29 21:31:07 +00:00
|
|
|
IsEqualCLSID( rclsid, &CLSID_FreeThreadedDOMDocument60 ))
|
2007-12-10 22:02:36 +00:00
|
|
|
{
|
2010-09-14 05:15:31 +00:00
|
|
|
return DOMClassFactory_Create(rclsid, riid, ppv, DOMDocument_create);
|
2007-12-10 22:02:36 +00:00
|
|
|
}
|
2008-03-25 03:19:10 +00:00
|
|
|
else if( IsEqualCLSID( rclsid, &CLSID_SAXXMLReader) ||
|
2010-02-13 11:59:18 +00:00
|
|
|
IsEqualCLSID( rclsid, &CLSID_SAXXMLReader30 ) ||
|
2010-09-09 10:21:21 +00:00
|
|
|
IsEqualCLSID( rclsid, &CLSID_SAXXMLReader40 ) ||
|
|
|
|
IsEqualCLSID( rclsid, &CLSID_SAXXMLReader60 ))
|
2008-03-25 03:19:10 +00:00
|
|
|
{
|
|
|
|
cf = (IClassFactory*) &saxreadcf.lpVtbl;
|
|
|
|
}
|
2008-10-03 11:50:59 +00:00
|
|
|
else if( IsEqualCLSID( rclsid, &CLSID_XMLHTTPRequest))
|
|
|
|
{
|
|
|
|
cf = (IClassFactory*) &httpreqcf.lpVtbl;
|
|
|
|
}
|
2007-02-27 12:32:02 +00:00
|
|
|
|
2005-08-02 11:29:04 +00:00
|
|
|
if ( !cf )
|
|
|
|
return CLASS_E_CLASSNOTAVAILABLE;
|
|
|
|
|
2010-09-14 05:15:31 +00:00
|
|
|
return IClassFactory_QueryInterface( cf, riid, ppv );
|
2005-08-02 11:29:04 +00:00
|
|
|
}
|