Commit ac96be9c authored by Nikolay Sivov's avatar Nikolay Sivov Committed by Alexandre Julliard

msxml3: Support comment nodes in MXWriter.

parent 32c96e63
......@@ -1155,11 +1155,24 @@ static HRESULT WINAPI SAXLexicalHandler_endCDATA(ISAXLexicalHandler *iface)
return E_NOTIMPL;
}
static HRESULT WINAPI SAXLexicalHandler_comment(ISAXLexicalHandler *iface, const WCHAR *chars, int len)
static HRESULT WINAPI SAXLexicalHandler_comment(ISAXLexicalHandler *iface, const WCHAR *chars, int nchars)
{
mxwriter *This = impl_from_ISAXLexicalHandler( iface );
FIXME("(%p)->(%s): stub\n", This, debugstr_wn(chars, len));
return E_NOTIMPL;
static const WCHAR copenW[] = {'<','!','-','-'};
static const WCHAR ccloseW[] = {'-','-','>','\r','\n'};
TRACE("(%p)->(%s:%d)\n", This, debugstr_wn(chars, nchars), nchars);
if (!chars) return E_INVALIDARG;
close_element_starttag(This);
write_output_buffer(This->buffer, copenW, sizeof(copenW)/sizeof(WCHAR));
if (nchars)
write_output_buffer(This->buffer, chars, nchars);
write_output_buffer(This->buffer, ccloseW, sizeof(ccloseW)/sizeof(WCHAR));
return S_OK;
}
static const struct ISAXLexicalHandlerVtbl SAXLexicalHandlerVtbl =
......
......@@ -2851,6 +2851,60 @@ static void test_mxwriter_dispex(void)
IMXWriter_Release(writer);
}
static void test_mxwriter_comment(void)
{
static const WCHAR commentW[] = {'c','o','m','m','e','n','t',0};
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_comment(lexical, NULL, 0);
EXPECT_HR(hr, E_INVALIDARG);
hr = ISAXLexicalHandler_comment(lexical, commentW, 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"), V_BSTR(&dest)), "got wrong content %s\n", wine_dbgstr_w(V_BSTR(&dest)));
VariantClear(&dest);
hr = ISAXLexicalHandler_comment(lexical, commentW, sizeof(commentW)/sizeof(WCHAR)-1);
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<!--comment-->\r\n"), 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;
......@@ -2886,6 +2940,7 @@ START_TEST(saxreader)
test_mxwriter_startenddocument();
test_mxwriter_startendelement();
test_mxwriter_characters();
test_mxwriter_comment();
test_mxwriter_properties();
test_mxwriter_flush();
test_mxwriter_stream();
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment