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., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
21 #include "wine/debug.h"
26 WINE_DEFAULT_DEBUG_CHANNEL(shdocvw);
28 static inline DocHost *impl_from_IOleClientSite(IOleClientSite *iface)
30 return CONTAINING_RECORD(iface, DocHost, IOleClientSite_iface);
33 static HRESULT WINAPI ClientSite_QueryInterface(IOleClientSite *iface, REFIID riid, void **ppv)
35 DocHost *This = impl_from_IOleClientSite(iface);
37 if(IsEqualGUID(&IID_IUnknown, riid)) {
38 TRACE("(%p)->(IID_IUnknown %p)\n", This, ppv);
39 *ppv = &This->IOleClientSite_iface;
40 }else if(IsEqualGUID(&IID_IOleClientSite, riid)) {
41 TRACE("(%p)->(IID_IOleClientSite %p)\n", This, ppv);
42 *ppv = &This->IOleClientSite_iface;
43 }else if(IsEqualGUID(&IID_IOleWindow, riid)) {
44 TRACE("(%p)->(IID_IOleWindow %p)\n", This, ppv);
45 *ppv = &This->IOleInPlaceSite_iface;
46 }else if(IsEqualGUID(&IID_IOleInPlaceSite, riid)) {
47 TRACE("(%p)->(IID_IOleInPlaceSite %p)\n", This, ppv);
48 *ppv = &This->IOleInPlaceSite_iface;
49 }else if(IsEqualGUID(&IID_IDocHostUIHandler, riid)) {
50 TRACE("(%p)->(IID_IDocHostUIHandler %p)\n", This, ppv);
51 *ppv = &This->IDocHostUIHandler2_iface;
52 }else if(IsEqualGUID(&IID_IDocHostUIHandler2, riid)) {
53 TRACE("(%p)->(IID_IDocHostUIHandler2 %p)\n", This, ppv);
54 *ppv = &This->IDocHostUIHandler2_iface;
55 }else if(IsEqualGUID(&IID_IOleDocumentSite, riid)) {
56 TRACE("(%p)->(IID_IOleDocumentSite %p)\n", This, ppv);
57 *ppv = &This->IOleDocumentSite_iface;
58 }else if(IsEqualGUID(&IID_IOleControlSite, riid)) {
59 TRACE("(%p)->(IID_IOleControlSite %p)\n", This, ppv);
60 *ppv = &This->IOleControlSite_iface;
61 }else if(IsEqualGUID(&IID_IOleCommandTarget, riid)) {
62 TRACE("(%p)->(IID_IOleCommandTarget %p)\n", This, ppv);
63 *ppv = &This->IOleCommandTarget_iface;
64 }else if(IsEqualGUID(&IID_IDispatch, riid)) {
65 TRACE("(%p)->(IID_IDispatch %p)\n", This, ppv);
66 *ppv = &This->IDispatch_iface;
67 }else if(IsEqualGUID(&IID_IPropertyNotifySink, riid)) {
68 TRACE("(%p)->(IID_IPropertyNotifySink %p)\n", This, ppv);
69 *ppv = &This->IPropertyNotifySink_iface;
70 }else if(IsEqualGUID(&IID_IServiceProvider, riid)) {
71 TRACE("(%p)->(IID_IServiceProvider %p)\n", This, ppv);
72 *ppv = &This->IServiceProvider_iface;
75 WARN("Unsupported interface %s\n", debugstr_guid(riid));
79 IOleClientSite_AddRef((IUnknown*)*ppv);
83 static ULONG WINAPI ClientSite_AddRef(IOleClientSite *iface)
85 DocHost *This = impl_from_IOleClientSite(iface);
86 return This->container_vtbl->addref(This);
89 static ULONG WINAPI ClientSite_Release(IOleClientSite *iface)
91 DocHost *This = impl_from_IOleClientSite(iface);
92 return This->container_vtbl->release(This);
95 static HRESULT WINAPI ClientSite_SaveObject(IOleClientSite *iface)
97 DocHost *This = impl_from_IOleClientSite(iface);
98 FIXME("(%p)\n", This);
102 static HRESULT WINAPI ClientSite_GetMoniker(IOleClientSite *iface, DWORD dwAssign,
103 DWORD dwWhichMoniker, IMoniker **ppmk)
105 DocHost *This = impl_from_IOleClientSite(iface);
106 FIXME("(%p)->(%d %d %p)\n", This, dwAssign, dwWhichMoniker, ppmk);
110 static HRESULT WINAPI ClientSite_GetContainer(IOleClientSite *iface, IOleContainer **ppContainer)
112 DocHost *This = impl_from_IOleClientSite(iface);
113 FIXME("(%p)->(%p)\n", This, ppContainer);
117 static HRESULT WINAPI ClientSite_ShowObject(IOleClientSite *iface)
119 DocHost *This = impl_from_IOleClientSite(iface);
120 FIXME("(%p)\n", This);
124 static HRESULT WINAPI ClientSite_OnShowWindow(IOleClientSite *iface, BOOL fShow)
126 DocHost *This = impl_from_IOleClientSite(iface);
127 FIXME("(%p)->(%x)\n", This, fShow);
131 static HRESULT WINAPI ClientSite_RequestNewObjectLayout(IOleClientSite *iface)
133 DocHost *This = impl_from_IOleClientSite(iface);
134 FIXME("(%p)\n", This);
138 static const IOleClientSiteVtbl OleClientSiteVtbl = {
139 ClientSite_QueryInterface,
142 ClientSite_SaveObject,
143 ClientSite_GetMoniker,
144 ClientSite_GetContainer,
145 ClientSite_ShowObject,
146 ClientSite_OnShowWindow,
147 ClientSite_RequestNewObjectLayout
150 static inline DocHost *impl_from_IOleInPlaceSite(IOleInPlaceSite *iface)
152 return CONTAINING_RECORD(iface, DocHost, IOleInPlaceSite_iface);
155 static HRESULT WINAPI InPlaceSite_QueryInterface(IOleInPlaceSite *iface, REFIID riid, void **ppv)
157 DocHost *This = impl_from_IOleInPlaceSite(iface);
158 return IOleClientSite_QueryInterface(&This->IOleClientSite_iface, riid, ppv);
161 static ULONG WINAPI InPlaceSite_AddRef(IOleInPlaceSite *iface)
163 DocHost *This = impl_from_IOleInPlaceSite(iface);
164 return IOleClientSite_AddRef(&This->IOleClientSite_iface);
167 static ULONG WINAPI InPlaceSite_Release(IOleInPlaceSite *iface)
169 DocHost *This = impl_from_IOleInPlaceSite(iface);
170 return IOleClientSite_Release(&This->IOleClientSite_iface);
173 static HRESULT WINAPI InPlaceSite_GetWindow(IOleInPlaceSite *iface, HWND *phwnd)
175 DocHost *This = impl_from_IOleInPlaceSite(iface);
177 TRACE("(%p)->(%p)\n", This, phwnd);
183 static HRESULT WINAPI InPlaceSite_ContextSensitiveHelp(IOleInPlaceSite *iface, BOOL fEnterMode)
185 DocHost *This = impl_from_IOleInPlaceSite(iface);
186 FIXME("(%p)->(%x)\n", This, fEnterMode);
190 static HRESULT WINAPI InPlaceSite_CanInPlaceActivate(IOleInPlaceSite *iface)
192 DocHost *This = impl_from_IOleInPlaceSite(iface);
194 TRACE("(%p)\n", This);
196 /* Nothing to do here */
200 static HRESULT WINAPI InPlaceSite_OnInPlaceActivate(IOleInPlaceSite *iface)
202 DocHost *This = impl_from_IOleInPlaceSite(iface);
204 TRACE("(%p)\n", This);
206 /* Nothing to do here */
210 static HRESULT WINAPI InPlaceSite_OnUIActivate(IOleInPlaceSite *iface)
212 DocHost *This = impl_from_IOleInPlaceSite(iface);
213 FIXME("(%p)\n", This);
217 static HRESULT WINAPI InPlaceSite_GetWindowContext(IOleInPlaceSite *iface,
218 IOleInPlaceFrame **ppFrame, IOleInPlaceUIWindow **ppDoc, LPRECT lprcPosRect,
219 LPRECT lprcClipRect, LPOLEINPLACEFRAMEINFO lpFrameInfo)
221 DocHost *This = impl_from_IOleInPlaceSite(iface);
223 TRACE("(%p)->(%p %p %p %p %p)\n", This, ppFrame, ppDoc, lprcPosRect,
224 lprcClipRect, lpFrameInfo);
226 IOleInPlaceFrame_AddRef(&This->IOleInPlaceFrame_iface);
227 *ppFrame = &This->IOleInPlaceFrame_iface;
230 GetClientRect(This->hwnd, lprcPosRect);
231 *lprcClipRect = *lprcPosRect;
233 lpFrameInfo->cb = sizeof(*lpFrameInfo);
234 lpFrameInfo->fMDIApp = FALSE;
235 lpFrameInfo->hwndFrame = This->frame_hwnd;
236 lpFrameInfo->haccel = NULL;
237 lpFrameInfo->cAccelEntries = 0; /* FIXME: should be 5 */
242 static HRESULT WINAPI InPlaceSite_Scroll(IOleInPlaceSite *iface, SIZE scrollExtent)
244 DocHost *This = impl_from_IOleInPlaceSite(iface);
245 FIXME("(%p)->({%d %d})\n", This, scrollExtent.cx, scrollExtent.cy);
249 static HRESULT WINAPI InPlaceSite_OnUIDeactivate(IOleInPlaceSite *iface, BOOL fUndoable)
251 DocHost *This = impl_from_IOleInPlaceSite(iface);
252 FIXME("(%p)->(%x)\n", This, fUndoable);
256 static HRESULT WINAPI InPlaceSite_OnInPlaceDeactivate(IOleInPlaceSite *iface)
258 DocHost *This = impl_from_IOleInPlaceSite(iface);
260 TRACE("(%p)\n", This);
262 /* Nothing to do here */
266 static HRESULT WINAPI InPlaceSite_DiscardUndoState(IOleInPlaceSite *iface)
268 DocHost *This = impl_from_IOleInPlaceSite(iface);
269 FIXME("(%p)\n", This);
273 static HRESULT WINAPI InPlaceSite_DeactivateAndUndo(IOleInPlaceSite *iface)
275 DocHost *This = impl_from_IOleInPlaceSite(iface);
276 FIXME("(%p)\n", This);
280 static HRESULT WINAPI InPlaceSite_OnPosRectChange(IOleInPlaceSite *iface,
283 DocHost *This = impl_from_IOleInPlaceSite(iface);
284 FIXME("(%p)->(%p)\n", This, lprcPosRect);
288 static const IOleInPlaceSiteVtbl OleInPlaceSiteVtbl = {
289 InPlaceSite_QueryInterface,
292 InPlaceSite_GetWindow,
293 InPlaceSite_ContextSensitiveHelp,
294 InPlaceSite_CanInPlaceActivate,
295 InPlaceSite_OnInPlaceActivate,
296 InPlaceSite_OnUIActivate,
297 InPlaceSite_GetWindowContext,
299 InPlaceSite_OnUIDeactivate,
300 InPlaceSite_OnInPlaceDeactivate,
301 InPlaceSite_DiscardUndoState,
302 InPlaceSite_DeactivateAndUndo,
303 InPlaceSite_OnPosRectChange
306 static inline DocHost *impl_from_IOleDocumentSite(IOleDocumentSite *iface)
308 return CONTAINING_RECORD(iface, DocHost, IOleDocumentSite_iface);
311 static HRESULT WINAPI OleDocumentSite_QueryInterface(IOleDocumentSite *iface,
312 REFIID riid, void **ppv)
314 DocHost *This = impl_from_IOleDocumentSite(iface);
315 return IOleClientSite_QueryInterface(&This->IOleClientSite_iface, riid, ppv);
318 static ULONG WINAPI OleDocumentSite_AddRef(IOleDocumentSite *iface)
320 DocHost *This = impl_from_IOleDocumentSite(iface);
321 return IOleClientSite_AddRef(&This->IOleClientSite_iface);
324 static ULONG WINAPI OleDocumentSite_Release(IOleDocumentSite *iface)
326 DocHost *This = impl_from_IOleDocumentSite(iface);
327 return IOleClientSite_Release(&This->IOleClientSite_iface);
330 static HRESULT WINAPI OleDocumentSite_ActivateMe(IOleDocumentSite *iface,
331 IOleDocumentView *pViewToActivate)
333 DocHost *This = impl_from_IOleDocumentSite(iface);
334 IOleDocument *oledoc;
338 TRACE("(%p)->(%p)\n", This, pViewToActivate);
340 hres = IUnknown_QueryInterface(This->document, &IID_IOleDocument, (void**)&oledoc);
344 IOleDocument_CreateView(oledoc, &This->IOleInPlaceSite_iface, NULL, 0, &This->view);
345 IOleDocument_Release(oledoc);
347 GetClientRect(This->hwnd, &rect);
348 IOleDocumentView_SetRect(This->view, &rect);
350 hres = IOleDocumentView_Show(This->view, TRUE);
355 static const IOleDocumentSiteVtbl OleDocumentSiteVtbl = {
356 OleDocumentSite_QueryInterface,
357 OleDocumentSite_AddRef,
358 OleDocumentSite_Release,
359 OleDocumentSite_ActivateMe
362 static inline DocHost *impl_from_IOleControlSite(IOleControlSite *iface)
364 return CONTAINING_RECORD(iface, DocHost, IOleControlSite_iface);
367 static HRESULT WINAPI ControlSite_QueryInterface(IOleControlSite *iface, REFIID riid, void **ppv)
369 DocHost *This = impl_from_IOleControlSite(iface);
370 return IOleClientSite_QueryInterface(&This->IOleClientSite_iface, riid, ppv);
373 static ULONG WINAPI ControlSite_AddRef(IOleControlSite *iface)
375 DocHost *This = impl_from_IOleControlSite(iface);
376 return IOleClientSite_AddRef(&This->IOleClientSite_iface);
379 static ULONG WINAPI ControlSite_Release(IOleControlSite *iface)
381 DocHost *This = impl_from_IOleControlSite(iface);
382 return IOleClientSite_Release(&This->IOleClientSite_iface);
385 static HRESULT WINAPI ControlSite_OnControlInfoChanged(IOleControlSite *iface)
387 DocHost *This = impl_from_IOleControlSite(iface);
388 FIXME("(%p)\n", This);
392 static HRESULT WINAPI ControlSite_LockInPlaceActive(IOleControlSite *iface, BOOL fLock)
394 DocHost *This = impl_from_IOleControlSite(iface);
395 FIXME("(%p)->(%d)\n", This, fLock);
399 static HRESULT WINAPI ControlSite_GetExtendedControl(IOleControlSite *iface, IDispatch **ppDisp)
401 DocHost *This = impl_from_IOleControlSite(iface);
402 FIXME("(%p)->(%p)\n", This, ppDisp);
406 static HRESULT WINAPI ControlSite_TransformCoords(IOleControlSite *iface, POINTL *pPtlHimetric,
407 POINTF *pPtfContainer, DWORD dwFlags)
409 DocHost *This = impl_from_IOleControlSite(iface);
410 FIXME("(%p)->(%p, %p, %08x)\n", This, pPtlHimetric, pPtfContainer, dwFlags);
414 static HRESULT WINAPI ControlSite_TranslateAccelerator(IOleControlSite *iface, MSG *pMsg,
417 DocHost *This = impl_from_IOleControlSite(iface);
419 IOleClientSite *clientsite;
420 IOleControlSite *controlsite;
423 TRACE("(%p)->(%p, %08x)\n", This, pMsg, grfModifiers);
425 hr = IDispatch_QueryInterface(This->disp, &IID_IOleObject, (void**)&wb_obj);
427 hr = IOleObject_GetClientSite(wb_obj, &clientsite);
429 hr = IOleClientSite_QueryInterface(clientsite, &IID_IOleControlSite, (void**)&controlsite);
431 hr = IOleControlSite_TranslateAccelerator(controlsite, pMsg, grfModifiers);
432 IOleControlSite_Release(controlsite);
434 IOleClientSite_Release(clientsite);
436 IOleObject_Release(wb_obj);
445 static HRESULT WINAPI ControlSite_OnFocus(IOleControlSite *iface, BOOL fGotFocus)
447 DocHost *This = impl_from_IOleControlSite(iface);
448 FIXME("(%p)->(%d)\n", This, fGotFocus);
452 static HRESULT WINAPI ControlSite_ShowPropertyFrame(IOleControlSite *iface)
454 DocHost *This = impl_from_IOleControlSite(iface);
455 FIXME("(%p)\n", This);
459 static IOleControlSiteVtbl OleControlSiteVtbl = {
460 ControlSite_QueryInterface,
463 ControlSite_OnControlInfoChanged,
464 ControlSite_LockInPlaceActive,
465 ControlSite_GetExtendedControl,
466 ControlSite_TransformCoords,
467 ControlSite_TranslateAccelerator,
469 ControlSite_ShowPropertyFrame
472 static inline DocHost *impl_from_IDispatch(IDispatch *iface)
474 return CONTAINING_RECORD(iface, DocHost, IDispatch_iface);
477 static HRESULT WINAPI ClDispatch_QueryInterface(IDispatch *iface, REFIID riid, void **ppv)
479 DocHost *This = impl_from_IDispatch(iface);
480 return IOleClientSite_QueryInterface(&This->IOleClientSite_iface, riid, ppv);
483 static ULONG WINAPI ClDispatch_AddRef(IDispatch *iface)
485 DocHost *This = impl_from_IDispatch(iface);
486 return IOleClientSite_AddRef(&This->IOleClientSite_iface);
489 static ULONG WINAPI ClDispatch_Release(IDispatch *iface)
491 DocHost *This = impl_from_IDispatch(iface);
492 return IOleClientSite_Release(&This->IOleClientSite_iface);
495 static HRESULT WINAPI ClDispatch_GetTypeInfoCount(IDispatch *iface, UINT *pctinfo)
497 DocHost *This = impl_from_IDispatch(iface);
499 TRACE("(%p)->(%p)\n", This, pctinfo);
504 static HRESULT WINAPI ClDispatch_GetTypeInfo(IDispatch *iface, UINT iTInfo, LCID lcid,
507 DocHost *This = impl_from_IDispatch(iface);
509 TRACE("(%p)->(%u %d %p)\n", This, iTInfo, lcid, ppTInfo);
514 static HRESULT WINAPI ClDispatch_GetIDsOfNames(IDispatch *iface, REFIID riid, LPOLESTR *rgszNames,
515 UINT cNames, LCID lcid, DISPID *rgDispId)
517 DocHost *This = impl_from_IDispatch(iface);
519 TRACE("(%p)->(%s %p %u %d %p)\n", This, debugstr_guid(riid), rgszNames, cNames,
525 static const char *debugstr_dispid(DISPID dispid)
529 #define CASE_DISPID(did) case did: return #did
531 CASE_DISPID(DISPID_AMBIENT_USERMODE);
532 CASE_DISPID(DISPID_AMBIENT_DLCONTROL);
533 CASE_DISPID(DISPID_AMBIENT_USERAGENT);
534 CASE_DISPID(DISPID_AMBIENT_PALETTE);
535 CASE_DISPID(DISPID_AMBIENT_OFFLINEIFNOTCONNECTED);
536 CASE_DISPID(DISPID_AMBIENT_SILENT);
540 sprintf(buf, "%d", dispid);
544 static HRESULT WINAPI ClDispatch_Invoke(IDispatch *iface, DISPID dispIdMember, REFIID riid,
545 LCID lcid, WORD wFlags, DISPPARAMS *pDispParams,
546 VARIANT *pVarResult, EXCEPINFO *pExcepInfo, UINT *puArgErr)
548 DocHost *This = impl_from_IDispatch(iface);
550 TRACE("(%p)->(%s %s %d %04x %p %p %p %p)\n", This, debugstr_dispid(dispIdMember),
551 debugstr_guid(riid), lcid, wFlags, pDispParams, pVarResult, pExcepInfo, puArgErr);
553 switch(dispIdMember) {
554 case DISPID_AMBIENT_USERMODE:
555 case DISPID_AMBIENT_DLCONTROL:
556 case DISPID_AMBIENT_USERAGENT:
557 case DISPID_AMBIENT_PALETTE:
558 if(!This->client_disp)
560 return IDispatch_Invoke(This->client_disp, dispIdMember, riid, lcid, wFlags,
561 pDispParams, pVarResult, pExcepInfo, puArgErr);
562 case DISPID_AMBIENT_OFFLINEIFNOTCONNECTED:
563 V_VT(pVarResult) = VT_BOOL;
564 V_BOOL(pVarResult) = This->offline;
566 case DISPID_AMBIENT_SILENT:
567 V_VT(pVarResult) = VT_BOOL;
568 V_BOOL(pVarResult) = This->offline;
572 FIXME("unhandled dispid %d\n", dispIdMember);
576 static const IDispatchVtbl DispatchVtbl = {
577 ClDispatch_QueryInterface,
580 ClDispatch_GetTypeInfoCount,
581 ClDispatch_GetTypeInfo,
582 ClDispatch_GetIDsOfNames,
586 static inline DocHost *impl_from_IServiceProvider(IServiceProvider *iface)
588 return CONTAINING_RECORD(iface, DocHost, IServiceProvider_iface);
591 static HRESULT WINAPI ClServiceProvider_QueryInterface(IServiceProvider *iface, REFIID riid,
594 DocHost *This = impl_from_IServiceProvider(iface);
595 return IOleClientSite_QueryInterface(&This->IOleClientSite_iface, riid, ppv);
598 static ULONG WINAPI ClServiceProvider_AddRef(IServiceProvider *iface)
600 DocHost *This = impl_from_IServiceProvider(iface);
601 return IOleClientSite_AddRef(&This->IOleClientSite_iface);
604 static ULONG WINAPI ClServiceProvider_Release(IServiceProvider *iface)
606 DocHost *This = impl_from_IServiceProvider(iface);
607 return IOleClientSite_Release(&This->IOleClientSite_iface);
610 static HRESULT WINAPI ClServiceProvider_QueryService(IServiceProvider *iface, REFGUID guidService,
611 REFIID riid, void **ppv)
613 DocHost *This = impl_from_IServiceProvider(iface);
615 if(IsEqualGUID(&IID_IHlinkFrame, guidService)) {
616 TRACE("(%p)->(IID_IHlinkFrame %s %p)\n", This, debugstr_guid(riid), ppv);
617 return IDispatch_QueryInterface(This->disp, riid, ppv);
620 if(IsEqualGUID(&IID_IWebBrowserApp, guidService)) {
621 TRACE("IWebBrowserApp service\n");
622 return IDispatch_QueryInterface(This->disp, riid, ppv);
625 FIXME("(%p)->(%s %s %p)\n", This, debugstr_guid(guidService), debugstr_guid(riid), ppv);
627 return E_NOINTERFACE;
630 static const IServiceProviderVtbl ServiceProviderVtbl = {
631 ClServiceProvider_QueryInterface,
632 ClServiceProvider_AddRef,
633 ClServiceProvider_Release,
634 ClServiceProvider_QueryService
637 void DocHost_ClientSite_Init(DocHost *This)
639 This->IOleClientSite_iface.lpVtbl = &OleClientSiteVtbl;
640 This->IOleInPlaceSite_iface.lpVtbl = &OleInPlaceSiteVtbl;
641 This->IOleDocumentSite_iface.lpVtbl = &OleDocumentSiteVtbl;
642 This->IOleControlSite_iface.lpVtbl = &OleControlSiteVtbl;
643 This->IDispatch_iface.lpVtbl = &DispatchVtbl;
644 This->IServiceProvider_iface.lpVtbl = &ServiceProviderVtbl;
647 void DocHost_ClientSite_Release(DocHost *This)
650 IOleDocumentView_Release(This->view);