2 * Copyright 2005 Jacek Caban for CodeWeavers
4 * This library is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU Lesser General Public
6 * License as published by the Free Software Foundation; either
7 * version 2.1 of the License, or (at your option) any later version.
9 * This library is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 * Lesser General Public License for more details.
14 * You should have received a copy of the GNU Lesser General Public
15 * License along with this library; if not, write to the Free Software
16 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
19 #include "wine/debug.h"
22 WINE_DEFAULT_DEBUG_CHANNEL(shdocvw);
24 #define CLIENTSITE_THIS(iface) DEFINE_THIS(WebBrowser, OleClientSite, iface)
26 static HRESULT WINAPI ClientSite_QueryInterface(IOleClientSite *iface, REFIID riid, void **ppv)
28 WebBrowser *This = CLIENTSITE_THIS(iface);
32 if(IsEqualGUID(&IID_IUnknown, riid)) {
33 TRACE("(%p)->(IID_IUnknown %p)\n", This, ppv);
34 *ppv = CLIENTSITE(This);
35 }else if(IsEqualGUID(&IID_IOleClientSite, riid)) {
36 TRACE("(%p)->(IID_IOleClientSite %p)\n", This, ppv);
37 *ppv = CLIENTSITE(This);
38 }else if(IsEqualGUID(&IID_IOleWindow, riid)) {
39 TRACE("(%p)->(IID_IOleWindow %p)\n", This, ppv);
40 *ppv = INPLACESITE(This);
41 }else if(IsEqualGUID(&IID_IOleInPlaceSite, riid)) {
42 TRACE("(%p)->(IID_IOleInPlaceSite %p)\n", This, ppv);
43 *ppv = INPLACESITE(This);
44 }else if(IsEqualGUID(&IID_IDocHostUIHandler, riid)) {
45 TRACE("(%p)->(IID_IDocHostUIHandler %p)\n", This, ppv);
46 *ppv = DOCHOSTUI(This);
47 }else if(IsEqualGUID(&IID_IDocHostUIHandler2, riid)) {
48 TRACE("(%p)->(IID_IDocHostUIHandler2 %p)\n", This, ppv);
49 *ppv = DOCHOSTUI2(This);
50 }else if(IsEqualGUID(&IID_IOleDocumentSite, riid)) {
51 TRACE("(%p)->(IID_IOleDocumentSite %p)\n", This, ppv);
56 IWebBrowser2_AddRef(WEBBROWSER(This));
60 WARN("Unsupported intrface %s\n", debugstr_guid(riid));
65 static ULONG WINAPI ClientSite_AddRef(IOleClientSite *iface)
67 WebBrowser *This = CLIENTSITE_THIS(iface);
68 return IWebBrowser2_AddRef(WEBBROWSER(This));
71 static ULONG WINAPI ClientSite_Release(IOleClientSite *iface)
73 WebBrowser *This = CLIENTSITE_THIS(iface);
74 return IWebBrowser2_Release(WEBBROWSER(This));
77 static HRESULT WINAPI ClientSite_SaveObject(IOleClientSite *iface)
79 WebBrowser *This = CLIENTSITE_THIS(iface);
80 FIXME("(%p)\n", This);
84 static HRESULT WINAPI ClientSite_GetMoniker(IOleClientSite *iface, DWORD dwAssign,
85 DWORD dwWhichMoniker, IMoniker **ppmk)
87 WebBrowser *This = CLIENTSITE_THIS(iface);
88 FIXME("(%p)->(%ld %ld %p)\n", This, dwAssign, dwWhichMoniker, ppmk);
92 static HRESULT WINAPI ClientSite_GetContainer(IOleClientSite *iface, IOleContainer **ppContainer)
94 WebBrowser *This = CLIENTSITE_THIS(iface);
95 FIXME("(%p)->(%p)\n", This, ppContainer);
99 static HRESULT WINAPI ClientSite_ShowObject(IOleClientSite *iface)
101 WebBrowser *This = CLIENTSITE_THIS(iface);
102 FIXME("(%p)\n", This);
106 static HRESULT WINAPI ClientSite_OnShowWindow(IOleClientSite *iface, BOOL fShow)
108 WebBrowser *This = CLIENTSITE_THIS(iface);
109 FIXME("(%p)->(%x)\n", This, fShow);
113 static HRESULT WINAPI ClientSite_RequestNewObjectLayout(IOleClientSite *iface)
115 WebBrowser *This = CLIENTSITE_THIS(iface);
116 FIXME("(%p)\n", This);
120 #undef CLIENTSITE_THIS
122 static const IOleClientSiteVtbl OleClientSiteVtbl = {
123 ClientSite_QueryInterface,
126 ClientSite_SaveObject,
127 ClientSite_GetMoniker,
128 ClientSite_GetContainer,
129 ClientSite_ShowObject,
130 ClientSite_OnShowWindow,
131 ClientSite_RequestNewObjectLayout
134 #define INPLACESITE_THIS(iface) DEFINE_THIS(WebBrowser, OleInPlaceSite, iface)
136 static HRESULT WINAPI InPlaceSite_QueryInterface(IOleInPlaceSite *iface, REFIID riid, void **ppv)
138 WebBrowser *This = INPLACESITE_THIS(iface);
139 return IOleClientSite_QueryInterface(CLIENTSITE(This), riid, ppv);
142 static ULONG WINAPI InPlaceSite_AddRef(IOleInPlaceSite *iface)
144 WebBrowser *This = INPLACESITE_THIS(iface);
145 return IOleClientSite_AddRef(CLIENTSITE(This));
148 static ULONG WINAPI InPlaceSite_Release(IOleInPlaceSite *iface)
150 WebBrowser *This = INPLACESITE_THIS(iface);
151 return IOleClientSite_Release(CLIENTSITE(This));
154 static HRESULT WINAPI InPlaceSite_GetWindow(IOleInPlaceSite *iface, HWND *phwnd)
156 WebBrowser *This = INPLACESITE_THIS(iface);
158 TRACE("(%p)->(%p)\n", This, phwnd);
160 *phwnd = This->doc_view_hwnd;
164 static HRESULT WINAPI InPlaceSite_ContextSensitiveHelp(IOleInPlaceSite *iface, BOOL fEnterMode)
166 WebBrowser *This = INPLACESITE_THIS(iface);
167 FIXME("(%p)->(%x)\n", This, fEnterMode);
171 static HRESULT WINAPI InPlaceSite_CanInPlaceActivate(IOleInPlaceSite *iface)
173 WebBrowser *This = INPLACESITE_THIS(iface);
175 TRACE("(%p)\n", This);
177 /* Nothing to do here */
181 static HRESULT WINAPI InPlaceSite_OnInPlaceActivate(IOleInPlaceSite *iface)
183 WebBrowser *This = INPLACESITE_THIS(iface);
185 TRACE("(%p)\n", This);
187 /* Nothing to do here */
191 static HRESULT WINAPI InPlaceSite_OnUIActivate(IOleInPlaceSite *iface)
193 WebBrowser *This = INPLACESITE_THIS(iface);
194 FIXME("(%p)\n", This);
198 static HRESULT WINAPI InPlaceSite_GetWindowContext(IOleInPlaceSite *iface,
199 IOleInPlaceFrame **ppFrame, IOleInPlaceUIWindow **ppDoc, LPRECT lprcPosRect,
200 LPRECT lprcClipRect, LPOLEINPLACEFRAMEINFO lpFrameInfo)
202 WebBrowser *This = INPLACESITE_THIS(iface);
204 TRACE("(%p)->(%p %p %p %p %p)\n", This, ppFrame, ppDoc, lprcPosRect,
205 lprcClipRect, lpFrameInfo);
207 *ppFrame = INPLACEFRAME(This);
210 GetClientRect(This->doc_view_hwnd, lprcPosRect);
211 memcpy(lprcClipRect, lprcPosRect, sizeof(RECT));
213 lpFrameInfo->cb = sizeof(*lpFrameInfo);
214 lpFrameInfo->fMDIApp = FALSE;
215 lpFrameInfo->hwndFrame = This->shell_embedding_hwnd;
216 lpFrameInfo->haccel = NULL;
217 lpFrameInfo->cAccelEntries = 0; /* FIXME: should be 5 */
222 static HRESULT WINAPI InPlaceSite_Scroll(IOleInPlaceSite *iface, SIZE scrollExtent)
224 WebBrowser *This = INPLACESITE_THIS(iface);
225 FIXME("(%p)->({%ld %ld})\n", This, scrollExtent.cx, scrollExtent.cy);
229 static HRESULT WINAPI InPlaceSite_OnUIDeactivate(IOleInPlaceSite *iface, BOOL fUndoable)
231 WebBrowser *This = INPLACESITE_THIS(iface);
232 FIXME("(%p)->(%x)\n", This, fUndoable);
236 static HRESULT WINAPI InPlaceSite_OnInPlaceDeactivate(IOleInPlaceSite *iface)
238 WebBrowser *This = INPLACESITE_THIS(iface);
239 FIXME("(%p)\n", This);
243 static HRESULT WINAPI InPlaceSite_DiscardUndoState(IOleInPlaceSite *iface)
245 WebBrowser *This = INPLACESITE_THIS(iface);
246 FIXME("(%p)\n", This);
250 static HRESULT WINAPI InPlaceSite_DeactivateAndUndo(IOleInPlaceSite *iface)
252 WebBrowser *This = INPLACESITE_THIS(iface);
253 FIXME("(%p)\n", This);
257 static HRESULT WINAPI InPlaceSite_OnPosRectChange(IOleInPlaceSite *iface,
260 WebBrowser *This = INPLACESITE_THIS(iface);
261 FIXME("(%p)->(%p)\n", This, lprcPosRect);
265 #undef INPLACESITE_THIS
267 static const IOleInPlaceSiteVtbl OleInPlaceSiteVtbl = {
268 InPlaceSite_QueryInterface,
271 InPlaceSite_GetWindow,
272 InPlaceSite_ContextSensitiveHelp,
273 InPlaceSite_CanInPlaceActivate,
274 InPlaceSite_OnInPlaceActivate,
275 InPlaceSite_OnUIActivate,
276 InPlaceSite_GetWindowContext,
278 InPlaceSite_OnUIDeactivate,
279 InPlaceSite_OnInPlaceDeactivate,
280 InPlaceSite_DiscardUndoState,
281 InPlaceSite_DeactivateAndUndo,
282 InPlaceSite_OnPosRectChange
285 #define DOCSITE_THIS(iface) DEFINE_THIS(WebBrowser, OleDocumentSite, iface)
287 static HRESULT WINAPI OleDocumentSite_QueryInterface(IOleDocumentSite *iface,
288 REFIID riid, void **ppv)
290 WebBrowser *This = DOCSITE_THIS(iface);
291 return IOleClientSite_QueryInterface(CLIENTSITE(This), riid, ppv);
294 static ULONG WINAPI OleDocumentSite_AddRef(IOleDocumentSite *iface)
296 WebBrowser *This = DOCSITE_THIS(iface);
297 return IOleClientSite_AddRef(CLIENTSITE(This));
300 static ULONG WINAPI OleDocumentSite_Release(IOleDocumentSite *iface)
302 WebBrowser *This = DOCSITE_THIS(iface);
303 return IOleClientSite_Release(CLIENTSITE(This));
306 static HRESULT WINAPI OleDocumentSite_ActivateMe(IOleDocumentSite *iface,
307 IOleDocumentView *pViewToActivate)
309 WebBrowser *This = DOCSITE_THIS(iface);
310 IOleDocument *oledoc;
314 TRACE("(%p)->(%p)\n", This, pViewToActivate);
316 hres = IUnknown_QueryInterface(This->document, &IID_IOleDocument, (void**)&oledoc);
320 IOleDocument_CreateView(oledoc, INPLACESITE(This), NULL, 0, &This->view);
321 IOleDocument_Release(oledoc);
323 GetClientRect(This->doc_view_hwnd, &rect);
324 IOleDocumentView_SetRect(This->view, &rect);
326 hres = IOleDocumentView_Show(This->view, TRUE);
333 static const IOleDocumentSiteVtbl OleDocumentSiteVtbl = {
334 OleDocumentSite_QueryInterface,
335 OleDocumentSite_AddRef,
336 OleDocumentSite_Release,
337 OleDocumentSite_ActivateMe
340 void WebBrowser_ClientSite_Init(WebBrowser *This)
342 This->lpOleClientSiteVtbl = &OleClientSiteVtbl;
343 This->lpOleInPlaceSiteVtbl = &OleInPlaceSiteVtbl;
344 This->lpOleDocumentSiteVtbl = &OleDocumentSiteVtbl;
349 void WebBrowser_ClientSite_Destroy(WebBrowser *This)
352 IOleDocumentView_Release(This->view);