msxml3: Fix return value for IXMLDOMNode_put_nodeValue() for unsupported types.
This commit is contained in:
parent
5262c570f1
commit
c1464f8ab9
|
@ -327,23 +327,11 @@ static HRESULT WINAPI xmlnode_put_nodeValue(
|
||||||
{
|
{
|
||||||
xmlnode *This = impl_from_IXMLDOMNode( iface );
|
xmlnode *This = impl_from_IXMLDOMNode( iface );
|
||||||
HRESULT hr;
|
HRESULT hr;
|
||||||
xmlChar *str = NULL;
|
|
||||||
VARIANT string_value;
|
|
||||||
|
|
||||||
TRACE("%p type(%d)\n", This, This->node->type);
|
TRACE("%p type(%d)\n", This, This->node->type);
|
||||||
|
|
||||||
VariantInit(&string_value);
|
|
||||||
hr = VariantChangeType(&string_value, &value, 0, VT_BSTR);
|
|
||||||
if(FAILED(hr))
|
|
||||||
{
|
|
||||||
VariantClear(&string_value);
|
|
||||||
WARN("Couldn't convert to VT_BSTR\n");
|
|
||||||
return hr;
|
|
||||||
}
|
|
||||||
|
|
||||||
hr = S_FALSE;
|
|
||||||
/* Document, Document Fragment, Document Type, Element,
|
/* Document, Document Fragment, Document Type, Element,
|
||||||
Entity, Entity Reference, Notation aren't supported. */
|
Entity, Entity Reference, Notation aren't supported. */
|
||||||
switch ( This->node->type )
|
switch ( This->node->type )
|
||||||
{
|
{
|
||||||
case XML_ATTRIBUTE_NODE:
|
case XML_ATTRIBUTE_NODE:
|
||||||
|
@ -351,20 +339,33 @@ static HRESULT WINAPI xmlnode_put_nodeValue(
|
||||||
case XML_COMMENT_NODE:
|
case XML_COMMENT_NODE:
|
||||||
case XML_PI_NODE:
|
case XML_PI_NODE:
|
||||||
case XML_TEXT_NODE:
|
case XML_TEXT_NODE:
|
||||||
{
|
{
|
||||||
|
VARIANT string_value;
|
||||||
|
xmlChar *str;
|
||||||
|
|
||||||
|
VariantInit(&string_value);
|
||||||
|
hr = VariantChangeType(&string_value, &value, 0, VT_BSTR);
|
||||||
|
if(FAILED(hr))
|
||||||
|
{
|
||||||
|
VariantClear(&string_value);
|
||||||
|
WARN("Couldn't convert to VT_BSTR\n");
|
||||||
|
return hr;
|
||||||
|
}
|
||||||
|
|
||||||
str = xmlChar_from_wchar(V_BSTR(&string_value));
|
str = xmlChar_from_wchar(V_BSTR(&string_value));
|
||||||
|
VariantClear(&string_value);
|
||||||
|
|
||||||
xmlNodeSetContent(This->node, str);
|
xmlNodeSetContent(This->node, str);
|
||||||
heap_free(str);
|
heap_free(str);
|
||||||
hr = S_OK;
|
hr = S_OK;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
default:
|
default:
|
||||||
/* Do nothing for unsupported types. */
|
/* Do nothing for unsupported types. */
|
||||||
|
hr = E_FAIL;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
VariantClear(&string_value);
|
|
||||||
|
|
||||||
return hr;
|
return hr;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -5000,6 +5000,73 @@ static void test_TransformWithLoadingLocalFile(void)
|
||||||
free_bstrs();
|
free_bstrs();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void test_put_nodeValue(void)
|
||||||
|
{
|
||||||
|
IXMLDOMDocument *doc;
|
||||||
|
IXMLDOMEntityReference *entityref;
|
||||||
|
IXMLDOMNode *node;
|
||||||
|
HRESULT hr;
|
||||||
|
VARIANT data, type;
|
||||||
|
|
||||||
|
hr = CoCreateInstance( &CLSID_DOMDocument, NULL, CLSCTX_INPROC_SERVER, &IID_IXMLDOMDocument, (LPVOID*)&doc );
|
||||||
|
if( hr != S_OK )
|
||||||
|
return;
|
||||||
|
|
||||||
|
/* test for unsupported types */
|
||||||
|
/* NODE_DOCUMENT */
|
||||||
|
hr = IXMLDOMDocument_QueryInterface(doc, &IID_IXMLDOMNode, (void**)&node);
|
||||||
|
ok(hr == S_OK, "ret %08x\n", hr );
|
||||||
|
V_VT(&data) = VT_BSTR;
|
||||||
|
V_BSTR(&data) = _bstr_("one two three");
|
||||||
|
hr = IXMLDOMNode_put_nodeValue(node, data);
|
||||||
|
ok(hr == E_FAIL, "ret %08x\n", hr );
|
||||||
|
IXMLDOMNode_Release(node);
|
||||||
|
|
||||||
|
/* NODE_DOCUMENT_FRAGMENT */
|
||||||
|
V_VT(&type) = VT_I1;
|
||||||
|
V_I1(&type) = NODE_DOCUMENT_FRAGMENT;
|
||||||
|
hr = IXMLDOMDocument_createNode(doc, type, _bstr_("test"), NULL, &node);
|
||||||
|
ok(hr == S_OK, "ret %08x\n", hr );
|
||||||
|
V_VT(&data) = VT_BSTR;
|
||||||
|
V_BSTR(&data) = _bstr_("one two three");
|
||||||
|
hr = IXMLDOMNode_put_nodeValue(node, data);
|
||||||
|
ok(hr == E_FAIL, "ret %08x\n", hr );
|
||||||
|
IXMLDOMNode_Release(node);
|
||||||
|
|
||||||
|
/* NODE_ELEMENT */
|
||||||
|
V_VT(&type) = VT_I1;
|
||||||
|
V_I1(&type) = NODE_ELEMENT;
|
||||||
|
hr = IXMLDOMDocument_createNode(doc, type, _bstr_("test"), NULL, &node);
|
||||||
|
ok(hr == S_OK, "ret %08x\n", hr );
|
||||||
|
V_VT(&data) = VT_BSTR;
|
||||||
|
V_BSTR(&data) = _bstr_("one two three");
|
||||||
|
hr = IXMLDOMNode_put_nodeValue(node, data);
|
||||||
|
ok(hr == E_FAIL, "ret %08x\n", hr );
|
||||||
|
IXMLDOMNode_Release(node);
|
||||||
|
|
||||||
|
/* NODE_ENTITY_REFERENCE */
|
||||||
|
hr = IXMLDOMDocument_createEntityReference(doc, _bstr_("ref"), &entityref);
|
||||||
|
ok(hr == S_OK, "ret %08x\n", hr );
|
||||||
|
|
||||||
|
V_VT(&data) = VT_BSTR;
|
||||||
|
V_BSTR(&data) = _bstr_("one two three");
|
||||||
|
hr = IXMLDOMEntityReference_put_nodeValue(node, data);
|
||||||
|
ok(hr == E_FAIL, "ret %08x\n", hr );
|
||||||
|
|
||||||
|
hr = IXMLDOMEntityReference_QueryInterface(entityref, &IID_IXMLDOMNode, (void**)&node);
|
||||||
|
ok(hr == S_OK, "ret %08x\n", hr );
|
||||||
|
V_VT(&data) = VT_BSTR;
|
||||||
|
V_BSTR(&data) = _bstr_("one two three");
|
||||||
|
hr = IXMLDOMNode_put_nodeValue(node, data);
|
||||||
|
ok(hr == E_FAIL, "ret %08x\n", hr );
|
||||||
|
IXMLDOMNode_Release(node);
|
||||||
|
IXMLDOMEntityReference_Release(entityref);
|
||||||
|
|
||||||
|
free_bstrs();
|
||||||
|
|
||||||
|
IXMLDOMDocument_Release(doc);
|
||||||
|
}
|
||||||
|
|
||||||
START_TEST(domdoc)
|
START_TEST(domdoc)
|
||||||
{
|
{
|
||||||
HRESULT r;
|
HRESULT r;
|
||||||
|
@ -5030,6 +5097,7 @@ START_TEST(domdoc)
|
||||||
test_FormattingXML();
|
test_FormattingXML();
|
||||||
test_NodeTypeValue();
|
test_NodeTypeValue();
|
||||||
test_TransformWithLoadingLocalFile();
|
test_TransformWithLoadingLocalFile();
|
||||||
|
test_put_nodeValue();
|
||||||
|
|
||||||
CoUninitialize();
|
CoUninitialize();
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue