msi: Downgrade a few messages to WARN.
[wine.git] / dlls / shdocvw / client.c
blob14a7f904e31463d22a02e8e67849a32a425ae65a
1 /*
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 <stdio.h>
21 #include "wine/debug.h"
22 #include "shdocvw.h"
23 #include "mshtmdid.h"
24 #include "idispids.h"
26 WINE_DEFAULT_DEBUG_CHANNEL(shdocvw);
28 #define CLIENTSITE_THIS(iface) DEFINE_THIS(DocHost, OleClientSite, iface)
30 static HRESULT WINAPI ClientSite_QueryInterface(IOleClientSite *iface, REFIID riid, void **ppv)
32 DocHost *This = CLIENTSITE_THIS(iface);
34 *ppv = NULL;
36 if(IsEqualGUID(&IID_IUnknown, riid)) {
37 TRACE("(%p)->(IID_IUnknown %p)\n", This, ppv);
38 *ppv = CLIENTSITE(This);
39 }else if(IsEqualGUID(&IID_IOleClientSite, riid)) {
40 TRACE("(%p)->(IID_IOleClientSite %p)\n", This, ppv);
41 *ppv = CLIENTSITE(This);
42 }else if(IsEqualGUID(&IID_IOleWindow, riid)) {
43 TRACE("(%p)->(IID_IOleWindow %p)\n", This, ppv);
44 *ppv = INPLACESITE(This);
45 }else if(IsEqualGUID(&IID_IOleInPlaceSite, riid)) {
46 TRACE("(%p)->(IID_IOleInPlaceSite %p)\n", This, ppv);
47 *ppv = INPLACESITE(This);
48 }else if(IsEqualGUID(&IID_IDocHostUIHandler, riid)) {
49 TRACE("(%p)->(IID_IDocHostUIHandler %p)\n", This, ppv);
50 *ppv = DOCHOSTUI(This);
51 }else if(IsEqualGUID(&IID_IDocHostUIHandler2, riid)) {
52 TRACE("(%p)->(IID_IDocHostUIHandler2 %p)\n", This, ppv);
53 *ppv = DOCHOSTUI2(This);
54 }else if(IsEqualGUID(&IID_IOleDocumentSite, riid)) {
55 TRACE("(%p)->(IID_IOleDocumentSite %p)\n", This, ppv);
56 *ppv = DOCSITE(This);
57 }else if(IsEqualGUID(&IID_IOleCommandTarget, riid)) {
58 TRACE("(%p)->(IID_IOleCommandTarget %p)\n", This, ppv);
59 *ppv = OLECMD(This);
60 }else if(IsEqualGUID(&IID_IDispatch, riid)) {
61 TRACE("(%p)->(IID_IDispatch %p)\n", This, ppv);
62 *ppv = CLDISP(This);
63 }else if(IsEqualGUID(&IID_IServiceProvider, riid)) {
64 TRACE("(%p)->(IID_IServiceProvider %p)\n", This, ppv);
65 *ppv = SERVPROV(This);
68 if(*ppv) {
69 IOleClientSite_AddRef(CLIENTSITE(This));
70 return S_OK;
73 WARN("Unsupported intrface %s\n", debugstr_guid(riid));
75 return E_NOINTERFACE;
78 static ULONG WINAPI ClientSite_AddRef(IOleClientSite *iface)
80 DocHost *This = CLIENTSITE_THIS(iface);
81 return IDispatch_AddRef(This->disp);
84 static ULONG WINAPI ClientSite_Release(IOleClientSite *iface)
86 DocHost *This = CLIENTSITE_THIS(iface);
87 return IDispatch_Release(This->disp);
90 static HRESULT WINAPI ClientSite_SaveObject(IOleClientSite *iface)
92 DocHost *This = CLIENTSITE_THIS(iface);
93 FIXME("(%p)\n", This);
94 return E_NOTIMPL;
97 static HRESULT WINAPI ClientSite_GetMoniker(IOleClientSite *iface, DWORD dwAssign,
98 DWORD dwWhichMoniker, IMoniker **ppmk)
100 DocHost *This = CLIENTSITE_THIS(iface);
101 FIXME("(%p)->(%d %d %p)\n", This, dwAssign, dwWhichMoniker, ppmk);
102 return E_NOTIMPL;
105 static HRESULT WINAPI ClientSite_GetContainer(IOleClientSite *iface, IOleContainer **ppContainer)
107 DocHost *This = CLIENTSITE_THIS(iface);
108 FIXME("(%p)->(%p)\n", This, ppContainer);
109 return E_NOTIMPL;
112 static HRESULT WINAPI ClientSite_ShowObject(IOleClientSite *iface)
114 DocHost *This = CLIENTSITE_THIS(iface);
115 FIXME("(%p)\n", This);
116 return E_NOTIMPL;
119 static HRESULT WINAPI ClientSite_OnShowWindow(IOleClientSite *iface, BOOL fShow)
121 DocHost *This = CLIENTSITE_THIS(iface);
122 FIXME("(%p)->(%x)\n", This, fShow);
123 return E_NOTIMPL;
126 static HRESULT WINAPI ClientSite_RequestNewObjectLayout(IOleClientSite *iface)
128 DocHost *This = CLIENTSITE_THIS(iface);
129 FIXME("(%p)\n", This);
130 return E_NOTIMPL;
133 #undef CLIENTSITE_THIS
135 static const IOleClientSiteVtbl OleClientSiteVtbl = {
136 ClientSite_QueryInterface,
137 ClientSite_AddRef,
138 ClientSite_Release,
139 ClientSite_SaveObject,
140 ClientSite_GetMoniker,
141 ClientSite_GetContainer,
142 ClientSite_ShowObject,
143 ClientSite_OnShowWindow,
144 ClientSite_RequestNewObjectLayout
147 #define INPLACESITE_THIS(iface) DEFINE_THIS(DocHost, OleInPlaceSite, iface)
149 static HRESULT WINAPI InPlaceSite_QueryInterface(IOleInPlaceSite *iface, REFIID riid, void **ppv)
151 DocHost *This = INPLACESITE_THIS(iface);
152 return IOleClientSite_QueryInterface(CLIENTSITE(This), riid, ppv);
155 static ULONG WINAPI InPlaceSite_AddRef(IOleInPlaceSite *iface)
157 DocHost *This = INPLACESITE_THIS(iface);
158 return IOleClientSite_AddRef(CLIENTSITE(This));
161 static ULONG WINAPI InPlaceSite_Release(IOleInPlaceSite *iface)
163 DocHost *This = INPLACESITE_THIS(iface);
164 return IOleClientSite_Release(CLIENTSITE(This));
167 static HRESULT WINAPI InPlaceSite_GetWindow(IOleInPlaceSite *iface, HWND *phwnd)
169 DocHost *This = INPLACESITE_THIS(iface);
171 TRACE("(%p)->(%p)\n", This, phwnd);
173 *phwnd = This->hwnd;
174 return S_OK;
177 static HRESULT WINAPI InPlaceSite_ContextSensitiveHelp(IOleInPlaceSite *iface, BOOL fEnterMode)
179 DocHost *This = INPLACESITE_THIS(iface);
180 FIXME("(%p)->(%x)\n", This, fEnterMode);
181 return E_NOTIMPL;
184 static HRESULT WINAPI InPlaceSite_CanInPlaceActivate(IOleInPlaceSite *iface)
186 DocHost *This = INPLACESITE_THIS(iface);
188 TRACE("(%p)\n", This);
190 /* Nothing to do here */
191 return S_OK;
194 static HRESULT WINAPI InPlaceSite_OnInPlaceActivate(IOleInPlaceSite *iface)
196 DocHost *This = INPLACESITE_THIS(iface);
198 TRACE("(%p)\n", This);
200 /* Nothing to do here */
201 return S_OK;
204 static HRESULT WINAPI InPlaceSite_OnUIActivate(IOleInPlaceSite *iface)
206 DocHost *This = INPLACESITE_THIS(iface);
207 FIXME("(%p)\n", This);
208 return E_NOTIMPL;
211 static HRESULT WINAPI InPlaceSite_GetWindowContext(IOleInPlaceSite *iface,
212 IOleInPlaceFrame **ppFrame, IOleInPlaceUIWindow **ppDoc, LPRECT lprcPosRect,
213 LPRECT lprcClipRect, LPOLEINPLACEFRAMEINFO lpFrameInfo)
215 DocHost *This = INPLACESITE_THIS(iface);
217 TRACE("(%p)->(%p %p %p %p %p)\n", This, ppFrame, ppDoc, lprcPosRect,
218 lprcClipRect, lpFrameInfo);
220 IOleInPlaceFrame_AddRef(INPLACEFRAME(This));
221 *ppFrame = INPLACEFRAME(This);
222 *ppDoc = NULL;
224 GetClientRect(This->hwnd, lprcPosRect);
225 *lprcClipRect = *lprcPosRect;
227 lpFrameInfo->cb = sizeof(*lpFrameInfo);
228 lpFrameInfo->fMDIApp = FALSE;
229 lpFrameInfo->hwndFrame = This->frame_hwnd;
230 lpFrameInfo->haccel = NULL;
231 lpFrameInfo->cAccelEntries = 0; /* FIXME: should be 5 */
233 return S_OK;
236 static HRESULT WINAPI InPlaceSite_Scroll(IOleInPlaceSite *iface, SIZE scrollExtent)
238 DocHost *This = INPLACESITE_THIS(iface);
239 FIXME("(%p)->({%d %d})\n", This, scrollExtent.cx, scrollExtent.cy);
240 return E_NOTIMPL;
243 static HRESULT WINAPI InPlaceSite_OnUIDeactivate(IOleInPlaceSite *iface, BOOL fUndoable)
245 DocHost *This = INPLACESITE_THIS(iface);
246 FIXME("(%p)->(%x)\n", This, fUndoable);
247 return E_NOTIMPL;
250 static HRESULT WINAPI InPlaceSite_OnInPlaceDeactivate(IOleInPlaceSite *iface)
252 DocHost *This = INPLACESITE_THIS(iface);
254 TRACE("(%p)\n", This);
256 /* Nothing to do here */
257 return S_OK;
260 static HRESULT WINAPI InPlaceSite_DiscardUndoState(IOleInPlaceSite *iface)
262 DocHost *This = INPLACESITE_THIS(iface);
263 FIXME("(%p)\n", This);
264 return E_NOTIMPL;
267 static HRESULT WINAPI InPlaceSite_DeactivateAndUndo(IOleInPlaceSite *iface)
269 DocHost *This = INPLACESITE_THIS(iface);
270 FIXME("(%p)\n", This);
271 return E_NOTIMPL;
274 static HRESULT WINAPI InPlaceSite_OnPosRectChange(IOleInPlaceSite *iface,
275 LPCRECT lprcPosRect)
277 DocHost *This = INPLACESITE_THIS(iface);
278 FIXME("(%p)->(%p)\n", This, lprcPosRect);
279 return E_NOTIMPL;
282 #undef INPLACESITE_THIS
284 static const IOleInPlaceSiteVtbl OleInPlaceSiteVtbl = {
285 InPlaceSite_QueryInterface,
286 InPlaceSite_AddRef,
287 InPlaceSite_Release,
288 InPlaceSite_GetWindow,
289 InPlaceSite_ContextSensitiveHelp,
290 InPlaceSite_CanInPlaceActivate,
291 InPlaceSite_OnInPlaceActivate,
292 InPlaceSite_OnUIActivate,
293 InPlaceSite_GetWindowContext,
294 InPlaceSite_Scroll,
295 InPlaceSite_OnUIDeactivate,
296 InPlaceSite_OnInPlaceDeactivate,
297 InPlaceSite_DiscardUndoState,
298 InPlaceSite_DeactivateAndUndo,
299 InPlaceSite_OnPosRectChange
302 #define DOCSITE_THIS(iface) DEFINE_THIS(DocHost, OleDocumentSite, iface)
304 static HRESULT WINAPI OleDocumentSite_QueryInterface(IOleDocumentSite *iface,
305 REFIID riid, void **ppv)
307 DocHost *This = DOCSITE_THIS(iface);
308 return IOleClientSite_QueryInterface(CLIENTSITE(This), riid, ppv);
311 static ULONG WINAPI OleDocumentSite_AddRef(IOleDocumentSite *iface)
313 DocHost *This = DOCSITE_THIS(iface);
314 return IOleClientSite_AddRef(CLIENTSITE(This));
317 static ULONG WINAPI OleDocumentSite_Release(IOleDocumentSite *iface)
319 DocHost *This = DOCSITE_THIS(iface);
320 return IOleClientSite_Release(CLIENTSITE(This));
323 static HRESULT WINAPI OleDocumentSite_ActivateMe(IOleDocumentSite *iface,
324 IOleDocumentView *pViewToActivate)
326 DocHost *This = DOCSITE_THIS(iface);
327 IOleDocument *oledoc;
328 RECT rect;
329 HRESULT hres;
331 TRACE("(%p)->(%p)\n", This, pViewToActivate);
333 hres = IUnknown_QueryInterface(This->document, &IID_IOleDocument, (void**)&oledoc);
334 if(FAILED(hres))
335 return hres;
337 IOleDocument_CreateView(oledoc, INPLACESITE(This), NULL, 0, &This->view);
338 IOleDocument_Release(oledoc);
340 GetClientRect(This->hwnd, &rect);
341 IOleDocumentView_SetRect(This->view, &rect);
343 hres = IOleDocumentView_Show(This->view, TRUE);
345 return hres;
348 #undef DOCSITE_THIS
350 static const IOleDocumentSiteVtbl OleDocumentSiteVtbl = {
351 OleDocumentSite_QueryInterface,
352 OleDocumentSite_AddRef,
353 OleDocumentSite_Release,
354 OleDocumentSite_ActivateMe
357 #define DISP_THIS(iface) DEFINE_THIS(DocHost, Dispatch, iface)
359 static HRESULT WINAPI ClDispatch_QueryInterface(IDispatch *iface, REFIID riid, void **ppv)
361 DocHost *This = DISP_THIS(iface);
362 return IOleClientSite_QueryInterface(CLIENTSITE(This), riid, ppv);
365 static ULONG WINAPI ClDispatch_AddRef(IDispatch *iface)
367 DocHost *This = DISP_THIS(iface);
368 return IOleClientSite_AddRef(CLIENTSITE(This));
371 static ULONG WINAPI ClDispatch_Release(IDispatch *iface)
373 DocHost *This = DISP_THIS(iface);
374 return IOleClientSite_Release(CLIENTSITE(This));
377 static HRESULT WINAPI ClDispatch_GetTypeInfoCount(IDispatch *iface, UINT *pctinfo)
379 DocHost *This = DISP_THIS(iface);
381 TRACE("(%p)->(%p)\n", This, pctinfo);
383 return E_NOTIMPL;
386 static HRESULT WINAPI ClDispatch_GetTypeInfo(IDispatch *iface, UINT iTInfo, LCID lcid,
387 ITypeInfo **ppTInfo)
389 DocHost *This = DISP_THIS(iface);
391 TRACE("(%p)->(%u %d %p)\n", This, iTInfo, lcid, ppTInfo);
393 return E_NOTIMPL;
396 static HRESULT WINAPI ClDispatch_GetIDsOfNames(IDispatch *iface, REFIID riid, LPOLESTR *rgszNames,
397 UINT cNames, LCID lcid, DISPID *rgDispId)
399 DocHost *This = DISP_THIS(iface);
401 TRACE("(%p)->(%s %p %u %d %p)\n", This, debugstr_guid(riid), rgszNames, cNames,
402 lcid, rgDispId);
404 return E_NOTIMPL;
407 static const char *debugstr_dispid(DISPID dispid)
409 static char buf[16];
411 #define CASE_DISPID(did) case did: return #did
412 switch(dispid) {
413 CASE_DISPID(DISPID_AMBIENT_USERMODE);
414 CASE_DISPID(DISPID_AMBIENT_DLCONTROL);
415 CASE_DISPID(DISPID_AMBIENT_USERAGENT);
416 CASE_DISPID(DISPID_AMBIENT_PALETTE);
417 CASE_DISPID(DISPID_AMBIENT_OFFLINEIFNOTCONNECTED);
418 CASE_DISPID(DISPID_AMBIENT_SILENT);
420 #undef CASE_DISPID
422 sprintf(buf, "%d", dispid);
423 return buf;
426 static HRESULT WINAPI ClDispatch_Invoke(IDispatch *iface, DISPID dispIdMember, REFIID riid,
427 LCID lcid, WORD wFlags, DISPPARAMS *pDispParams,
428 VARIANT *pVarResult, EXCEPINFO *pExcepInfo, UINT *puArgErr)
430 DocHost *This = DISP_THIS(iface);
432 TRACE("(%p)->(%s %s %d %04x %p %p %p %p)\n", This, debugstr_dispid(dispIdMember),
433 debugstr_guid(riid), lcid, wFlags, pDispParams, pVarResult, pExcepInfo, puArgErr);
435 switch(dispIdMember) {
436 case DISPID_AMBIENT_USERMODE:
437 case DISPID_AMBIENT_DLCONTROL:
438 case DISPID_AMBIENT_USERAGENT:
439 case DISPID_AMBIENT_PALETTE:
440 if(!This->client_disp)
441 return E_FAIL;
442 return IDispatch_Invoke(This->client_disp, dispIdMember, riid, lcid, wFlags,
443 pDispParams, pVarResult, pExcepInfo, puArgErr);
444 case DISPID_AMBIENT_OFFLINEIFNOTCONNECTED:
445 V_VT(pVarResult) = VT_BOOL;
446 V_BOOL(pVarResult) = This->offline;
447 return S_OK;
448 case DISPID_AMBIENT_SILENT:
449 V_VT(pVarResult) = VT_BOOL;
450 V_BOOL(pVarResult) = This->offline;
451 return S_OK;
454 FIXME("unhandled dispid %d\n", dispIdMember);
455 return E_NOTIMPL;
458 #undef DISP_THIS
460 static const IDispatchVtbl DispatchVtbl = {
461 ClDispatch_QueryInterface,
462 ClDispatch_AddRef,
463 ClDispatch_Release,
464 ClDispatch_GetTypeInfoCount,
465 ClDispatch_GetTypeInfo,
466 ClDispatch_GetIDsOfNames,
467 ClDispatch_Invoke
470 #define SERVPROV_THIS(iface) DEFINE_THIS(DocHost, ServiceProvider, iface)
472 static HRESULT WINAPI ClServiceProvider_QueryInterface(IServiceProvider *iface, REFIID riid,
473 void **ppv)
475 DocHost *This = SERVPROV_THIS(iface);
476 return IOleClientSite_QueryInterface(CLIENTSITE(This), riid, ppv);
479 static ULONG WINAPI ClServiceProvider_AddRef(IServiceProvider *iface)
481 DocHost *This = SERVPROV_THIS(iface);
482 return IOleClientSite_AddRef(CLIENTSITE(This));
485 static ULONG WINAPI ClServiceProvider_Release(IServiceProvider *iface)
487 DocHost *This = SERVPROV_THIS(iface);
488 return IOleClientSite_Release(CLIENTSITE(This));
491 static HRESULT WINAPI ClServiceProvider_QueryService(IServiceProvider *iface, REFGUID guidService,
492 REFIID riid, void **ppv)
494 DocHost *This = SERVPROV_THIS(iface);
496 if(IsEqualGUID(&IID_IHlinkFrame, guidService)) {
497 TRACE("(%p)->(IID_IHlinkFrame %s %p)\n", This, debugstr_guid(riid), ppv);
498 return IDispatch_QueryInterface(This->disp, riid, ppv);
501 FIXME("(%p)->(%s %s %p)\n", This, debugstr_guid(guidService), debugstr_guid(riid), ppv);
503 return E_NOINTERFACE;
506 #undef SERVPROV_THIS
508 static const IServiceProviderVtbl ServiceProviderVtbl = {
509 ClServiceProvider_QueryInterface,
510 ClServiceProvider_AddRef,
511 ClServiceProvider_Release,
512 ClServiceProvider_QueryService
515 void DocHost_ClientSite_Init(DocHost *This)
517 This->lpOleClientSiteVtbl = &OleClientSiteVtbl;
518 This->lpOleInPlaceSiteVtbl = &OleInPlaceSiteVtbl;
519 This->lpOleDocumentSiteVtbl = &OleDocumentSiteVtbl;
520 This->lpDispatchVtbl = &DispatchVtbl;
521 This->lpServiceProviderVtbl = &ServiceProviderVtbl;
523 This->view = NULL;
526 void DocHost_ClientSite_Release(DocHost *This)
528 if(This->view)
529 IOleDocumentView_Release(This->view);