msxml3: Handle all variant types in IXMLDOMDocument::createNode.

This commit is contained in:
Michael Karcher 2008-10-07 11:55:57 +02:00 committed by Alexandre Julliard
parent 27e9a98350
commit 91513caa16
2 changed files with 48 additions and 6 deletions

View File

@ -1110,13 +1110,19 @@ static HRESULT WINAPI domdoc_getElementsByTagName(
return hr;
}
static DOMNodeType get_node_type(VARIANT Type)
static HRESULT get_node_type(VARIANT Type, DOMNodeType * type)
{
if(V_VT(&Type) == VT_I4)
return V_I4(&Type);
VARIANT tmp;
HRESULT hr;
FIXME("Unsupported variant type %x\n", V_VT(&Type));
return 0;
VariantInit(&tmp);
hr = VariantChangeType(&tmp, &Type, 0, VT_I4);
if(FAILED(hr))
return E_INVALIDARG;
*type = V_I4(&tmp);
return S_OK;
}
static HRESULT WINAPI domdoc_createNode(
@ -1130,10 +1136,14 @@ static HRESULT WINAPI domdoc_createNode(
DOMNodeType node_type;
xmlNodePtr xmlnode = NULL;
xmlChar *xml_name;
HRESULT hr;
TRACE("(%p)->(type,%s,%s,%p)\n", This, debugstr_w(name), debugstr_w(namespaceURI), node);
node_type = get_node_type(Type);
hr = get_node_type(Type, &node_type);
if(FAILED(hr))
return hr;
TRACE("node_type %d\n", node_type);
xml_name = xmlChar_from_wchar((WCHAR*)name);

View File

@ -1353,6 +1353,8 @@ static void test_refs(void)
static void test_create(void)
{
static const WCHAR szOne[] = {'1',0};
static const WCHAR szOneGarbage[] = {'1','G','a','r','b','a','g','e',0};
HRESULT r;
VARIANT var;
BSTR str, name;
@ -1369,6 +1371,36 @@ static void test_create(void)
if( r != S_OK )
return;
V_VT(&var) = VT_I1;
V_I1(&var) = NODE_ELEMENT;
str = SysAllocString( szlc );
r = IXMLDOMDocument_createNode( doc, var, str, NULL, &node );
ok( r == S_OK, "returns %08x\n", r );
if( SUCCEEDED(r) ) IXMLDOMNode_Release( node );
V_VT(&var) = VT_R4;
V_R4(&var) = NODE_ELEMENT;
str = SysAllocString( szlc );
r = IXMLDOMDocument_createNode( doc, var, str, NULL, &node );
ok( r == S_OK, "returns %08x\n", r );
if( SUCCEEDED(r) ) IXMLDOMNode_Release( node );
V_VT(&var) = VT_BSTR;
V_BSTR(&var) = SysAllocString( szOne );
str = SysAllocString( szlc );
r = IXMLDOMDocument_createNode( doc, var, str, NULL, &node );
ok( r == S_OK, "returns %08x\n", r );
if( SUCCEEDED(r) ) IXMLDOMNode_Release( node );
VariantClear(&var);
V_VT(&var) = VT_BSTR;
V_BSTR(&var) = SysAllocString( szOneGarbage );
str = SysAllocString( szlc );
r = IXMLDOMDocument_createNode( doc, var, str, NULL, &node );
ok( r == E_INVALIDARG, "returns %08x\n", r );
if( SUCCEEDED(r) ) IXMLDOMNode_Release( node );
VariantClear(&var);
V_VT(&var) = VT_I4;
V_I4(&var) = NODE_ELEMENT;
str = SysAllocString( szlc );