mirror of
git://source.winehq.org/git/wine.git
synced 2024-09-01 00:23:37 +00:00
msxml3: Support comment nodes in MXWriter.
This commit is contained in:
parent
32c96e6329
commit
ac96be9c08
|
@ -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();
|
||||
|
|
Loading…
Reference in a new issue