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(
static HRESULT WINAPI domdoc_createEntityReference(
IXMLDOMDocument2 *iface,
BSTR name,
IXMLDOMEntityReference** entityRef )
IXMLDOMEntityReference** entityref )
{
domdoc *This = impl_from_IXMLDOMDocument2( iface );
xmlNodePtr xmlnode;
xmlChar *xml_name;
TRACE("%p\n", iface);
IXMLDOMNode *node;
VARIANT type;
HRESULT hr;
if(!entityRef)
return E_INVALIDARG;
TRACE("%p->(%s %p)\n", This, debugstr_w(name), entityref);
*entityRef = NULL;
if (!entityref) return E_INVALIDARG;
xml_name = xmlChar_from_wchar(name);
xmlnode = xmlNewReference(get_doc( This ), xml_name );
heap_free(xml_name);
*entityref = NULL;
if(!xmlnode)
return E_FAIL;
xmlnode->doc = get_doc( This );
xmldoc_add_orphan(xmlnode->doc, xmlnode);
V_VT(&type) = VT_I1;
V_I1(&type) = NODE_ENTITY_REFERENCE;
*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(
{
case NODE_ELEMENT:
case NODE_ATTRIBUTE:
case NODE_ENTITY_REFERENCE:
case NODE_PROCESSING_INSTRUCTION:
if (!name || SysStringLen(name) == 0) return E_FAIL;
default:
......@@ -1380,6 +1379,9 @@ static HRESULT WINAPI domdoc_createNode(
case NODE_CDATA_SECTION:
xmlnode = xmlNewCDataBlock(get_doc(This), NULL, 0);
break;
case NODE_ENTITY_REFERENCE:
xmlnode = xmlNewReference(get_doc(This), xml_name);
break;
case NODE_PROCESSING_INSTRUCTION:
#ifdef HAVE_XMLNEWDOCPI
xmlnode = xmlNewDocPI(get_doc(This), xml_name, NULL);
......
......@@ -1907,6 +1907,22 @@ static void test_create(void)
r = IXMLDOMDocument_createNode( doc, var, _bstr_("pi"), NULL, NULL );
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 */
V_VT(&var) = VT_I1;
V_I1(&var) = NODE_ELEMENT;
......@@ -3882,6 +3898,11 @@ static void test_xmlTypes(void)
}
/* 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);
hr = IXMLDOMDocument_createEntityReference(doc, str, NULL);
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