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
);
56 }else if(IsEqualGUID(&IID_IDispatch
, riid
)) {
57 TRACE("(%p)->(IID_IDispatch %p)\n", This
, ppv
);
59 }else if(IsEqualGUID(&IID_IServiceProvider
, riid
)) {
60 TRACE("(%p)->(IID_IServiceProvider %p)\n", This
, ppv
);
61 *ppv
= CLSERVPROV(This
);
65 IWebBrowser2_AddRef(WEBBROWSER(This
));
69 WARN("Unsupported intrface %s\n", debugstr_guid(riid
));
74 static ULONG WINAPI
ClientSite_AddRef(IOleClientSite
*iface
)
76 WebBrowser
*This
= CLIENTSITE_THIS(iface
);
77 return IWebBrowser2_AddRef(WEBBROWSER(This
));
80 static ULONG WINAPI
ClientSite_Release(IOleClientSite
*iface
)
82 WebBrowser
*This
= CLIENTSITE_THIS(iface
);
83 return IWebBrowser2_Release(WEBBROWSER(This
));
86 static HRESULT WINAPI
ClientSite_SaveObject(IOleClientSite
*iface
)
88 WebBrowser
*This
= CLIENTSITE_THIS(iface
);
89 FIXME("(%p)\n", This
);
93 static HRESULT WINAPI
ClientSite_GetMoniker(IOleClientSite
*iface
, DWORD dwAssign
,
94 DWORD dwWhichMoniker
, IMoniker
**ppmk
)
96 WebBrowser
*This
= CLIENTSITE_THIS(iface
);
97 FIXME("(%p)->(%ld %ld %p)\n", This
, dwAssign
, dwWhichMoniker
, ppmk
);
101 static HRESULT WINAPI
ClientSite_GetContainer(IOleClientSite
*iface
, IOleContainer
**ppContainer
)
103 WebBrowser
*This
= CLIENTSITE_THIS(iface
);
104 FIXME("(%p)->(%p)\n", This
, ppContainer
);
108 static HRESULT WINAPI
ClientSite_ShowObject(IOleClientSite
*iface
)
110 WebBrowser
*This
= CLIENTSITE_THIS(iface
);
111 FIXME("(%p)\n", This
);
115 static HRESULT WINAPI
ClientSite_OnShowWindow(IOleClientSite
*iface
, BOOL fShow
)
117 WebBrowser
*This
= CLIENTSITE_THIS(iface
);
118 FIXME("(%p)->(%x)\n", This
, fShow
);
122 static HRESULT WINAPI
ClientSite_RequestNewObjectLayout(IOleClientSite
*iface
)
124 WebBrowser
*This
= CLIENTSITE_THIS(iface
);
125 FIXME("(%p)\n", This
);
129 #undef CLIENTSITE_THIS
131 static const IOleClientSiteVtbl OleClientSiteVtbl
= {
132 ClientSite_QueryInterface
,
135 ClientSite_SaveObject
,
136 ClientSite_GetMoniker
,
137 ClientSite_GetContainer
,
138 ClientSite_ShowObject
,
139 ClientSite_OnShowWindow
,
140 ClientSite_RequestNewObjectLayout
143 #define INPLACESITE_THIS(iface) DEFINE_THIS(WebBrowser, OleInPlaceSite, iface)
145 static HRESULT WINAPI
InPlaceSite_QueryInterface(IOleInPlaceSite
*iface
, REFIID riid
, void **ppv
)
147 WebBrowser
*This
= INPLACESITE_THIS(iface
);
148 return IOleClientSite_QueryInterface(CLIENTSITE(This
), riid
, ppv
);
151 static ULONG WINAPI
InPlaceSite_AddRef(IOleInPlaceSite
*iface
)
153 WebBrowser
*This
= INPLACESITE_THIS(iface
);
154 return IOleClientSite_AddRef(CLIENTSITE(This
));
157 static ULONG WINAPI
InPlaceSite_Release(IOleInPlaceSite
*iface
)
159 WebBrowser
*This
= INPLACESITE_THIS(iface
);
160 return IOleClientSite_Release(CLIENTSITE(This
));
163 static HRESULT WINAPI
InPlaceSite_GetWindow(IOleInPlaceSite
*iface
, HWND
*phwnd
)
165 WebBrowser
*This
= INPLACESITE_THIS(iface
);
167 TRACE("(%p)->(%p)\n", This
, phwnd
);
169 *phwnd
= This
->doc_view_hwnd
;
173 static HRESULT WINAPI
InPlaceSite_ContextSensitiveHelp(IOleInPlaceSite
*iface
, BOOL fEnterMode
)
175 WebBrowser
*This
= INPLACESITE_THIS(iface
);
176 FIXME("(%p)->(%x)\n", This
, fEnterMode
);
180 static HRESULT WINAPI
InPlaceSite_CanInPlaceActivate(IOleInPlaceSite
*iface
)
182 WebBrowser
*This
= INPLACESITE_THIS(iface
);
184 TRACE("(%p)\n", This
);
186 /* Nothing to do here */
190 static HRESULT WINAPI
InPlaceSite_OnInPlaceActivate(IOleInPlaceSite
*iface
)
192 WebBrowser
*This
= INPLACESITE_THIS(iface
);
194 TRACE("(%p)\n", This
);
196 /* Nothing to do here */
200 static HRESULT WINAPI
InPlaceSite_OnUIActivate(IOleInPlaceSite
*iface
)
202 WebBrowser
*This
= INPLACESITE_THIS(iface
);
203 FIXME("(%p)\n", This
);
207 static HRESULT WINAPI
InPlaceSite_GetWindowContext(IOleInPlaceSite
*iface
,
208 IOleInPlaceFrame
**ppFrame
, IOleInPlaceUIWindow
**ppDoc
, LPRECT lprcPosRect
,
209 LPRECT lprcClipRect
, LPOLEINPLACEFRAMEINFO lpFrameInfo
)
211 WebBrowser
*This
= INPLACESITE_THIS(iface
);
213 TRACE("(%p)->(%p %p %p %p %p)\n", This
, ppFrame
, ppDoc
, lprcPosRect
,
214 lprcClipRect
, lpFrameInfo
);
216 IOleInPlaceFrame_AddRef(INPLACEFRAME(This
));
217 *ppFrame
= INPLACEFRAME(This
);
220 GetClientRect(This
->doc_view_hwnd
, lprcPosRect
);
221 memcpy(lprcClipRect
, lprcPosRect
, sizeof(RECT
));
223 lpFrameInfo
->cb
= sizeof(*lpFrameInfo
);
224 lpFrameInfo
->fMDIApp
= FALSE
;
225 lpFrameInfo
->hwndFrame
= This
->shell_embedding_hwnd
;
226 lpFrameInfo
->haccel
= NULL
;
227 lpFrameInfo
->cAccelEntries
= 0; /* FIXME: should be 5 */
232 static HRESULT WINAPI
InPlaceSite_Scroll(IOleInPlaceSite
*iface
, SIZE scrollExtent
)
234 WebBrowser
*This
= INPLACESITE_THIS(iface
);
235 FIXME("(%p)->({%ld %ld})\n", This
, scrollExtent
.cx
, scrollExtent
.cy
);
239 static HRESULT WINAPI
InPlaceSite_OnUIDeactivate(IOleInPlaceSite
*iface
, BOOL fUndoable
)
241 WebBrowser
*This
= INPLACESITE_THIS(iface
);
242 FIXME("(%p)->(%x)\n", This
, fUndoable
);
246 static HRESULT WINAPI
InPlaceSite_OnInPlaceDeactivate(IOleInPlaceSite
*iface
)
248 WebBrowser
*This
= INPLACESITE_THIS(iface
);
249 FIXME("(%p)\n", This
);
253 static HRESULT WINAPI
InPlaceSite_DiscardUndoState(IOleInPlaceSite
*iface
)
255 WebBrowser
*This
= INPLACESITE_THIS(iface
);
256 FIXME("(%p)\n", This
);
260 static HRESULT WINAPI
InPlaceSite_DeactivateAndUndo(IOleInPlaceSite
*iface
)
262 WebBrowser
*This
= INPLACESITE_THIS(iface
);
263 FIXME("(%p)\n", This
);
267 static HRESULT WINAPI
InPlaceSite_OnPosRectChange(IOleInPlaceSite
*iface
,
270 WebBrowser
*This
= INPLACESITE_THIS(iface
);
271 FIXME("(%p)->(%p)\n", This
, lprcPosRect
);
275 #undef INPLACESITE_THIS
277 static const IOleInPlaceSiteVtbl OleInPlaceSiteVtbl
= {
278 InPlaceSite_QueryInterface
,
281 InPlaceSite_GetWindow
,
282 InPlaceSite_ContextSensitiveHelp
,
283 InPlaceSite_CanInPlaceActivate
,
284 InPlaceSite_OnInPlaceActivate
,
285 InPlaceSite_OnUIActivate
,
286 InPlaceSite_GetWindowContext
,
288 InPlaceSite_OnUIDeactivate
,
289 InPlaceSite_OnInPlaceDeactivate
,
290 InPlaceSite_DiscardUndoState
,
291 InPlaceSite_DeactivateAndUndo
,
292 InPlaceSite_OnPosRectChange
295 #define DOCSITE_THIS(iface) DEFINE_THIS(WebBrowser, OleDocumentSite, iface)
297 static HRESULT WINAPI
OleDocumentSite_QueryInterface(IOleDocumentSite
*iface
,
298 REFIID riid
, void **ppv
)
300 WebBrowser
*This
= DOCSITE_THIS(iface
);
301 return IOleClientSite_QueryInterface(CLIENTSITE(This
), riid
, ppv
);
304 static ULONG WINAPI
OleDocumentSite_AddRef(IOleDocumentSite
*iface
)
306 WebBrowser
*This
= DOCSITE_THIS(iface
);
307 return IOleClientSite_AddRef(CLIENTSITE(This
));
310 static ULONG WINAPI
OleDocumentSite_Release(IOleDocumentSite
*iface
)
312 WebBrowser
*This
= DOCSITE_THIS(iface
);
313 return IOleClientSite_Release(CLIENTSITE(This
));
316 static HRESULT WINAPI
OleDocumentSite_ActivateMe(IOleDocumentSite
*iface
,
317 IOleDocumentView
*pViewToActivate
)
319 WebBrowser
*This
= DOCSITE_THIS(iface
);
320 IOleDocument
*oledoc
;
324 TRACE("(%p)->(%p)\n", This
, pViewToActivate
);
326 hres
= IUnknown_QueryInterface(This
->document
, &IID_IOleDocument
, (void**)&oledoc
);
330 IOleDocument_CreateView(oledoc
, INPLACESITE(This
), NULL
, 0, &This
->view
);
331 IOleDocument_Release(oledoc
);
333 GetClientRect(This
->doc_view_hwnd
, &rect
);
334 IOleDocumentView_SetRect(This
->view
, &rect
);
336 hres
= IOleDocumentView_Show(This
->view
, TRUE
);
343 static const IOleDocumentSiteVtbl OleDocumentSiteVtbl
= {
344 OleDocumentSite_QueryInterface
,
345 OleDocumentSite_AddRef
,
346 OleDocumentSite_Release
,
347 OleDocumentSite_ActivateMe
350 #define DISP_THIS(iface) DEFINE_THIS(WebBrowser, Dispatch, iface)
352 static HRESULT WINAPI
ClDispatch_QueryInterface(IDispatch
*iface
, REFIID riid
, void **ppv
)
354 WebBrowser
*This
= DISP_THIS(iface
);
355 return IOleClientSite_QueryInterface(CLIENTSITE(This
), riid
, ppv
);
358 static ULONG WINAPI
ClDispatch_AddRef(IDispatch
*iface
)
360 WebBrowser
*This
= DISP_THIS(iface
);
361 return IWebBrowser2_AddRef(WEBBROWSER(This
));
364 static ULONG WINAPI
ClDispatch_Release(IDispatch
*iface
)
366 WebBrowser
*This
= DISP_THIS(iface
);
367 return IWebBrowser2_Release(WEBBROWSER(This
));
370 static HRESULT WINAPI
ClDispatch_GetTypeInfoCount(IDispatch
*iface
, UINT
*pctinfo
)
372 WebBrowser
*This
= DISP_THIS(iface
);
374 TRACE("(%p)->(%p)\n", This
, pctinfo
);
379 static HRESULT WINAPI
ClDispatch_GetTypeInfo(IDispatch
*iface
, UINT iTInfo
, LCID lcid
,
382 WebBrowser
*This
= DISP_THIS(iface
);
384 TRACE("(%p)->(%u %ld %p)\n", This
, iTInfo
, lcid
, ppTInfo
);
389 static HRESULT WINAPI
ClDispatch_GetIDsOfNames(IDispatch
*iface
, REFIID riid
, LPOLESTR
*rgszNames
,
390 UINT cNames
, LCID lcid
, DISPID
*rgDispId
)
392 WebBrowser
*This
= DISP_THIS(iface
);
394 TRACE("(%p)->(%s %p %u %ld %p)\n", This
, debugstr_guid(riid
), rgszNames
, cNames
,
400 static HRESULT WINAPI
ClDispatch_Invoke(IDispatch
*iface
, DISPID dispIdMember
, REFIID riid
,
401 LCID lcid
, WORD wFlags
, DISPPARAMS
*pDispParams
,
402 VARIANT
*pVarResult
, EXCEPINFO
*pExcepInfo
, UINT
*puArgErr
)
404 WebBrowser
*This
= DISP_THIS(iface
);
405 FIXME("(%p)->(%ld %s %ld %04x %p %p %p %p)\n", This
, dispIdMember
, debugstr_guid(riid
),
406 lcid
, wFlags
, pDispParams
, pVarResult
, pExcepInfo
, puArgErr
);
412 static const IDispatchVtbl DispatchVtbl
= {
413 ClDispatch_QueryInterface
,
416 ClDispatch_GetTypeInfoCount
,
417 ClDispatch_GetTypeInfo
,
418 ClDispatch_GetIDsOfNames
,
422 #define SERVPROV_THIS(iface) DEFINE_THIS(WebBrowser, ClServiceProvider, iface)
424 static HRESULT WINAPI
ClServiceProvider_QueryInterface(IServiceProvider
*iface
, REFIID riid
,
427 WebBrowser
*This
= SERVPROV_THIS(iface
);
428 return IOleClientSite_QueryInterface(CLIENTSITE(This
), riid
, ppv
);
431 static ULONG WINAPI
ClServiceProvider_AddRef(IServiceProvider
*iface
)
433 WebBrowser
*This
= SERVPROV_THIS(iface
);
434 return IWebBrowser2_AddRef(WEBBROWSER2(This
));
437 static ULONG WINAPI
ClServiceProvider_Release(IServiceProvider
*iface
)
439 WebBrowser
*This
= SERVPROV_THIS(iface
);
440 return IWebBrowser2_Release(WEBBROWSER2(This
));
443 static HRESULT WINAPI
ClServiceProvider_QueryService(IServiceProvider
*iface
, REFGUID guidService
,
444 REFIID riid
, void **ppv
)
446 WebBrowser
*This
= SERVPROV_THIS(iface
);
448 if(IsEqualGUID(&IID_IHlinkFrame
, guidService
)) {
449 TRACE("(%p)->(IID_IHlinkFrame %s %p)\n", This
, debugstr_guid(riid
), ppv
);
450 return IWebBrowser2_QueryInterface(WEBBROWSER(This
), riid
, ppv
);
453 FIXME("(%p)->(%s %s %p)\n", This
, debugstr_guid(guidService
), debugstr_guid(riid
), ppv
);
455 return E_NOINTERFACE
;
460 static const IServiceProviderVtbl ServiceProviderVtbl
= {
461 ClServiceProvider_QueryInterface
,
462 ClServiceProvider_AddRef
,
463 ClServiceProvider_Release
,
464 ClServiceProvider_QueryService
467 void WebBrowser_ClientSite_Init(WebBrowser
*This
)
469 This
->lpOleClientSiteVtbl
= &OleClientSiteVtbl
;
470 This
->lpOleInPlaceSiteVtbl
= &OleInPlaceSiteVtbl
;
471 This
->lpOleDocumentSiteVtbl
= &OleDocumentSiteVtbl
;
472 This
->lpDispatchVtbl
= &DispatchVtbl
;
473 This
->lpClServiceProviderVtbl
= &ServiceProviderVtbl
;
478 void WebBrowser_ClientSite_Destroy(WebBrowser
*This
)
481 IOleDocumentView_Release(This
->view
);