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
19 #include "wine/debug.h"
22 WINE_DEFAULT_DEBUG_CHANNEL(shdocvw);
24 #define CLIENTSITE_THIS(iface) DEFINE_THIS(DocHost, OleClientSite, iface)
26 static HRESULT WINAPI ClientSite_QueryInterface(IOleClientSite *iface, REFIID riid, void **ppv)
28 DocHost *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_IOleCommandTarget, riid)) {
54 TRACE("(%p)->(IID_IOleCommandTarget %p)\n", This, ppv);
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 = SERVPROV(This);
65 IOleClientSite_AddRef(CLIENTSITE(This));
69 WARN("Unsupported intrface %s\n", debugstr_guid(riid));
74 static ULONG WINAPI ClientSite_AddRef(IOleClientSite *iface)
76 DocHost *This = CLIENTSITE_THIS(iface);
77 return IDispatch_AddRef(This->disp);
80 static ULONG WINAPI ClientSite_Release(IOleClientSite *iface)
82 DocHost *This = CLIENTSITE_THIS(iface);
83 return IDispatch_Release(This->disp);
86 static HRESULT WINAPI ClientSite_SaveObject(IOleClientSite *iface)
88 DocHost *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 DocHost *This = CLIENTSITE_THIS(iface);
97 FIXME("(%p)->(%d %d %p)\n", This, dwAssign, dwWhichMoniker, ppmk);
101 static HRESULT WINAPI ClientSite_GetContainer(IOleClientSite *iface, IOleContainer **ppContainer)
103 DocHost *This = CLIENTSITE_THIS(iface);
104 FIXME("(%p)->(%p)\n", This, ppContainer);
108 static HRESULT WINAPI ClientSite_ShowObject(IOleClientSite *iface)
110 DocHost *This = CLIENTSITE_THIS(iface);
111 FIXME("(%p)\n", This);
115 static HRESULT WINAPI ClientSite_OnShowWindow(IOleClientSite *iface, BOOL fShow)
117 DocHost *This = CLIENTSITE_THIS(iface);
118 FIXME("(%p)->(%x)\n", This, fShow);
122 static HRESULT WINAPI ClientSite_RequestNewObjectLayout(IOleClientSite *iface)
124 DocHost *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(DocHost, OleInPlaceSite, iface)
145 static HRESULT WINAPI InPlaceSite_QueryInterface(IOleInPlaceSite *iface, REFIID riid, void **ppv)
147 DocHost *This = INPLACESITE_THIS(iface);
148 return IOleClientSite_QueryInterface(CLIENTSITE(This), riid, ppv);
151 static ULONG WINAPI InPlaceSite_AddRef(IOleInPlaceSite *iface)
153 DocHost *This = INPLACESITE_THIS(iface);
154 return IOleClientSite_AddRef(CLIENTSITE(This));
157 static ULONG WINAPI InPlaceSite_Release(IOleInPlaceSite *iface)
159 DocHost *This = INPLACESITE_THIS(iface);
160 return IOleClientSite_Release(CLIENTSITE(This));
163 static HRESULT WINAPI InPlaceSite_GetWindow(IOleInPlaceSite *iface, HWND *phwnd)
165 DocHost *This = INPLACESITE_THIS(iface);
167 TRACE("(%p)->(%p)\n", This, phwnd);
173 static HRESULT WINAPI InPlaceSite_ContextSensitiveHelp(IOleInPlaceSite *iface, BOOL fEnterMode)
175 DocHost *This = INPLACESITE_THIS(iface);
176 FIXME("(%p)->(%x)\n", This, fEnterMode);
180 static HRESULT WINAPI InPlaceSite_CanInPlaceActivate(IOleInPlaceSite *iface)
182 DocHost *This = INPLACESITE_THIS(iface);
184 TRACE("(%p)\n", This);
186 /* Nothing to do here */
190 static HRESULT WINAPI InPlaceSite_OnInPlaceActivate(IOleInPlaceSite *iface)
192 DocHost *This = INPLACESITE_THIS(iface);
194 TRACE("(%p)\n", This);
196 /* Nothing to do here */
200 static HRESULT WINAPI InPlaceSite_OnUIActivate(IOleInPlaceSite *iface)
202 DocHost *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 DocHost *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->hwnd, lprcPosRect);
221 memcpy(lprcClipRect, lprcPosRect, sizeof(RECT));
223 lpFrameInfo->cb = sizeof(*lpFrameInfo);
224 lpFrameInfo->fMDIApp = FALSE;
225 lpFrameInfo->hwndFrame = This->frame_hwnd;
226 lpFrameInfo->haccel = NULL;
227 lpFrameInfo->cAccelEntries = 0; /* FIXME: should be 5 */
232 static HRESULT WINAPI InPlaceSite_Scroll(IOleInPlaceSite *iface, SIZE scrollExtent)
234 DocHost *This = INPLACESITE_THIS(iface);
235 FIXME("(%p)->({%d %d})\n", This, scrollExtent.cx, scrollExtent.cy);
239 static HRESULT WINAPI InPlaceSite_OnUIDeactivate(IOleInPlaceSite *iface, BOOL fUndoable)
241 DocHost *This = INPLACESITE_THIS(iface);
242 FIXME("(%p)->(%x)\n", This, fUndoable);
246 static HRESULT WINAPI InPlaceSite_OnInPlaceDeactivate(IOleInPlaceSite *iface)
248 DocHost *This = INPLACESITE_THIS(iface);
250 TRACE("(%p)\n", This);
252 /* Nothing to do here */
256 static HRESULT WINAPI InPlaceSite_DiscardUndoState(IOleInPlaceSite *iface)
258 DocHost *This = INPLACESITE_THIS(iface);
259 FIXME("(%p)\n", This);
263 static HRESULT WINAPI InPlaceSite_DeactivateAndUndo(IOleInPlaceSite *iface)
265 DocHost *This = INPLACESITE_THIS(iface);
266 FIXME("(%p)\n", This);
270 static HRESULT WINAPI InPlaceSite_OnPosRectChange(IOleInPlaceSite *iface,
273 DocHost *This = INPLACESITE_THIS(iface);
274 FIXME("(%p)->(%p)\n", This, lprcPosRect);
278 #undef INPLACESITE_THIS
280 static const IOleInPlaceSiteVtbl OleInPlaceSiteVtbl = {
281 InPlaceSite_QueryInterface,
284 InPlaceSite_GetWindow,
285 InPlaceSite_ContextSensitiveHelp,
286 InPlaceSite_CanInPlaceActivate,
287 InPlaceSite_OnInPlaceActivate,
288 InPlaceSite_OnUIActivate,
289 InPlaceSite_GetWindowContext,
291 InPlaceSite_OnUIDeactivate,
292 InPlaceSite_OnInPlaceDeactivate,
293 InPlaceSite_DiscardUndoState,
294 InPlaceSite_DeactivateAndUndo,
295 InPlaceSite_OnPosRectChange
298 #define DOCSITE_THIS(iface) DEFINE_THIS(DocHost, OleDocumentSite, iface)
300 static HRESULT WINAPI OleDocumentSite_QueryInterface(IOleDocumentSite *iface,
301 REFIID riid, void **ppv)
303 DocHost *This = DOCSITE_THIS(iface);
304 return IOleClientSite_QueryInterface(CLIENTSITE(This), riid, ppv);
307 static ULONG WINAPI OleDocumentSite_AddRef(IOleDocumentSite *iface)
309 DocHost *This = DOCSITE_THIS(iface);
310 return IOleClientSite_AddRef(CLIENTSITE(This));
313 static ULONG WINAPI OleDocumentSite_Release(IOleDocumentSite *iface)
315 DocHost *This = DOCSITE_THIS(iface);
316 return IOleClientSite_Release(CLIENTSITE(This));
319 static HRESULT WINAPI OleDocumentSite_ActivateMe(IOleDocumentSite *iface,
320 IOleDocumentView *pViewToActivate)
322 DocHost *This = DOCSITE_THIS(iface);
323 IOleDocument *oledoc;
327 TRACE("(%p)->(%p)\n", This, pViewToActivate);
329 hres = IUnknown_QueryInterface(This->document, &IID_IOleDocument, (void**)&oledoc);
333 IOleDocument_CreateView(oledoc, INPLACESITE(This), NULL, 0, &This->view);
334 IOleDocument_Release(oledoc);
336 GetClientRect(This->hwnd, &rect);
337 IOleDocumentView_SetRect(This->view, &rect);
339 hres = IOleDocumentView_Show(This->view, TRUE);
346 static const IOleDocumentSiteVtbl OleDocumentSiteVtbl = {
347 OleDocumentSite_QueryInterface,
348 OleDocumentSite_AddRef,
349 OleDocumentSite_Release,
350 OleDocumentSite_ActivateMe
353 #define DISP_THIS(iface) DEFINE_THIS(DocHost, Dispatch, iface)
355 static HRESULT WINAPI ClDispatch_QueryInterface(IDispatch *iface, REFIID riid, void **ppv)
357 DocHost *This = DISP_THIS(iface);
358 return IOleClientSite_QueryInterface(CLIENTSITE(This), riid, ppv);
361 static ULONG WINAPI ClDispatch_AddRef(IDispatch *iface)
363 DocHost *This = DISP_THIS(iface);
364 return IOleClientSite_AddRef(CLIENTSITE(This));
367 static ULONG WINAPI ClDispatch_Release(IDispatch *iface)
369 DocHost *This = DISP_THIS(iface);
370 return IOleClientSite_Release(CLIENTSITE(This));
373 static HRESULT WINAPI ClDispatch_GetTypeInfoCount(IDispatch *iface, UINT *pctinfo)
375 DocHost *This = DISP_THIS(iface);
377 TRACE("(%p)->(%p)\n", This, pctinfo);
382 static HRESULT WINAPI ClDispatch_GetTypeInfo(IDispatch *iface, UINT iTInfo, LCID lcid,
385 DocHost *This = DISP_THIS(iface);
387 TRACE("(%p)->(%u %d %p)\n", This, iTInfo, lcid, ppTInfo);
392 static HRESULT WINAPI ClDispatch_GetIDsOfNames(IDispatch *iface, REFIID riid, LPOLESTR *rgszNames,
393 UINT cNames, LCID lcid, DISPID *rgDispId)
395 DocHost *This = DISP_THIS(iface);
397 TRACE("(%p)->(%s %p %u %d %p)\n", This, debugstr_guid(riid), rgszNames, cNames,
403 static HRESULT WINAPI ClDispatch_Invoke(IDispatch *iface, DISPID dispIdMember, REFIID riid,
404 LCID lcid, WORD wFlags, DISPPARAMS *pDispParams,
405 VARIANT *pVarResult, EXCEPINFO *pExcepInfo, UINT *puArgErr)
407 DocHost *This = DISP_THIS(iface);
408 FIXME("(%p)->(%d %s %d %04x %p %p %p %p)\n", This, dispIdMember, debugstr_guid(riid),
409 lcid, wFlags, pDispParams, pVarResult, pExcepInfo, puArgErr);
415 static const IDispatchVtbl DispatchVtbl = {
416 ClDispatch_QueryInterface,
419 ClDispatch_GetTypeInfoCount,
420 ClDispatch_GetTypeInfo,
421 ClDispatch_GetIDsOfNames,
425 #define SERVPROV_THIS(iface) DEFINE_THIS(DocHost, ServiceProvider, iface)
427 static HRESULT WINAPI ClServiceProvider_QueryInterface(IServiceProvider *iface, REFIID riid,
430 DocHost *This = SERVPROV_THIS(iface);
431 return IOleClientSite_QueryInterface(CLIENTSITE(This), riid, ppv);
434 static ULONG WINAPI ClServiceProvider_AddRef(IServiceProvider *iface)
436 DocHost *This = SERVPROV_THIS(iface);
437 return IOleClientSite_AddRef(CLIENTSITE(This));
440 static ULONG WINAPI ClServiceProvider_Release(IServiceProvider *iface)
442 DocHost *This = SERVPROV_THIS(iface);
443 return IOleClientSite_Release(CLIENTSITE(This));
446 static HRESULT WINAPI ClServiceProvider_QueryService(IServiceProvider *iface, REFGUID guidService,
447 REFIID riid, void **ppv)
449 DocHost *This = SERVPROV_THIS(iface);
451 if(IsEqualGUID(&IID_IHlinkFrame, guidService)) {
452 TRACE("(%p)->(IID_IHlinkFrame %s %p)\n", This, debugstr_guid(riid), ppv);
453 return IDispatch_QueryInterface(This->disp, riid, ppv);
456 FIXME("(%p)->(%s %s %p)\n", This, debugstr_guid(guidService), debugstr_guid(riid), ppv);
458 return E_NOINTERFACE;
463 static const IServiceProviderVtbl ServiceProviderVtbl = {
464 ClServiceProvider_QueryInterface,
465 ClServiceProvider_AddRef,
466 ClServiceProvider_Release,
467 ClServiceProvider_QueryService
470 void DocHost_ClientSite_Init(DocHost *This)
472 This->lpOleClientSiteVtbl = &OleClientSiteVtbl;
473 This->lpOleInPlaceSiteVtbl = &OleInPlaceSiteVtbl;
474 This->lpOleDocumentSiteVtbl = &OleDocumentSiteVtbl;
475 This->lpDispatchVtbl = &DispatchVtbl;
476 This->lpServiceProviderVtbl = &ServiceProviderVtbl;
481 void DocHost_ClientSite_Release(DocHost *This)
484 IOleDocumentView_Release(This->view);