Commit 8cefe9b0 authored by Nikolay Sivov's avatar Nikolay Sivov Committed by Alexandre Julliard

msxml3: Store raw text data passed through characters().

parent 630e5f81
......@@ -389,17 +389,25 @@ static inline HRESULT return_null_bstr(BSTR *p)
return S_FALSE;
}
static inline xmlChar *xmlchar_from_wchar( LPCWSTR str )
static inline xmlChar *xmlchar_from_wcharn(const WCHAR *str, int nchars)
{
xmlChar *xmlstr;
DWORD len = WideCharToMultiByte( CP_UTF8, 0, str, -1, NULL, 0, NULL, NULL );
DWORD len = WideCharToMultiByte( CP_UTF8, 0, str, nchars, NULL, 0, NULL, NULL );
xmlstr = heap_alloc( len );
xmlstr = heap_alloc( len+1 );
if ( xmlstr )
WideCharToMultiByte( CP_UTF8, 0, str, -1, (LPSTR) xmlstr, len, NULL, NULL );
{
WideCharToMultiByte( CP_UTF8, 0, str, nchars, (LPSTR) xmlstr, len+1, NULL, NULL );
xmlstr[len] = 0;
}
return xmlstr;
}
static inline xmlChar *xmlchar_from_wchar( const WCHAR *str )
{
return xmlchar_from_wcharn(str, -1);
}
#endif
extern IXMLDOMParseError *create_parseError( LONG code, BSTR url, BSTR reason, BSTR srcText,
......
......@@ -636,8 +636,19 @@ static HRESULT WINAPI mxwriter_saxcontent_characters(
int nchars)
{
mxwriter *This = impl_from_ISAXContentHandler( iface );
FIXME("(%p)->(%s)\n", This, debugstr_wn(chars, nchars));
return E_NOTIMPL;
TRACE("(%p)->(%s:%d)\n", This, debugstr_wn(chars, nchars), nchars);
if (!chars) return E_INVALIDARG;
if (nchars)
{
xmlChar *s = xmlchar_from_wcharn(chars, nchars);
xmlOutputBufferWriteString(This->buffer, (char*)s);
heap_free(s);
}
return S_OK;
}
static HRESULT WINAPI mxwriter_saxcontent_ignorableWhitespace(
......
......@@ -1285,6 +1285,52 @@ static void test_mxwriter_startendelement(void)
free_bstrs();
}
static void test_mxwriter_characters(void)
{
static const WCHAR chardataW[] = {'T','E','S','T','C','H','A','R','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);
ok(hr == S_OK, "Expected S_OK, got %08x\n", hr);
hr = IMXWriter_QueryInterface(writer, &IID_ISAXContentHandler, (void**)&content);
ok(hr == S_OK, "got %08x\n", hr);
hr = IMXWriter_put_omitXMLDeclaration(writer, VARIANT_TRUE);
ok(hr == S_OK, "got %08x\n", hr);
hr = ISAXContentHandler_startDocument(content);
ok(hr == S_OK, "got %08x\n", hr);
hr = ISAXContentHandler_characters(content, NULL, 0);
ok(hr == E_INVALIDARG, "got %08x\n", hr);
hr = ISAXContentHandler_characters(content, chardataW, 0);
ok(hr == S_OK, "got %08x\n", hr);
hr = ISAXContentHandler_characters(content, chardataW, sizeof(chardataW)/sizeof(WCHAR) - 1);
ok(hr == S_OK, "got %08x\n", hr);
V_VT(&dest) = VT_EMPTY;
hr = IMXWriter_get_output(writer, &dest);
ok(hr == S_OK, "got %08x\n", hr);
ok(V_VT(&dest) == VT_BSTR, "got %d\n", V_VT(&dest));
ok(!lstrcmpW(_bstr_("TESTCHARDATA ."), V_BSTR(&dest)), "got wrong content %s\n", wine_dbgstr_w(V_BSTR(&dest)));
VariantClear(&dest);
hr = ISAXContentHandler_endDocument(content);
todo_wine ok(hr == S_OK, "got %08x\n", hr);
ISAXContentHandler_Release(content);
IMXWriter_Release(writer);
free_bstrs();
}
START_TEST(saxreader)
{
ISAXXMLReader *reader;
......@@ -1317,6 +1363,7 @@ START_TEST(saxreader)
test_mxwriter_contenthandler();
test_mxwriter_startenddocument();
test_mxwriter_startendelement();
test_mxwriter_characters();
test_mxwriter_properties();
test_mxwriter_flush();
}
......
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