Module: wine Branch: master Commit: d20e487717cb9e6b47629932f44d9b7c9212df2e URL: http://source.winehq.org/git/wine.git/?a=commit;h=d20e487717cb9e6b47629932f4...
Author: Nikolay Sivov nsivov@codeweavers.com Date: Sat Jun 23 13:38:03 2012 +0400
msxml3: Initial implementation of attributeDecl() in writer.
---
dlls/msxml3/mxwriter.c | 34 ++++++++++++++++++++++++++++++++-- dlls/msxml3/tests/saxreader.c | 38 ++++++++++++++++++++++++++++++++++++++ 2 files changed, 70 insertions(+), 2 deletions(-)
diff --git a/dlls/msxml3/mxwriter.c b/dlls/msxml3/mxwriter.c index daa6db8..b9989b2 100644 --- a/dlls/msxml3/mxwriter.c +++ b/dlls/msxml3/mxwriter.c @@ -1481,10 +1481,40 @@ static HRESULT WINAPI SAXDeclHandler_attributeDecl(ISAXDeclHandler *iface, const WCHAR *value, int n_value) { mxwriter *This = impl_from_ISAXDeclHandler( iface ); - FIXME("(%p)->(%s:%d %s:%d %s:%d %s:%d %s:%d): stub\n", This, debugstr_wn(element, n_element), n_element, + static const WCHAR attlistW[] = {'<','!','A','T','T','L','I','S','T',' '}; + static const WCHAR closeelementW[] = {'>','\r','\n'}; + + TRACE("(%p)->(%s:%d %s:%d %s:%d %s:%d %s:%d)\n", This, debugstr_wn(element, n_element), n_element, debugstr_wn(attr, n_attr), n_attr, debugstr_wn(type, n_type), n_type, debugstr_wn(Default, n_default), n_default, debugstr_wn(value, n_value), n_value); - return E_NOTIMPL; + + write_output_buffer(This->buffer, attlistW, sizeof(attlistW)/sizeof(WCHAR)); + if (n_element) { + write_output_buffer(This->buffer, element, n_element); + write_output_buffer(This->buffer, spaceW, sizeof(spaceW)/sizeof(WCHAR)); + } + + if (n_attr) { + write_output_buffer(This->buffer, attr, n_attr); + write_output_buffer(This->buffer, spaceW, sizeof(spaceW)/sizeof(WCHAR)); + } + + if (n_type) { + write_output_buffer(This->buffer, type, n_type); + write_output_buffer(This->buffer, spaceW, sizeof(spaceW)/sizeof(WCHAR)); + } + + if (n_default) { + write_output_buffer(This->buffer, Default, n_default); + write_output_buffer(This->buffer, spaceW, sizeof(spaceW)/sizeof(WCHAR)); + } + + if (n_value) + write_output_buffer_quoted(This->buffer, value, n_value); + + write_output_buffer(This->buffer, closeelementW, sizeof(closeelementW)/sizeof(WCHAR)); + + return S_OK; }
static HRESULT WINAPI SAXDeclHandler_internalEntityDecl(ISAXDeclHandler *iface, diff --git a/dlls/msxml3/tests/saxreader.c b/dlls/msxml3/tests/saxreader.c index be96716..5efe44e 100644 --- a/dlls/msxml3/tests/saxreader.c +++ b/dlls/msxml3/tests/saxreader.c @@ -4450,6 +4450,44 @@ static void test_mxwriter_dtd(void) V_BSTR(&dest)), "got wrong content %s\n", wine_dbgstr_w(V_BSTR(&dest))); VariantClear(&dest);
+ /* attribute declaration */ + V_VT(&dest) = VT_EMPTY; + hr = IMXWriter_put_output(writer, dest); + EXPECT_HR(hr, S_OK); + + hr = ISAXDeclHandler_attributeDecl(decl, _bstr_("element"), strlen("element"), + _bstr_("attribute"), strlen("attribute"), _bstr_("CDATA"), strlen("CDATA"), + _bstr_("#REQUIRED"), strlen("#REQUIRED"), _bstr_("value"), strlen("value")); + EXPECT_HR(hr, S_OK); + + V_VT(&dest) = VT_EMPTY; + hr = IMXWriter_get_output(writer, &dest); + EXPECT_HR(hr, S_OK); + ok(V_VT(&dest) == VT_BSTR, "got %d\n", V_VT(&dest)); + ok(!lstrcmpW(_bstr_("<!ATTLIST element attribute CDATA #REQUIRED \"value\">\r\n"), + V_BSTR(&dest)), "got wrong content %s\n", wine_dbgstr_w(V_BSTR(&dest))); + VariantClear(&dest); + + hr = ISAXDeclHandler_attributeDecl(decl, _bstr_("element"), strlen("element"), + _bstr_("attribute2"), strlen("attribute2"), _bstr_("CDATA"), strlen("CDATA"), + _bstr_("#REQUIRED"), strlen("#REQUIRED"), _bstr_("value2"), strlen("value2")); + EXPECT_HR(hr, S_OK); + + hr = ISAXDeclHandler_attributeDecl(decl, _bstr_("element2"), strlen("element2"), + _bstr_("attribute3"), strlen("attribute3"), _bstr_("CDATA"), strlen("CDATA"), + _bstr_("#REQUIRED"), strlen("#REQUIRED"), _bstr_("value3"), strlen("value3")); + EXPECT_HR(hr, S_OK); + + V_VT(&dest) = VT_EMPTY; + hr = IMXWriter_get_output(writer, &dest); + EXPECT_HR(hr, S_OK); + ok(V_VT(&dest) == VT_BSTR, "got %d\n", V_VT(&dest)); + ok(!lstrcmpW(_bstr_("<!ATTLIST element attribute CDATA #REQUIRED \"value\">\r\n" + "<!ATTLIST element attribute2 CDATA #REQUIRED \"value2\">\r\n" + "<!ATTLIST element2 attribute3 CDATA #REQUIRED \"value3\">\r\n"), + V_BSTR(&dest)), "got wrong content %s\n", wine_dbgstr_w(V_BSTR(&dest))); + VariantClear(&dest); + ISAXContentHandler_Release(content); ISAXLexicalHandler_Release(lexical); ISAXDeclHandler_Release(decl);