Commit ca01a441 authored by Nikolay Sivov's avatar Nikolay Sivov Committed by Alexandre Julliard

msxml3: Reimplement IXMLDOMDocument::createElement() over ::createNode().

parent 469b0ff6
......@@ -1038,28 +1038,17 @@ static HRESULT WINAPI domdoc_createElement(
BSTR tagname,
IXMLDOMElement** element )
{
xmlNodePtr xmlnode;
domdoc *This = impl_from_IXMLDOMDocument2( iface );
xmlChar *xml_name;
IUnknown *elem_unk;
HRESULT hr;
TRACE("%p->(%s,%p)\n", iface, debugstr_w(tagname), element);
VARIANT type;
if (!element) return E_INVALIDARG;
TRACE("(%p)->(%s,%p)\n", This, debugstr_w(tagname), element);
xml_name = xmlChar_from_wchar(tagname);
xmlnode = xmlNewDocNode(get_doc(This), NULL, xml_name, NULL);
xmldoc_add_orphan(xmlnode->doc, xmlnode);
if (!element || !tagname) return E_INVALIDARG;
TRACE("created xmlptr %p\n", xmlnode);
elem_unk = create_element(xmlnode);
heap_free(xml_name);
V_VT(&type) = VT_I1;
V_I1(&type) = NODE_ELEMENT;
hr = IUnknown_QueryInterface(elem_unk, &IID_IXMLDOMElement, (void **)element);
IUnknown_Release(elem_unk);
TRACE("returning %p\n", *element);
return hr;
return IXMLDOMDocument_createNode(iface, type, tagname, NULL, (IXMLDOMNode**)element);
}
......@@ -1347,6 +1336,9 @@ static HRESULT WINAPI domdoc_createNode(
TRACE("node_type %d\n", node_type);
if ((!name || SysStringLen(name) == 0) && (node_type == NODE_ELEMENT))
return E_FAIL;
xml_name = xmlChar_from_wchar(name);
switch(node_type)
......
/*
* MSXML Class Factory
* Common definitions
*
* Copyright 2005 Mike McCormack
*
......
......@@ -1698,6 +1698,21 @@ static void test_create(void)
V_VT(&var) = VT_I1;
V_I1(&var) = NODE_ELEMENT;
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_ELEMENT;
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);
V_VT(&var) = VT_I1;
V_I1(&var) = NODE_ELEMENT;
str = SysAllocString( szlc );
r = IXMLDOMDocument_createNode( doc, var, str, NULL, &node );
ok( r == S_OK, "returns %08x\n", r );
if( SUCCEEDED(r) ) IXMLDOMNode_Release( node );
......@@ -2885,7 +2900,15 @@ static void test_xmlTypes(void)
IXMLDOMImplementation_Release(pIXMLDOMImplementation);
}
pRoot = (IXMLDOMElement*)0x1;
hr = IXMLDOMDocument_createElement(doc, NULL, &pRoot);
ok(hr == E_INVALIDARG, "ret %08x\n", hr );
ok(pRoot == (void*)0x1, "Expect same ptr, got %p\n", pRoot);
pRoot = (IXMLDOMElement*)0x1;
hr = IXMLDOMDocument_createElement(doc, _bstr_(""), &pRoot);
ok(hr == E_FAIL, "ret %08x\n", hr );
ok(pRoot == (void*)0x1, "Expect same ptr, got %p\n", pRoot);
hr = IXMLDOMDocument_createElement(doc, _bstr_("Testing"), &pRoot);
ok(hr == S_OK, "ret %08x\n", hr );
......@@ -3146,7 +3169,7 @@ static void test_xmlTypes(void)
/* Element */
str = SysAllocString(szElement);
hr = IXMLDOMDocument_createElement(doc, szElement, &pElement);
hr = IXMLDOMDocument_createElement(doc, str, &pElement);
SysFreeString(str);
ok(hr == S_OK, "ret %08x\n", hr );
if(hr == S_OK)
......
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