>From 7fae3dc4bd0d5e71d2d800161822e65be4012e78 Mon Sep 17 00:00:00 2001
From: Nikolay Sivov <nsivov@codeweavers.com>
Date: Mon, 14 Nov 2011 10:03:31 +0300
Subject: [PATCH 2/7] Added IDispatchEx support for IXMLDOMImplementation

---
 dlls/msxml3/domimpl.c      |   24 ++++++++++++++++++++----
 dlls/msxml3/tests/domdoc.c |   10 ++++++++++
 2 files changed, 30 insertions(+), 4 deletions(-)

diff --git a/dlls/msxml3/domimpl.c b/dlls/msxml3/domimpl.c
index 2ecf073..501d596 100644
--- a/dlls/msxml3/domimpl.c
+++ b/dlls/msxml3/domimpl.c
@@ -44,6 +44,7 @@ WINE_DEFAULT_DEBUG_CHANNEL(msxml);
 
 typedef struct _domimpl
 {
+    DispatchEx dispex;
     IXMLDOMImplementation IXMLDOMImplementation_iface;
     LONG ref;
 } domimpl;
@@ -67,6 +68,10 @@ static HRESULT WINAPI dimimpl_QueryInterface(
     {
         *ppvObject = iface;
     }
+    else if (dispex_query_interface(&This->dispex, riid, ppvObject))
+    {
+        return *ppvObject ? S_OK : E_NOINTERFACE;
+    }
     else
     {
         TRACE("Unsupported interface %s\n", debugstr_guid(riid));
@@ -97,6 +102,7 @@ static ULONG WINAPI dimimpl_Release(
     TRACE("(%p)->(%d)\n", This, ref);
     if ( ref == 0 )
     {
+        release_dispex(&This->dispex);
         heap_free( This );
     }
 
@@ -122,13 +128,10 @@ static HRESULT WINAPI dimimpl_GetTypeInfo(
     ITypeInfo** ppTInfo )
 {
     domimpl *This = impl_from_IXMLDOMImplementation( iface );
-    HRESULT hr;
 
     TRACE("(%p)->(%u %u %p)\n", This, iTInfo, lcid, ppTInfo);
 
-    hr = get_typeinfo(IXMLDOMImplementation_tid, ppTInfo);
-
-    return hr;
+    return get_typeinfo(IXMLDOMImplementation_tid, ppTInfo);
 }
 
 static HRESULT WINAPI dimimpl_GetIDsOfNames(
@@ -220,6 +223,18 @@ static const struct IXMLDOMImplementationVtbl dimimpl_vtbl =
     dimimpl_hasFeature
 };
 
+static const tid_t dimimpl_iface_tids[] = {
+    IXMLDOMImplementation_tid,
+    0
+};
+
+static dispex_static_data_t dimimpl_dispex = {
+    NULL,
+    IXMLDOMImplementation_tid,
+    NULL,
+    dimimpl_iface_tids
+};
+
 IUnknown* create_doc_Implementation(void)
 {
     domimpl *This;
@@ -230,6 +245,7 @@ IUnknown* create_doc_Implementation(void)
 
     This->IXMLDOMImplementation_iface.lpVtbl = &dimimpl_vtbl;
     This->ref = 1;
+    init_dispex(&This->dispex, (IUnknown*)&This->IXMLDOMImplementation_iface, &dimimpl_dispex);
 
     return (IUnknown*)&This->IXMLDOMImplementation_iface;
 }
diff --git a/dlls/msxml3/tests/domdoc.c b/dlls/msxml3/tests/domdoc.c
index a79da43..dfad107 100644
--- a/dlls/msxml3/tests/domdoc.c
+++ b/dlls/msxml3/tests/domdoc.c
@@ -10507,6 +10507,7 @@ static const DOMNodeType dispex_types_test[] =
 static void test_dispex(void)
 {
     const DOMNodeType *type = dispex_types_test;
+    IXMLDOMImplementation *impl;
     IXMLDOMNodeList *node_list;
     IXMLDOMParseError *error;
     IXMLDOMNamedNodeMap *map;
@@ -10612,6 +10613,15 @@ static void test_dispex(void)
     IXMLDOMNamedNodeMap_Release(map);
     IXMLDOMElement_Release(elem);
 
+    /* IXMLDOMImplementation */
+    hr = IXMLDOMDocument_get_implementation(doc, &impl);
+    EXPECT_HR(hr, S_OK);
+
+    hr = IXMLDOMImplementation_QueryInterface(impl, &IID_IDispatchEx, (void**)&dispex);
+    EXPECT_HR(hr, S_OK);
+    IDispatchEx_Release(dispex);
+    IXMLDOMImplementation_Release(impl);
+
     IXMLDOMDocument_Release(doc);
 
     /* IXMLHTTPRequest */
-- 
1.5.6.5


