Nikolay Sivov : msxml3: Implement getType() for MXAttributes.

Alexandre Julliard julliard at winehq.org
Wed Mar 14 13:56:10 CDT 2012


Module: wine
Branch: master
Commit: 69bc0966458d0e22b7f3aed4ae3cc549f4a8da18
URL:    http://source.winehq.org/git/wine.git/?a=commit;h=69bc0966458d0e22b7f3aed4ae3cc549f4a8da18

Author: Nikolay Sivov <nsivov at codeweavers.com>
Date:   Wed Mar 14 11:44:34 2012 +0300

msxml3: Implement getType() for MXAttributes.

---

 dlls/msxml3/mxwriter.c        |   20 +++++++++++++++-----
 dlls/msxml3/tests/saxreader.c |   38 ++++++++++++++++++++++++++++++++++++++
 2 files changed, 53 insertions(+), 5 deletions(-)

diff --git a/dlls/msxml3/mxwriter.c b/dlls/msxml3/mxwriter.c
index b28bd19..86c0da0 100644
--- a/dlls/msxml3/mxwriter.c
+++ b/dlls/msxml3/mxwriter.c
@@ -1612,7 +1612,7 @@ static HRESULT WINAPI MXAttributes_addAttribute(IMXAttributes *iface,
     attr->qname = SysAllocString(QName);
     attr->local = SysAllocString(localName);
     attr->uri   = SysAllocString(uri);
-    attr->type  = SysAllocString(type);
+    attr->type  = SysAllocString(type ? type : emptyW);
     attr->value = SysAllocString(value);
     This->length++;
 
@@ -1794,12 +1794,22 @@ static HRESULT WINAPI SAXAttributes_getIndexFromQName(ISAXAttributes *iface, con
     return E_NOTIMPL;
 }
 
-static HRESULT WINAPI SAXAttributes_getType(ISAXAttributes *iface, int nIndex, const WCHAR ** pType,
-    int * pTypeLength)
+static HRESULT WINAPI SAXAttributes_getType(ISAXAttributes *iface, int index, const WCHAR **type,
+    int *len)
 {
     mxattributes *This = impl_from_ISAXAttributes( iface );
-    FIXME("(%p)->(%d %p %p): stub\n", This, nIndex, pType, pTypeLength);
-    return E_NOTIMPL;
+
+    TRACE("(%p)->(%d %p %p)\n", This, index, type, len);
+
+    if (index >= This->length) return E_INVALIDARG;
+
+    if ((!type || !len) && (This->class_version == MSXML_DEFAULT || This->class_version == MSXML3))
+       return E_POINTER;
+
+    *type = This->attr[index].type;
+    *len = SysStringLen(This->attr[index].type);
+
+    return S_OK;
 }
 
 static HRESULT WINAPI SAXAttributes_getTypeFromName(ISAXAttributes *iface, const WCHAR * pUri, int nUri,
diff --git a/dlls/msxml3/tests/saxreader.c b/dlls/msxml3/tests/saxreader.c
index 95c7787..ccd690a 100644
--- a/dlls/msxml3/tests/saxreader.c
+++ b/dlls/msxml3/tests/saxreader.c
@@ -3341,6 +3341,18 @@ static void test_mxattr_addAttribute(void)
         hr = ISAXAttributes_getValue(saxattr, 0, NULL, NULL);
         EXPECT_HR(hr, E_INVALIDARG);
 
+        hr = ISAXAttributes_getType(saxattr, 0, &value, &len);
+        EXPECT_HR(hr, E_INVALIDARG);
+
+        hr = ISAXAttributes_getType(saxattr, 0, NULL, &len);
+        EXPECT_HR(hr, E_INVALIDARG);
+
+        hr = ISAXAttributes_getType(saxattr, 0, &value, NULL);
+        EXPECT_HR(hr, E_INVALIDARG);
+
+        hr = ISAXAttributes_getType(saxattr, 0, NULL, NULL);
+        EXPECT_HR(hr, E_INVALIDARG);
+
         hr = IMXAttributes_addAttribute(mxattr, _bstr_(table->uri), _bstr_(table->local),
             _bstr_(table->qname), _bstr_(table->type), _bstr_(table->value));
         ok(hr == table->hr, "%d: got 0x%08x, expected 0x%08x\n", i, hr, table->hr);
@@ -3359,6 +3371,15 @@ static void test_mxattr_addAttribute(void)
 
                hr = ISAXAttributes_getValue(saxattr, 0, NULL, NULL);
                EXPECT_HR(hr, E_POINTER);
+
+               hr = ISAXAttributes_getType(saxattr, 0, NULL, &len);
+               EXPECT_HR(hr, E_POINTER);
+
+               hr = ISAXAttributes_getType(saxattr, 0, &value, NULL);
+               EXPECT_HR(hr, E_POINTER);
+
+               hr = ISAXAttributes_getType(saxattr, 0, NULL, NULL);
+               EXPECT_HR(hr, E_POINTER);
             }
 
             len = -1;
@@ -3367,6 +3388,23 @@ static void test_mxattr_addAttribute(void)
             ok(!lstrcmpW(_bstr_(table->value), value), "%d: got %s, expected %s\n", i, wine_dbgstr_w(value),
                 table->value);
             ok(lstrlenW(value) == len, "%d: got wrong value length %d\n", i, len);
+
+            len = -1;
+            value = (void*)0xdeadbeef;
+            hr = ISAXAttributes_getType(saxattr, 0, &value, &len);
+            EXPECT_HR(hr, S_OK);
+
+            if (table->type)
+            {
+                ok(!lstrcmpW(_bstr_(table->type), value), "%d: got %s, expected %s\n", i, wine_dbgstr_w(value),
+                    table->type);
+                ok(lstrlenW(value) == len, "%d: got wrong type value length %d\n", i, len);
+            }
+            else
+            {
+                ok(*value == 0, "%d: got type value %s\n", i, wine_dbgstr_w(value));
+                ok(len == 0, "%d: got wrong type value length %d\n", i, len);
+            }
         }
 
         len = -1;




More information about the wine-cvs mailing list