msxml3: Make version dependency checks more flexible, move CLSID checks to factory creation.

This commit is contained in:
Nikolay Sivov 2011-08-24 16:00:16 +04:00 committed by Alexandre Julliard
parent 74a7edd41b
commit 4877da66b3
6 changed files with 71 additions and 56 deletions

View File

@ -287,7 +287,7 @@ static xmldoc_priv * create_priv(void)
return priv;
}
static domdoc_properties * create_properties(const GUID *clsid)
static domdoc_properties * create_properties(MSXML_VERSION version)
{
domdoc_properties *properties = heap_alloc(sizeof(domdoc_properties));
@ -298,26 +298,8 @@ static domdoc_properties * create_properties(const GUID *clsid)
properties->selectNsStr_len = 0;
/* properties that are dependent on object versions */
if (IsEqualCLSID(clsid, &CLSID_DOMDocument30))
{
properties->version = MSXML3;
properties->XPath = FALSE;
}
else if (IsEqualCLSID(clsid, &CLSID_DOMDocument40))
{
properties->version = MSXML4;
properties->XPath = TRUE;
}
else if (IsEqualCLSID(clsid, &CLSID_DOMDocument60))
{
properties->version = MSXML6;
properties->XPath = TRUE;
}
else
{
properties->version = MSXML_DEFAULT;
properties->XPath = FALSE;
}
properties->version = version;
properties->XPath = (version == MSXML4 || version == MSXML6);
return properties;
}
@ -556,10 +538,10 @@ static xmlDocPtr doparse(domdoc* This, char const* ptr, int len, xmlCharEncoding
return doc;
}
void xmldoc_init(xmlDocPtr doc, const GUID *clsid)
void xmldoc_init(xmlDocPtr doc, MSXML_VERSION version)
{
doc->_private = create_priv();
priv_from_xmlDocPtr(doc)->properties = create_properties(clsid);
priv_from_xmlDocPtr(doc)->properties = create_properties(version);
}
LONG xmldoc_add_ref(xmlDocPtr doc)
@ -3516,19 +3498,19 @@ HRESULT get_domdoc_from_xmldoc(xmlDocPtr xmldoc, IXMLDOMDocument3 **document)
return S_OK;
}
HRESULT DOMDocument_create(const GUID *clsid, IUnknown *pUnkOuter, void **ppObj)
HRESULT DOMDocument_create(MSXML_VERSION version, IUnknown *pUnkOuter, void **ppObj)
{
xmlDocPtr xmldoc;
HRESULT hr;
TRACE("(%s, %p, %p)\n", debugstr_guid(clsid), pUnkOuter, ppObj);
TRACE("(%d, %p, %p)\n", version, pUnkOuter, ppObj);
xmldoc = xmlNewDoc(NULL);
if(!xmldoc)
return E_OUTOFMEMORY;
xmldoc->_private = create_priv();
priv_from_xmlDocPtr(xmldoc)->properties = create_properties(clsid);
priv_from_xmlDocPtr(xmldoc)->properties = create_properties(version);
hr = get_domdoc_from_xmldoc(xmldoc, (IXMLDOMDocument3**)ppObj);
if(FAILED(hr))
@ -3558,7 +3540,7 @@ IUnknown* create_domdoc( xmlNodePtr document )
#else
HRESULT DOMDocument_create(const GUID *clsid, IUnknown *pUnkOuter, void **ppObj)
HRESULT DOMDocument_create(MSXML_VERSION version, IUnknown *pUnkOuter, void **ppObj)
{
MESSAGE("This program tried to use a DOMDocument object, but\n"
"libxml2 support was not present at compile time.\n");

View File

@ -46,8 +46,49 @@
WINE_DEFAULT_DEBUG_CHANNEL(msxml);
typedef HRESULT (*ClassFactoryCreateInstanceFunc)(IUnknown *pUnkOuter, LPVOID *ppObj);
typedef HRESULT (*DOMFactoryCreateInstanceFunc)(const GUID *clsid, IUnknown *pUnkOuter, LPVOID *ppObj);
typedef HRESULT (*ClassFactoryCreateInstanceFunc)(IUnknown*, void**);
typedef HRESULT (*DOMFactoryCreateInstanceFunc)(MSXML_VERSION, IUnknown*, void**);
struct clsid_version_t
{
const GUID *clsid;
MSXML_VERSION version;
};
static const struct clsid_version_t clsid_versions_table[] =
{
{ &CLSID_DOMDocument, MSXML_DEFAULT },
{ &CLSID_DOMDocument2, MSXML_DEFAULT },
{ &CLSID_DOMDocument26, MSXML_DEFAULT },
{ &CLSID_DOMDocument30, MSXML3 },
{ &CLSID_DOMDocument40, MSXML4 },
{ &CLSID_DOMDocument60, MSXML6 },
{ &CLSID_DOMFreeThreadedDocument, MSXML_DEFAULT },
{ &CLSID_FreeThreadedDOMDocument, MSXML_DEFAULT },
{ &CLSID_FreeThreadedDOMDocument26, MSXML_DEFAULT },
{ &CLSID_FreeThreadedDOMDocument30, MSXML3 },
{ &CLSID_FreeThreadedDOMDocument40, MSXML4 },
{ &CLSID_FreeThreadedDOMDocument60, MSXML6 },
{ &CLSID_XMLSchemaCache, MSXML_DEFAULT },
{ &CLSID_XMLSchemaCache26, MSXML_DEFAULT },
{ &CLSID_XMLSchemaCache30, MSXML3 },
{ &CLSID_XMLSchemaCache40, MSXML4 },
{ &CLSID_XMLSchemaCache60, MSXML6 }
};
static MSXML_VERSION get_msxml_version(const GUID *clsid)
{
int i;
for (i = 0; i < sizeof(clsid_versions_table)/sizeof(struct clsid_version_t); i++)
if (IsEqualGUID(clsid, clsid_versions_table[i].clsid))
return clsid_versions_table[i].version;
ERR("unknown clsid=%s\n", debugstr_guid(clsid));
return MSXML_DEFAULT;
}
/******************************************************************************
* MSXML ClassFactory
@ -63,7 +104,7 @@ typedef struct
IClassFactory IClassFactory_iface;
LONG ref;
DOMFactoryCreateInstanceFunc pCreateInstance;
GUID clsid;
MSXML_VERSION version;
} DOMFactory;
static inline ClassFactory *ClassFactory_from_IClassFactory(IClassFactory *iface)
@ -174,7 +215,7 @@ static HRESULT WINAPI DOMClassFactory_CreateInstance(
if (pOuter)
return CLASS_E_NOAGGREGATION;
r = This->pCreateInstance( &This->clsid, pOuter, (void**) &punk );
r = This->pCreateInstance( This->version, pOuter, (void**) &punk );
if (FAILED(r))
return r;
@ -208,7 +249,7 @@ static HRESULT DOMClassFactory_Create(const GUID *clsid, REFIID riid, void **ppv
ret->IClassFactory_iface.lpVtbl = &DOMClassFactoryVtbl;
ret->ref = 0;
ret->clsid = *clsid;
ret->version = get_msxml_version(clsid);
ret->pCreateInstance = fnCreateInstance;
hres = IClassFactory_QueryInterface(&ret->IClassFactory_iface, riid, ppv);

View File

@ -848,7 +848,7 @@ static HRESULT WINAPI httprequest_get_responseXML(IXMLHTTPRequest *iface, IDispa
if (!body) return E_INVALIDARG;
if (This->state != READYSTATE_COMPLETE) return E_FAIL;
hr = DOMDocument_create(&CLSID_DOMDocument, NULL, (void**)&doc);
hr = DOMDocument_create(MSXML_DEFAULT, NULL, (void**)&doc);
if (hr != S_OK) return hr;
hr = IXMLHTTPRequest_get_responseText(iface, &str);

View File

@ -253,7 +253,7 @@ xmlNodePtr xmlNodePtr_from_domnode( IXMLDOMNode *iface, xmlElementType type ) DE
/* helpers */
extern xmlChar *xmlChar_from_wchar( LPCWSTR str ) DECLSPEC_HIDDEN;
extern void xmldoc_init( xmlDocPtr doc, const GUID *clsid ) DECLSPEC_HIDDEN;
extern void xmldoc_init( xmlDocPtr doc, MSXML_VERSION version ) DECLSPEC_HIDDEN;
extern LONG xmldoc_add_ref( xmlDocPtr doc ) DECLSPEC_HIDDEN;
extern LONG xmldoc_release( xmlDocPtr doc ) DECLSPEC_HIDDEN;
extern HRESULT xmldoc_add_orphan( xmlDocPtr doc, xmlNodePtr node ) DECLSPEC_HIDDEN;
@ -429,8 +429,8 @@ static inline xmlChar *xmlchar_from_wchar( const WCHAR *str )
extern IXMLDOMParseError *create_parseError( LONG code, BSTR url, BSTR reason, BSTR srcText,
LONG line, LONG linepos, LONG filepos ) DECLSPEC_HIDDEN;
extern HRESULT DOMDocument_create(const GUID*, IUnknown*, void**) DECLSPEC_HIDDEN;
extern HRESULT SchemaCache_create(const GUID*, IUnknown*, void**) DECLSPEC_HIDDEN;
extern HRESULT DOMDocument_create(MSXML_VERSION, IUnknown*, void**) DECLSPEC_HIDDEN;
extern HRESULT SchemaCache_create(MSXML_VERSION, IUnknown*, void**) DECLSPEC_HIDDEN;
extern HRESULT XMLDocument_create(IUnknown*, void**) DECLSPEC_HIDDEN;
extern HRESULT SAXXMLReader_create(IUnknown*, void**) DECLSPEC_HIDDEN;
extern HRESULT XMLHTTPRequest_create(IUnknown*, void **) DECLSPEC_HIDDEN;

View File

@ -842,7 +842,7 @@ static cache_entry* cache_entry_from_xsd_doc(xmlDocPtr doc, xmlChar const* nsURI
if ((entry->schema = Schema_parse(spctx)))
{
xmldoc_init(entry->schema->doc, DOMDocument_version(v));
xmldoc_init(entry->schema->doc, v);
entry->doc = entry->schema->doc;
xmldoc_add_ref(entry->doc);
}
@ -857,7 +857,7 @@ static cache_entry* cache_entry_from_xsd_doc(xmlDocPtr doc, xmlChar const* nsURI
return entry;
}
static cache_entry* cache_entry_from_xdr_doc(xmlDocPtr doc, xmlChar const* nsURI, MSXML_VERSION v)
static cache_entry* cache_entry_from_xdr_doc(xmlDocPtr doc, xmlChar const* nsURI, MSXML_VERSION version)
{
cache_entry* entry = heap_alloc(sizeof(cache_entry));
xmlSchemaParserCtxtPtr spctx;
@ -872,8 +872,8 @@ static cache_entry* cache_entry_from_xdr_doc(xmlDocPtr doc, xmlChar const* nsURI
if ((entry->schema = Schema_parse(spctx)))
{
entry->doc = new_doc;
xmldoc_init(entry->schema->doc, DOMDocument_version(v));
xmldoc_init(entry->doc, DOMDocument_version(v));
xmldoc_init(entry->schema->doc, version);
xmldoc_init(entry->doc, version);
xmldoc_add_ref(entry->doc);
xmldoc_add_ref(entry->schema->doc);
}
@ -890,12 +890,12 @@ static cache_entry* cache_entry_from_xdr_doc(xmlDocPtr doc, xmlChar const* nsURI
return entry;
}
static cache_entry* cache_entry_from_url(VARIANT url, xmlChar const* nsURI, MSXML_VERSION v)
static cache_entry* cache_entry_from_url(VARIANT url, xmlChar const* nsURI, MSXML_VERSION version)
{
cache_entry* entry;
IXMLDOMDocument3* domdoc = NULL;
xmlDocPtr doc = NULL;
HRESULT hr = DOMDocument_create(DOMDocument_version(v), NULL, (void**)&domdoc);
HRESULT hr = DOMDocument_create(version, NULL, (void**)&domdoc);
VARIANT_BOOL b = VARIANT_FALSE;
SCHEMA_TYPE type = SCHEMA_TYPE_INVALID;
@ -924,10 +924,10 @@ static cache_entry* cache_entry_from_url(VARIANT url, xmlChar const* nsURI, MSXM
switch (type)
{
case SCHEMA_TYPE_XSD:
entry = cache_entry_from_xsd_doc(doc, nsURI, v);
entry = cache_entry_from_xsd_doc(doc, nsURI, version);
break;
case SCHEMA_TYPE_XDR:
entry = cache_entry_from_xdr_doc(doc, nsURI, v);
entry = cache_entry_from_xdr_doc(doc, nsURI, version);
break;
case SCHEMA_TYPE_INVALID:
entry = NULL;
@ -1414,7 +1414,7 @@ XDR_DT SchemaCache_get_node_dt(IXMLDOMSchemaCollection2* iface, xmlNodePtr node)
return dt;
}
HRESULT SchemaCache_create(const GUID *clsid, IUnknown* pUnkOuter, void** ppObj)
HRESULT SchemaCache_create(MSXML_VERSION version, IUnknown* pUnkOuter, void** ppObj)
{
schema_cache* This = heap_alloc(sizeof(schema_cache));
if (!This)
@ -1423,15 +1423,7 @@ HRESULT SchemaCache_create(const GUID *clsid, IUnknown* pUnkOuter, void** ppObj)
This->lpVtbl = &schema_cache_vtbl;
This->cache = xmlHashCreate(DEFAULT_HASHTABLE_SIZE);
This->ref = 1;
if (IsEqualCLSID(clsid, &CLSID_XMLSchemaCache30))
This->version = MSXML3;
else if (IsEqualCLSID(clsid, &CLSID_DOMDocument40))
This->version = MSXML4;
else if (IsEqualCLSID(clsid, &CLSID_DOMDocument60))
This->version = MSXML6;
else
This->version = MSXML_DEFAULT;
This->version = version;
*ppObj = &This->lpVtbl;
return S_OK;
@ -1439,7 +1431,7 @@ HRESULT SchemaCache_create(const GUID *clsid, IUnknown* pUnkOuter, void** ppObj)
#else
HRESULT SchemaCache_create(const GUID *clsid, IUnknown* pUnkOuter, void** ppObj)
HRESULT SchemaCache_create(MSXML_VERSION version, IUnknown* pUnkOuter, void** ppObj)
{
MESSAGE("This program tried to use a SchemaCache object, but\n"
"libxml2 support was not present at compile time.\n");

View File

@ -414,7 +414,7 @@ static HRESULT WINAPI xslprocessor_put_input( IXSLProcessor *iface, VARIANT inpu
{
IXMLDOMDocument *doc;
hr = DOMDocument_create(&CLSID_DOMDocument, NULL, (void**)&doc);
hr = DOMDocument_create(MSXML_DEFAULT, NULL, (void**)&doc);
if (hr == S_OK)
{
VARIANT_BOOL b;