Jacek Caban : ieframe: Store container IOleCommandTarget in DocHost.

Alexandre Julliard julliard at wine.codeweavers.com
Mon Aug 17 09:01:11 CDT 2015


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

Author: Jacek Caban <jacek at codeweavers.com>
Date:   Fri Aug 14 16:30:45 2015 +0200

ieframe: Store container IOleCommandTarget in DocHost.

---

 dlls/ieframe/dochost.c    |  5 +++++
 dlls/ieframe/ieframe.h    |  1 +
 dlls/ieframe/oleobject.c  | 11 +++++++++++
 dlls/ieframe/webbrowser.c | 20 ++------------------
 4 files changed, 19 insertions(+), 18 deletions(-)

diff --git a/dlls/ieframe/dochost.c b/dlls/ieframe/dochost.c
index b0d713b..a495292 100644
--- a/dlls/ieframe/dochost.c
+++ b/dlls/ieframe/dochost.c
@@ -582,6 +582,11 @@ void release_dochost_client(DocHost *This)
         IOleInPlaceFrame_Release(This->frame);
         This->frame = NULL;
     }
+
+    if(This->olecmd) {
+        IOleCommandTarget_Release(This->olecmd);
+        This->olecmd = NULL;
+    }
 }
 
 static inline DocHost *impl_from_IOleCommandTarget(IOleCommandTarget *iface)
diff --git a/dlls/ieframe/ieframe.h b/dlls/ieframe/ieframe.h
index a83ff35..8a0b074 100644
--- a/dlls/ieframe/ieframe.h
+++ b/dlls/ieframe/ieframe.h
@@ -128,6 +128,7 @@ struct DocHost {
     IDispatch *client_disp;
     IDocHostUIHandler *hostui;
     IOleInPlaceFrame *frame;
+    IOleCommandTarget *olecmd;
 
     IUnknown *document;
     IOleDocumentView *view;
diff --git a/dlls/ieframe/oleobject.c b/dlls/ieframe/oleobject.c
index fb9e12f..3a75a71 100644
--- a/dlls/ieframe/oleobject.c
+++ b/dlls/ieframe/oleobject.c
@@ -458,6 +458,7 @@ static HRESULT WINAPI OleObject_SetClientSite(IOleObject *iface, LPOLECLIENTSITE
 {
     WebBrowser *This = impl_from_IOleObject(iface);
     IDocHostUIHandler *hostui;
+    IOleCommandTarget *olecmd;
     IOleContainer *container;
     IDispatch *disp;
     HRESULT hres;
@@ -502,9 +503,19 @@ static HRESULT WINAPI OleObject_SetClientSite(IOleObject *iface, LPOLECLIENTSITE
             ITargetContainer_Release(target_container);
         }
 
+        hres = IOleContainer_QueryInterface(container, &IID_IOleCommandTarget, (void**)&olecmd);
+        if(FAILED(hres))
+            olecmd = NULL;
+
         IOleContainer_Release(container);
+    }else {
+        hres = IOleClientSite_QueryInterface(This->client, &IID_IOleCommandTarget, (void**)&olecmd);
+        if(FAILED(hres))
+            olecmd = NULL;
     }
 
+    This->doc_host.olecmd = olecmd;
+
     create_shell_embedding_hwnd(This);
 
     on_offlineconnected_change(This);
diff --git a/dlls/ieframe/webbrowser.c b/dlls/ieframe/webbrowser.c
index 1f58bbb..8689c7e 100644
--- a/dlls/ieframe/webbrowser.c
+++ b/dlls/ieframe/webbrowser.c
@@ -1206,33 +1206,17 @@ static HRESULT WINAPI DocHostContainer_SetStatusText(DocHost* This, LPCWSTR text
 
 static void WINAPI DocHostContainer_SetURL(DocHost* This, LPCWSTR url)
 {
-
 }
 
 static HRESULT DocHostContainer_exec(DocHost *doc_host, const GUID *cmd_group, DWORD cmdid, DWORD execopt, VARIANT *in,
         VARIANT *out)
 {
-    WebBrowser *This = impl_from_DocHost(doc_host);
-    IOleCommandTarget *cmdtrg = NULL;
     HRESULT hres;
 
-    if(This->client) {
-        hres = IOleClientSite_QueryInterface(This->client, &IID_IOleCommandTarget, (void**)&cmdtrg);
-        if(FAILED(hres))
-            cmdtrg = NULL;
-    }
-
-    if(!cmdtrg && This->container) {
-        hres = IOleContainer_QueryInterface(This->container, &IID_IOleCommandTarget, (void**)&cmdtrg);
-        if(FAILED(hres))
-            cmdtrg = NULL;
-    }
-
-    if(!cmdtrg)
+    if(!doc_host->olecmd)
         return E_NOTIMPL;
 
-    hres = IOleCommandTarget_Exec(cmdtrg, cmd_group, cmdid, execopt, in, out);
-    IOleCommandTarget_Release(cmdtrg);
+    hres = IOleCommandTarget_Exec(doc_host->olecmd, cmd_group, cmdid, execopt, in, out);
     if(SUCCEEDED(hres))
         TRACE("Exec returned %08x %s\n", hres, debugstr_variant(out));
     else




More information about the wine-cvs mailing list