From 2a9eb6e3bb452333c7a5750478bb8a88f8d1232c Mon Sep 17 00:00:00 2001 From: Piotr Caban Date: Thu, 19 Nov 2009 20:50:22 +0100 Subject: [PATCH] msxml3: Implemented more data types handling xmlnode_get_nodeTypedValue. --- dlls/msxml3/node.c | 16 ++++- dlls/msxml3/tests/domdoc.c | 126 +++++++++++++++++++++++++++++++++++++ 2 files changed, 140 insertions(+), 2 deletions(-) diff --git a/dlls/msxml3/node.c b/dlls/msxml3/node.c index 1ddbc073785..485a108e8ee 100644 --- a/dlls/msxml3/node.c +++ b/dlls/msxml3/node.c @@ -949,7 +949,7 @@ static HRESULT WINAPI xmlnode_get_dataType(IXMLDOMNode*, VARIANT*); inline HRESULT VARIANT_from_xmlChar(xmlChar *str, VARIANT *v, BSTR type) { if(!type || !lstrcmpiW(type, szString) || - !lstrcmpiW(type, szNumber)) + !lstrcmpiW(type, szNumber) || !lstrcmpiW(type, szUUID)) { V_VT(v) = VT_BSTR; V_BSTR(v) = bstr_from_xmlChar(str); @@ -1020,7 +1020,7 @@ inline HRESULT VARIANT_from_xmlChar(xmlChar *str, VARIANT *v, BSTR type) VARIANT src; HRESULT hres; - if(!lstrcmpiW(type, szInt)) + if(!lstrcmpiW(type, szInt) || !lstrcmpiW(type, szI4)) V_VT(v) = VT_I4; else if(!lstrcmpiW(type, szFixed)) V_VT(v) = VT_CY; @@ -1028,6 +1028,18 @@ inline HRESULT VARIANT_from_xmlChar(xmlChar *str, VARIANT *v, BSTR type) V_VT(v) = VT_BOOL; else if(!lstrcmpiW(type, szI1)) V_VT(v) = VT_I1; + else if(!lstrcmpiW(type, szI2)) + V_VT(v) = VT_I2; + else if(!lstrcmpiW(type, szIU1)) + V_VT(v) = VT_UI1; + else if(!lstrcmpiW(type, szIU2)) + V_VT(v) = VT_UI2; + else if(!lstrcmpiW(type, szIU4)) + V_VT(v) = VT_UI4; + else if(!lstrcmpiW(type, szR4)) + V_VT(v) = VT_R4; + else if(!lstrcmpiW(type, szR8) || !lstrcmpiW(type, szFloat)) + V_VT(v) = VT_R8; else { FIXME("Type handling not yet implemented\n"); diff --git a/dlls/msxml3/tests/domdoc.c b/dlls/msxml3/tests/domdoc.c index 20c6a9f9766..3f02ff56756 100644 --- a/dlls/msxml3/tests/domdoc.c +++ b/dlls/msxml3/tests/domdoc.c @@ -162,6 +162,15 @@ static const CHAR szTypeValueXML[] = " \n" " 23:21:01.13+03:21\n" " -13\n" +" 31915\n" +" -312232\n" +" 123\n" +" 48282\n" +" 949281\n" +" 213124.0\n" +" 0.412\n" +" 41221.421\n" +" 333C7BC4-460F-11D0-BC04-0080C7055a83\n" ""; static const CHAR szBasicTransformSSXMLPart1[] = @@ -4164,6 +4173,123 @@ static void test_NodeTypeValue(void) IXMLDOMNode_Release(pNode); } + + hr = IXMLDOMDocument2_selectSingleNode(doc, _bstr_("root/i2"), &pNode); + ok(hr == S_OK, "ret %08x\n", hr ); + if(hr == S_OK) + { + hr = IXMLDOMNode_get_nodeTypedValue(pNode, &v); + ok(hr == S_OK, "ret %08x\n", hr ); + ok(V_VT(&v) == VT_I2, "incorrect type\n"); + ok(V_I2(&v) == 31915, "incorrect value\n"); + VariantClear( &v ); + + IXMLDOMNode_Release(pNode); + } + + hr = IXMLDOMDocument2_selectSingleNode(doc, _bstr_("root/i4"), &pNode); + ok(hr == S_OK, "ret %08x\n", hr ); + if(hr == S_OK) + { + hr = IXMLDOMNode_get_nodeTypedValue(pNode, &v); + ok(hr == S_OK, "ret %08x\n", hr ); + ok(V_VT(&v) == VT_I4, "incorrect type\n"); + ok(V_I4(&v) == -312232, "incorrect value\n"); + VariantClear(&v); + + IXMLDOMNode_Release(pNode); + } + + hr = IXMLDOMDocument2_selectSingleNode(doc, _bstr_("root/ui1"), &pNode); + ok(hr == S_OK, "ret %08x\n", hr ); + if(hr == S_OK) + { + hr = IXMLDOMNode_get_nodeTypedValue(pNode, &v); + ok(hr == S_OK, "ret %08x\n", hr ); + ok(V_VT(&v) == VT_UI1, "incorrect type\n"); + ok(V_UI1(&v) == 123, "incorrect value\n"); + VariantClear(&v); + + IXMLDOMNode_Release(pNode); + } + + hr = IXMLDOMDocument2_selectSingleNode(doc, _bstr_("root/ui2"), &pNode); + ok(hr == S_OK, "ret %08x\n", hr ); + if(hr == S_OK) + { + hr = IXMLDOMNode_get_nodeTypedValue(pNode, &v); + ok(hr == S_OK, "ret %08x\n", hr ); + ok(V_VT(&v) == VT_UI2, "incorrect type\n"); + ok(V_UI2(&v) == 48282, "incorrect value\n"); + VariantClear(&v); + + IXMLDOMNode_Release(pNode); + } + + hr = IXMLDOMDocument2_selectSingleNode(doc, _bstr_("root/ui4"), &pNode); + ok(hr == S_OK, "ret %08x\n", hr ); + if(hr == S_OK) + { + hr = IXMLDOMNode_get_nodeTypedValue(pNode, &v); + ok(hr == S_OK, "ret %08x\n", hr ); + ok(V_VT(&v) == VT_UI4, "incorrect type\n"); + ok(V_UI4(&v) == 949281, "incorrect value\n"); + VariantClear(&v); + + IXMLDOMNode_Release(pNode); + } + + hr = IXMLDOMDocument2_selectSingleNode(doc, _bstr_("root/r4"), &pNode); + ok(hr == S_OK, "ret %08x\n", hr ); + if(hr == S_OK) + { + hr = IXMLDOMNode_get_nodeTypedValue(pNode, &v); + ok(hr == S_OK, "ret %08x\n", hr ); + ok(V_VT(&v) == VT_R4, "incorrect type\n"); + double_eq(213124.0, V_R4(&v)); + VariantClear(&v); + + IXMLDOMNode_Release(pNode); + } + + hr = IXMLDOMDocument2_selectSingleNode(doc, _bstr_("root/r8"), &pNode); + ok(hr == S_OK, "ret %08x\n", hr ); + if(hr == S_OK) + { + hr = IXMLDOMNode_get_nodeTypedValue(pNode, &v); + ok(hr == S_OK, "ret %08x\n", hr ); + ok(V_VT(&v) == VT_R8, "incorrect type\n"); + double_eq(0.412, V_R8(&v)); + VariantClear(&v); + + IXMLDOMNode_Release(pNode); + } + + hr = IXMLDOMDocument2_selectSingleNode(doc, _bstr_("root/float"), &pNode); + ok(hr == S_OK, "ret %08x\n", hr ); + if(hr == S_OK) + { + hr = IXMLDOMNode_get_nodeTypedValue(pNode, &v); + ok(hr == S_OK, "ret %08x\n", hr ); + ok(V_VT(&v) == VT_R8, "incorrect type\n"); + double_eq(41221.421, V_R8(&v)); + VariantClear(&v); + + IXMLDOMNode_Release(pNode); + } + + hr = IXMLDOMDocument2_selectSingleNode(doc, _bstr_("root/uuid"), &pNode); + ok(hr == S_OK, "ret %08x\n", hr ); + if(hr == S_OK) + { + hr = IXMLDOMNode_get_nodeTypedValue(pNode, &v); + ok(hr == S_OK, "ret %08x\n", hr ); + ok(V_VT(&v) == VT_BSTR, "incorrect type\n"); + ok(!lstrcmpW(V_BSTR(&v), _bstr_("333C7BC4-460F-11D0-BC04-0080C7055a83")), "incorrect value\n"); + VariantClear(&v); + + IXMLDOMNode_Release(pNode); + } } IXMLDOMDocument2_Release(doc);