Nikolay Sivov : msxml3: Support processing instructions in writer.

Alexandre Julliard julliard at winehq.org
Mon Mar 26 12:29:35 CDT 2012


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

Author: Nikolay Sivov <nsivov at codeweavers.com>
Date:   Sat Mar 17 10:33:04 2012 +0300

msxml3: Support processing instructions in writer.

---

 dlls/msxml3/mxwriter.c        |   23 ++++++++++++++-
 dlls/msxml3/tests/saxreader.c |   61 +++++++++++++++++++++++++++++++++++++++++
 2 files changed, 82 insertions(+), 2 deletions(-)

diff --git a/dlls/msxml3/mxwriter.c b/dlls/msxml3/mxwriter.c
index 281031a..2534555 100644
--- a/dlls/msxml3/mxwriter.c
+++ b/dlls/msxml3/mxwriter.c
@@ -1143,8 +1143,27 @@ static HRESULT WINAPI SAXContentHandler_processingInstruction(
     int ndata)
 {
     mxwriter *This = impl_from_ISAXContentHandler( iface );
-    FIXME("(%p)->(%s %s)\n", This, debugstr_wn(target, ntarget), debugstr_wn(data, ndata));
-    return E_NOTIMPL;
+    static const WCHAR openpiW[] = {'<','?'};
+    static const WCHAR closepiW[] = {'?','>','\r','\n'};
+
+    TRACE("(%p)->(%s %s)\n", This, debugstr_wn(target, ntarget), debugstr_wn(data, ndata));
+
+    if (!target) return E_INVALIDARG;
+
+    write_output_buffer(This->buffer, openpiW, sizeof(openpiW)/sizeof(WCHAR));
+
+    if (*target)
+        write_output_buffer(This->buffer, target, ntarget);
+
+    if (data && *data && ndata)
+    {
+        write_output_buffer(This->buffer, spaceW, 1);
+        write_output_buffer(This->buffer, data, ndata);
+    }
+
+    write_output_buffer(This->buffer, closepiW, sizeof(closepiW)/sizeof(WCHAR));
+
+    return S_OK;
 }
 
 static HRESULT WINAPI SAXContentHandler_skippedEntity(
diff --git a/dlls/msxml3/tests/saxreader.c b/dlls/msxml3/tests/saxreader.c
index ff790a0..c1a3260 100644
--- a/dlls/msxml3/tests/saxreader.c
+++ b/dlls/msxml3/tests/saxreader.c
@@ -3126,6 +3126,66 @@ static void test_mxwriter_cdata(void)
     free_bstrs();
 }
 
+static void test_mxwriter_pi(void)
+{
+    static const WCHAR targetW[] = {'t','a','r','g','e','t',0};
+    static const WCHAR dataW[] = {'d','a','t','a',0};
+    ISAXContentHandler *content;
+    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 = ISAXContentHandler_processingInstruction(content, NULL, 0, NULL, 0);
+    EXPECT_HR(hr, E_INVALIDARG);
+
+    hr = ISAXContentHandler_processingInstruction(content, targetW, 0, NULL, 0);
+    EXPECT_HR(hr, S_OK);
+
+    hr = ISAXContentHandler_processingInstruction(content, targetW, 6, NULL, 0);
+    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_("<?\?>\r\n<?target?>\r\n"), V_BSTR(&dest)), "got wrong content %s\n", wine_dbgstr_w(V_BSTR(&dest)));
+    VariantClear(&dest);
+
+    hr = ISAXContentHandler_processingInstruction(content, targetW, 4, dataW, 4);
+    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_("<?\?>\r\n<?target?>\r\n<?targ data?>\r\n"), V_BSTR(&dest)), "got wrong content %s\n", wine_dbgstr_w(V_BSTR(&dest)));
+    VariantClear(&dest);
+
+    V_VT(&dest) = VT_EMPTY;
+    hr = IMXWriter_put_output(writer, dest);
+    EXPECT_HR(hr, S_OK);
+
+    hr = ISAXContentHandler_processingInstruction(content, targetW, 6, dataW, 0);
+    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_("<?target?>\r\n"), V_BSTR(&dest)), "got wrong content %s\n", wine_dbgstr_w(V_BSTR(&dest)));
+    VariantClear(&dest);
+
+    ISAXContentHandler_Release(content);
+    IMXWriter_Release(writer);
+}
+
 static void test_mxwriter_dtd(void)
 {
     static const WCHAR contentW[] = {'c','o','n','t','e','n','t'};
@@ -3656,6 +3716,7 @@ START_TEST(saxreader)
         test_mxwriter_characters();
         test_mxwriter_comment();
         test_mxwriter_cdata();
+        test_mxwriter_pi();
         test_mxwriter_dtd();
         test_mxwriter_properties();
         test_mxwriter_flush();




More information about the wine-cvs mailing list