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);
53 IWebBrowser2_AddRef(WEBBROWSER(This));
57 WARN("Unsupported intrface %s\n", debugstr_guid(riid));
62 static ULONG WINAPI ClientSite_AddRef(IOleClientSite *iface)
64 WebBrowser *This = CLIENTSITE_THIS(iface);
65 return IWebBrowser2_AddRef(WEBBROWSER(This));
68 static ULONG WINAPI ClientSite_Release(IOleClientSite *iface)
70 WebBrowser *This = CLIENTSITE_THIS(iface);
71 return IWebBrowser2_Release(WEBBROWSER(This));
74 static HRESULT WINAPI ClientSite_SaveObject(IOleClientSite *iface)
76 WebBrowser *This = CLIENTSITE_THIS(iface);
77 FIXME("(%p)\n", This);
81 static HRESULT WINAPI ClientSite_GetMoniker(IOleClientSite *iface, DWORD dwAssign,
82 DWORD dwWhichMoniker, IMoniker **ppmk)
84 WebBrowser *This = CLIENTSITE_THIS(iface);
85 FIXME("(%p)->(%ld %ld %p)\n", This, dwAssign, dwWhichMoniker, ppmk);
89 static HRESULT WINAPI ClientSite_GetContainer(IOleClientSite *iface, IOleContainer **ppContainer)
91 WebBrowser *This = CLIENTSITE_THIS(iface);
92 FIXME("(%p)->(%p)\n", This, ppContainer);
96 static HRESULT WINAPI ClientSite_ShowObject(IOleClientSite *iface)
98 WebBrowser *This = CLIENTSITE_THIS(iface);
99 FIXME("(%p)\n", This);
103 static HRESULT WINAPI ClientSite_OnShowWindow(IOleClientSite *iface, BOOL fShow)
105 WebBrowser *This = CLIENTSITE_THIS(iface);
106 FIXME("(%p)->(%x)\n", This, fShow);
110 static HRESULT WINAPI ClientSite_RequestNewObjectLayout(IOleClientSite *iface)
112 WebBrowser *This = CLIENTSITE_THIS(iface);
113 FIXME("(%p)\n", This);
117 #undef CLIENTSITE_THIS
119 static const IOleClientSiteVtbl OleClientSiteVtbl = {
120 ClientSite_QueryInterface,
123 ClientSite_SaveObject,
124 ClientSite_GetMoniker,
125 ClientSite_GetContainer,
126 ClientSite_ShowObject,
127 ClientSite_OnShowWindow,
128 ClientSite_RequestNewObjectLayout
131 #define INPLACESITE_THIS(iface) DEFINE_THIS(WebBrowser, OleInPlaceSite, iface)
133 static HRESULT WINAPI InPlaceSite_QueryInterface(IOleInPlaceSite *iface, REFIID riid, void **ppv)
135 WebBrowser *This = INPLACESITE_THIS(iface);
136 return IOleClientSite_QueryInterface(CLIENTSITE(This), riid, ppv);
139 static ULONG WINAPI InPlaceSite_AddRef(IOleInPlaceSite *iface)
141 WebBrowser *This = INPLACESITE_THIS(iface);
142 return IOleClientSite_AddRef(CLIENTSITE(This));
145 static ULONG WINAPI InPlaceSite_Release(IOleInPlaceSite *iface)
147 WebBrowser *This = INPLACESITE_THIS(iface);
148 return IOleClientSite_Release(CLIENTSITE(This));
151 static HRESULT WINAPI InPlaceSite_GetWindow(IOleInPlaceSite *iface, HWND *phwnd)
153 WebBrowser *This = INPLACESITE_THIS(iface);
155 TRACE("(%p)->(%p)\n", This, phwnd);
157 *phwnd = This->doc_view_hwnd;
161 static HRESULT WINAPI InPlaceSite_ContextSensitiveHelp(IOleInPlaceSite *iface, BOOL fEnterMode)
163 WebBrowser *This = INPLACESITE_THIS(iface);
164 FIXME("(%p)->(%x)\n", This, fEnterMode);
168 static HRESULT WINAPI InPlaceSite_CanInPlaceActivate(IOleInPlaceSite *iface)
170 WebBrowser *This = INPLACESITE_THIS(iface);
171 FIXME("(%p)\n", This);
175 static HRESULT WINAPI InPlaceSite_OnInPlaceActivate(IOleInPlaceSite *iface)
177 WebBrowser *This = INPLACESITE_THIS(iface);
178 FIXME("(%p)\n", This);
182 static HRESULT WINAPI InPlaceSite_OnUIActivate(IOleInPlaceSite *iface)
184 WebBrowser *This = INPLACESITE_THIS(iface);
185 FIXME("(%p)\n", This);
189 static HRESULT WINAPI InPlaceSite_GetWindowContext(IOleInPlaceSite *iface,
190 IOleInPlaceFrame **ppFrame, IOleInPlaceUIWindow **ppDoc, LPRECT lprcPosRect,
191 LPRECT lprcClipRect, LPOLEINPLACEFRAMEINFO lpFrameInfo)
193 WebBrowser *This = INPLACESITE_THIS(iface);
195 TRACE("(%p)->(%p %p %p %p %p)\n", This, ppFrame, ppDoc, lprcPosRect,
196 lprcClipRect, lpFrameInfo);
198 *ppFrame = INPLACEFRAME(This);
200 GetClientRect(This->doc_view_hwnd, lprcPosRect);
201 memcpy(lprcClipRect, lprcPosRect, sizeof(RECT));
203 lpFrameInfo->cb = sizeof(*lpFrameInfo);
204 lpFrameInfo->fMDIApp = FALSE;
205 lpFrameInfo->hwndFrame = This->shell_embedding_hwnd;
206 lpFrameInfo->haccel = NULL;
207 lpFrameInfo->cAccelEntries = 0; /* FIXME: should be 5 */
212 static HRESULT WINAPI InPlaceSite_Scroll(IOleInPlaceSite *iface, SIZE scrollExtent)
214 WebBrowser *This = INPLACESITE_THIS(iface);
215 FIXME("(%p)->({%ld %ld})\n", This, scrollExtent.cx, scrollExtent.cy);
219 static HRESULT WINAPI InPlaceSite_OnUIDeactivate(IOleInPlaceSite *iface, BOOL fUndoable)
221 WebBrowser *This = INPLACESITE_THIS(iface);
222 FIXME("(%p)->(%x)\n", This, fUndoable);
226 static HRESULT WINAPI InPlaceSite_OnInPlaceDeactivate(IOleInPlaceSite *iface)
228 WebBrowser *This = INPLACESITE_THIS(iface);
229 FIXME("(%p)\n", This);
233 static HRESULT WINAPI InPlaceSite_DiscardUndoState(IOleInPlaceSite *iface)
235 WebBrowser *This = INPLACESITE_THIS(iface);
236 FIXME("(%p)\n", This);
240 static HRESULT WINAPI InPlaceSite_DeactivateAndUndo(IOleInPlaceSite *iface)
242 WebBrowser *This = INPLACESITE_THIS(iface);
243 FIXME("(%p)\n", This);
247 static HRESULT WINAPI InPlaceSite_OnPosRectChange(IOleInPlaceSite *iface,
250 WebBrowser *This = INPLACESITE_THIS(iface);
251 FIXME("(%p)->(%p)\n", This, lprcPosRect);
255 #undef INPLACESITE_THIS
257 static const IOleInPlaceSiteVtbl OleInPlaceSiteVtbl = {
258 InPlaceSite_QueryInterface,
261 InPlaceSite_GetWindow,
262 InPlaceSite_ContextSensitiveHelp,
263 InPlaceSite_CanInPlaceActivate,
264 InPlaceSite_OnInPlaceActivate,
265 InPlaceSite_OnUIActivate,
266 InPlaceSite_GetWindowContext,
268 InPlaceSite_OnUIDeactivate,
269 InPlaceSite_OnInPlaceDeactivate,
270 InPlaceSite_DiscardUndoState,
271 InPlaceSite_DeactivateAndUndo,
272 InPlaceSite_OnPosRectChange
275 #define DOCSITE_THIS(iface) DEFINE_THIS(WebBrowser, OleDocumentSite, iface)
277 static HRESULT WINAPI OleDocumentSite_QueryInterface(IOleDocumentSite *iface,
278 REFIID riid, void **ppv)
280 WebBrowser *This = DOCSITE_THIS(iface);
281 return IOleClientSite_QueryInterface(CLIENTSITE(This), riid, ppv);
284 static ULONG WINAPI OleDocumentSite_AddRef(IOleDocumentSite *iface)
286 WebBrowser *This = DOCSITE_THIS(iface);
287 return IOleClientSite_AddRef(CLIENTSITE(This));
290 static ULONG WINAPI OleDocumentSite_Release(IOleDocumentSite *iface)
292 WebBrowser *This = DOCSITE_THIS(iface);
293 return IOleClientSite_Release(CLIENTSITE(This));
296 static HRESULT WINAPI OleDocumentSite_ActivateMe(IOleDocumentSite *iface,
297 IOleDocumentView *pViewToActivate)
299 WebBrowser *This = DOCSITE_THIS(iface);
300 IOleDocument *oledoc;
304 TRACE("(%p)->(%p)\n", This, pViewToActivate);
306 hres = IUnknown_QueryInterface(This->document, &IID_IOleDocument, (void**)&oledoc);
310 IOleDocument_CreateView(oledoc, INPLACESITE(This), NULL, 0, &This->view);
311 IOleDocument_Release(oledoc);
313 GetClientRect(This->doc_view_hwnd, &rect);
314 IOleDocumentView_SetRect(This->view, &rect);
316 hres = IOleDocumentView_Show(This->view, TRUE);
323 static const IOleDocumentSiteVtbl OleDocumentSiteVtbl = {
324 OleDocumentSite_QueryInterface,
325 OleDocumentSite_AddRef,
326 OleDocumentSite_Release,
327 OleDocumentSite_ActivateMe
330 void WebBrowser_ClientSite_Init(WebBrowser *This)
332 This->lpOleClientSiteVtbl = &OleClientSiteVtbl;
333 This->lpOleInPlaceSiteVtbl = &OleInPlaceSiteVtbl;
334 This->lpOleDocumentSiteVtbl = &OleDocumentSiteVtbl;
339 void WebBrowser_ClientSite_Destroy(WebBrowser *This)
342 IOleDocumentView_Release(This->view);