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