Commit 893e8a46 authored by Nikolay Sivov's avatar Nikolay Sivov Committed by Alexandre Julliard

msxml3: Store selected query language in backend document instance.

parent a930084d
...@@ -77,7 +77,6 @@ typedef struct _domdoc ...@@ -77,7 +77,6 @@ typedef struct _domdoc
VARIANT_BOOL validating; VARIANT_BOOL validating;
VARIANT_BOOL resolving; VARIANT_BOOL resolving;
VARIANT_BOOL preserving; VARIANT_BOOL preserving;
BOOL XPath;
IXMLDOMSchemaCollection *schema; IXMLDOMSchemaCollection *schema;
bsc_t *bsc; bsc_t *bsc;
HRESULT error; HRESULT error;
...@@ -117,6 +116,7 @@ typedef struct _domdoc ...@@ -117,6 +116,7 @@ typedef struct _domdoc
typedef struct _xmldoc_priv { typedef struct _xmldoc_priv {
LONG refs; LONG refs;
struct list orphans; struct list orphans;
BOOL XPath;
} xmldoc_priv; } xmldoc_priv;
typedef struct _orphan_entry { typedef struct _orphan_entry {
...@@ -124,19 +124,35 @@ typedef struct _orphan_entry { ...@@ -124,19 +124,35 @@ typedef struct _orphan_entry {
xmlNode * node; xmlNode * node;
} orphan_entry; } orphan_entry;
static inline xmldoc_priv * priv_from_xmlDocPtr(xmlDocPtr doc) static inline xmldoc_priv * priv_from_xmlDocPtr(const xmlDocPtr doc)
{ {
return doc->_private; return doc->_private;
} }
static inline BOOL is_xpathmode(const xmlDocPtr doc)
{
return priv_from_xmlDocPtr(doc)->XPath;
}
static inline void set_xpathmode(const xmlDocPtr doc)
{
priv_from_xmlDocPtr(doc)->XPath = TRUE;
}
static inline void reset_xpathmode(const xmlDocPtr doc)
{
priv_from_xmlDocPtr(doc)->XPath = FALSE;
}
static xmldoc_priv * create_priv(void) static xmldoc_priv * create_priv(void)
{ {
xmldoc_priv *priv; xmldoc_priv *priv;
priv = heap_alloc( sizeof (*priv) ); priv = heap_alloc( sizeof (*priv) );
if(priv) if (priv)
{ {
priv->refs = 0; priv->refs = 0;
priv->XPath = FALSE;
list_init( &priv->orphans ); list_init( &priv->orphans );
} }
...@@ -2139,9 +2155,9 @@ static HRESULT WINAPI domdoc_setProperty( ...@@ -2139,9 +2155,9 @@ static HRESULT WINAPI domdoc_setProperty(
hr = S_OK; hr = S_OK;
if (lstrcmpiW(bstr, PropValueXPathW) == 0) if (lstrcmpiW(bstr, PropValueXPathW) == 0)
This->XPath = TRUE; set_xpathmode(get_doc(This));
else if (lstrcmpiW(bstr, PropValueXSLPatternW) == 0) else if (lstrcmpiW(bstr, PropValueXSLPatternW) == 0)
This->XPath = FALSE; reset_xpathmode(get_doc(This));
else else
hr = E_FAIL; hr = E_FAIL;
...@@ -2174,17 +2190,16 @@ static HRESULT WINAPI domdoc_getProperty( ...@@ -2174,17 +2190,16 @@ static HRESULT WINAPI domdoc_getProperty(
TRACE("(%p)->(%p)\n", This, debugstr_w(p)); TRACE("(%p)->(%p)\n", This, debugstr_w(p));
if (var == NULL) if (!var)
return E_INVALIDARG; return E_INVALIDARG;
if (lstrcmpiW(p, PropertySelectionLanguageW) == 0) if (lstrcmpiW(p, PropertySelectionLanguageW) == 0)
{ {
V_VT(var) = VT_BSTR; V_VT(var) = VT_BSTR;
if (This->XPath) V_BSTR(var) = is_xpathmode(This->node.node->doc) ?
V_BSTR(var) = SysAllocString(PropValueXPathW); SysAllocString(PropValueXPathW) :
else SysAllocString(PropValueXSLPatternW);
V_BSTR(var) = SysAllocString(PropValueXSLPatternW); return V_BSTR(var) ? S_OK : E_OUTOFMEMORY;
return S_OK;
} }
FIXME("Unknown property %s\n", wine_dbgstr_w(p)); FIXME("Unknown property %s\n", wine_dbgstr_w(p));
...@@ -2461,7 +2476,6 @@ HRESULT DOMDocument_create_from_xmldoc(xmlDocPtr xmldoc, IXMLDOMDocument3 **docu ...@@ -2461,7 +2476,6 @@ HRESULT DOMDocument_create_from_xmldoc(xmlDocPtr xmldoc, IXMLDOMDocument3 **docu
doc->validating = 0; doc->validating = 0;
doc->resolving = 0; doc->resolving = 0;
doc->preserving = 0; doc->preserving = 0;
doc->XPath = FALSE;
doc->error = S_OK; doc->error = S_OK;
doc->schema = NULL; doc->schema = NULL;
doc->stream = NULL; doc->stream = NULL;
...@@ -2482,7 +2496,7 @@ HRESULT DOMDocument_create(const GUID *clsid, IUnknown *pUnkOuter, void **ppObj) ...@@ -2482,7 +2496,7 @@ HRESULT DOMDocument_create(const GUID *clsid, IUnknown *pUnkOuter, void **ppObj)
xmlDocPtr xmldoc; xmlDocPtr xmldoc;
HRESULT hr; HRESULT hr;
TRACE("(%p, %p)\n", pUnkOuter, ppObj); TRACE("(%s, %p, %p)\n", debugstr_guid(clsid), pUnkOuter, ppObj);
xmldoc = xmlNewDoc(NULL); xmldoc = xmlNewDoc(NULL);
if(!xmldoc) if(!xmldoc)
...@@ -2492,14 +2506,17 @@ HRESULT DOMDocument_create(const GUID *clsid, IUnknown *pUnkOuter, void **ppObj) ...@@ -2492,14 +2506,17 @@ HRESULT DOMDocument_create(const GUID *clsid, IUnknown *pUnkOuter, void **ppObj)
hr = DOMDocument_create_from_xmldoc(xmldoc, (IXMLDOMDocument3**)ppObj); hr = DOMDocument_create_from_xmldoc(xmldoc, (IXMLDOMDocument3**)ppObj);
if(FAILED(hr)) if(FAILED(hr))
{
xmlFreeDoc(xmldoc); xmlFreeDoc(xmldoc);
return hr;
}
/* properties that are dependent on object versions */ /* properties that are dependent on object versions */
if (IsEqualCLSID( clsid, &CLSID_DOMDocument40 ) || if (IsEqualCLSID( clsid, &CLSID_DOMDocument40 ) ||
IsEqualCLSID( clsid, &CLSID_DOMDocument60 )) IsEqualCLSID( clsid, &CLSID_DOMDocument60 ))
{ {
domdoc *This = impl_from_IXMLDOMDocument3(*ppObj); domdoc *This = impl_from_IXMLDOMDocument3(*ppObj);
This->XPath = TRUE; set_xpathmode(get_doc(This));
} }
return hr; return hr;
......
...@@ -5961,6 +5961,17 @@ static void test_get_ownerDocument(void) ...@@ -5961,6 +5961,17 @@ static void test_get_ownerDocument(void)
ok( b == VARIANT_TRUE, "failed to load XML string\n"); ok( b == VARIANT_TRUE, "failed to load XML string\n");
SysFreeString( str ); SysFreeString( str );
hr = IXMLDOMDocument2_getProperty(doc, _bstr_("SelectionLanguage"), &var);
ok( hr == S_OK, "got 0x%08x\n", hr);
ok( lstrcmpW(V_BSTR(&var), _bstr_("XSLPattern")) == 0, "expected XSLPattern\n");
VariantClear(&var);
/* set to XPath and check that new instances use it */
V_VT(&var) = VT_BSTR;
V_BSTR(&var) = _bstr_("XPath");
hr = IXMLDOMDocument2_setProperty(doc, _bstr_("SelectionLanguage"), var);
ok( hr == S_OK, "got 0x%08x\n", hr);
V_VT(&var) = VT_BSTR; V_VT(&var) = VT_BSTR;
V_BSTR(&var) = _bstr_("xmlns:wi=\'www.winehq.org\'"); V_BSTR(&var) = _bstr_("xmlns:wi=\'www.winehq.org\'");
hr = IXMLDOMDocument2_setProperty(doc, _bstr_("SelectionNamespaces"), var); hr = IXMLDOMDocument2_setProperty(doc, _bstr_("SelectionNamespaces"), var);
...@@ -5979,9 +5990,14 @@ static void test_get_ownerDocument(void) ...@@ -5979,9 +5990,14 @@ static void test_get_ownerDocument(void)
hr = IXMLDOMDocument2_getProperty(doc_owner, _bstr_("SelectionNamespaces"), &var); hr = IXMLDOMDocument2_getProperty(doc_owner, _bstr_("SelectionNamespaces"), &var);
todo_wine ok( hr == S_OK, "got 0x%08x\n", hr); todo_wine ok( hr == S_OK, "got 0x%08x\n", hr);
todo_wine ok( lstrcmpW(V_BSTR(&var), _bstr_("xmlns:wi=\'www.winehq.org\'")) == 0, "expected previously set value\n"); todo_wine ok( lstrcmpW(V_BSTR(&var), _bstr_("xmlns:wi=\'www.winehq.org\'")) == 0, "expected previously set value\n");
IXMLDOMDocument2_Release(doc_owner);
VariantClear(&var); VariantClear(&var);
hr = IXMLDOMDocument2_getProperty(doc_owner, _bstr_("SelectionLanguage"), &var);
ok( hr == S_OK, "got 0x%08x\n", hr);
ok( lstrcmpW(V_BSTR(&var), _bstr_("XPath")) == 0, "expected XPath\n");
VariantClear(&var);
IXMLDOMDocument2_Release(doc_owner);
hr = IXMLDOMNode_get_ownerDocument(node, &doc2); hr = IXMLDOMNode_get_ownerDocument(node, &doc2);
ok( hr == S_OK, "got 0x%08x\n", hr); ok( hr == S_OK, "got 0x%08x\n", hr);
IXMLDOMNode_Release(node); IXMLDOMNode_Release(node);
......
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