Nikolay Sivov : msxml3: Support attributes list for elements.
Alexandre Julliard
julliard at winehq.org
Mon May 9 13:34:43 CDT 2011
Module: wine
Branch: master
Commit: 2dfa1bffc4b975cdd72f0f1f7cd55d7db28e6c57
URL: http://source.winehq.org/git/wine.git/?a=commit;h=2dfa1bffc4b975cdd72f0f1f7cd55d7db28e6c57
Author: Nikolay Sivov <nsivov at codeweavers.com>
Date: Sat May 7 19:37:59 2011 +0400
msxml3: Support attributes list for elements.
---
dlls/msxml3/mxwriter.c | 39 +++++++-
dlls/msxml3/tests/saxreader.c | 209 +++++++++++++++++++++++++++++++++++++++++
2 files changed, 246 insertions(+), 2 deletions(-)
diff --git a/dlls/msxml3/mxwriter.c b/dlls/msxml3/mxwriter.c
index 141f58d..a791acb 100644
--- a/dlls/msxml3/mxwriter.c
+++ b/dlls/msxml3/mxwriter.c
@@ -548,12 +548,47 @@ static HRESULT WINAPI mxwriter_saxcontent_startElement(
if (!namespaceUri || !local_name || !QName) return E_INVALIDARG;
- if (attr) FIXME("attributes not handled\n");
-
xmlOutputBufferWriteString(This->buffer, "<");
s = xmlchar_from_wchar(QName);
xmlOutputBufferWriteString(This->buffer, (char*)s);
heap_free(s);
+
+ if (attr)
+ {
+ HRESULT hr;
+ INT length;
+ INT i;
+
+ hr = ISAXAttributes_getLength(attr, &length);
+ if (FAILED(hr)) return hr;
+
+ if (length) xmlOutputBufferWriteString(This->buffer, " ");
+
+ for (i = 0; i < length; i++)
+ {
+ const WCHAR *str;
+ INT len;
+
+ hr = ISAXAttributes_getQName(attr, i, &str, &len);
+ if (FAILED(hr)) return hr;
+
+ s = xmlchar_from_wchar(str);
+ xmlOutputBufferWriteString(This->buffer, (char*)s);
+ heap_free(s);
+
+ xmlOutputBufferWriteString(This->buffer, "=\"");
+
+ hr = ISAXAttributes_getValue(attr, i, &str, &len);
+ if (FAILED(hr)) return hr;
+
+ s = xmlchar_from_wchar(str);
+ xmlOutputBufferWriteString(This->buffer, (char*)s);
+ heap_free(s);
+
+ xmlOutputBufferWriteString(This->buffer, "\"");
+ }
+ }
+
xmlOutputBufferWriteString(This->buffer, ">");
return S_OK;
diff --git a/dlls/msxml3/tests/saxreader.c b/dlls/msxml3/tests/saxreader.c
index 2bdb8b5..cac238c 100644
--- a/dlls/msxml3/tests/saxreader.c
+++ b/dlls/msxml3/tests/saxreader.c
@@ -491,6 +491,211 @@ static const ISAXErrorHandlerVtbl errorHandlerVtbl =
static ISAXErrorHandler errorHandler = { &errorHandlerVtbl };
+static HRESULT WINAPI isaxattributes_QueryInterface(
+ ISAXAttributes* iface,
+ REFIID riid,
+ void **ppvObject)
+{
+ *ppvObject = NULL;
+
+ if(IsEqualGUID(riid, &IID_IUnknown) || IsEqualGUID(riid, &IID_ISAXAttributes))
+ {
+ *ppvObject = iface;
+ }
+ else
+ {
+ return E_NOINTERFACE;
+ }
+
+ return S_OK;
+}
+
+static ULONG WINAPI isaxattributes_AddRef(ISAXAttributes* iface)
+{
+ return 2;
+}
+
+static ULONG WINAPI isaxattributes_Release(ISAXAttributes* iface)
+{
+ return 1;
+}
+
+static HRESULT WINAPI isaxattributes_getLength(ISAXAttributes* iface, int *length)
+{
+ *length = 2;
+ return S_OK;
+}
+
+static HRESULT WINAPI isaxattributes_getURI(
+ ISAXAttributes* iface,
+ int nIndex,
+ const WCHAR **pUrl,
+ int *pUriSize)
+{
+ ok(0, "unexpected call\n");
+ return E_NOTIMPL;
+}
+
+static HRESULT WINAPI isaxattributes_getLocalName(
+ ISAXAttributes* iface,
+ int nIndex,
+ const WCHAR **pLocalName,
+ int *pLocalNameLength)
+{
+ ok(0, "unexpected call\n");
+ return E_NOTIMPL;
+}
+
+static HRESULT WINAPI isaxattributes_getQName(
+ ISAXAttributes* iface,
+ int nIndex,
+ const WCHAR **pQName,
+ int *pQNameLength)
+{
+ static const WCHAR attr1W[] = {'a',':','a','t','t','r','1',0};
+ static const WCHAR attr2W[] = {'a','t','t','r','2',0};
+
+ ok(nIndex == 0 || nIndex == 1, "invalid index received %d\n", nIndex);
+
+ *pQName = (nIndex == 0) ? attr1W : attr2W;
+ *pQNameLength = lstrlenW(*pQName);
+
+ return S_OK;
+}
+
+static HRESULT WINAPI isaxattributes_getName(
+ ISAXAttributes* iface,
+ int nIndex,
+ const WCHAR **pUri,
+ int * pUriLength,
+ const WCHAR ** pLocalName,
+ int * pLocalNameSize,
+ const WCHAR ** pQName,
+ int * pQNameLength)
+{
+ ok(0, "unexpected call\n");
+ return E_NOTIMPL;
+}
+
+static HRESULT WINAPI isaxattributes_getIndexFromName(
+ ISAXAttributes* iface,
+ const WCHAR * pUri,
+ int cUriLength,
+ const WCHAR * pLocalName,
+ int cocalNameLength,
+ int * index)
+{
+ ok(0, "unexpected call\n");
+ return E_NOTIMPL;
+}
+
+static HRESULT WINAPI isaxattributes_getIndexFromQName(
+ ISAXAttributes* iface,
+ const WCHAR * pQName,
+ int nQNameLength,
+ int * index)
+{
+ ok(0, "unexpected call\n");
+ return E_NOTIMPL;
+}
+
+static HRESULT WINAPI isaxattributes_getType(
+ ISAXAttributes* iface,
+ int nIndex,
+ const WCHAR ** pType,
+ int * pTypeLength)
+{
+ ok(0, "unexpected call\n");
+ return E_NOTIMPL;
+}
+
+static HRESULT WINAPI isaxattributes_getTypeFromName(
+ ISAXAttributes* iface,
+ const WCHAR * pUri,
+ int nUri,
+ const WCHAR * pLocalName,
+ int nLocalName,
+ const WCHAR ** pType,
+ int * nType)
+{
+ ok(0, "unexpected call\n");
+ return E_NOTIMPL;
+}
+
+static HRESULT WINAPI isaxattributes_getTypeFromQName(
+ ISAXAttributes* iface,
+ const WCHAR * pQName,
+ int nQName,
+ const WCHAR ** pType,
+ int * nType)
+{
+ ok(0, "unexpected call\n");
+ return E_NOTIMPL;
+}
+
+static HRESULT WINAPI isaxattributes_getValue(
+ ISAXAttributes* iface,
+ int nIndex,
+ const WCHAR ** pValue,
+ int * nValue)
+{
+ static const WCHAR attrval1W[] = {'a','1',0};
+ static const WCHAR attrval2W[] = {'a','2',0};
+
+ ok(nIndex == 0 || nIndex == 1, "invalid index received %d\n", nIndex);
+
+ *pValue = (nIndex == 0) ? attrval1W : attrval2W;
+ *nValue = lstrlenW(*pValue);
+
+ return S_OK;
+}
+
+static HRESULT WINAPI isaxattributes_getValueFromName(
+ ISAXAttributes* iface,
+ const WCHAR * pUri,
+ int nUri,
+ const WCHAR * pLocalName,
+ int nLocalName,
+ const WCHAR ** pValue,
+ int * nValue)
+{
+ ok(0, "unexpected call\n");
+ return E_NOTIMPL;
+}
+
+static HRESULT WINAPI isaxattributes_getValueFromQName(
+ ISAXAttributes* iface,
+ const WCHAR * pQName,
+ int nQName,
+ const WCHAR ** pValue,
+ int * nValue)
+{
+ ok(0, "unexpected call\n");
+ return E_NOTIMPL;
+}
+
+static const ISAXAttributesVtbl SAXAttributesVtbl =
+{
+ isaxattributes_QueryInterface,
+ isaxattributes_AddRef,
+ isaxattributes_Release,
+ isaxattributes_getLength,
+ isaxattributes_getURI,
+ isaxattributes_getLocalName,
+ isaxattributes_getQName,
+ isaxattributes_getName,
+ isaxattributes_getIndexFromName,
+ isaxattributes_getIndexFromQName,
+ isaxattributes_getType,
+ isaxattributes_getTypeFromName,
+ isaxattributes_getTypeFromQName,
+ isaxattributes_getValue,
+ isaxattributes_getValueFromName,
+ isaxattributes_getValueFromQName
+};
+
+static ISAXAttributes saxattributes = { &SAXAttributesVtbl };
+
static void test_saxreader(void)
{
HRESULT hr;
@@ -1059,6 +1264,10 @@ static void test_mxwriter_startendelement(void)
todo_wine ok(!lstrcmpW(_bstr_("<><b></b><nspace:c/></a>"), V_BSTR(&dest)), "got wrong content %s\n", wine_dbgstr_w(V_BSTR(&dest)));
VariantClear(&dest);
+ /* try with attributes */
+ hr = ISAXContentHandler_startElement(content, _bstr_(""), 0, _bstr_(""), 0, _bstr_("b"), 1, &saxattributes);
+ ok(hr == S_OK, "got %08x\n", hr);
+
hr = ISAXContentHandler_endDocument(content);
todo_wine ok(hr == S_OK, "got %08x\n", hr);
More information about the wine-cvs
mailing list