Commit 459c29ba authored by Adam Martinson's avatar Adam Martinson Committed by Alexandre Julliard

msxml3: Store the DOMDocument/XMLSchemaCache object version.

parent 10e2d26e
...@@ -75,6 +75,7 @@ static const WCHAR PropValueXSLPatternW[] = {'X','S','L','P','a','t','t','e','r' ...@@ -75,6 +75,7 @@ static const WCHAR PropValueXSLPatternW[] = {'X','S','L','P','a','t','t','e','r'
* We need to preserve this when reloading a document, * We need to preserve this when reloading a document,
* and also need access to it from the libxml backend. */ * and also need access to it from the libxml backend. */
typedef struct _domdoc_properties { typedef struct _domdoc_properties {
MSXML_VERSION version;
VARIANT_BOOL preserving; VARIANT_BOOL preserving;
IXMLDOMSchemaCollection2* schemaCache; IXMLDOMSchemaCollection2* schemaCache;
struct list selectNsList; struct list selectNsList;
...@@ -249,20 +250,31 @@ static domdoc_properties * create_properties(const GUID *clsid) ...@@ -249,20 +250,31 @@ static domdoc_properties * create_properties(const GUID *clsid)
{ {
domdoc_properties *properties = heap_alloc(sizeof(domdoc_properties)); domdoc_properties *properties = heap_alloc(sizeof(domdoc_properties));
list_init( &properties->selectNsList ); list_init(&properties->selectNsList);
properties->preserving = VARIANT_FALSE; properties->preserving = VARIANT_FALSE;
properties->schemaCache = NULL; properties->schemaCache = NULL;
properties->selectNsStr = heap_alloc_zero(sizeof(xmlChar)); properties->selectNsStr = heap_alloc_zero(sizeof(xmlChar));
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_DOMDocument40 ) || if (IsEqualCLSID(clsid, &CLSID_DOMDocument30))
IsEqualCLSID( clsid, &CLSID_DOMDocument60 ))
{ {
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; properties->XPath = TRUE;
} }
else else
{ {
properties->version = MSXML_DEFAULT;
properties->XPath = FALSE; properties->XPath = FALSE;
} }
...@@ -279,6 +291,7 @@ static domdoc_properties* copy_properties(domdoc_properties const* properties) ...@@ -279,6 +291,7 @@ static domdoc_properties* copy_properties(domdoc_properties const* properties)
if (pcopy) if (pcopy)
{ {
pcopy->version = properties->version;
pcopy->preserving = properties->preserving; pcopy->preserving = properties->preserving;
pcopy->schemaCache = properties->schemaCache; pcopy->schemaCache = properties->schemaCache;
pcopy->XPath = properties->XPath; pcopy->XPath = properties->XPath;
...@@ -630,33 +643,34 @@ static inline domdoc *impl_from_IConnectionPointContainer(IConnectionPointContai ...@@ -630,33 +643,34 @@ static inline domdoc *impl_from_IConnectionPointContainer(IConnectionPointContai
static HRESULT WINAPI domdoc_IPersistStreamInit_QueryInterface( static HRESULT WINAPI domdoc_IPersistStreamInit_QueryInterface(
IPersistStreamInit *iface, REFIID riid, void **ppvObj) IPersistStreamInit *iface, REFIID riid, void **ppvObj)
{ {
domdoc *this = impl_from_IPersistStreamInit(iface); domdoc* This = impl_from_IPersistStreamInit(iface);
return IXMLDOMDocument2_QueryInterface((IXMLDOMDocument2 *)this, riid, ppvObj); return IXMLDOMDocument3_QueryInterface((IXMLDOMDocument3*)&This->lpVtbl, riid, ppvObj);
} }
static ULONG WINAPI domdoc_IPersistStreamInit_AddRef( static ULONG WINAPI domdoc_IPersistStreamInit_AddRef(
IPersistStreamInit *iface) IPersistStreamInit *iface)
{ {
domdoc *this = impl_from_IPersistStreamInit(iface); domdoc* This = impl_from_IPersistStreamInit(iface);
return IXMLDOMDocument2_AddRef((IXMLDOMDocument2 *)this); return IXMLDOMDocument3_AddRef((IXMLDOMDocument3*)&This->lpVtbl);
} }
static ULONG WINAPI domdoc_IPersistStreamInit_Release( static ULONG WINAPI domdoc_IPersistStreamInit_Release(
IPersistStreamInit *iface) IPersistStreamInit *iface)
{ {
domdoc *this = impl_from_IPersistStreamInit(iface); domdoc* This = impl_from_IPersistStreamInit(iface);
return IXMLDOMDocument2_Release((IXMLDOMDocument2 *)this); return IXMLDOMDocument3_Release((IXMLDOMDocument3*)&This->lpVtbl);
} }
static HRESULT WINAPI domdoc_IPersistStreamInit_GetClassID( static HRESULT WINAPI domdoc_IPersistStreamInit_GetClassID(
IPersistStreamInit *iface, CLSID *classid) IPersistStreamInit *iface, CLSID *classid)
{ {
TRACE("(%p,%p): stub!\n", iface, classid); domdoc* This = impl_from_IPersistStreamInit(iface);
TRACE("(%p)->(%p)\n", This, classid);
if(!classid) if(!classid)
return E_POINTER; return E_POINTER;
*classid = CLSID_DOMDocument2; *classid = *DOMDocument_version(This->properties->version);
return S_OK; return S_OK;
} }
......
...@@ -204,7 +204,6 @@ static HRESULT DOMClassFactory_Create(const GUID *clsid, REFIID riid, void **ppv ...@@ -204,7 +204,6 @@ static HRESULT DOMClassFactory_Create(const GUID *clsid, REFIID riid, void **ppv
return hres; return hres;
} }
static ClassFactory schemacf = { &ClassFactoryVtbl, SchemaCache_create };
static ClassFactory xmldoccf = { &ClassFactoryVtbl, XMLDocument_create }; static ClassFactory xmldoccf = { &ClassFactoryVtbl, XMLDocument_create };
static ClassFactory saxreadcf = { &ClassFactoryVtbl, SAXXMLReader_create }; static ClassFactory saxreadcf = { &ClassFactoryVtbl, SAXXMLReader_create };
static ClassFactory httpreqcf = { &ClassFactoryVtbl, XMLHTTPRequest_create }; static ClassFactory httpreqcf = { &ClassFactoryVtbl, XMLHTTPRequest_create };
...@@ -231,7 +230,7 @@ HRESULT WINAPI DllGetClassObject( REFCLSID rclsid, REFIID riid, void **ppv ) ...@@ -231,7 +230,7 @@ HRESULT WINAPI DllGetClassObject( REFCLSID rclsid, REFIID riid, void **ppv )
IsEqualCLSID( rclsid, &CLSID_XMLSchemaCache40 ) || IsEqualCLSID( rclsid, &CLSID_XMLSchemaCache40 ) ||
IsEqualCLSID( rclsid, &CLSID_XMLSchemaCache60 )) IsEqualCLSID( rclsid, &CLSID_XMLSchemaCache60 ))
{ {
cf = (IClassFactory*) &schemacf.lpVtbl; return DOMClassFactory_Create(rclsid, riid, ppv, SchemaCache_create);
} }
else if( IsEqualCLSID( rclsid, &CLSID_XMLDocument ) ) else if( IsEqualCLSID( rclsid, &CLSID_XMLDocument ) )
{ {
......
...@@ -29,6 +29,13 @@ ...@@ -29,6 +29,13 @@
# error You must include config.h to use this header # error You must include config.h to use this header
#endif #endif
typedef enum {
MSXML_DEFAULT = 0,
MSXML3 = 30,
MSXML4 = 40,
MSXML6 = 60
} MSXML_VERSION;
/* typelibs */ /* typelibs */
typedef enum tid_t { typedef enum tid_t {
IXMLDOMAttribute_tid, IXMLDOMAttribute_tid,
...@@ -371,11 +378,53 @@ MAKE_FUNCPTR(xsltParseStylesheetDoc); ...@@ -371,11 +378,53 @@ MAKE_FUNCPTR(xsltParseStylesheetDoc);
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 ); LONG line, LONG linepos, LONG filepos );
extern HRESULT DOMDocument_create( const GUID *clsid, IUnknown *pUnkOuter, void **ppObj ); extern HRESULT DOMDocument_create( const GUID *clsid, IUnknown *pUnkOuter, void **ppObj );
extern HRESULT SchemaCache_create( IUnknown *pUnkOuter, void **pObj ); extern HRESULT SchemaCache_create( const GUID *clsid, IUnknown *pUnkOuter, void **ppObj );
extern HRESULT XMLDocument_create( IUnknown *pUnkOuter, void **pObj ); extern HRESULT XMLDocument_create( IUnknown *pUnkOuter, void **pObj );
extern HRESULT SAXXMLReader_create(IUnknown *pUnkOuter, void **pObj ); extern HRESULT SAXXMLReader_create(IUnknown *pUnkOuter, void **pObj );
extern HRESULT XMLHTTPRequest_create(IUnknown *pUnkOuter, void **pObj); extern HRESULT XMLHTTPRequest_create(IUnknown *pUnkOuter, void **pObj);
static inline const CLSID* DOMDocument_version(const MSXML_VERSION v)
{
CLSID const* clsid;
switch (v)
{
case MSXML_DEFAULT:
clsid = &CLSID_DOMDocument;
break;
case MSXML3:
clsid = &CLSID_DOMDocument30;
break;
case MSXML4:
clsid = &CLSID_DOMDocument40;
break;
case MSXML6:
clsid = &CLSID_DOMDocument60;
break;
}
return clsid;
}
static inline const CLSID* SchemaCache_version(const MSXML_VERSION v)
{
CLSID const* clsid;
switch (v)
{
case MSXML_DEFAULT:
clsid = &CLSID_XMLSchemaCache;
break;
case MSXML3:
clsid = &CLSID_XMLSchemaCache30;
break;
case MSXML4:
clsid = &CLSID_XMLSchemaCache40;
break;
case MSXML6:
clsid = &CLSID_XMLSchemaCache60;
break;
}
return clsid;
}
typedef struct bsc_t bsc_t; typedef struct bsc_t bsc_t;
HRESULT bind_url(LPCWSTR, HRESULT (*onDataAvailable)(void*,char*,DWORD), void*, bsc_t**); HRESULT bind_url(LPCWSTR, HRESULT (*onDataAvailable)(void*,char*,DWORD), void*, bsc_t**);
......
...@@ -85,6 +85,7 @@ typedef enum _SCHEMA_TYPE { ...@@ -85,6 +85,7 @@ typedef enum _SCHEMA_TYPE {
typedef struct _schema_cache typedef struct _schema_cache
{ {
const struct IXMLDOMSchemaCollection2Vtbl* lpVtbl; const struct IXMLDOMSchemaCollection2Vtbl* lpVtbl;
MSXML_VERSION version;
xmlHashTablePtr cache; xmlHashTablePtr cache;
LONG ref; LONG ref;
} schema_cache; } schema_cache;
...@@ -818,7 +819,7 @@ static BOOL link_datatypes(xmlDocPtr schema) ...@@ -818,7 +819,7 @@ static BOOL link_datatypes(xmlDocPtr schema)
return TRUE; return TRUE;
} }
static cache_entry* cache_entry_from_xsd_doc(xmlDocPtr doc, xmlChar const* nsURI) static cache_entry* cache_entry_from_xsd_doc(xmlDocPtr doc, xmlChar const* nsURI, MSXML_VERSION v)
{ {
cache_entry* entry = heap_alloc(sizeof(cache_entry)); cache_entry* entry = heap_alloc(sizeof(cache_entry));
xmlSchemaParserCtxtPtr spctx; xmlSchemaParserCtxtPtr spctx;
...@@ -834,7 +835,7 @@ static cache_entry* cache_entry_from_xsd_doc(xmlDocPtr doc, xmlChar const* nsURI ...@@ -834,7 +835,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, &CLSID_DOMDocument40); xmldoc_init(entry->schema->doc, DOMDocument_version(v));
entry->doc = entry->schema->doc; entry->doc = entry->schema->doc;
xmldoc_add_ref(entry->doc); xmldoc_add_ref(entry->doc);
} }
...@@ -849,7 +850,7 @@ static cache_entry* cache_entry_from_xsd_doc(xmlDocPtr doc, xmlChar const* nsURI ...@@ -849,7 +850,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) static cache_entry* cache_entry_from_xdr_doc(xmlDocPtr doc, xmlChar const* nsURI, MSXML_VERSION v)
{ {
cache_entry* entry = heap_alloc(sizeof(cache_entry)); cache_entry* entry = heap_alloc(sizeof(cache_entry));
xmlSchemaParserCtxtPtr spctx; xmlSchemaParserCtxtPtr spctx;
...@@ -864,8 +865,8 @@ static cache_entry* cache_entry_from_xdr_doc(xmlDocPtr doc, xmlChar const* nsURI ...@@ -864,8 +865,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, &CLSID_DOMDocument30); xmldoc_init(entry->schema->doc, DOMDocument_version(v));
xmldoc_init(entry->doc, &CLSID_DOMDocument30); xmldoc_init(entry->doc, DOMDocument_version(v));
xmldoc_add_ref(entry->doc); xmldoc_add_ref(entry->doc);
xmldoc_add_ref(entry->schema->doc); xmldoc_add_ref(entry->schema->doc);
} }
...@@ -882,12 +883,12 @@ static cache_entry* cache_entry_from_xdr_doc(xmlDocPtr doc, xmlChar const* nsURI ...@@ -882,12 +883,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) static cache_entry* cache_entry_from_url(VARIANT url, xmlChar const* nsURI, MSXML_VERSION v)
{ {
cache_entry* entry; cache_entry* entry;
IXMLDOMDocument3* domdoc = NULL; IXMLDOMDocument3* domdoc = NULL;
xmlDocPtr doc = NULL; xmlDocPtr doc = NULL;
HRESULT hr = DOMDocument_create(&CLSID_DOMDocument, NULL, (void**)&domdoc); HRESULT hr = DOMDocument_create(DOMDocument_version(v), 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;
...@@ -916,10 +917,10 @@ static cache_entry* cache_entry_from_url(VARIANT url, xmlChar const* nsURI) ...@@ -916,10 +917,10 @@ static cache_entry* cache_entry_from_url(VARIANT url, xmlChar const* nsURI)
switch (type) switch (type)
{ {
case SCHEMA_TYPE_XSD: case SCHEMA_TYPE_XSD:
entry = cache_entry_from_xsd_doc(doc, nsURI); entry = cache_entry_from_xsd_doc(doc, nsURI, v);
break; break;
case SCHEMA_TYPE_XDR: case SCHEMA_TYPE_XDR:
entry = cache_entry_from_xdr_doc(doc, nsURI); entry = cache_entry_from_xdr_doc(doc, nsURI, v);
break; break;
case SCHEMA_TYPE_INVALID: case SCHEMA_TYPE_INVALID:
entry = NULL; entry = NULL;
...@@ -1073,7 +1074,7 @@ static HRESULT WINAPI schema_cache_add(IXMLDOMSchemaCollection2* iface, BSTR uri ...@@ -1073,7 +1074,7 @@ static HRESULT WINAPI schema_cache_add(IXMLDOMSchemaCollection2* iface, BSTR uri
case VT_BSTR: case VT_BSTR:
{ {
cache_entry* entry = cache_entry_from_url(var, name); cache_entry* entry = cache_entry_from_url(var, name, This->version);
if (entry) if (entry)
{ {
...@@ -1111,11 +1112,11 @@ static HRESULT WINAPI schema_cache_add(IXMLDOMSchemaCollection2* iface, BSTR uri ...@@ -1111,11 +1112,11 @@ static HRESULT WINAPI schema_cache_add(IXMLDOMSchemaCollection2* iface, BSTR uri
if (type == SCHEMA_TYPE_XSD) if (type == SCHEMA_TYPE_XSD)
{ {
entry = cache_entry_from_xsd_doc(doc, name); entry = cache_entry_from_xsd_doc(doc, name, This->version);
} }
else if (type == SCHEMA_TYPE_XDR) else if (type == SCHEMA_TYPE_XDR)
{ {
entry = cache_entry_from_xdr_doc(doc, name); entry = cache_entry_from_xdr_doc(doc, name, This->version);
} }
else else
{ {
...@@ -1405,7 +1406,7 @@ XDR_DT SchemaCache_get_node_dt(IXMLDOMSchemaCollection2* iface, xmlNodePtr node) ...@@ -1405,7 +1406,7 @@ XDR_DT SchemaCache_get_node_dt(IXMLDOMSchemaCollection2* iface, xmlNodePtr node)
return dt; return dt;
} }
HRESULT SchemaCache_create(IUnknown* pUnkOuter, void** ppObj) HRESULT SchemaCache_create(const GUID *clsid, IUnknown* pUnkOuter, void** ppObj)
{ {
schema_cache* This = heap_alloc(sizeof(schema_cache)); schema_cache* This = heap_alloc(sizeof(schema_cache));
if (!This) if (!This)
...@@ -1415,13 +1416,22 @@ HRESULT SchemaCache_create(IUnknown* pUnkOuter, void** ppObj) ...@@ -1415,13 +1416,22 @@ HRESULT SchemaCache_create(IUnknown* pUnkOuter, void** ppObj)
This->cache = xmlHashCreate(DEFAULT_HASHTABLE_SIZE); This->cache = xmlHashCreate(DEFAULT_HASHTABLE_SIZE);
This->ref = 1; 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;
*ppObj = &This->lpVtbl; *ppObj = &This->lpVtbl;
return S_OK; return S_OK;
} }
#else #else
HRESULT SchemaCache_create(IUnknown* pUnkOuter, void** ppObj) HRESULT SchemaCache_create(const GUID *clsid, 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");
......
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