Jacek Caban : mshtml: Added support for IDispatch-only ActiveX objects.

Alexandre Julliard julliard at winehq.org
Thu Apr 5 12:31:46 CDT 2012


Module: wine
Branch: master
Commit: 8791ce15e9e6d327d3f0c1185aaa9aed67ce592d
URL:    http://source.winehq.org/git/wine.git/?a=commit;h=8791ce15e9e6d327d3f0c1185aaa9aed67ce592d

Author: Jacek Caban <jacek at codeweavers.com>
Date:   Thu Apr  5 13:57:42 2012 +0200

mshtml: Added support for IDispatch-only ActiveX objects.

---

 dlls/mshtml/pluginhost.c    |   47 ++++++++++++++++++++++---------------------
 dlls/mshtml/tests/activex.c |   46 +++++++++++++++++++++++++++++++++--------
 2 files changed, 61 insertions(+), 32 deletions(-)

diff --git a/dlls/mshtml/pluginhost.c b/dlls/mshtml/pluginhost.c
index 9309310..f059670 100644
--- a/dlls/mshtml/pluginhost.c
+++ b/dlls/mshtml/pluginhost.c
@@ -185,9 +185,9 @@ static void activate_plugin(PluginHost *host)
 {
     IClientSecurity *client_security;
     IQuickActivate *quick_activate;
+    IOleObject *ole_obj = NULL;
     IOleCommandTarget *cmdtrg;
     IViewObjectEx *view_obj;
-    IOleObject *ole_obj;
     IDispatchEx *dispex;
     IDispatch *disp;
     RECT rect;
@@ -223,29 +223,28 @@ static void activate_plugin(PluginHost *host)
         IQuickActivate_Release(quick_activate);
         if(FAILED(hres))
             FIXME("QuickActivate failed: %08x\n", hres);
-
-        load_plugin(host);
     }else {
         DWORD status = 0;
 
         hres = IUnknown_QueryInterface(host->plugin_unk, &IID_IOleObject, (void**)&ole_obj);
-        if(FAILED(hres)) {
-            FIXME("Plugin does not support IOleObject\n");
-            return;
-        }
-
-        hres = IOleObject_GetMiscStatus(ole_obj, DVASPECT_CONTENT, &status);
-        TRACE("GetMiscStatus returned %08x %x\n", hres, status);
+        if(SUCCEEDED(hres)) {
+            hres = IOleObject_GetMiscStatus(ole_obj, DVASPECT_CONTENT, &status);
+            TRACE("GetMiscStatus returned %08x %x\n", hres, status);
 
-        hres = IOleObject_SetClientSite(ole_obj, &host->IOleClientSite_iface);
-        IOleObject_Release(ole_obj);
-        if(FAILED(hres)) {
-            FIXME("SetClientSite failed: %08x\n", hres);
-            return;
+            hres = IOleObject_SetClientSite(ole_obj, &host->IOleClientSite_iface);
+            IOleObject_Release(ole_obj);
+            if(FAILED(hres)) {
+                FIXME("SetClientSite failed: %08x\n", hres);
+                return;
+            }
+        }else {
+            TRACE("Plugin does not support IOleObject\n");
         }
+    }
 
-        load_plugin(host);
+    load_plugin(host);
 
+    if(ole_obj) {
         hres = IUnknown_QueryInterface(host->plugin_unk, &IID_IViewObjectEx, (void**)&view_obj);
         if(SUCCEEDED(hres)) {
             DWORD view_status = 0;
@@ -288,11 +287,13 @@ static void activate_plugin(PluginHost *host)
         return;
     }
 
-    get_pos_rect(host, &rect);
-    hres = IOleObject_DoVerb(ole_obj, OLEIVERB_INPLACEACTIVATE, NULL, &host->IOleClientSite_iface, 0, host->hwnd, &rect);
-    IOleObject_Release(ole_obj);
-    if(FAILED(hres))
-        WARN("DoVerb failed: %08x\n", hres);
+    if(ole_obj) {
+        get_pos_rect(host, &rect);
+        hres = IOleObject_DoVerb(ole_obj, OLEIVERB_INPLACEACTIVATE, NULL, &host->IOleClientSite_iface, 0, host->hwnd, &rect);
+        IOleObject_Release(ole_obj);
+        if(FAILED(hres))
+            WARN("DoVerb failed: %08x\n", hres);
+    }
 
     if(host->ip_object) {
         HWND hwnd;
@@ -390,7 +391,7 @@ HRESULT get_plugin_dispid(HTMLPluginContainer *plugin_container, WCHAR *name, DI
     }else if(plugin_container->props_len == plugin_container->props_size) {
         DISPID *new_props;
 
-        new_props = heap_realloc(plugin_container->props, plugin_container->props_size*2);
+        new_props = heap_realloc(plugin_container->props, plugin_container->props_size*2*sizeof(DISPID));
         if(!new_props)
             return E_OUTOFMEMORY;
 
diff --git a/dlls/mshtml/tests/activex.c b/dlls/mshtml/tests/activex.c
index 0972392..feb178e 100644
--- a/dlls/mshtml/tests/activex.c
+++ b/dlls/mshtml/tests/activex.c
@@ -95,11 +95,13 @@ DEFINE_EXPECT(wrapped_func);
 
 enum {
     TEST_FLASH,
-    TEST_NOQUICKACT
+    TEST_NOQUICKACT,
+    TEST_DISPONLY
 };
 
 static HWND container_hwnd, plugin_hwnd;
 static int plugin_behavior;
+static BOOL no_quickact;
 
 #define TESTACTIVEX_CLSID "{178fc163-f585-4e24-9c13-4bb7f6680746}"
 
@@ -1204,24 +1206,24 @@ static void init_wrapped_iface(void)
 static HRESULT ax_qi(REFIID riid, void **ppv)
 {
     if(IsEqualGUID(riid, &IID_IUnknown) || IsEqualGUID(riid, &IID_IOleControl)) {
-        *ppv = &OleControl;
+        *ppv = plugin_behavior == TEST_DISPONLY ? NULL : &OleControl;
     }else if(IsEqualGUID(riid, &IID_IQuickActivate)) {
-        *ppv = plugin_behavior == TEST_NOQUICKACT ? NULL : &QuickActivate;
+        *ppv = no_quickact ? NULL : &QuickActivate;
     }else if(IsEqualGUID(riid, &IID_IPersistPropertyBag)) {
-        *ppv = plugin_behavior == TEST_NOQUICKACT ? NULL : &PersistPropertyBag;
+        *ppv = no_quickact ? NULL : &PersistPropertyBag;
     }else if(IsEqualGUID(riid, &IID_IDispatch)) {
         *ppv = &Dispatch;
     }else if(IsEqualGUID(riid, &IID_IViewObject) || IsEqualGUID(riid, &IID_IViewObject2)
             || IsEqualGUID(riid, &IID_IViewObjectEx)) {
-        *ppv = &ViewObjectEx;
+        *ppv = plugin_behavior == TEST_DISPONLY ? NULL : &ViewObjectEx;
     }else if(IsEqualGUID(riid, &IID_IOleObject)) {
-        *ppv = &OleObject;
+        *ppv = plugin_behavior == TEST_DISPONLY ? NULL : &OleObject;
     }else if(IsEqualGUID(riid, &IID_ITestActiveX)) {
         CHECK_EXPECT(QI_ITestActiveX);
         *ppv = &wrapped_iface;
     }else  if(IsEqualGUID(riid, &IID_IOleWindow) || IsEqualGUID(riid, &IID_IOleInPlaceObject)
        || IsEqualGUID(&IID_IOleInPlaceObjectWindowless, riid)) {
-        *ppv = &OleInPlaceObjectWindowless;
+        *ppv = plugin_behavior == TEST_DISPONLY ? NULL : &OleInPlaceObjectWindowless;
     }else {
         trace("QI %s\n", debugstr_guid(riid));
         *ppv = NULL;
@@ -2081,11 +2083,18 @@ static void release_doc(IHTMLDocument2 *doc)
     }
 }
 
+static void init_test(int behavior)
+{
+    plugin_behavior = behavior;
+
+    no_quickact = behavior == TEST_NOQUICKACT || behavior == TEST_DISPONLY;
+}
+
 static void test_flash_ax(void)
 {
     IHTMLDocument2 *doc;
 
-    plugin_behavior = TEST_FLASH;
+    init_test(TEST_FLASH);
 
     /*
      * We pump messages until both document is loaded and plugin instance is created.
@@ -2147,7 +2156,7 @@ static void test_noquickact_ax(void)
 {
     IHTMLDocument2 *doc;
 
-    plugin_behavior = TEST_NOQUICKACT;
+    init_test(TEST_NOQUICKACT);
 
     SET_EXPECT(CreateInstance);
     SET_EXPECT(FreezeEvents_TRUE);
@@ -2188,6 +2197,23 @@ static void test_noquickact_ax(void)
     CHECK_CALLED(SetClientSite_NULL);
 }
 
+static void test_nooleobj_ax(void)
+{
+    IHTMLDocument2 *doc;
+
+    init_test(TEST_DISPONLY);
+
+    SET_EXPECT(CreateInstance);
+    SET_EXPECT(Invoke_READYSTATE);
+
+    doc = create_doc(object_ax_str, &called_CreateInstance);
+
+    CHECK_CALLED(CreateInstance);
+    CHECK_CALLED(Invoke_READYSTATE);
+
+    release_doc(doc);
+}
+
 static LRESULT WINAPI wnd_proc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)
 {
     return DefWindowProc(hwnd, msg, wParam, lParam);
@@ -2305,6 +2331,8 @@ START_TEST(activex)
         test_flash_ax();
         trace("Testing plugin without IQuickActivate iface...\n");
         test_noquickact_ax();
+        trace("Testing plugin with IDispatch iface only...\n");
+        test_nooleobj_ax();
         init_registry(FALSE);
     }else {
         skip("Could not register ActiveX\n");




More information about the wine-cvs mailing list