msxml3: Reimplement IXMLDOMDocument::createCDATASection() on top ::createNode().

This commit is contained in:
Nikolay Sivov 2010-02-12 21:58:17 +03:00 committed by Alexandre Julliard
parent ce2372667e
commit f0e885759e
2 changed files with 63 additions and 16 deletions

View File

@ -1158,29 +1158,28 @@ static HRESULT WINAPI domdoc_createCDATASection(
IXMLDOMCDATASection** cdata )
{
domdoc *This = impl_from_IXMLDOMDocument2( iface );
xmlNodePtr xmlnode;
xmlChar *xml_content;
IXMLDOMNode *node;
VARIANT type;
HRESULT hr;
TRACE("%p->(%s %p)\n", iface, debugstr_w(data), cdata);
TRACE("%p->(%s %p)\n", This, debugstr_w(data), cdata);
if(!cdata)
return E_INVALIDARG;
if (!cdata) return E_INVALIDARG;
*cdata = NULL;
xml_content = xmlChar_from_wchar(data);
xmlnode = xmlNewCDataBlock(get_doc( This ), xml_content, strlen( (char*)xml_content) );
heap_free(xml_content);
V_VT(&type) = VT_I1;
V_I1(&type) = NODE_CDATA_SECTION;
if(!xmlnode)
return E_FAIL;
hr = IXMLDOMDocument2_createNode(iface, type, NULL, NULL, &node);
if (hr == S_OK)
{
IXMLDOMNode_QueryInterface(node, &IID_IXMLDOMCDATASection, (void**)cdata);
IXMLDOMNode_Release(node);
hr = IXMLDOMCDATASection_put_data(*cdata, data);
}
xmlnode->doc = get_doc( This );
xmldoc_add_orphan(xmlnode->doc, xmlnode);
*cdata = (IXMLDOMCDATASection*)create_cdata(xmlnode);
return S_OK;
return hr;
}

View File

@ -1682,6 +1682,7 @@ static void test_create(void)
IXMLDOMElement *element;
IXMLDOMComment *comment;
IXMLDOMText *text;
IXMLDOMCDATASection *cdata;
IXMLDOMNode *root, *node, *child;
IXMLDOMNamedNodeMap *attr_map;
IUnknown *unk;
@ -1816,6 +1817,53 @@ static void test_create(void)
ok( str && SysStringLen(str) == 0, "expected empty comment, %p\n", str);
IXMLDOMText_Release(text);
/* NODE_CDATA_SECTION */
V_VT(&var) = VT_I1;
V_I1(&var) = NODE_CDATA_SECTION;
node = NULL;
r = IXMLDOMDocument_createNode( doc, var, NULL, NULL, &node );
ok( r == S_OK, "returns %08x\n", r );
ok( node != NULL, "\n");
r = IXMLDOMNode_QueryInterface(node, &IID_IXMLDOMCDATASection, (void**)&cdata);
ok( r == S_OK, "returns %08x\n", r );
IXMLDOMNode_Release(node);
str = NULL;
r = IXMLDOMCDATASection_get_data(cdata, &str);
ok( r == S_OK, "returns %08x\n", r );
ok( str && SysStringLen(str) == 0, "expected empty comment, %p\n", str);
IXMLDOMCDATASection_Release(cdata);
SysFreeString(str);
node = (IXMLDOMNode*)0x1;
r = IXMLDOMDocument_createNode( doc, var, _bstr_(""), NULL, &node );
ok( r == S_OK, "returns %08x\n", r );
r = IXMLDOMNode_QueryInterface(node, &IID_IXMLDOMCDATASection, (void**)&cdata);
ok( r == S_OK, "returns %08x\n", r );
IXMLDOMNode_Release(node);
str = NULL;
r = IXMLDOMCDATASection_get_data(cdata, &str);
ok( r == S_OK, "returns %08x\n", r );
ok( str && SysStringLen(str) == 0, "expected empty comment, %p\n", str);
IXMLDOMCDATASection_Release(cdata);
node = (IXMLDOMNode*)0x1;
r = IXMLDOMDocument_createNode( doc, var, _bstr_("blah"), NULL, &node );
ok( r == S_OK, "returns %08x\n", r );
r = IXMLDOMNode_QueryInterface(node, &IID_IXMLDOMCDATASection, (void**)&text);
ok( r == S_OK, "returns %08x\n", r );
IXMLDOMNode_Release(node);
str = NULL;
r = IXMLDOMCDATASection_get_data(cdata, &str);
ok( r == S_OK, "returns %08x\n", r );
ok( str && SysStringLen(str) == 0, "expected empty comment, %p\n", str);
IXMLDOMCDATASection_Release(cdata);
/* NODE_ELEMENT */
V_VT(&var) = VT_I1;
V_I1(&var) = NODE_ELEMENT;