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

This commit is contained in:
Nikolay Sivov 2010-02-12 23:24:40 +03:00 committed by Alexandre Julliard
parent 20a240fe41
commit 5262c570f1
2 changed files with 41 additions and 18 deletions

View File

@ -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;
IXMLDOMNode *node;
VARIANT type;
HRESULT hr;
TRACE("%p\n", iface);
TRACE("%p->(%s %p)\n", This, debugstr_w(name), entityref);
if(!entityRef)
return E_INVALIDARG;
if (!entityref) return E_INVALIDARG;
*entityRef = NULL;
*entityref = NULL;
xml_name = xmlChar_from_wchar(name);
xmlnode = xmlNewReference(get_doc( This ), xml_name );
heap_free(xml_name);
V_VT(&type) = VT_I1;
V_I1(&type) = NODE_ENTITY_REFERENCE;
if(!xmlnode)
return E_FAIL;
hr = IXMLDOMDocument2_createNode(iface, type, name, NULL, &node);
if (hr == S_OK)
{
IXMLDOMNode_QueryInterface(node, &IID_IXMLDOMEntityReference, (void**)entityref);
IXMLDOMNode_Release(node);
}
xmlnode->doc = get_doc( This );
xmldoc_add_orphan(xmlnode->doc, xmlnode);
*entityRef = (IXMLDOMEntityReference*)create_doc_entity_ref(xmlnode);
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);

View File

@ -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 );