xmllite/writer: Implement WriteCharEntity().

Signed-off-by: Nikolay Sivov <nsivov@codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
This commit is contained in:
Nikolay Sivov 2016-07-14 12:43:31 +03:00 committed by Alexandre Julliard
parent 8b2b455bd0
commit 0fd4fae7c5
2 changed files with 52 additions and 2 deletions

View File

@ -1217,6 +1217,47 @@ static void test_WriteFullEndElement(void)
IStream_Release(stream);
}
static void test_WriteCharEntity(void)
{
static const WCHAR aW[] = {'a',0};
IXmlWriter *writer;
IStream *stream;
HRESULT hr;
hr = CreateXmlWriter(&IID_IXmlWriter, (void**)&writer, NULL);
ok(hr == S_OK, "Expected S_OK, got %08x\n", hr);
/* without indentation */
stream = writer_set_output(writer);
hr = IXmlWriter_SetProperty(writer, XmlWriterProperty_OmitXmlDeclaration, TRUE);
ok(hr == S_OK, "got 0x%08x\n", hr);
hr = IXmlWriter_WriteStartDocument(writer, XmlStandalone_Omit);
ok(hr == S_OK, "got 0x%08x\n", hr);
hr = IXmlWriter_WriteStartElement(writer, NULL, aW, NULL);
ok(hr == S_OK, "got 0x%08x\n", hr);
hr = IXmlWriter_WriteCharEntity(writer, 0x100);
ok(hr == S_OK, "got 0x%08x\n", hr);
hr = IXmlWriter_WriteStartElement(writer, NULL, aW, NULL);
ok(hr == S_OK, "got 0x%08x\n", hr);
hr = IXmlWriter_WriteEndDocument(writer);
ok(hr == S_OK, "got 0x%08x\n", hr);
hr = IXmlWriter_Flush(writer);
ok(hr == S_OK, "got 0x%08x\n", hr);
CHECK_OUTPUT(stream,
"<a>&#x100;<a /></a>");
IXmlWriter_Release(writer);
IStream_Release(stream);
}
START_TEST(writer)
{
test_writer_create();
@ -1235,4 +1276,5 @@ START_TEST(writer)
test_indentation();
test_WriteAttributeString();
test_WriteFullEndElement();
test_WriteCharEntity();
}

View File

@ -704,21 +704,29 @@ static HRESULT WINAPI xmlwriter_WriteCData(IXmlWriter *iface, LPCWSTR data)
static HRESULT WINAPI xmlwriter_WriteCharEntity(IXmlWriter *iface, WCHAR ch)
{
static const WCHAR fmtW[] = {'&','#','x','%','x',';',0};
xmlwriter *This = impl_from_IXmlWriter(iface);
WCHAR bufW[16];
FIXME("%p %x\n", This, ch);
TRACE("%p %#x\n", This, ch);
switch (This->state)
{
case XmlWriterState_Initial:
return E_UNEXPECTED;
case XmlWriterState_ElemStarted:
writer_close_starttag(This);
break;
case XmlWriterState_DocClosed:
return WR_E_INVALIDACTION;
default:
;
}
return E_NOTIMPL;
sprintfW(bufW, fmtW, ch);
write_output_buffer(This->output, bufW, -1);
return S_OK;
}
static HRESULT WINAPI xmlwriter_WriteChars(IXmlWriter *iface, const WCHAR *pwch, UINT cwch)