msxml3: Support processing instructions in writer.

This commit is contained in:
Nikolay Sivov 2012-03-17 10:33:04 +03:00 committed by Alexandre Julliard
parent d3c5b2c4f1
commit 8072884136
2 changed files with 82 additions and 2 deletions

View File

@ -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(

View File

@ -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();