From 6d54716f175d14563118bebbc0a2db6c24e45ab2 Mon Sep 17 00:00:00 2001 From: Jacek Caban Date: Fri, 15 Apr 2005 16:12:45 +0000 Subject: [PATCH] - More implementation of view - Added IOleInPlaceActiveObject --- dlls/mshtml/htmldoc.c | 5 +++ dlls/mshtml/mshtml_private.h | 33 +++++++++------- dlls/mshtml/oleobj.c | 94 ++++++++++++++++++++++++++++++++++++++++++++ dlls/mshtml/view.c | 41 ++++++++++++++----- 4 files changed, 149 insertions(+), 24 deletions(-) diff --git a/dlls/mshtml/htmldoc.c b/dlls/mshtml/htmldoc.c index a843fabb579..8005e53062b 100644 --- a/dlls/mshtml/htmldoc.c +++ b/dlls/mshtml/htmldoc.c @@ -76,6 +76,9 @@ static HRESULT WINAPI HTMLDocument_QueryInterface(IHTMLDocument2 *iface, REFIID }else if(IsEqualGUID(&IID_IOleDocumentView, riid)) { TRACE("(%p)->(IID_IOleDocumentView, %p)\n", This, ppvObject); *ppvObject = DOCVIEW(This); + }else if(IsEqualGUID(&IID_IOleInPlaceActiveObject, riid)) { + TRACE("(%p)->(IID_IOleInPlaceActiveObject, %p)\n", This, ppvObject); + *ppvObject = ACTOBJ(This); } if(*ppvObject) { @@ -107,6 +110,8 @@ static ULONG WINAPI HTMLDocument_Release(IHTMLDocument2 *iface) IOleClientSite_Release(This->client); if(This->ipsite) IOleInPlaceSite_Release(This->ipsite); + if(This->frame) + IOleInPlaceFrame_Release(This->frame); HeapFree(GetProcessHeap(), 0, This); } diff --git a/dlls/mshtml/mshtml_private.h b/dlls/mshtml/mshtml_private.h index e7e8c116ff8..a20f61b3eee 100644 --- a/dlls/mshtml/mshtml_private.h +++ b/dlls/mshtml/mshtml_private.h @@ -17,30 +17,33 @@ */ typedef struct { - IHTMLDocument2Vtbl *lpHTMLDocument2Vtbl; - IPersistMonikerVtbl *lpPersistMonikerVtbl; - IPersistFileVtbl *lpPersistFileVtbl; - IMonikerPropVtbl *lpMonikerPropVtbl; - IOleObjectVtbl *lpOleObjectVtbl; - IOleDocumentVtbl *lpOleDocumentVtbl; - IOleDocumentViewVtbl*lpOleDocumentViewVtbl; + IHTMLDocument2Vtbl *lpHTMLDocument2Vtbl; + IPersistMonikerVtbl *lpPersistMonikerVtbl; + IPersistFileVtbl *lpPersistFileVtbl; + IMonikerPropVtbl *lpMonikerPropVtbl; + IOleObjectVtbl *lpOleObjectVtbl; + IOleDocumentVtbl *lpOleDocumentVtbl; + IOleDocumentViewVtbl *lpOleDocumentViewVtbl; + IOleInPlaceActiveObjectVtbl *lpOleInPlaceActiveObjectVtbl; ULONG ref; IOleClientSite *client; IOleInPlaceSite *ipsite; + IOleInPlaceFrame *frame; HWND hwnd; } HTMLDocument; -#define HTMLDOC(x) ((IHTMLDocument2*) &(x)->lpHTMLDocument2Vtbl) -#define PERSIST(x) ((IPersist*) &(x)->lpPersistFileVtbl) -#define PERSISTMON(x) ((IPersistMoniker*) &(x)->lpPersistMonikerVtbl) -#define PERSISTFILE(x) ((IPersistFile*) &(x)->lpPersistFileVtbl) -#define MONPROP(x) ((IMonikerProp*) &(x)->lpMonikerPropVtbl) -#define OLEOBJ(x) ((IOleObject*) &(x)->lpOleObjectVtbl) -#define OLEDOC(x) ((IOleDocument*) &(x)->lpOleDocumentVtbl) -#define DOCVIEW(x) ((IOleDocumentView*) &(x)->lpOleDocumentViewVtbl) +#define HTMLDOC(x) ((IHTMLDocument2*) &(x)->lpHTMLDocument2Vtbl) +#define PERSIST(x) ((IPersist*) &(x)->lpPersistFileVtbl) +#define PERSISTMON(x) ((IPersistMoniker*) &(x)->lpPersistMonikerVtbl) +#define PERSISTFILE(x) ((IPersistFile*) &(x)->lpPersistFileVtbl) +#define MONPROP(x) ((IMonikerProp*) &(x)->lpMonikerPropVtbl) +#define OLEOBJ(x) ((IOleObject*) &(x)->lpOleObjectVtbl) +#define OLEDOC(x) ((IOleDocument*) &(x)->lpOleDocumentVtbl) +#define DOCVIEW(x) ((IOleDocumentView*) &(x)->lpOleDocumentViewVtbl) +#define ACTOBJ(x) ((IOleInPlaceActiveObject*) &(x)->lpOleInPlaceActiveObjectVtbl) HRESULT HTMLDocument_Create(IUnknown*,REFIID,void**); diff --git a/dlls/mshtml/oleobj.c b/dlls/mshtml/oleobj.c index 5adbe73d52f..ee22ffb83f3 100644 --- a/dlls/mshtml/oleobj.c +++ b/dlls/mshtml/oleobj.c @@ -374,10 +374,104 @@ static IOleDocumentVtbl OleDocumentVtbl = { OleDocument_EnumViews }; +/********************************************************** + * IOleInPlaceActiveObject implementation + */ + +#define ACTOBJ_THIS \ + HTMLDocument* const This=(HTMLDocument*)((char*)(iface)-offsetof(HTMLDocument,lpOleInPlaceActiveObjectVtbl)); + +static HRESULT WINAPI OleInPlaceActiveObject_QueryInterface(IOleInPlaceActiveObject *iface, REFIID riid, void **ppvObject) +{ + ACTOBJ_THIS + return IHTMLDocument2_QueryInterface(HTMLDOC(This), riid, ppvObject); +} + +static ULONG WINAPI OleInPlaceActiveObject_AddRef(IOleInPlaceActiveObject *iface) +{ + ACTOBJ_THIS + return IHTMLDocument2_AddRef(HTMLDOC(This)); +} + +static ULONG WINAPI OleInPlaceActiveObject_Release(IOleInPlaceActiveObject *iface) +{ + ACTOBJ_THIS + return IHTMLDocument2_Release(HTMLDOC(This)); +} + +static HRESULT WINAPI OleInPlaceActiveObject_GetWindow(IOleInPlaceActiveObject *iface, HWND *phwnd) +{ + ACTOBJ_THIS + TRACE("(%p)->(%p)\n", This, phwnd); + + if(!phwnd) + return E_INVALIDARG; + + *phwnd = This->hwnd; + return S_OK; +} + +static HRESULT WINAPI OleInPlaceActiveObject_ContextSensitiveHelp(IOleInPlaceActiveObject *iface, BOOL fEnterMode) +{ + ACTOBJ_THIS + FIXME("(%p)->(%x)\n", This, fEnterMode); + return E_NOTIMPL; +} + +static HRESULT WINAPI OleInPlaceActiveObject_TranslateAccelerator(IOleInPlaceActiveObject *iface, LPMSG lpmsg) +{ + ACTOBJ_THIS + FIXME("(%p)->(%p)\n", This, lpmsg); + return E_NOTIMPL; +} + +static HRESULT WINAPI OleInPlaceActiveObject_OnFrameWindowActivate(IOleInPlaceActiveObject *iface, BOOL fActivate) +{ + ACTOBJ_THIS + FIXME("(%p)->(%x)\n", This, fActivate); + return E_NOTIMPL; +} + +static HRESULT WINAPI OleInPlaceActiveObject_OnDocWindowActivate(IOleInPlaceActiveObject *iface, BOOL fActivate) +{ + ACTOBJ_THIS + FIXME("(%p)->(%x)\n", This, fActivate); + return E_NOTIMPL; +} + +static HRESULT WINAPI OleInPlaceActiveObject_ResizeBorder(IOleInPlaceActiveObject *iface, LPCRECT prcBorder, + IOleInPlaceUIWindow *pUIWindow, BOOL fFrameWindow) +{ + ACTOBJ_THIS + FIXME("(%p)->(%p %p %x)\n", This, prcBorder, pUIWindow, fFrameWindow); + return E_NOTIMPL; +} + +static HRESULT WINAPI OleInPlaceActiveObject_EnableModeless(IOleInPlaceActiveObject *iface, BOOL fEnable) +{ + ACTOBJ_THIS + FIXME("(%p)->(%x)\n", This, fEnable); + return E_NOTIMPL; +} + +static IOleInPlaceActiveObjectVtbl OleInPlaceActiveObjectVtbl = { + OleInPlaceActiveObject_QueryInterface, + OleInPlaceActiveObject_AddRef, + OleInPlaceActiveObject_Release, + OleInPlaceActiveObject_GetWindow, + OleInPlaceActiveObject_ContextSensitiveHelp, + OleInPlaceActiveObject_TranslateAccelerator, + OleInPlaceActiveObject_OnFrameWindowActivate, + OleInPlaceActiveObject_OnDocWindowActivate, + OleInPlaceActiveObject_ResizeBorder, + OleInPlaceActiveObject_EnableModeless +}; + void HTMLDocument_OleObj_Init(HTMLDocument *This) { This->lpOleObjectVtbl = &OleObjectVtbl; This->lpOleDocumentVtbl = &OleDocumentVtbl; + This->lpOleInPlaceActiveObjectVtbl = &OleInPlaceActiveObjectVtbl; This->client = NULL; } diff --git a/dlls/mshtml/view.c b/dlls/mshtml/view.c index b57b32492e8..ed9b4075844 100644 --- a/dlls/mshtml/view.c +++ b/dlls/mshtml/view.c @@ -40,6 +40,8 @@ WINE_DEFAULT_DEBUG_CHANNEL(mshtml); static const WCHAR wszInternetExplorer_Server[] = {'I','n','t','e','r','n','e','t',' ','E','x','p','l','o','r','e','r','_','S','e','r','v','e','r',0}; +static const WCHAR wszHTML_Document[] = + {'H','T','M','L',' ','D','o','c','u','m','e','n','t',0}; static ATOM serverwnd_class = 0; @@ -206,8 +208,12 @@ static HRESULT WINAPI OleDocumentView_SetRectComplex(IOleDocumentView *iface, LP static HRESULT WINAPI OleDocumentView_Show(IOleDocumentView *iface, BOOL fShow) { DOCVIEW_THIS - FIXME("(%p)->(%x)\n", This, fShow); - return E_NOTIMPL; + TRACE("(%p)->(%x)\n", This, fShow); + + if(This->hwnd) + ShowWindow(This->hwnd, fShow); + + return S_OK; } static HRESULT WINAPI OleDocumentView_UIActivate(IOleDocumentView *iface, BOOL fUIActivate) @@ -244,8 +250,6 @@ static HRESULT WINAPI OleDocumentView_UIActivate(IOleDocumentView *iface, BOOL f WARN("GetWindowContext failed: %08lx\n", hres); return hres; } - if(pIPFrame) - IOleInPlaceFrame_Release(pIPFrame); if(pIPWnd) IOleInPlaceUIWindow_Release(pIPWnd); TRACE("got window context: %p %p {%ld %ld %ld %ld} {%ld %ld %ld %ld} {%d %x %p %p %d}\n", @@ -283,16 +287,23 @@ static HRESULT WINAPI OleDocumentView_UIActivate(IOleDocumentView *iface, BOOL f hres = IOleInPlaceSite_OnUIActivate(This->ipsite); if(SUCCEEDED(hres)) { - /* IOleInPlaceFrame_SetActiveObject(pIPFrame, ACTOBJ(This->pDoc), wszHTMLDocument); */ + IOleInPlaceFrame_SetActiveObject(pIPFrame, ACTOBJ(This), wszHTML_Document); }else { FIXME("OnUIActivate failed: %08lx\n", hres); DestroyWindow(hwnd); return hres; } + if(This->frame) + IOleInPlaceFrame_Release(This->frame); + This->frame = pIPFrame; This->hwnd = hwnd; }else { - FIXME("deactivating is not supported\n"); - return E_NOTIMPL; + static const WCHAR wszEmpty[] = {0}; + + if(This->frame) + IOleInPlaceFrame_SetActiveObject(This->frame, NULL, wszEmpty); + if(This->ipsite) + IOleInPlaceSite_OnUIDeactivate(This->ipsite, FALSE); } return S_OK; } @@ -307,8 +318,19 @@ static HRESULT WINAPI OleDocumentView_Open(IOleDocumentView *iface) static HRESULT WINAPI OleDocumentView_CloseView(IOleDocumentView *iface, DWORD dwReserved) { DOCVIEW_THIS - FIXME("(%p)->(%lx)\n", This, dwReserved); - return E_NOTIMPL; + TRACE("(%p)->(%lx)\n", This, dwReserved); + + if(dwReserved) + WARN("dwReserved = %ld\n", dwReserved); + + /* NOTE: + * Windows implementation calls QueryInterface(IID_IOleCommandTarget), + * QueryInterface(IID_IOleControlSite) and KillTimer + */ + + IOleDocumentView_Show(iface, FALSE); + + return S_OK; } static HRESULT WINAPI OleDocumentView_SaveViewState(IOleDocumentView *iface, LPSTREAM pstm) @@ -357,5 +379,6 @@ void HTMLDocument_View_Init(HTMLDocument *This) This->lpOleDocumentViewVtbl = &OleDocumentViewVtbl; This->ipsite = NULL; + This->frame = NULL; This->hwnd = NULL; } -- 2.11.4.GIT