From da56a9c16ec5338f5a58f8b15bffca302882f671 Mon Sep 17 00:00:00 2001 From: Jacek Caban Date: Wed, 13 Apr 2005 14:41:19 +0000 Subject: [PATCH] - Added IOleDocumentView interface. - Added implementation of DoVerb and CreateView. --- dlls/mshtml/Makefile.in | 3 +- dlls/mshtml/htmldoc.c | 11 +- dlls/mshtml/mshtml_private.h | 4 + dlls/mshtml/oleobj.c | 67 +++++++++++- dlls/mshtml/view.c | 207 +++++++++++++++++++++++++++++++++++ 5 files changed, 286 insertions(+), 6 deletions(-) create mode 100644 dlls/mshtml/view.c diff --git a/dlls/mshtml/Makefile.in b/dlls/mshtml/Makefile.in index afe7434e7ef..182730a1270 100644 --- a/dlls/mshtml/Makefile.in +++ b/dlls/mshtml/Makefile.in @@ -11,7 +11,8 @@ C_SRCS = \ htmldoc.c \ main.c \ oleobj.c \ - persist.c + persist.c \ + view.c @MAKE_DLL_RULES@ diff --git a/dlls/mshtml/htmldoc.c b/dlls/mshtml/htmldoc.c index 48a229538d4..526887e3b5f 100644 --- a/dlls/mshtml/htmldoc.c +++ b/dlls/mshtml/htmldoc.c @@ -73,6 +73,9 @@ static HRESULT WINAPI HTMLDocument_QueryInterface(IHTMLDocument2 *iface, REFIID }else if(IsEqualGUID(&IID_IOleDocument, riid)) { TRACE("(%p)->(IID_IOleDocument, %p)\n", This, ppvObject); *ppvObject = OLEDOC(This); + }else if(IsEqualGUID(&IID_IOleDocumentView, riid)) { + TRACE("(%p)->(IID_IOleDocumentView, %p)\n", This, ppvObject); + *ppvObject = DOCVIEW(This); } if(*ppvObject) { @@ -99,8 +102,13 @@ static ULONG WINAPI HTMLDocument_Release(IHTMLDocument2 *iface) TRACE("(%p) ref = %lu\n", This, ref); - if(!ref) + if(!ref) { + if(This->client) + IOleClientSite_Release(This->client); + if(This->ipsite) + IOleInPlaceSite_Release(This->ipsite); HeapFree(GetProcessHeap(), 0, This); + } return ref; } @@ -939,6 +947,7 @@ HRESULT HTMLDocument_Create(IUnknown *pUnkOuter, REFIID riid, void** ppvObject) HTMLDocument_Persist_Init(ret); HTMLDocument_OleObj_Init(ret); + HTMLDocument_View_Init(ret); return hres; } diff --git a/dlls/mshtml/mshtml_private.h b/dlls/mshtml/mshtml_private.h index 216c2723f06..871c6b53024 100644 --- a/dlls/mshtml/mshtml_private.h +++ b/dlls/mshtml/mshtml_private.h @@ -23,10 +23,12 @@ typedef struct { IMonikerPropVtbl *lpMonikerPropVtbl; IOleObjectVtbl *lpOleObjectVtbl; IOleDocumentVtbl *lpOleDocumentVtbl; + IOleDocumentViewVtbl*lpOleDocumentViewVtbl; ULONG ref; IOleClientSite *client; + IOleInPlaceSite *ipsite; } HTMLDocument; #define HTMLDOC(x) ((IHTMLDocument2*) &(x)->lpHTMLDocument2Vtbl) @@ -36,8 +38,10 @@ typedef struct { #define MONPROP(x) ((IMonikerProp*) &(x)->lpMonikerPropVtbl) #define OLEOBJ(x) ((IOleObject*) &(x)->lpOleObjectVtbl) #define OLEDOC(x) ((IOleDocument*) &(x)->lpOleDocumentVtbl) +#define DOCVIEW(x) ((IOleDocumentView*) &(x)->lpOleDocumentViewVtbl) HRESULT HTMLDocument_Create(IUnknown*,REFIID,void**); void HTMLDocument_Persist_Init(HTMLDocument*); void HTMLDocument_OleObj_Init(HTMLDocument*); +void HTMLDocument_View_Init(HTMLDocument*); diff --git a/dlls/mshtml/oleobj.c b/dlls/mshtml/oleobj.c index ee841c37939..5adbe73d52f 100644 --- a/dlls/mshtml/oleobj.c +++ b/dlls/mshtml/oleobj.c @@ -138,8 +138,43 @@ static HRESULT WINAPI OleObject_DoVerb(IOleObject *iface, LONG iVerb, LPMSG lpms LONG lindex, HWND hwndParent, LPCRECT lprcPosRect) { OLEOBJ_THIS - FIXME("(%p)->(%ld %p %p %ld %p %p)\n", This, iVerb, lpmsg, pActiveSite, lindex, hwndParent, lprcPosRect); - return E_NOTIMPL; + IOleDocumentSite *pDocSite; + HRESULT hres; + + TRACE("(%p)->(%ld %p %p %ld %p %p)\n", This, iVerb, lpmsg, pActiveSite, lindex, hwndParent, lprcPosRect); + + if(iVerb != OLEIVERB_SHOW) { + FIXME("iVerb = %ld not supported\n", iVerb); + return E_NOTIMPL; + } + + if(!pActiveSite) + pActiveSite = This->client; + + hres = IOleClientSite_QueryInterface(pActiveSite, &IID_IOleDocumentSite, (void**)&pDocSite); + if(SUCCEEDED(hres)) { + IOleContainer *pContainer; + hres = IOleClientSite_GetContainer(pActiveSite, &pContainer); + if(SUCCEEDED(hres)) { + IOleContainer_LockContainer(pContainer, TRUE); + /* FIXME: Create new IOleDocumentView. See CreateView for more info. */ + hres = IOleDocumentSite_ActivateMe(pDocSite, DOCVIEW(This)); + IOleContainer_Release(pContainer); + } + IOleDocumentSite_Release(pDocSite); + }else { + hres = IOleDocumentView_UIActivate(DOCVIEW(This), TRUE); + if(SUCCEEDED(hres)) { + if(lprcPosRect) { + RECT rect; /* We need to pass rect as not const pointer */ + memcpy(&rect, lprcPosRect, sizeof(RECT)); + IOleDocumentView_SetRect(DOCVIEW(This), &rect); + } + IOleDocumentView_Show(DOCVIEW(This), TRUE); + } + } + + return hres; } static HRESULT WINAPI OleObject_EnumVerbs(IOleObject *iface, IEnumOLEVERB **ppEnumOleVerb) @@ -287,8 +322,32 @@ static HRESULT WINAPI OleDocument_CreateView(IOleDocument *iface, IOleInPlaceSit DWORD dwReserved, IOleDocumentView **ppView) { OLEDOC_THIS - FIXME("(%p)->(%p %p %ld %p)\n", This, pIPSite, pstm, dwReserved, ppView); - return E_NOTIMPL; + HRESULT hres; + + TRACE("(%p)->(%p %p %ld %p)\n", This, pIPSite, pstm, dwReserved, ppView); + + if(!ppView) + return E_INVALIDARG; + + /* FIXME: + * Windows implementation creates new IOleDocumentView when function is called for the + * first time and returns E_FAIL when it is called for the second time, but it doesn't matter + * if the application uses returned interfaces, passed to ActivateMe or returned by + * QueryInterface, so there is no reason to create new interface. This needs more testing. + */ + + if(pIPSite) { + hres = IOleDocumentView_SetInPlaceSite(DOCVIEW(This), pIPSite); + if(FAILED(hres)) + return hres; + } + + if(pstm) + FIXME("pstm is not supported\n"); + + IOleDocumentView_AddRef(DOCVIEW(This)); + *ppView = DOCVIEW(This); + return S_OK; } static HRESULT WINAPI OleDocument_GetDocMiscStatus(IOleDocument *iface, DWORD *pdwStatus) diff --git a/dlls/mshtml/view.c b/dlls/mshtml/view.c new file mode 100644 index 00000000000..b64fc92a370 --- /dev/null +++ b/dlls/mshtml/view.c @@ -0,0 +1,207 @@ +/* + * Copyright 2005 Jacek Caban + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ + +#include "config.h" + +#include +#include + +#define COBJMACROS + +#include "windef.h" +#include "winbase.h" +#include "winuser.h" +#include "ole2.h" +#include "docobj.h" + +#include "mshtml.h" + +#include "wine/debug.h" + +#include "mshtml_private.h" + +WINE_DEFAULT_DEBUG_CHANNEL(mshtml); + +/********************************************************** + * IOleDocumentView implementation + */ + +#define DOCVIEW_THIS \ + HTMLDocument* const This=(HTMLDocument*)((char*)(iface)-offsetof(HTMLDocument,lpOleDocumentViewVtbl)); + +static HRESULT WINAPI OleDocumentView_QueryInterface(IOleDocumentView *iface, REFIID riid, void **ppvObject) +{ + DOCVIEW_THIS + return IHTMLDocument2_QueryInterface(HTMLDOC(This), riid, ppvObject); +} + +static ULONG WINAPI OleDocumentView_AddRef(IOleDocumentView *iface) +{ + DOCVIEW_THIS + return IHTMLDocument2_AddRef(HTMLDOC(This)); +} + +static ULONG WINAPI OleDocumentView_Release(IOleDocumentView *iface) +{ + DOCVIEW_THIS + return IHTMLDocument2_Release(HTMLDOC(This)); +} + +static HRESULT WINAPI OleDocumentView_SetInPlaceSite(IOleDocumentView *iface, IOleInPlaceSite *pIPSite) +{ + DOCVIEW_THIS + TRACE("(%p)->(%p)\n", This, pIPSite); + + if(!pIPSite) + return E_INVALIDARG; + + if(pIPSite) + IOleInPlaceSite_AddRef(pIPSite); + + if(This->ipsite) + IOleInPlaceSite_Release(This->ipsite); + + This->ipsite = pIPSite; + return S_OK; +} + +static HRESULT WINAPI OleDocumentView_GetInPlaceSite(IOleDocumentView *iface, IOleInPlaceSite **ppIPSite) +{ + DOCVIEW_THIS + TRACE("(%p)->(%p)\n", This, ppIPSite); + + if(!ppIPSite) + return E_INVALIDARG; + + if(This->ipsite) + IOleInPlaceSite_AddRef(This->ipsite); + + *ppIPSite = This->ipsite; + return S_OK; +} + +static HRESULT WINAPI OleDocumentView_GetDocument(IOleDocumentView *iface, IUnknown **ppunk) +{ + DOCVIEW_THIS + TRACE("(%p)->(%p)\n", This, ppunk); + + if(!ppunk) + return E_INVALIDARG; + + IHTMLDocument2_AddRef(HTMLDOC(This)); + *ppunk = (IUnknown*)HTMLDOC(This); + return S_OK; +} + +static HRESULT WINAPI OleDocumentView_SetRect(IOleDocumentView *iface, LPRECT prcView) +{ + DOCVIEW_THIS + FIXME("(%p)->(%p)\n", This, prcView); + return E_NOTIMPL; +} + +static HRESULT WINAPI OleDocumentView_GetRect(IOleDocumentView *iface, LPRECT prcView) +{ + DOCVIEW_THIS + FIXME("(%p)->(%p)\n", This, prcView); + return E_NOTIMPL; +} + +static HRESULT WINAPI OleDocumentView_SetRectComplex(IOleDocumentView *iface, LPRECT prcView, + LPRECT prcHScroll, LPRECT prcVScroll, LPRECT prcSizeBox) +{ + DOCVIEW_THIS + FIXME("(%p)->(%p %p %p %p)\n", This, prcView, prcHScroll, prcVScroll, prcSizeBox); + return E_NOTIMPL; +} + +static HRESULT WINAPI OleDocumentView_Show(IOleDocumentView *iface, BOOL fShow) +{ + DOCVIEW_THIS + FIXME("(%p)->(%x)\n", This, fShow); + return E_NOTIMPL; +} + +static HRESULT WINAPI OleDocumentView_UIActivate(IOleDocumentView *iface, BOOL fUIActivate) +{ + DOCVIEW_THIS + FIXME("(%p)->(%x)\n", This, fUIActivate); + return E_NOTIMPL; +} + +static HRESULT WINAPI OleDocumentView_Open(IOleDocumentView *iface) +{ + DOCVIEW_THIS + FIXME("(%p)\n", This); + return E_NOTIMPL; +} + +static HRESULT WINAPI OleDocumentView_CloseView(IOleDocumentView *iface, DWORD dwReserved) +{ + DOCVIEW_THIS + FIXME("(%p)->(%lx)\n", This, dwReserved); + return E_NOTIMPL; +} + +static HRESULT WINAPI OleDocumentView_SaveViewState(IOleDocumentView *iface, LPSTREAM pstm) +{ + DOCVIEW_THIS + FIXME("(%p)->(%p)\n", This, pstm); + return E_NOTIMPL; +} + +static HRESULT WINAPI OleDocumentView_ApplyViewState(IOleDocumentView *iface, LPSTREAM pstm) +{ + DOCVIEW_THIS + FIXME("(%p)->(%p)\n", This, pstm); + return E_NOTIMPL; +} + +static HRESULT WINAPI OleDocumentView_Clone(IOleDocumentView *iface, IOleInPlaceSite *pIPSiteNew, + IOleDocumentView **ppViewNew) +{ + DOCVIEW_THIS + FIXME("(%p)->(%p %p)\n", This, pIPSiteNew, ppViewNew); + return E_NOTIMPL; +} + +static IOleDocumentViewVtbl OleDocumentViewVtbl = { + OleDocumentView_QueryInterface, + OleDocumentView_AddRef, + OleDocumentView_Release, + OleDocumentView_SetInPlaceSite, + OleDocumentView_GetInPlaceSite, + OleDocumentView_GetDocument, + OleDocumentView_SetRect, + OleDocumentView_GetRect, + OleDocumentView_SetRectComplex, + OleDocumentView_Show, + OleDocumentView_UIActivate, + OleDocumentView_Open, + OleDocumentView_CloseView, + OleDocumentView_SaveViewState, + OleDocumentView_ApplyViewState, + OleDocumentView_Clone +}; + +void HTMLDocument_View_Init(HTMLDocument *This) +{ + This->lpOleDocumentViewVtbl = &OleDocumentViewVtbl; + + This->ipsite = NULL; +}