>From 51dc69ca0a41879ac98c72941374e8788fbb6f7e Mon Sep 17 00:00:00 2001
From: Nikolay Sivov <nsivov@codeweavers.com>
Date: Fri, 27 Jan 2012 21:35:45 +0300
Subject: [PATCH 1/7] Add stub support of ISAXDeclHandler for MXWriter

---
 dlls/msxml3/mxwriter.c        |   81 +++++++++++++++++++++++++++++++++++++++++
 dlls/msxml3/tests/saxreader.c |   16 ++++++++
 2 files changed, 97 insertions(+), 0 deletions(-)

diff --git a/dlls/msxml3/mxwriter.c b/dlls/msxml3/mxwriter.c
index cb1a67f..0fac729 100644
--- a/dlls/msxml3/mxwriter.c
+++ b/dlls/msxml3/mxwriter.c
@@ -88,6 +88,7 @@ typedef struct
     IMXWriter IMXWriter_iface;
     ISAXContentHandler ISAXContentHandler_iface;
     ISAXLexicalHandler ISAXLexicalHandler_iface;
+    ISAXDeclHandler    ISAXDeclHandler_iface;
 
     LONG ref;
     MSXML_VERSION class_version;
@@ -470,6 +471,11 @@ static inline mxwriter *impl_from_ISAXLexicalHandler(ISAXLexicalHandler *iface)
     return CONTAINING_RECORD(iface, mxwriter, ISAXLexicalHandler_iface);
 }
 
+static inline mxwriter *impl_from_ISAXDeclHandler(ISAXDeclHandler *iface)
+{
+    return CONTAINING_RECORD(iface, mxwriter, ISAXDeclHandler_iface);
+}
+
 static HRESULT WINAPI mxwriter_QueryInterface(IMXWriter *iface, REFIID riid, void **obj)
 {
     mxwriter *This = impl_from_IMXWriter( iface );
@@ -492,6 +498,10 @@ static HRESULT WINAPI mxwriter_QueryInterface(IMXWriter *iface, REFIID riid, voi
     {
         *obj = &This->ISAXLexicalHandler_iface;
     }
+    else if ( IsEqualGUID( riid, &IID_ISAXDeclHandler ) )
+    {
+        *obj = &This->ISAXDeclHandler_iface;
+    }
     else if (dispex_query_interface(&This->dispex, riid, obj))
     {
         return *obj ? S_OK : E_NOINTERFACE;
@@ -1253,6 +1263,76 @@ static const struct ISAXLexicalHandlerVtbl SAXLexicalHandlerVtbl =
     SAXLexicalHandler_comment
 };
 
+/*** ISAXDeclHandler ***/
+static HRESULT WINAPI SAXDeclHandler_QueryInterface(ISAXDeclHandler *iface,
+    REFIID riid, void **obj)
+{
+    mxwriter *This = impl_from_ISAXDeclHandler( iface );
+    return IMXWriter_QueryInterface(&This->IMXWriter_iface, riid, obj);
+}
+
+static ULONG WINAPI SAXDeclHandler_AddRef(ISAXDeclHandler *iface)
+{
+    mxwriter *This = impl_from_ISAXDeclHandler( iface );
+    return IMXWriter_AddRef(&This->IMXWriter_iface);
+}
+
+static ULONG WINAPI SAXDeclHandler_Release(ISAXDeclHandler *iface)
+{
+    mxwriter *This = impl_from_ISAXDeclHandler( iface );
+    return IMXWriter_Release(&This->IMXWriter_iface);
+}
+
+static HRESULT WINAPI SAXDeclHandler_elementDecl(ISAXDeclHandler *iface,
+    const WCHAR *name, int n_name, const WCHAR *model, int n_model)
+{
+    mxwriter *This = impl_from_ISAXDeclHandler( iface );
+    FIXME("(%p)->(%s:%d %s:%d)\n", This, debugstr_wn(name, n_name), n_name,
+        debugstr_wn(model, n_model), n_model);
+    return E_NOTIMPL;
+}
+
+static HRESULT WINAPI SAXDeclHandler_attributeDecl(ISAXDeclHandler *iface,
+    const WCHAR *element, int n_element, const WCHAR *attr, int n_attr,
+    const WCHAR *type, int n_type, const WCHAR *Default, int n_default,
+    const WCHAR *value, int n_value)
+{
+    mxwriter *This = impl_from_ISAXDeclHandler( iface );
+    FIXME("(%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,
+        debugstr_wn(value, n_value), n_value);
+    return E_NOTIMPL;
+}
+
+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)\n", This, debugstr_wn(name, n_name), n_name,
+        debugstr_wn(value, n_value), n_value);
+    return E_NOTIMPL;
+}
+
+static HRESULT WINAPI SAXDeclHandler_externalEntityDecl(ISAXDeclHandler *iface,
+    const WCHAR *name, int n_name, const WCHAR *publicId, int n_publicId,
+    const WCHAR *systemId, int n_systemId)
+{
+    mxwriter *This = impl_from_ISAXDeclHandler( iface );
+    FIXME("(%p)->(%s:%d %s:%d %s:%d)\n", This, debugstr_wn(name, n_name), n_name,
+        debugstr_wn(publicId, n_publicId), n_publicId, debugstr_wn(systemId, n_systemId), n_systemId);
+    return E_NOTIMPL;
+}
+
+static const ISAXDeclHandlerVtbl SAXDeclHandlerVtbl = {
+    SAXDeclHandler_QueryInterface,
+    SAXDeclHandler_AddRef,
+    SAXDeclHandler_Release,
+    SAXDeclHandler_elementDecl,
+    SAXDeclHandler_attributeDecl,
+    SAXDeclHandler_internalEntityDecl,
+    SAXDeclHandler_externalEntityDecl
+};
+
 static const tid_t mxwriter_iface_tids[] = {
     IMXWriter_tid,
     0
@@ -1282,6 +1362,7 @@ HRESULT MXWriter_create(MSXML_VERSION version, IUnknown *outer, void **ppObj)
     This->IMXWriter_iface.lpVtbl = &MXWriterVtbl;
     This->ISAXContentHandler_iface.lpVtbl = &SAXContentHandlerVtbl;
     This->ISAXLexicalHandler_iface.lpVtbl = &SAXLexicalHandlerVtbl;
+    This->ISAXDeclHandler_iface.lpVtbl = &SAXDeclHandlerVtbl;
     This->ref = 1;
     This->class_version = version;
 
diff --git a/dlls/msxml3/tests/saxreader.c b/dlls/msxml3/tests/saxreader.c
index 1f47062..4935078 100644
--- a/dlls/msxml3/tests/saxreader.c
+++ b/dlls/msxml3/tests/saxreader.c
@@ -1632,6 +1632,7 @@ static void test_mxwriter_handlers(void)
 {
     ISAXContentHandler *handler;
     IMXWriter *writer, *writer2;
+    ISAXDeclHandler *decl;
     ISAXLexicalHandler *lh;
     HRESULT hr;
 
@@ -1667,6 +1668,21 @@ static void test_mxwriter_handlers(void)
     EXPECT_REF(writer, 3);
     EXPECT_REF(writer2, 3);
     IMXWriter_Release(writer2);
+    ISAXLexicalHandler_Release(lh);
+
+    /* ISAXDeclHandler */
+    hr = IMXWriter_QueryInterface(writer, &IID_ISAXDeclHandler, (void**)&decl);
+    ok(hr == S_OK, "Expected S_OK, got %08x\n", hr);
+    EXPECT_REF(writer, 2);
+    EXPECT_REF(lh, 2);
+
+    hr = ISAXDeclHandler_QueryInterface(decl, &IID_IMXWriter, (void**)&writer2);
+    ok(hr == S_OK, "Expected S_OK, got %08x\n", hr);
+    ok(writer2 == writer, "got %p, expected %p\n", writer2, writer);
+    EXPECT_REF(writer, 3);
+    EXPECT_REF(writer2, 3);
+    IMXWriter_Release(writer2);
+    ISAXDeclHandler_Release(decl);
 
     IMXWriter_Release(writer);
 }
-- 
1.5.6.5


