Module: wine Branch: master Commit: c685b92b3d36835c436c4c86dae707c4cca8fe0e URL: http://source.winehq.org/git/wine.git/?a=commit;h=c685b92b3d36835c436c4c86da...
Author: Nikolay Sivov nsivov@codeweavers.com Date: Wed Mar 14 12:18:55 2012 +0300
msxml3: Implement getIndexFromQName() for MXAttributes.
---
dlls/msxml3/mxwriter.c | 25 +++++++++++++++++++++---- dlls/msxml3/tests/saxreader.c | 34 +++++++++++++++++++++++++++++++++- 2 files changed, 54 insertions(+), 5 deletions(-)
diff --git a/dlls/msxml3/mxwriter.c b/dlls/msxml3/mxwriter.c index 86c0da0..3bb4c7a 100644 --- a/dlls/msxml3/mxwriter.c +++ b/dlls/msxml3/mxwriter.c @@ -1786,12 +1786,29 @@ static HRESULT WINAPI SAXAttributes_getIndexFromName(ISAXAttributes *iface, cons return E_NOTIMPL; }
-static HRESULT WINAPI SAXAttributes_getIndexFromQName(ISAXAttributes *iface, const WCHAR * pQName, - int nQNameLength, int * index) +static HRESULT WINAPI SAXAttributes_getIndexFromQName(ISAXAttributes *iface, const WCHAR *qname, + int len, int *index) { mxattributes *This = impl_from_ISAXAttributes( iface ); - FIXME("(%p)->(%s:%d %p): stub\n", This, debugstr_wn(pQName, nQNameLength), nQNameLength, index); - return E_NOTIMPL; + int i; + + TRACE("(%p)->(%s:%d %p)\n", This, debugstr_wn(qname, len), len, index); + + if (!index && (This->class_version == MSXML_DEFAULT || This->class_version == MSXML3)) + return E_POINTER; + + if (!qname || !index || !len) return E_INVALIDARG; + + for (i = 0; i < This->length; i++) + { + if (len != SysStringLen(This->attr[i].qname)) continue; + if (strncmpW(qname, This->attr[i].qname, len)) continue; + + *index = i; + return S_OK; + } + + return E_INVALIDARG; }
static HRESULT WINAPI SAXAttributes_getType(ISAXAttributes *iface, int index, const WCHAR **type, diff --git a/dlls/msxml3/tests/saxreader.c b/dlls/msxml3/tests/saxreader.c index ccd690a..e9cfda8 100644 --- a/dlls/msxml3/tests/saxreader.c +++ b/dlls/msxml3/tests/saxreader.c @@ -3299,8 +3299,8 @@ static void test_mxattr_addAttribute(void) ISAXAttributes *saxattr; IMXAttributes *mxattr; const WCHAR *value; + int len, index; HRESULT hr; - int len;
if (!is_clsid_supported(table->clsid, mxattributes_support_data)) { @@ -3405,6 +3405,38 @@ static void test_mxattr_addAttribute(void) 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); } + + hr = ISAXAttributes_getIndexFromQName(saxattr, NULL, 0, NULL); + if (IsEqualGUID(table->clsid, &CLSID_SAXAttributes) || + IsEqualGUID(table->clsid, &CLSID_SAXAttributes30)) + { + EXPECT_HR(hr, E_POINTER); + } + else + EXPECT_HR(hr, E_INVALIDARG); + + hr = ISAXAttributes_getIndexFromQName(saxattr, NULL, 0, &index); + EXPECT_HR(hr, E_INVALIDARG); + + index = -1; + hr = ISAXAttributes_getIndexFromQName(saxattr, _bstr_("nonexistent"), 11, &index); + EXPECT_HR(hr, E_INVALIDARG); + ok(index == -1, "%d: got wrong index %d\n", i, index); + + index = -1; + hr = ISAXAttributes_getIndexFromQName(saxattr, _bstr_(table->qname), 0, &index); + EXPECT_HR(hr, E_INVALIDARG); + ok(index == -1, "%d: got wrong index %d\n", i, index); + + index = -1; + hr = ISAXAttributes_getIndexFromQName(saxattr, _bstr_(table->qname), strlen(table->qname), &index); + EXPECT_HR(hr, S_OK); + ok(index == 0, "%d: got wrong index %d\n", i, index); + + index = -1; + hr = ISAXAttributes_getIndexFromQName(saxattr, _bstr_(table->qname), strlen(table->qname)-1, &index); + EXPECT_HR(hr, E_INVALIDARG); + ok(index == -1, "%d: got wrong index %d\n", i, index); }
len = -1;