Nikolay Sivov : msxml3: Implement internalEntityDecl() for writer.
Alexandre Julliard
julliard at winehq.org
Mon Jun 25 13:24:12 CDT 2012
Module: wine
Branch: master
Commit: acce94a04ee35f01dd77fa8aedf7255443941c0c
URL: http://source.winehq.org/git/wine.git/?a=commit;h=acce94a04ee35f01dd77fa8aedf7255443941c0c
Author: Nikolay Sivov <nsivov at codeweavers.com>
Date: Sat Jun 23 13:56:53 2012 +0400
msxml3: Implement internalEntityDecl() for writer.
---
dlls/msxml3/mxwriter.c | 28 ++++++++++++++++++++++------
dlls/msxml3/tests/saxreader.c | 21 +++++++++++++++++++++
2 files changed, 43 insertions(+), 6 deletions(-)
diff --git a/dlls/msxml3/mxwriter.c b/dlls/msxml3/mxwriter.c
index b9989b2..f03ceb0 100644
--- a/dlls/msxml3/mxwriter.c
+++ b/dlls/msxml3/mxwriter.c
@@ -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,
diff --git a/dlls/msxml3/tests/saxreader.c b/dlls/msxml3/tests/saxreader.c
index 5efe44e..2858583 100644
--- a/dlls/msxml3/tests/saxreader.c
+++ b/dlls/msxml3/tests/saxreader.c
@@ -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);
More information about the wine-cvs
mailing list