Commit 5262c570 authored by Nikolay Sivov's avatar Nikolay Sivov Committed by Alexandre Julliard

msxml3: Accept NODE_ENTITY_REFERENCE in ::createNode() and use it for ::createEntityReference().

parent 20a240fe
...@@ -1253,32 +1253,30 @@ static HRESULT WINAPI domdoc_createAttribute( ...@@ -1253,32 +1253,30 @@ static HRESULT WINAPI domdoc_createAttribute(
static HRESULT WINAPI domdoc_createEntityReference( static HRESULT WINAPI domdoc_createEntityReference(
IXMLDOMDocument2 *iface, IXMLDOMDocument2 *iface,
BSTR name, BSTR name,
IXMLDOMEntityReference** entityRef ) IXMLDOMEntityReference** entityref )
{ {
domdoc *This = impl_from_IXMLDOMDocument2( iface ); domdoc *This = impl_from_IXMLDOMDocument2( iface );
xmlNodePtr xmlnode; IXMLDOMNode *node;
xmlChar *xml_name; VARIANT type;
HRESULT hr;
TRACE("%p\n", iface);
if(!entityRef) TRACE("%p->(%s %p)\n", This, debugstr_w(name), entityref);
return E_INVALIDARG;
*entityRef = NULL; if (!entityref) return E_INVALIDARG;
xml_name = xmlChar_from_wchar(name); *entityref = NULL;
xmlnode = xmlNewReference(get_doc( This ), xml_name );
heap_free(xml_name);
if(!xmlnode) V_VT(&type) = VT_I1;
return E_FAIL; V_I1(&type) = NODE_ENTITY_REFERENCE;
xmlnode->doc = get_doc( This );
xmldoc_add_orphan(xmlnode->doc, xmlnode);
*entityRef = (IXMLDOMEntityReference*)create_doc_entity_ref(xmlnode); hr = IXMLDOMDocument2_createNode(iface, type, name, NULL, &node);
if (hr == S_OK)
{
IXMLDOMNode_QueryInterface(node, &IID_IXMLDOMEntityReference, (void**)entityref);
IXMLDOMNode_Release(node);
}
return S_OK; return hr;
} }
...@@ -1358,6 +1356,7 @@ static HRESULT WINAPI domdoc_createNode( ...@@ -1358,6 +1356,7 @@ static HRESULT WINAPI domdoc_createNode(
{ {
case NODE_ELEMENT: case NODE_ELEMENT:
case NODE_ATTRIBUTE: case NODE_ATTRIBUTE:
case NODE_ENTITY_REFERENCE:
case NODE_PROCESSING_INSTRUCTION: case NODE_PROCESSING_INSTRUCTION:
if (!name || SysStringLen(name) == 0) return E_FAIL; if (!name || SysStringLen(name) == 0) return E_FAIL;
default: default:
...@@ -1380,6 +1379,9 @@ static HRESULT WINAPI domdoc_createNode( ...@@ -1380,6 +1379,9 @@ static HRESULT WINAPI domdoc_createNode(
case NODE_CDATA_SECTION: case NODE_CDATA_SECTION:
xmlnode = xmlNewCDataBlock(get_doc(This), NULL, 0); xmlnode = xmlNewCDataBlock(get_doc(This), NULL, 0);
break; break;
case NODE_ENTITY_REFERENCE:
xmlnode = xmlNewReference(get_doc(This), xml_name);
break;
case NODE_PROCESSING_INSTRUCTION: case NODE_PROCESSING_INSTRUCTION:
#ifdef HAVE_XMLNEWDOCPI #ifdef HAVE_XMLNEWDOCPI
xmlnode = xmlNewDocPI(get_doc(This), xml_name, NULL); xmlnode = xmlNewDocPI(get_doc(This), xml_name, NULL);
......
...@@ -1907,6 +1907,22 @@ static void test_create(void) ...@@ -1907,6 +1907,22 @@ static void test_create(void)
r = IXMLDOMDocument_createNode( doc, var, _bstr_("pi"), NULL, NULL ); r = IXMLDOMDocument_createNode( doc, var, _bstr_("pi"), NULL, NULL );
ok( r == E_INVALIDARG, "returns %08x\n", r ); ok( r == E_INVALIDARG, "returns %08x\n", r );
/* NODE_ENTITY_REFERENCE */
V_VT(&var) = VT_I1;
V_I1(&var) = NODE_ENTITY_REFERENCE;
str = SysAllocString( szlc );
node = (IXMLDOMNode*)0x1;
r = IXMLDOMDocument_createNode( doc, var, NULL, NULL, &node );
ok( r == E_FAIL, "returns %08x\n", r );
ok( node == (void*)0x1, "expected same ptr, got %p\n", node);
V_VT(&var) = VT_I1;
V_I1(&var) = NODE_ENTITY_REFERENCE;
node = (IXMLDOMNode*)0x1;
r = IXMLDOMDocument_createNode( doc, var, _bstr_(""), NULL, &node );
ok( r == E_FAIL, "returns %08x\n", r );
ok( node == (void*)0x1, "expected same ptr, got %p\n", node);
/* NODE_ELEMENT */ /* NODE_ELEMENT */
V_VT(&var) = VT_I1; V_VT(&var) = VT_I1;
V_I1(&var) = NODE_ELEMENT; V_I1(&var) = NODE_ELEMENT;
...@@ -3882,6 +3898,11 @@ static void test_xmlTypes(void) ...@@ -3882,6 +3898,11 @@ static void test_xmlTypes(void)
} }
/* Entity References */ /* Entity References */
hr = IXMLDOMDocument_createEntityReference(doc, NULL, &pEntityRef);
ok(hr == E_FAIL, "ret %08x\n", hr );
hr = IXMLDOMDocument_createEntityReference(doc, _bstr_(""), &pEntityRef);
ok(hr == E_FAIL, "ret %08x\n", hr );
str = SysAllocString(szEntityRef); str = SysAllocString(szEntityRef);
hr = IXMLDOMDocument_createEntityReference(doc, str, NULL); hr = IXMLDOMDocument_createEntityReference(doc, str, NULL);
ok(hr == E_INVALIDARG, "ret %08x\n", hr ); ok(hr == E_INVALIDARG, "ret %08x\n", hr );
......
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