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);
53 }else if(IsEqualGUID(&IID_IOleClientSite, riid)) {
54 TRACE("(%p)->(IID_IOleClientSite %p)\n", This, ppv);
55 *ppv = CLOLECMD(This);
59 IWebBrowser2_AddRef(WEBBROWSER(This));
63 WARN("Unsupported intrface %s\n", debugstr_guid(riid));
68 static ULONG WINAPI ClientSite_AddRef(IOleClientSite *iface)
70 WebBrowser *This = CLIENTSITE_THIS(iface);
71 return IWebBrowser2_AddRef(WEBBROWSER(This));
74 static ULONG WINAPI ClientSite_Release(IOleClientSite *iface)
76 WebBrowser *This = CLIENTSITE_THIS(iface);
77 return IWebBrowser2_Release(WEBBROWSER(This));
80 static HRESULT WINAPI ClientSite_SaveObject(IOleClientSite *iface)
82 WebBrowser *This = CLIENTSITE_THIS(iface);
83 FIXME("(%p)\n", This);
87 static HRESULT WINAPI ClientSite_GetMoniker(IOleClientSite *iface, DWORD dwAssign,
88 DWORD dwWhichMoniker, IMoniker **ppmk)
90 WebBrowser *This = CLIENTSITE_THIS(iface);
91 FIXME("(%p)->(%ld %ld %p)\n", This, dwAssign, dwWhichMoniker, ppmk);
95 static HRESULT WINAPI ClientSite_GetContainer(IOleClientSite *iface, IOleContainer **ppContainer)
97 WebBrowser *This = CLIENTSITE_THIS(iface);
98 FIXME("(%p)->(%p)\n", This, ppContainer);
102 static HRESULT WINAPI ClientSite_ShowObject(IOleClientSite *iface)
104 WebBrowser *This = CLIENTSITE_THIS(iface);
105 FIXME("(%p)\n", This);
109 static HRESULT WINAPI ClientSite_OnShowWindow(IOleClientSite *iface, BOOL fShow)
111 WebBrowser *This = CLIENTSITE_THIS(iface);
112 FIXME("(%p)->(%x)\n", This, fShow);
116 static HRESULT WINAPI ClientSite_RequestNewObjectLayout(IOleClientSite *iface)
118 WebBrowser *This = CLIENTSITE_THIS(iface);
119 FIXME("(%p)\n", This);
123 #undef CLIENTSITE_THIS
125 static const IOleClientSiteVtbl OleClientSiteVtbl = {
126 ClientSite_QueryInterface,
129 ClientSite_SaveObject,
130 ClientSite_GetMoniker,
131 ClientSite_GetContainer,
132 ClientSite_ShowObject,
133 ClientSite_OnShowWindow,
134 ClientSite_RequestNewObjectLayout
137 #define INPLACESITE_THIS(iface) DEFINE_THIS(WebBrowser, OleInPlaceSite, iface)
139 static HRESULT WINAPI InPlaceSite_QueryInterface(IOleInPlaceSite *iface, REFIID riid, void **ppv)
141 WebBrowser *This = INPLACESITE_THIS(iface);
142 return IOleClientSite_QueryInterface(CLIENTSITE(This), riid, ppv);
145 static ULONG WINAPI InPlaceSite_AddRef(IOleInPlaceSite *iface)
147 WebBrowser *This = INPLACESITE_THIS(iface);
148 return IOleClientSite_AddRef(CLIENTSITE(This));
151 static ULONG WINAPI InPlaceSite_Release(IOleInPlaceSite *iface)
153 WebBrowser *This = INPLACESITE_THIS(iface);
154 return IOleClientSite_Release(CLIENTSITE(This));
157 static HRESULT WINAPI InPlaceSite_GetWindow(IOleInPlaceSite *iface, HWND *phwnd)
159 WebBrowser *This = INPLACESITE_THIS(iface);
161 TRACE("(%p)->(%p)\n", This, phwnd);
163 *phwnd = This->doc_view_hwnd;
167 static HRESULT WINAPI InPlaceSite_ContextSensitiveHelp(IOleInPlaceSite *iface, BOOL fEnterMode)
169 WebBrowser *This = INPLACESITE_THIS(iface);
170 FIXME("(%p)->(%x)\n", This, fEnterMode);
174 static HRESULT WINAPI InPlaceSite_CanInPlaceActivate(IOleInPlaceSite *iface)
176 WebBrowser *This = INPLACESITE_THIS(iface);
178 TRACE("(%p)\n", This);
180 /* Nothing to do here */
184 static HRESULT WINAPI InPlaceSite_OnInPlaceActivate(IOleInPlaceSite *iface)
186 WebBrowser *This = INPLACESITE_THIS(iface);
188 TRACE("(%p)\n", This);
190 /* Nothing to do here */
194 static HRESULT WINAPI InPlaceSite_OnUIActivate(IOleInPlaceSite *iface)
196 WebBrowser *This = INPLACESITE_THIS(iface);
197 FIXME("(%p)\n", This);
201 static HRESULT WINAPI InPlaceSite_GetWindowContext(IOleInPlaceSite *iface,
202 IOleInPlaceFrame **ppFrame, IOleInPlaceUIWindow **ppDoc, LPRECT lprcPosRect,
203 LPRECT lprcClipRect, LPOLEINPLACEFRAMEINFO lpFrameInfo)
205 WebBrowser *This = INPLACESITE_THIS(iface);
207 TRACE("(%p)->(%p %p %p %p %p)\n", This, ppFrame, ppDoc, lprcPosRect,
208 lprcClipRect, lpFrameInfo);
210 IOleInPlaceFrame_AddRef(INPLACEFRAME(This));
211 *ppFrame = INPLACEFRAME(This);
214 GetClientRect(This->doc_view_hwnd, lprcPosRect);
215 memcpy(lprcClipRect, lprcPosRect, sizeof(RECT));
217 lpFrameInfo->cb = sizeof(*lpFrameInfo);
218 lpFrameInfo->fMDIApp = FALSE;
219 lpFrameInfo->hwndFrame = This->shell_embedding_hwnd;
220 lpFrameInfo->haccel = NULL;
221 lpFrameInfo->cAccelEntries = 0; /* FIXME: should be 5 */
226 static HRESULT WINAPI InPlaceSite_Scroll(IOleInPlaceSite *iface, SIZE scrollExtent)
228 WebBrowser *This = INPLACESITE_THIS(iface);
229 FIXME("(%p)->({%ld %ld})\n", This, scrollExtent.cx, scrollExtent.cy);
233 static HRESULT WINAPI InPlaceSite_OnUIDeactivate(IOleInPlaceSite *iface, BOOL fUndoable)
235 WebBrowser *This = INPLACESITE_THIS(iface);
236 FIXME("(%p)->(%x)\n", This, fUndoable);
240 static HRESULT WINAPI InPlaceSite_OnInPlaceDeactivate(IOleInPlaceSite *iface)
242 WebBrowser *This = INPLACESITE_THIS(iface);
243 FIXME("(%p)\n", This);
247 static HRESULT WINAPI InPlaceSite_DiscardUndoState(IOleInPlaceSite *iface)
249 WebBrowser *This = INPLACESITE_THIS(iface);
250 FIXME("(%p)\n", This);
254 static HRESULT WINAPI InPlaceSite_DeactivateAndUndo(IOleInPlaceSite *iface)
256 WebBrowser *This = INPLACESITE_THIS(iface);
257 FIXME("(%p)\n", This);
261 static HRESULT WINAPI InPlaceSite_OnPosRectChange(IOleInPlaceSite *iface,
264 WebBrowser *This = INPLACESITE_THIS(iface);
265 FIXME("(%p)->(%p)\n", This, lprcPosRect);
269 #undef INPLACESITE_THIS
271 static const IOleInPlaceSiteVtbl OleInPlaceSiteVtbl = {
272 InPlaceSite_QueryInterface,
275 InPlaceSite_GetWindow,
276 InPlaceSite_ContextSensitiveHelp,
277 InPlaceSite_CanInPlaceActivate,
278 InPlaceSite_OnInPlaceActivate,
279 InPlaceSite_OnUIActivate,
280 InPlaceSite_GetWindowContext,
282 InPlaceSite_OnUIDeactivate,
283 InPlaceSite_OnInPlaceDeactivate,
284 InPlaceSite_DiscardUndoState,
285 InPlaceSite_DeactivateAndUndo,
286 InPlaceSite_OnPosRectChange
289 #define DOCSITE_THIS(iface) DEFINE_THIS(WebBrowser, OleDocumentSite, iface)
291 static HRESULT WINAPI OleDocumentSite_QueryInterface(IOleDocumentSite *iface,
292 REFIID riid, void **ppv)
294 WebBrowser *This = DOCSITE_THIS(iface);
295 return IOleClientSite_QueryInterface(CLIENTSITE(This), riid, ppv);
298 static ULONG WINAPI OleDocumentSite_AddRef(IOleDocumentSite *iface)
300 WebBrowser *This = DOCSITE_THIS(iface);
301 return IOleClientSite_AddRef(CLIENTSITE(This));
304 static ULONG WINAPI OleDocumentSite_Release(IOleDocumentSite *iface)
306 WebBrowser *This = DOCSITE_THIS(iface);
307 return IOleClientSite_Release(CLIENTSITE(This));
310 static HRESULT WINAPI OleDocumentSite_ActivateMe(IOleDocumentSite *iface,
311 IOleDocumentView *pViewToActivate)
313 WebBrowser *This = DOCSITE_THIS(iface);
314 IOleDocument *oledoc;
318 TRACE("(%p)->(%p)\n", This, pViewToActivate);
320 hres = IUnknown_QueryInterface(This->document, &IID_IOleDocument, (void**)&oledoc);
324 IOleDocument_CreateView(oledoc, INPLACESITE(This), NULL, 0, &This->view);
325 IOleDocument_Release(oledoc);
327 GetClientRect(This->doc_view_hwnd, &rect);
328 IOleDocumentView_SetRect(This->view, &rect);
330 hres = IOleDocumentView_Show(This->view, TRUE);
337 static const IOleDocumentSiteVtbl OleDocumentSiteVtbl = {
338 OleDocumentSite_QueryInterface,
339 OleDocumentSite_AddRef,
340 OleDocumentSite_Release,
341 OleDocumentSite_ActivateMe
344 void WebBrowser_ClientSite_Init(WebBrowser *This)
346 This->lpOleClientSiteVtbl = &OleClientSiteVtbl;
347 This->lpOleInPlaceSiteVtbl = &OleInPlaceSiteVtbl;
348 This->lpOleDocumentSiteVtbl = &OleDocumentSiteVtbl;
353 void WebBrowser_ClientSite_Destroy(WebBrowser *This)
356 IOleDocumentView_Release(This->view);