msxml3: Implement internalEntityDecl() for writer.

This commit is contained in:
Nikolay Sivov 2012-06-23 13:56:53 +04:00 committed by Alexandre Julliard
parent d20e487717
commit acce94a04e
2 changed files with 43 additions and 6 deletions

View File

@ -42,6 +42,7 @@ WINE_DEFAULT_DEBUG_CHANNEL(msxml);
static const WCHAR emptyW[] = {0};
static const WCHAR spaceW[] = {' '};
static const WCHAR quotW[] = {'\"'};
static const WCHAR closetagW[] = {'>','\r','\n'};
/* should be ordered as encoding names are sorted */
typedef enum
@ -1455,7 +1456,6 @@ static HRESULT WINAPI SAXDeclHandler_elementDecl(ISAXDeclHandler *iface,
const WCHAR *name, int n_name, const WCHAR *model, int n_model)
{
static const WCHAR elementW[] = {'<','!','E','L','E','M','E','N','T',' '};
static const WCHAR closeelementW[] = {'>','\r','\n'};
mxwriter *This = impl_from_ISAXDeclHandler( iface );
TRACE("(%p)->(%s:%d %s:%d)\n", This, debugstr_wn(name, n_name), n_name,
@ -1470,7 +1470,7 @@ static HRESULT WINAPI SAXDeclHandler_elementDecl(ISAXDeclHandler *iface,
}
if (n_model)
write_output_buffer(This->buffer, model, n_model);
write_output_buffer(This->buffer, closeelementW, sizeof(closeelementW)/sizeof(WCHAR));
write_output_buffer(This->buffer, closetagW, sizeof(closetagW)/sizeof(WCHAR));
return S_OK;
}
@ -1482,7 +1482,7 @@ static HRESULT WINAPI SAXDeclHandler_attributeDecl(ISAXDeclHandler *iface,
{
mxwriter *This = impl_from_ISAXDeclHandler( iface );
static const WCHAR attlistW[] = {'<','!','A','T','T','L','I','S','T',' '};
static const WCHAR closeelementW[] = {'>','\r','\n'};
static const WCHAR closetagW[] = {'>','\r','\n'};
TRACE("(%p)->(%s:%d %s:%d %s:%d %s:%d %s:%d)\n", This, debugstr_wn(element, n_element), n_element,
debugstr_wn(attr, n_attr), n_attr, debugstr_wn(type, n_type), n_type, debugstr_wn(Default, n_default), n_default,
@ -1512,7 +1512,7 @@ static HRESULT WINAPI SAXDeclHandler_attributeDecl(ISAXDeclHandler *iface,
if (n_value)
write_output_buffer_quoted(This->buffer, value, n_value);
write_output_buffer(This->buffer, closeelementW, sizeof(closeelementW)/sizeof(WCHAR));
write_output_buffer(This->buffer, closetagW, sizeof(closetagW)/sizeof(WCHAR));
return S_OK;
}
@ -1521,9 +1521,25 @@ static HRESULT WINAPI SAXDeclHandler_internalEntityDecl(ISAXDeclHandler *iface,
const WCHAR *name, int n_name, const WCHAR *value, int n_value)
{
mxwriter *This = impl_from_ISAXDeclHandler( iface );
FIXME("(%p)->(%s:%d %s:%d): stub\n", This, debugstr_wn(name, n_name), n_name,
static const WCHAR entityW[] = {'<','!','E','N','T','I','T','Y',' '};
TRACE("(%p)->(%s:%d %s:%d)\n", This, debugstr_wn(name, n_name), n_name,
debugstr_wn(value, n_value), n_value);
return E_NOTIMPL;
if (!name || !value) return E_INVALIDARG;
write_output_buffer(This->buffer, entityW, sizeof(entityW)/sizeof(WCHAR));
if (n_name) {
write_output_buffer(This->buffer, name, n_name);
write_output_buffer(This->buffer, spaceW, sizeof(spaceW)/sizeof(WCHAR));
}
if (n_value)
write_output_buffer_quoted(This->buffer, value, n_value);
write_output_buffer(This->buffer, closetagW, sizeof(closetagW)/sizeof(WCHAR));
return S_OK;
}
static HRESULT WINAPI SAXDeclHandler_externalEntityDecl(ISAXDeclHandler *iface,

View File

@ -4488,6 +4488,27 @@ static void test_mxwriter_dtd(void)
V_BSTR(&dest)), "got wrong content %s\n", wine_dbgstr_w(V_BSTR(&dest)));
VariantClear(&dest);
/* internal entities */
V_VT(&dest) = VT_EMPTY;
hr = IMXWriter_put_output(writer, dest);
EXPECT_HR(hr, S_OK);
hr = ISAXDeclHandler_internalEntityDecl(decl, NULL, 0, NULL, 0);
EXPECT_HR(hr, E_INVALIDARG);
hr = ISAXDeclHandler_internalEntityDecl(decl, _bstr_("name"), -1, NULL, 0);
EXPECT_HR(hr, E_INVALIDARG);
hr = ISAXDeclHandler_internalEntityDecl(decl, _bstr_("name"), strlen("name"), _bstr_("value"), strlen("value"));
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_("<!ENTITY name \"value\">\r\n"), V_BSTR(&dest)), "got wrong content %s\n", wine_dbgstr_w(V_BSTR(&dest)));
VariantClear(&dest);
ISAXContentHandler_Release(content);
ISAXLexicalHandler_Release(lexical);
ISAXDeclHandler_Release(decl);