2005-08-02 13:29:04 +02: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 14:49:52 +02:00
|
|
|
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
|
2005-08-02 13:29:04 +02:00
|
|
|
*/
|
|
|
|
|
2005-08-09 13:17:47 +02:00
|
|
|
#include "config.h"
|
|
|
|
|
2008-02-14 10:55:33 +01:00
|
|
|
#define COBJMACROS
|
|
|
|
|
2005-08-02 13:29:04 +02:00
|
|
|
#include <stdarg.h>
|
|
|
|
#include "windef.h"
|
|
|
|
#include "winbase.h"
|
|
|
|
#include "winuser.h"
|
|
|
|
#include "ole2.h"
|
2008-02-14 10:55:33 +01:00
|
|
|
#include "msxml.h"
|
2005-11-08 20:59:36 +01:00
|
|
|
#include "msxml2.h"
|
2005-08-02 13:29:04 +02:00
|
|
|
|
|
|
|
#include "wine/debug.h"
|
|
|
|
|
2005-08-09 13:17:47 +02:00
|
|
|
#include "msxml_private.h"
|
|
|
|
|
2008-03-26 09:52:36 +01:00
|
|
|
#ifdef HAVE_LIBXSLT
|
|
|
|
#include <libxslt/xslt.h>
|
|
|
|
#endif
|
|
|
|
|
2005-08-02 13:29:04 +02:00
|
|
|
WINE_DEFAULT_DEBUG_CHANNEL(msxml);
|
|
|
|
|
2008-03-12 10:09:32 +01:00
|
|
|
static HINSTANCE hInstance;
|
2008-02-14 10:55:33 +01:00
|
|
|
static ITypeLib *typelib;
|
|
|
|
static ITypeInfo *typeinfos[LAST_tid];
|
|
|
|
|
|
|
|
static REFIID tid_ids[] = {
|
|
|
|
&IID_IXMLDOMAttribute,
|
|
|
|
&IID_IXMLDOMCDATASection,
|
|
|
|
&IID_IXMLDOMComment,
|
|
|
|
&IID_IXMLDOMDocument2,
|
|
|
|
&IID_IXMLDOMDocumentFragment,
|
|
|
|
&IID_IXMLDOMElement,
|
|
|
|
&IID_IXMLDOMEntityReference,
|
2008-02-20 13:05:45 +01:00
|
|
|
&IID_IXMLDOMImplementation,
|
2008-02-14 10:55:33 +01:00
|
|
|
&IID_IXMLDOMNamedNodeMap,
|
2008-04-29 12:25:14 +02:00
|
|
|
&IID_IXMLDOMNode,
|
2008-02-14 10:55:33 +01:00
|
|
|
&IID_IXMLDOMNodeList,
|
|
|
|
&IID_IXMLDOMParseError,
|
|
|
|
&IID_IXMLDOMProcessingInstruction,
|
|
|
|
&IID_IXMLDOMSchemaCollection,
|
|
|
|
&IID_IXMLDOMText,
|
|
|
|
&IID_IXMLElement,
|
2008-03-25 03:53:30 +01:00
|
|
|
&IID_IXMLDOMDocument,
|
|
|
|
&IID_IVBSAXAttributes,
|
|
|
|
&IID_IVBSAXContentHandler,
|
|
|
|
&IID_IVBSAXDeclHandler,
|
|
|
|
&IID_IVBSAXDTDHandler,
|
|
|
|
&IID_IVBSAXEntityResolver,
|
|
|
|
&IID_IVBSAXErrorHandler,
|
|
|
|
&IID_IVBSAXLexicalHandler,
|
|
|
|
&IID_IVBSAXLocator,
|
|
|
|
&IID_IVBSAXXMLFilter,
|
|
|
|
&IID_IVBSAXXMLReader,
|
|
|
|
&IID_IMXAttributes,
|
|
|
|
&IID_IMXReaderControl,
|
|
|
|
&IID_IMXWriter,
|
2008-02-14 10:55:33 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
HRESULT get_typeinfo(enum tid_t tid, ITypeInfo **typeinfo)
|
|
|
|
{
|
|
|
|
HRESULT hres;
|
|
|
|
|
|
|
|
if(!typelib) {
|
|
|
|
ITypeLib *tl;
|
|
|
|
|
|
|
|
hres = LoadRegTypeLib(&LIBID_MSXML2, 3, 0, LOCALE_SYSTEM_DEFAULT, &tl);
|
|
|
|
if(FAILED(hres)) {
|
|
|
|
ERR("LoadRegTypeLib failed: %08x\n", hres);
|
|
|
|
return hres;
|
|
|
|
}
|
|
|
|
|
|
|
|
if(InterlockedCompareExchangePointer((void**)&typelib, tl, NULL))
|
|
|
|
ITypeLib_Release(tl);
|
|
|
|
}
|
|
|
|
|
|
|
|
if(!typeinfos[tid]) {
|
|
|
|
ITypeInfo *typeinfo;
|
|
|
|
|
|
|
|
hres = ITypeLib_GetTypeInfoOfGuid(typelib, tid_ids[tid], &typeinfo);
|
|
|
|
if(FAILED(hres)) {
|
|
|
|
ERR("GetTypeInfoOfGuid failed: %08x\n", hres);
|
|
|
|
return hres;
|
|
|
|
}
|
|
|
|
|
|
|
|
if(InterlockedCompareExchangePointer((void**)(typeinfos+tid), typeinfo, NULL))
|
|
|
|
ITypeInfo_Release(typeinfo);
|
|
|
|
}
|
|
|
|
|
|
|
|
*typeinfo = typeinfos[tid];
|
|
|
|
|
|
|
|
ITypeInfo_AddRef(typeinfos[tid]);
|
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
|
2008-03-12 10:09:32 +01:00
|
|
|
static CRITICAL_SECTION MSXML3_typelib_cs;
|
|
|
|
static CRITICAL_SECTION_DEBUG MSXML3_typelib_cs_debug =
|
|
|
|
{
|
|
|
|
0, 0, &MSXML3_typelib_cs,
|
|
|
|
{ &MSXML3_typelib_cs_debug.ProcessLocksList,
|
|
|
|
&MSXML3_typelib_cs_debug.ProcessLocksList },
|
|
|
|
0, 0, { (DWORD_PTR)(__FILE__ ": MSXML3_typelib_cs") }
|
|
|
|
};
|
|
|
|
static CRITICAL_SECTION MSXML3_typelib_cs = { &MSXML3_typelib_cs_debug, -1, 0, 0, 0, 0 };
|
|
|
|
|
|
|
|
ITypeLib *get_msxml3_typelib( LPWSTR *path )
|
|
|
|
{
|
|
|
|
static WCHAR msxml3_path[MAX_PATH];
|
|
|
|
|
|
|
|
EnterCriticalSection( &MSXML3_typelib_cs );
|
|
|
|
|
|
|
|
if (!typelib)
|
|
|
|
{
|
|
|
|
TRACE("loading typelib\n");
|
|
|
|
|
|
|
|
if (GetModuleFileNameW( hInstance, msxml3_path, MAX_PATH ))
|
|
|
|
LoadTypeLib( msxml3_path, &typelib );
|
|
|
|
}
|
|
|
|
|
|
|
|
LeaveCriticalSection( &MSXML3_typelib_cs );
|
|
|
|
|
|
|
|
if (path)
|
|
|
|
*path = msxml3_path;
|
|
|
|
|
|
|
|
if (typelib)
|
|
|
|
ITypeLib_AddRef( typelib );
|
|
|
|
|
|
|
|
return typelib;
|
|
|
|
}
|
|
|
|
|
2008-02-14 10:55:33 +01:00
|
|
|
static void process_detach(void)
|
|
|
|
{
|
|
|
|
if(typelib) {
|
|
|
|
unsigned i;
|
|
|
|
|
|
|
|
for(i=0; i < sizeof(typeinfos)/sizeof(*typeinfos); i++)
|
|
|
|
if(typeinfos[i])
|
|
|
|
ITypeInfo_Release(typeinfos[i]);
|
|
|
|
|
|
|
|
ITypeLib_Release(typelib);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2005-08-08 19:35:28 +02:00
|
|
|
HRESULT WINAPI DllCanUnloadNow(void)
|
2005-08-02 13:29:04 +02:00
|
|
|
{
|
|
|
|
FIXME("\n");
|
|
|
|
return S_FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
BOOL WINAPI DllMain(HINSTANCE hInstDLL, DWORD fdwReason, LPVOID lpv)
|
|
|
|
{
|
|
|
|
switch(fdwReason)
|
|
|
|
{
|
|
|
|
case DLL_PROCESS_ATTACH:
|
2005-08-09 13:17:47 +02:00
|
|
|
#ifdef HAVE_LIBXML2
|
|
|
|
xmlInitParser();
|
2008-07-26 13:06:41 +02:00
|
|
|
|
|
|
|
/* Set the default indent character to a single tab. */
|
|
|
|
xmlThrDefTreeIndentString("\t");
|
2008-03-26 09:52:36 +01:00
|
|
|
#endif
|
2008-04-17 22:00:22 +02:00
|
|
|
#ifdef HAVE_XSLTINIT
|
2008-03-26 09:52:36 +01:00
|
|
|
xsltInit();
|
2005-08-09 13:17:47 +02:00
|
|
|
#endif
|
2008-07-26 13:06:41 +02:00
|
|
|
|
|
|
|
#ifdef HAVE_LIBXML2
|
|
|
|
/* Set the current ident to the default */
|
|
|
|
xmlTreeIndentString = "\t";
|
|
|
|
#endif
|
2008-03-12 10:09:32 +01:00
|
|
|
hInstance = hInstDLL;
|
2005-08-02 13:29:04 +02:00
|
|
|
DisableThreadLibraryCalls(hInstDLL);
|
|
|
|
break;
|
|
|
|
case DLL_PROCESS_DETACH:
|
2008-03-26 09:52:36 +01:00
|
|
|
#ifdef HAVE_LIBXSLT
|
|
|
|
xsltCleanupGlobals();
|
|
|
|
#endif
|
2005-08-09 13:17:47 +02:00
|
|
|
#ifdef HAVE_LIBXML2
|
|
|
|
xmlCleanupParser();
|
|
|
|
#endif
|
2008-07-14 11:48:37 +02:00
|
|
|
process_detach();
|
2005-08-02 13:29:04 +02:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
return TRUE;
|
|
|
|
}
|