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( ...@@ -344,11 +344,22 @@ static HRESULT WINAPI xmlnode_put_nodeValue(
VARIANT value) VARIANT value)
{ {
xmlnode *This = impl_from_IXMLDOMNode( iface ); xmlnode *This = impl_from_IXMLDOMNode( iface );
HRESULT hr = S_FALSE; HRESULT hr;
xmlChar *str = NULL; 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 )
...@@ -359,8 +370,7 @@ static HRESULT WINAPI xmlnode_put_nodeValue( ...@@ -359,8 +370,7 @@ static HRESULT WINAPI xmlnode_put_nodeValue(
case XML_PI_NODE: case XML_PI_NODE:
case XML_TEXT_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); xmlNodeSetContent(This->node, str);
hr = S_OK; hr = S_OK;
break; break;
...@@ -370,6 +380,8 @@ static HRESULT WINAPI xmlnode_put_nodeValue( ...@@ -370,6 +380,8 @@ static HRESULT WINAPI xmlnode_put_nodeValue(
break; break;
} }
VariantClear(&string_value);
return hr; return hr;
} }
......
...@@ -724,6 +724,30 @@ static void test_domdoc( void ) ...@@ -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"); ok( !lstrcmpW( str, _bstr_("Begin This &is a Middle; test <>\\Append End") ), "incorrect get_text string\n");
SysFreeString(str); 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 ); 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