Commit 4877da66 authored by Nikolay Sivov's avatar Nikolay Sivov Committed by Alexandre Julliard

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

parent 74a7edd4
...@@ -287,7 +287,7 @@ static xmldoc_priv * create_priv(void) ...@@ -287,7 +287,7 @@ static xmldoc_priv * create_priv(void)
return priv; 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)); domdoc_properties *properties = heap_alloc(sizeof(domdoc_properties));
...@@ -298,26 +298,8 @@ static domdoc_properties * create_properties(const GUID *clsid) ...@@ -298,26 +298,8 @@ static domdoc_properties * create_properties(const GUID *clsid)
properties->selectNsStr_len = 0; properties->selectNsStr_len = 0;
/* properties that are dependent on object versions */ /* properties that are dependent on object versions */
if (IsEqualCLSID(clsid, &CLSID_DOMDocument30)) properties->version = version;
{ properties->XPath = (version == MSXML4 || version == MSXML6);
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;
}
return properties; return properties;
} }
...@@ -556,10 +538,10 @@ static xmlDocPtr doparse(domdoc* This, char const* ptr, int len, xmlCharEncoding ...@@ -556,10 +538,10 @@ static xmlDocPtr doparse(domdoc* This, char const* ptr, int len, xmlCharEncoding
return doc; return doc;
} }
void xmldoc_init(xmlDocPtr doc, const GUID *clsid) void xmldoc_init(xmlDocPtr doc, MSXML_VERSION version)
{ {
doc->_private = create_priv(); 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) LONG xmldoc_add_ref(xmlDocPtr doc)
...@@ -3516,19 +3498,19 @@ HRESULT get_domdoc_from_xmldoc(xmlDocPtr xmldoc, IXMLDOMDocument3 **document) ...@@ -3516,19 +3498,19 @@ HRESULT get_domdoc_from_xmldoc(xmlDocPtr xmldoc, IXMLDOMDocument3 **document)
return S_OK; 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; xmlDocPtr xmldoc;
HRESULT hr; HRESULT hr;
TRACE("(%s, %p, %p)\n", debugstr_guid(clsid), pUnkOuter, ppObj); TRACE("(%d, %p, %p)\n", version, pUnkOuter, ppObj);
xmldoc = xmlNewDoc(NULL); xmldoc = xmlNewDoc(NULL);
if(!xmldoc) if(!xmldoc)
return E_OUTOFMEMORY; return E_OUTOFMEMORY;
xmldoc->_private = create_priv(); 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); hr = get_domdoc_from_xmldoc(xmldoc, (IXMLDOMDocument3**)ppObj);
if(FAILED(hr)) if(FAILED(hr))
...@@ -3558,7 +3540,7 @@ IUnknown* create_domdoc( xmlNodePtr document ) ...@@ -3558,7 +3540,7 @@ IUnknown* create_domdoc( xmlNodePtr document )
#else #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" MESSAGE("This program tried to use a DOMDocument object, but\n"
"libxml2 support was not present at compile time.\n"); "libxml2 support was not present at compile time.\n");
......
...@@ -46,8 +46,49 @@ ...@@ -46,8 +46,49 @@
WINE_DEFAULT_DEBUG_CHANNEL(msxml); WINE_DEFAULT_DEBUG_CHANNEL(msxml);
typedef HRESULT (*ClassFactoryCreateInstanceFunc)(IUnknown *pUnkOuter, LPVOID *ppObj); typedef HRESULT (*ClassFactoryCreateInstanceFunc)(IUnknown*, void**);
typedef HRESULT (*DOMFactoryCreateInstanceFunc)(const GUID *clsid, IUnknown *pUnkOuter, LPVOID *ppObj); 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 * MSXML ClassFactory
...@@ -63,7 +104,7 @@ typedef struct ...@@ -63,7 +104,7 @@ typedef struct
IClassFactory IClassFactory_iface; IClassFactory IClassFactory_iface;
LONG ref; LONG ref;
DOMFactoryCreateInstanceFunc pCreateInstance; DOMFactoryCreateInstanceFunc pCreateInstance;
GUID clsid; MSXML_VERSION version;
} DOMFactory; } DOMFactory;
static inline ClassFactory *ClassFactory_from_IClassFactory(IClassFactory *iface) static inline ClassFactory *ClassFactory_from_IClassFactory(IClassFactory *iface)
...@@ -174,7 +215,7 @@ static HRESULT WINAPI DOMClassFactory_CreateInstance( ...@@ -174,7 +215,7 @@ static HRESULT WINAPI DOMClassFactory_CreateInstance(
if (pOuter) if (pOuter)
return CLASS_E_NOAGGREGATION; return CLASS_E_NOAGGREGATION;
r = This->pCreateInstance( &This->clsid, pOuter, (void**) &punk ); r = This->pCreateInstance( This->version, pOuter, (void**) &punk );
if (FAILED(r)) if (FAILED(r))
return r; return r;
...@@ -208,7 +249,7 @@ static HRESULT DOMClassFactory_Create(const GUID *clsid, REFIID riid, void **ppv ...@@ -208,7 +249,7 @@ static HRESULT DOMClassFactory_Create(const GUID *clsid, REFIID riid, void **ppv
ret->IClassFactory_iface.lpVtbl = &DOMClassFactoryVtbl; ret->IClassFactory_iface.lpVtbl = &DOMClassFactoryVtbl;
ret->ref = 0; ret->ref = 0;
ret->clsid = *clsid; ret->version = get_msxml_version(clsid);
ret->pCreateInstance = fnCreateInstance; ret->pCreateInstance = fnCreateInstance;
hres = IClassFactory_QueryInterface(&ret->IClassFactory_iface, riid, ppv); hres = IClassFactory_QueryInterface(&ret->IClassFactory_iface, riid, ppv);
......
...@@ -848,7 +848,7 @@ static HRESULT WINAPI httprequest_get_responseXML(IXMLHTTPRequest *iface, IDispa ...@@ -848,7 +848,7 @@ static HRESULT WINAPI httprequest_get_responseXML(IXMLHTTPRequest *iface, IDispa
if (!body) return E_INVALIDARG; if (!body) return E_INVALIDARG;
if (This->state != READYSTATE_COMPLETE) return E_FAIL; 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; if (hr != S_OK) return hr;
hr = IXMLHTTPRequest_get_responseText(iface, &str); hr = IXMLHTTPRequest_get_responseText(iface, &str);
......
...@@ -253,7 +253,7 @@ xmlNodePtr xmlNodePtr_from_domnode( IXMLDOMNode *iface, xmlElementType type ) DE ...@@ -253,7 +253,7 @@ xmlNodePtr xmlNodePtr_from_domnode( IXMLDOMNode *iface, xmlElementType type ) DE
/* helpers */ /* helpers */
extern xmlChar *xmlChar_from_wchar( LPCWSTR str ) DECLSPEC_HIDDEN; 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_add_ref( xmlDocPtr doc ) DECLSPEC_HIDDEN;
extern LONG xmldoc_release( xmlDocPtr doc ) DECLSPEC_HIDDEN; extern LONG xmldoc_release( xmlDocPtr doc ) DECLSPEC_HIDDEN;
extern HRESULT xmldoc_add_orphan( xmlDocPtr doc, xmlNodePtr node ) 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 ) ...@@ -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, extern IXMLDOMParseError *create_parseError( LONG code, BSTR url, BSTR reason, BSTR srcText,
LONG line, LONG linepos, LONG filepos ) DECLSPEC_HIDDEN; LONG line, LONG linepos, LONG filepos ) DECLSPEC_HIDDEN;
extern HRESULT DOMDocument_create(const GUID*, IUnknown*, void**) DECLSPEC_HIDDEN; extern HRESULT DOMDocument_create(MSXML_VERSION, IUnknown*, void**) DECLSPEC_HIDDEN;
extern HRESULT SchemaCache_create(const GUID*, IUnknown*, void**) DECLSPEC_HIDDEN; extern HRESULT SchemaCache_create(MSXML_VERSION, IUnknown*, void**) DECLSPEC_HIDDEN;
extern HRESULT XMLDocument_create(IUnknown*, void**) DECLSPEC_HIDDEN; extern HRESULT XMLDocument_create(IUnknown*, void**) DECLSPEC_HIDDEN;
extern HRESULT SAXXMLReader_create(IUnknown*, void**) DECLSPEC_HIDDEN; extern HRESULT SAXXMLReader_create(IUnknown*, void**) DECLSPEC_HIDDEN;
extern HRESULT XMLHTTPRequest_create(IUnknown*, void **) DECLSPEC_HIDDEN; extern HRESULT XMLHTTPRequest_create(IUnknown*, void **) DECLSPEC_HIDDEN;
......
...@@ -842,7 +842,7 @@ static cache_entry* cache_entry_from_xsd_doc(xmlDocPtr doc, xmlChar const* nsURI ...@@ -842,7 +842,7 @@ static cache_entry* cache_entry_from_xsd_doc(xmlDocPtr doc, xmlChar const* nsURI
if ((entry->schema = Schema_parse(spctx))) 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; entry->doc = entry->schema->doc;
xmldoc_add_ref(entry->doc); xmldoc_add_ref(entry->doc);
} }
...@@ -857,7 +857,7 @@ static cache_entry* cache_entry_from_xsd_doc(xmlDocPtr doc, xmlChar const* nsURI ...@@ -857,7 +857,7 @@ static cache_entry* cache_entry_from_xsd_doc(xmlDocPtr doc, xmlChar const* nsURI
return entry; 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)); cache_entry* entry = heap_alloc(sizeof(cache_entry));
xmlSchemaParserCtxtPtr spctx; xmlSchemaParserCtxtPtr spctx;
...@@ -872,8 +872,8 @@ static cache_entry* cache_entry_from_xdr_doc(xmlDocPtr doc, xmlChar const* nsURI ...@@ -872,8 +872,8 @@ static cache_entry* cache_entry_from_xdr_doc(xmlDocPtr doc, xmlChar const* nsURI
if ((entry->schema = Schema_parse(spctx))) if ((entry->schema = Schema_parse(spctx)))
{ {
entry->doc = new_doc; entry->doc = new_doc;
xmldoc_init(entry->schema->doc, DOMDocument_version(v)); xmldoc_init(entry->schema->doc, version);
xmldoc_init(entry->doc, DOMDocument_version(v)); xmldoc_init(entry->doc, version);
xmldoc_add_ref(entry->doc); xmldoc_add_ref(entry->doc);
xmldoc_add_ref(entry->schema->doc); xmldoc_add_ref(entry->schema->doc);
} }
...@@ -890,12 +890,12 @@ static cache_entry* cache_entry_from_xdr_doc(xmlDocPtr doc, xmlChar const* nsURI ...@@ -890,12 +890,12 @@ static cache_entry* cache_entry_from_xdr_doc(xmlDocPtr doc, xmlChar const* nsURI
return entry; 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; cache_entry* entry;
IXMLDOMDocument3* domdoc = NULL; IXMLDOMDocument3* domdoc = NULL;
xmlDocPtr doc = 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; VARIANT_BOOL b = VARIANT_FALSE;
SCHEMA_TYPE type = SCHEMA_TYPE_INVALID; SCHEMA_TYPE type = SCHEMA_TYPE_INVALID;
...@@ -924,10 +924,10 @@ static cache_entry* cache_entry_from_url(VARIANT url, xmlChar const* nsURI, MSXM ...@@ -924,10 +924,10 @@ static cache_entry* cache_entry_from_url(VARIANT url, xmlChar const* nsURI, MSXM
switch (type) switch (type)
{ {
case SCHEMA_TYPE_XSD: case SCHEMA_TYPE_XSD:
entry = cache_entry_from_xsd_doc(doc, nsURI, v); entry = cache_entry_from_xsd_doc(doc, nsURI, version);
break; break;
case SCHEMA_TYPE_XDR: case SCHEMA_TYPE_XDR:
entry = cache_entry_from_xdr_doc(doc, nsURI, v); entry = cache_entry_from_xdr_doc(doc, nsURI, version);
break; break;
case SCHEMA_TYPE_INVALID: case SCHEMA_TYPE_INVALID:
entry = NULL; entry = NULL;
...@@ -1414,7 +1414,7 @@ XDR_DT SchemaCache_get_node_dt(IXMLDOMSchemaCollection2* iface, xmlNodePtr node) ...@@ -1414,7 +1414,7 @@ XDR_DT SchemaCache_get_node_dt(IXMLDOMSchemaCollection2* iface, xmlNodePtr node)
return dt; 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)); schema_cache* This = heap_alloc(sizeof(schema_cache));
if (!This) if (!This)
...@@ -1423,15 +1423,7 @@ HRESULT SchemaCache_create(const GUID *clsid, IUnknown* pUnkOuter, void** ppObj) ...@@ -1423,15 +1423,7 @@ HRESULT SchemaCache_create(const GUID *clsid, IUnknown* pUnkOuter, void** ppObj)
This->lpVtbl = &schema_cache_vtbl; This->lpVtbl = &schema_cache_vtbl;
This->cache = xmlHashCreate(DEFAULT_HASHTABLE_SIZE); This->cache = xmlHashCreate(DEFAULT_HASHTABLE_SIZE);
This->ref = 1; This->ref = 1;
This->version = version;
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;
*ppObj = &This->lpVtbl; *ppObj = &This->lpVtbl;
return S_OK; return S_OK;
...@@ -1439,7 +1431,7 @@ HRESULT SchemaCache_create(const GUID *clsid, IUnknown* pUnkOuter, void** ppObj) ...@@ -1439,7 +1431,7 @@ HRESULT SchemaCache_create(const GUID *clsid, IUnknown* pUnkOuter, void** ppObj)
#else #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" MESSAGE("This program tried to use a SchemaCache object, but\n"
"libxml2 support was not present at compile time.\n"); "libxml2 support was not present at compile time.\n");
......
...@@ -414,7 +414,7 @@ static HRESULT WINAPI xslprocessor_put_input( IXSLProcessor *iface, VARIANT inpu ...@@ -414,7 +414,7 @@ static HRESULT WINAPI xslprocessor_put_input( IXSLProcessor *iface, VARIANT inpu
{ {
IXMLDOMDocument *doc; IXMLDOMDocument *doc;
hr = DOMDocument_create(&CLSID_DOMDocument, NULL, (void**)&doc); hr = DOMDocument_create(MSXML_DEFAULT, NULL, (void**)&doc);
if (hr == S_OK) if (hr == S_OK)
{ {
VARIANT_BOOL b; VARIANT_BOOL b;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment