[PATCH 5/7] mshtml: COM cleanup for the IOleInPlaceActiveObject iface.

Michael Stefaniuc mstefani at redhat.de
Wed Dec 22 19:20:05 CST 2010


---
 dlls/mshtml/htmldoc.c        |    4 ++--
 dlls/mshtml/mshtml_private.h |    4 +---
 dlls/mshtml/olecmd.c         |    5 +++--
 dlls/mshtml/olewnd.c         |   33 +++++++++++++++++----------------
 dlls/mshtml/view.c           |    8 +++++---
 5 files changed, 28 insertions(+), 26 deletions(-)

diff --git a/dlls/mshtml/htmldoc.c b/dlls/mshtml/htmldoc.c
index eae9eff..5fa5adf 100644
--- a/dlls/mshtml/htmldoc.c
+++ b/dlls/mshtml/htmldoc.c
@@ -1752,7 +1752,7 @@ static BOOL htmldoc_qi(HTMLDocument *This, REFIID riid, void **ppv)
         *ppv = &This->IOleDocumentView_iface;
     }else if(IsEqualGUID(&IID_IOleInPlaceActiveObject, riid)) {
         TRACE("(%p)->(IID_IOleInPlaceActiveObject, %p)\n", This, ppv);
-        *ppv = ACTOBJ(This);
+        *ppv = &This->IOleInPlaceActiveObject_iface;
     }else if(IsEqualGUID(&IID_IViewObject, riid)) {
         TRACE("(%p)->(IID_IViewObject, %p)\n", This, ppv);
         *ppv = VIEWOBJ(This);
@@ -1764,7 +1764,7 @@ static BOOL htmldoc_qi(HTMLDocument *This, REFIID riid, void **ppv)
         *ppv = VIEWOBJEX(This);
     }else if(IsEqualGUID(&IID_IOleWindow, riid)) {
         TRACE("(%p)->(IID_IOleWindow, %p)\n", This, ppv);
-        *ppv = OLEWIN(This);
+        *ppv = &This->IOleInPlaceActiveObject_iface;
     }else if(IsEqualGUID(&IID_IOleInPlaceObject, riid)) {
         TRACE("(%p)->(IID_IOleInPlaceObject, %p)\n", This, ppv);
         *ppv = INPLACEOBJ(This);
diff --git a/dlls/mshtml/mshtml_private.h b/dlls/mshtml/mshtml_private.h
index 7c3fbbd..f8e808a 100644
--- a/dlls/mshtml/mshtml_private.h
+++ b/dlls/mshtml/mshtml_private.h
@@ -354,7 +354,7 @@ struct HTMLDocument {
     IOleObject                  IOleObject_iface;
     IOleDocument                IOleDocument_iface;
     IOleDocumentView            IOleDocumentView_iface;
-    const IOleInPlaceActiveObjectVtbl     *lpOleInPlaceActiveObjectVtbl;
+    IOleInPlaceActiveObject     IOleInPlaceActiveObject_iface;
     const IViewObjectExVtbl               *lpViewObjectExVtbl;
     const IOleInPlaceObjectWindowlessVtbl *lpOleInPlaceObjectWindowlessVtbl;
     const IServiceProviderVtbl            *lpServiceProviderVtbl;
@@ -625,8 +625,6 @@ struct HTMLDocumentNode {
 #define HTMLWINDOW2(x)   ((IHTMLWindow2*)                 &(x)->lpHTMLWindow2Vtbl)
 #define HTMLWINDOW3(x)   ((IHTMLWindow3*)                 &(x)->lpHTMLWindow3Vtbl)
 #define HTMLWINDOW4(x)   ((IHTMLWindow4*)                 &(x)->lpHTMLWindow4Vtbl)
-#define OLEWIN(x)        ((IOleWindow*)                   &(x)->lpOleInPlaceActiveObjectVtbl)
-#define ACTOBJ(x)        ((IOleInPlaceActiveObject*)      &(x)->lpOleInPlaceActiveObjectVtbl)
 #define VIEWOBJ(x)       ((IViewObject*)                  &(x)->lpViewObjectExVtbl)
 #define VIEWOBJ2(x)      ((IViewObject2*)                 &(x)->lpViewObjectExVtbl)
 #define VIEWOBJEX(x)      ((IViewObjectEx*)               &(x)->lpViewObjectExVtbl)
diff --git a/dlls/mshtml/olecmd.c b/dlls/mshtml/olecmd.c
index 8142d72..5bcf1b7 100644
--- a/dlls/mshtml/olecmd.c
+++ b/dlls/mshtml/olecmd.c
@@ -620,11 +620,12 @@ static HRESULT exec_editmode(HTMLDocument *This, DWORD cmdexecopt, VARIANT *in,
         RECT rcBorderWidths;
 
         if(This->doc_obj->hostui)
-            IDocHostUIHandler_ShowUI(This->doc_obj->hostui, DOCHOSTUITYPE_AUTHOR, ACTOBJ(This), CMDTARGET(This),
+            IDocHostUIHandler_ShowUI(This->doc_obj->hostui, DOCHOSTUITYPE_AUTHOR,
+                &This->IOleInPlaceActiveObject_iface, CMDTARGET(This),
                 This->doc_obj->frame, This->doc_obj->ip_window);
 
         if(This->doc_obj->ip_window)
-            call_set_active_object(This->doc_obj->ip_window, ACTOBJ(This));
+            call_set_active_object(This->doc_obj->ip_window, &This->IOleInPlaceActiveObject_iface);
 
         memset(&rcBorderWidths, 0, sizeof(rcBorderWidths));
         if(This->doc_obj->frame)
diff --git a/dlls/mshtml/olewnd.c b/dlls/mshtml/olewnd.c
index d6913b2..99d9b9e 100644
--- a/dlls/mshtml/olewnd.c
+++ b/dlls/mshtml/olewnd.c
@@ -39,29 +39,32 @@ WINE_DEFAULT_DEBUG_CHANNEL(mshtml);
  * IOleInPlaceActiveObject implementation
  */
 
-#define ACTOBJ_THIS(iface) DEFINE_THIS(HTMLDocument, OleInPlaceActiveObject, iface)
+static inline HTMLDocument *impl_from_IOleInPlaceActiveObject(IOleInPlaceActiveObject *iface)
+{
+    return CONTAINING_RECORD(iface, HTMLDocument, IOleInPlaceActiveObject_iface);
+}
 
 static HRESULT WINAPI OleInPlaceActiveObject_QueryInterface(IOleInPlaceActiveObject *iface, REFIID riid, void **ppv)
 {
-    HTMLDocument *This = ACTOBJ_THIS(iface);
+    HTMLDocument *This = impl_from_IOleInPlaceActiveObject(iface);
     return htmldoc_query_interface(This, riid, ppv);
 }
 
 static ULONG WINAPI OleInPlaceActiveObject_AddRef(IOleInPlaceActiveObject *iface)
 {
-    HTMLDocument *This = ACTOBJ_THIS(iface);
+    HTMLDocument *This = impl_from_IOleInPlaceActiveObject(iface);
     return htmldoc_addref(This);
 }
 
 static ULONG WINAPI OleInPlaceActiveObject_Release(IOleInPlaceActiveObject *iface)
 {
-    HTMLDocument *This = ACTOBJ_THIS(iface);
+    HTMLDocument *This = impl_from_IOleInPlaceActiveObject(iface);
     return htmldoc_release(This);
 }
 
 static HRESULT WINAPI OleInPlaceActiveObject_GetWindow(IOleInPlaceActiveObject *iface, HWND *phwnd)
 {
-    HTMLDocument *This = ACTOBJ_THIS(iface);
+    HTMLDocument *This = impl_from_IOleInPlaceActiveObject(iface);
 
     TRACE("(%p)->(%p)\n", This, phwnd);
 
@@ -79,14 +82,14 @@ static HRESULT WINAPI OleInPlaceActiveObject_GetWindow(IOleInPlaceActiveObject *
 
 static HRESULT WINAPI OleInPlaceActiveObject_ContextSensitiveHelp(IOleInPlaceActiveObject *iface, BOOL fEnterMode)
 {
-    HTMLDocument *This = ACTOBJ_THIS(iface);
+    HTMLDocument *This = impl_from_IOleInPlaceActiveObject(iface);
     FIXME("(%p)->(%x)\n", This, fEnterMode);
     return E_NOTIMPL;
 }
 
 static HRESULT WINAPI OleInPlaceActiveObject_TranslateAccelerator(IOleInPlaceActiveObject *iface, LPMSG lpmsg)
 {
-    HTMLDocument *This = ACTOBJ_THIS(iface);
+    HTMLDocument *This = impl_from_IOleInPlaceActiveObject(iface);
     FIXME("(%p)->(%p)\n", This, lpmsg);
     return E_NOTIMPL;
 }
@@ -94,7 +97,7 @@ static HRESULT WINAPI OleInPlaceActiveObject_TranslateAccelerator(IOleInPlaceAct
 static HRESULT WINAPI OleInPlaceActiveObject_OnFrameWindowActivate(IOleInPlaceActiveObject *iface,
         BOOL fActivate)
 {
-    HTMLDocument *This = ACTOBJ_THIS(iface);
+    HTMLDocument *This = impl_from_IOleInPlaceActiveObject(iface);
 
     TRACE("(%p)->(%x)\n", This, fActivate);
 
@@ -106,7 +109,7 @@ static HRESULT WINAPI OleInPlaceActiveObject_OnFrameWindowActivate(IOleInPlaceAc
 
 static HRESULT WINAPI OleInPlaceActiveObject_OnDocWindowActivate(IOleInPlaceActiveObject *iface, BOOL fActivate)
 {
-    HTMLDocument *This = ACTOBJ_THIS(iface);
+    HTMLDocument *This = impl_from_IOleInPlaceActiveObject(iface);
     FIXME("(%p)->(%x)\n", This, fActivate);
     return E_NOTIMPL;
 }
@@ -114,14 +117,14 @@ static HRESULT WINAPI OleInPlaceActiveObject_OnDocWindowActivate(IOleInPlaceActi
 static HRESULT WINAPI OleInPlaceActiveObject_ResizeBorder(IOleInPlaceActiveObject *iface, LPCRECT prcBorder,
                                                 IOleInPlaceUIWindow *pUIWindow, BOOL fFrameWindow)
 {
-    HTMLDocument *This = ACTOBJ_THIS(iface);
+    HTMLDocument *This = impl_from_IOleInPlaceActiveObject(iface);
     FIXME("(%p)->(%p %p %x)\n", This, prcBorder, pUIWindow, fFrameWindow);
     return E_NOTIMPL;
 }
 
 static HRESULT WINAPI OleInPlaceActiveObject_EnableModeless(IOleInPlaceActiveObject *iface, BOOL fEnable)
 {
-    HTMLDocument *This = ACTOBJ_THIS(iface);
+    HTMLDocument *This = impl_from_IOleInPlaceActiveObject(iface);
     FIXME("(%p)->(%x)\n", This, fEnable);
     return E_NOTIMPL;
 }
@@ -139,8 +142,6 @@ static const IOleInPlaceActiveObjectVtbl OleInPlaceActiveObjectVtbl = {
     OleInPlaceActiveObject_EnableModeless
 };
 
-#undef ACTOBJ_THIS
-
 /**********************************************************
  * IOleInPlaceObjectWindowless implementation
  */
@@ -170,14 +171,14 @@ static HRESULT WINAPI OleInPlaceObjectWindowless_GetWindow(IOleInPlaceObjectWind
         HWND *phwnd)
 {
     HTMLDocument *This = OLEINPLACEWND_THIS(iface);
-    return IOleWindow_GetWindow(OLEWIN(This), phwnd);
+    return IOleWindow_GetWindow(&This->IOleInPlaceActiveObject_iface, phwnd);
 }
 
 static HRESULT WINAPI OleInPlaceObjectWindowless_ContextSensitiveHelp(IOleInPlaceObjectWindowless *iface,
         BOOL fEnterMode)
 {
     HTMLDocument *This = OLEINPLACEWND_THIS(iface);
-    return IOleWindow_ContextSensitiveHelp(OLEWIN(This), fEnterMode);
+    return IOleWindow_ContextSensitiveHelp(&This->IOleInPlaceActiveObject_iface, fEnterMode);
 }
 
 static HRESULT WINAPI OleInPlaceObjectWindowless_InPlaceDeactivate(IOleInPlaceObjectWindowless *iface)
@@ -277,6 +278,6 @@ static const IOleInPlaceObjectWindowlessVtbl OleInPlaceObjectWindowlessVtbl = {
 
 void HTMLDocument_Window_Init(HTMLDocument *This)
 {
-    This->lpOleInPlaceActiveObjectVtbl = &OleInPlaceActiveObjectVtbl;
+    This->IOleInPlaceActiveObject_iface.lpVtbl = &OleInPlaceActiveObjectVtbl;
     This->lpOleInPlaceObjectWindowlessVtbl = &OleInPlaceObjectWindowlessVtbl;
 }
diff --git a/dlls/mshtml/view.c b/dlls/mshtml/view.c
index a395e89..cd716db 100644
--- a/dlls/mshtml/view.c
+++ b/dlls/mshtml/view.c
@@ -645,7 +645,8 @@ static HRESULT WINAPI OleDocumentView_UIActivate(IOleDocumentView *iface, BOOL f
 
         hres = IOleInPlaceSite_OnUIActivate(This->doc_obj->ipsite);
         if(SUCCEEDED(hres)) {
-            call_set_active_object((IOleInPlaceUIWindow*)This->doc_obj->frame, ACTOBJ(This));
+            call_set_active_object((IOleInPlaceUIWindow*)This->doc_obj->frame,
+                    &This->IOleInPlaceActiveObject_iface);
         }else {
             FIXME("OnUIActivate failed: %08x\n", hres);
             IOleInPlaceFrame_Release(This->doc_obj->frame);
@@ -657,13 +658,14 @@ static HRESULT WINAPI OleDocumentView_UIActivate(IOleDocumentView *iface, BOOL f
         if(This->doc_obj->hostui) {
             hres = IDocHostUIHandler_ShowUI(This->doc_obj->hostui,
                     This->doc_obj->usermode == EDITMODE ? DOCHOSTUITYPE_AUTHOR : DOCHOSTUITYPE_BROWSE,
-                    ACTOBJ(This), CMDTARGET(This), This->doc_obj->frame, This->doc_obj->ip_window);
+                    &This->IOleInPlaceActiveObject_iface, CMDTARGET(This), This->doc_obj->frame,
+                    This->doc_obj->ip_window);
             if(FAILED(hres))
                 IDocHostUIHandler_HideUI(This->doc_obj->hostui);
         }
 
         if(This->doc_obj->ip_window)
-            call_set_active_object(This->doc_obj->ip_window, ACTOBJ(This));
+            call_set_active_object(This->doc_obj->ip_window, &This->IOleInPlaceActiveObject_iface);
 
         memset(&rcBorderWidths, 0, sizeof(rcBorderWidths));
         IOleInPlaceFrame_SetBorderSpace(This->doc_obj->frame, &rcBorderWidths);
-- 
1.7.3.2



More information about the wine-patches mailing list