>From 7a9bb0cf1b462ff52ecaf0043150117e139aa318 Mon Sep 17 00:00:00 2001
From: Nikolay Sivov <nsivov@codeweavers.com>
Date: Fri, 4 Nov 2011 12:11:36 +0300
Subject: [PATCH 2/4] Support IDispatch in IXMLElement

---
 dlls/msxml3/tests/xmldoc.c |   26 ++++++++++++++++++++++----
 dlls/msxml3/xmlelem.c      |    3 ++-
 2 files changed, 24 insertions(+), 5 deletions(-)

diff --git a/dlls/msxml3/tests/xmldoc.c b/dlls/msxml3/tests/xmldoc.c
index d2828db..615d48c 100644
--- a/dlls/msxml3/tests/xmldoc.c
+++ b/dlls/msxml3/tests/xmldoc.c
@@ -852,8 +852,10 @@ static void test_xmlelem(void)
     IXMLElementCollection *children;
     VARIANT vType, vName;
     VARIANT vIndex, vValue;
-    BSTR str, val;
+    BSTR str, val, name;
     LONG type, num_child;
+    IDispatch *disp;
+    ITypeInfo *ti;
 
     static const WCHAR propName[] = {'p','r','o','p',0};
     static const WCHAR propVal[] = {'v','a','l',0};
@@ -864,17 +866,33 @@ static void test_xmlelem(void)
 
     hr = CoCreateInstance(&CLSID_XMLDocument, NULL, CLSCTX_INPROC_SERVER,
                           &IID_IXMLDocument, (LPVOID*)&doc);
-    ok(hr == S_OK, "Expected S_OK, got 0x%08x\n", hr);
+    EXPECT_HR(hr, S_OK);
 
     V_VT(&vType) = VT_I4;
     V_I4(&vType) = XMLELEMTYPE_ELEMENT;
     V_VT(&vName) = VT_NULL;
     hr = IXMLDocument_createElement(doc, vType, vName, &element);
-    ok(hr == S_OK, "Expected S_OK, got %08x\n", hr);
+    EXPECT_HR(hr, S_OK);
     ok(element != NULL, "Expected non-NULL element\n");
 
+    /* test for IDispatch */
+    disp = NULL;
+    hr = IXMLElement_QueryInterface(element, &IID_IDispatch, (void**)&disp);
+    EXPECT_HR(hr, S_OK);
+
+    hr = IDispatch_GetTypeInfo(disp, 0, 0, &ti);
+    EXPECT_HR(hr, S_OK);
+
+    name = NULL;
+    hr = ITypeInfo_GetDocumentation(ti, DISPID_XMLELEMENT_TAGNAME, &name, NULL, NULL, NULL);
+    EXPECT_HR(hr, S_OK);
+    SysFreeString(name);
+
+    ITypeInfo_Release(ti);
+    IDispatch_Release(disp);
+
     hr = IXMLElement_get_tagName(element, &str);
-    ok(hr == S_OK, "Expected S_OK, got %08x\n", hr);
+    EXPECT_HR(hr, S_OK);
     ok(lstrlenW(str) == 0, "Expected empty tag name\n");
     SysFreeString(str);
 
diff --git a/dlls/msxml3/xmlelem.c b/dlls/msxml3/xmlelem.c
index 86fa51d..679e159 100644
--- a/dlls/msxml3/xmlelem.c
+++ b/dlls/msxml3/xmlelem.c
@@ -67,7 +67,8 @@ static HRESULT WINAPI xmlelem_QueryInterface(IXMLElement *iface, REFIID riid, vo
 
     TRACE("(%p)->(%s %p)\n", This, debugstr_guid(riid), ppvObject);
 
-    if (IsEqualGUID(riid, &IID_IUnknown) ||
+    if (IsEqualGUID(riid, &IID_IUnknown)  ||
+        IsEqualGUID(riid, &IID_IDispatch) ||
         IsEqualGUID(riid, &IID_IXMLElement))
     {
         *ppvObject = iface;
-- 
1.5.6.5


