Commit b7ac3bde authored by Michael Karcher's avatar Michael Karcher Committed by Alexandre Julliard

msxml3: IXMLDOMNode_put_nodeValue: Use variant coercion.

parent c7293055
......@@ -344,11 +344,22 @@ static HRESULT WINAPI xmlnode_put_nodeValue(
VARIANT value)
{
xmlnode *This = impl_from_IXMLDOMNode( iface );
HRESULT hr = S_FALSE;
HRESULT hr;
xmlChar *str = NULL;
VARIANT string_value;
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,
Entity, Entity Reference, Notation aren't supported. */
switch ( This->node->type )
......@@ -359,8 +370,7 @@ static HRESULT WINAPI xmlnode_put_nodeValue(
case XML_PI_NODE:
case XML_TEXT_NODE:
{
str = xmlChar_from_wchar((WCHAR*)V_BSTR(&value));
str = xmlChar_from_wchar((WCHAR*)V_BSTR(&string_value));
xmlNodeSetContent(This->node, str);
hr = S_OK;
break;
......@@ -370,6 +380,8 @@ static HRESULT WINAPI xmlnode_put_nodeValue(
break;
}
VariantClear(&string_value);
return hr;
}
......
......@@ -724,6 +724,30 @@ static void test_domdoc( void )
ok( !lstrcmpW( str, _bstr_("Begin This &is a Middle; test <>\\Append End") ), "incorrect get_text string\n");
SysFreeString(str);
/* test put_data */
V_VT(&var) = VT_BSTR;
V_BSTR(&var) = SysAllocString(szstr1);
r = IXMLDOMText_put_nodeValue(nodetext, var);
ok(r == S_OK, "ret %08x\n", r );
VariantClear(&var);
r = IXMLDOMText_get_text(nodetext, &str);
ok(r == S_OK, "ret %08x\n", r );
ok( !lstrcmpW( str, szstr1 ), "incorrect get_text string\n");
SysFreeString(str);
/* test put_data */
V_VT(&var) = VT_I4;
V_I4(&var) = 99;
r = IXMLDOMText_put_nodeValue(nodetext, var);
ok(r == S_OK, "ret %08x\n", r );
VariantClear(&var);
r = IXMLDOMText_get_text(nodetext, &str);
ok(r == S_OK, "ret %08x\n", r );
ok( !lstrcmpW( str, _bstr_("99") ), "incorrect get_text string\n");
SysFreeString(str);
IXMLDOMText_Release( nodetext );
}
......
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