From 23c3d908667b96e5ee54679dee7c419d262da75f Mon Sep 17 00:00:00 2001 From: Nikolay Sivov Date: Fri, 27 Jan 2012 15:30:03 +0300 Subject: [PATCH] msxml3: Support CDATA nodes in MXWriter. --- dlls/msxml3/mxwriter.c | 18 +++++++++--- dlls/msxml3/tests/saxreader.c | 55 +++++++++++++++++++++++++++++++++++ 2 files changed, 69 insertions(+), 4 deletions(-) diff --git a/dlls/msxml3/mxwriter.c b/dlls/msxml3/mxwriter.c index a94fa51d053..3e08840c0e3 100644 --- a/dlls/msxml3/mxwriter.c +++ b/dlls/msxml3/mxwriter.c @@ -1143,16 +1143,26 @@ static HRESULT WINAPI SAXLexicalHandler_endEntity(ISAXLexicalHandler *iface, con static HRESULT WINAPI SAXLexicalHandler_startCDATA(ISAXLexicalHandler *iface) { + static const WCHAR scdataW[] = {'<','!','[','C','D','A','T','A','['}; mxwriter *This = impl_from_ISAXLexicalHandler( iface ); - FIXME("(%p): stub\n", This); - return E_NOTIMPL; + + TRACE("(%p)\n", This); + + write_output_buffer(This->buffer, scdataW, sizeof(scdataW)/sizeof(WCHAR)); + + return S_OK; } static HRESULT WINAPI SAXLexicalHandler_endCDATA(ISAXLexicalHandler *iface) { mxwriter *This = impl_from_ISAXLexicalHandler( iface ); - FIXME("(%p): stub\n", This); - return E_NOTIMPL; + static const WCHAR ecdataW[] = {']',']','>'}; + + TRACE("(%p)\n", This); + + write_output_buffer(This->buffer, ecdataW, sizeof(ecdataW)/sizeof(WCHAR)); + + return S_OK; } static HRESULT WINAPI SAXLexicalHandler_comment(ISAXLexicalHandler *iface, const WCHAR *chars, int nchars) diff --git a/dlls/msxml3/tests/saxreader.c b/dlls/msxml3/tests/saxreader.c index d05596e53d7..30ac57eca15 100644 --- a/dlls/msxml3/tests/saxreader.c +++ b/dlls/msxml3/tests/saxreader.c @@ -2905,6 +2905,60 @@ static void test_mxwriter_comment(void) free_bstrs(); } +static void test_mxwriter_cdata(void) +{ + ISAXContentHandler *content; + ISAXLexicalHandler *lexical; + IMXWriter *writer; + VARIANT dest; + HRESULT hr; + + hr = CoCreateInstance(&CLSID_MXXMLWriter, NULL, CLSCTX_INPROC_SERVER, + &IID_IMXWriter, (void**)&writer); + EXPECT_HR(hr, S_OK); + + hr = IMXWriter_QueryInterface(writer, &IID_ISAXContentHandler, (void**)&content); + EXPECT_HR(hr, S_OK); + + hr = IMXWriter_QueryInterface(writer, &IID_ISAXLexicalHandler, (void**)&lexical); + EXPECT_HR(hr, S_OK); + + hr = IMXWriter_put_omitXMLDeclaration(writer, VARIANT_TRUE); + EXPECT_HR(hr, S_OK); + + hr = ISAXContentHandler_startDocument(content); + EXPECT_HR(hr, S_OK); + + hr = ISAXLexicalHandler_startCDATA(lexical); + 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_(""), V_BSTR(&dest)), "got wrong content %s\n", wine_dbgstr_w(V_BSTR(&dest))); + VariantClear(&dest); + + ISAXContentHandler_Release(content); + ISAXLexicalHandler_Release(lexical); + IMXWriter_Release(writer); + free_bstrs(); + +} + START_TEST(saxreader) { ISAXXMLReader *reader; @@ -2941,6 +2995,7 @@ START_TEST(saxreader) test_mxwriter_startendelement(); test_mxwriter_characters(); test_mxwriter_comment(); + test_mxwriter_cdata(); test_mxwriter_properties(); test_mxwriter_flush(); test_mxwriter_stream();