Replace a few more direct lpVtbl accesses by the proper macros.
[wine] / dlls / shdocvw / oleobject.c
1 /*
2  * Implementation of IOleObject interfaces for WebBrowser control
3  *
4  * - IOleObject
5  * - IOleInPlaceObject
6  * - IOleControl
7  *
8  * Copyright 2001 John R. Sheets (for CodeWeavers)
9  * Copyright 2005 Jacek Caban
10  *
11  * This library is free software; you can redistribute it and/or
12  * modify it under the terms of the GNU Lesser General Public
13  * License as published by the Free Software Foundation; either
14  * version 2.1 of the License, or (at your option) any later version.
15  *
16  * This library is distributed in the hope that it will be useful,
17  * but WITHOUT ANY WARRANTY; without even the implied warranty of
18  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
19  * Lesser General Public License for more details.
20  *
21  * You should have received a copy of the GNU Lesser General Public
22  * License along with this library; if not, write to the Free Software
23  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
24  */
25
26 #include <string.h>
27 #include "wine/debug.h"
28 #include "shdocvw.h"
29
30 WINE_DEFAULT_DEBUG_CHANNEL(shdocvw);
31
32 /**********************************************************************
33  * Implement the IOleObject interface for the WebBrowser control
34  */
35
36 #define OLEOBJ_THIS(iface) DEFINE_THIS(WebBrowser, OleObject, iface)
37
38 static HRESULT WINAPI OleObject_QueryInterface(IOleObject *iface, REFIID riid, void **ppv)
39 {
40     WebBrowser *This = OLEOBJ_THIS(iface);
41     return IWebBrowser_QueryInterface(WEBBROWSER(This), riid, ppv);
42 }
43
44 static ULONG WINAPI OleObject_AddRef(IOleObject *iface)
45 {
46     WebBrowser *This = OLEOBJ_THIS(iface);
47     return IWebBrowser_AddRef(WEBBROWSER(This));
48 }
49
50 static ULONG WINAPI OleObject_Release(IOleObject *iface)
51 {
52     WebBrowser *This = OLEOBJ_THIS(iface);
53     return IWebBrowser_Release(WEBBROWSER(This));
54 }
55
56 static HRESULT WINAPI OleObject_SetClientSite(IOleObject *iface, LPOLECLIENTSITE pClientSite)
57 {
58     WebBrowser *This = OLEOBJ_THIS(iface);
59     FIXME("(%p)->(%p)\n", This, pClientSite);
60     return E_NOTIMPL;
61 }
62
63 static HRESULT WINAPI OleObject_GetClientSite(IOleObject *iface, LPOLECLIENTSITE *ppClientSite)
64 {
65     WebBrowser *This = OLEOBJ_THIS(iface);
66     FIXME("(%p)->(%p)\n", This, ppClientSite);
67     return E_NOTIMPL;
68 }
69
70 static HRESULT WINAPI OleObject_SetHostNames(IOleObject *iface, LPCOLESTR szContainerApp,
71         LPCOLESTR szContainerObj)
72 {
73     WebBrowser *This = OLEOBJ_THIS(iface);
74     FIXME("(%p)->(%s, %s)\n", This, debugstr_w(szContainerApp), debugstr_w(szContainerObj));
75     return E_NOTIMPL;
76 }
77
78 static HRESULT WINAPI OleObject_Close(IOleObject *iface, DWORD dwSaveOption)
79 {
80     WebBrowser *This = OLEOBJ_THIS(iface);
81     FIXME("(%p)->(%ld)\n", This, dwSaveOption);
82     return E_NOTIMPL;
83 }
84
85 static HRESULT WINAPI OleObject_SetMoniker(IOleObject *iface, DWORD dwWhichMoniker, IMoniker* pmk)
86 {
87     WebBrowser *This = OLEOBJ_THIS(iface);
88     FIXME("(%p)->(%ld, %p)\n", This, dwWhichMoniker, pmk);
89     return E_NOTIMPL;
90 }
91
92 static HRESULT WINAPI OleObject_GetMoniker(IOleObject *iface, DWORD dwAssign,
93         DWORD dwWhichMoniker, LPMONIKER *ppmk)
94 {
95     WebBrowser *This = OLEOBJ_THIS(iface);
96     FIXME("(%p)->(%ld, %ld, %p)\n", This, dwAssign, dwWhichMoniker, ppmk);
97     return E_NOTIMPL;
98 }
99
100 static HRESULT WINAPI OleObject_InitFromData(IOleObject *iface, LPDATAOBJECT pDataObject,
101         BOOL fCreation, DWORD dwReserved)
102 {
103     WebBrowser *This = OLEOBJ_THIS(iface);
104     FIXME("(%p)->(%p, %d, %ld)\n", This, pDataObject, fCreation, dwReserved);
105     return E_NOTIMPL;
106 }
107
108 static HRESULT WINAPI OleObject_GetClipboardData(IOleObject *iface, DWORD dwReserved,
109         LPDATAOBJECT *ppDataObject)
110 {
111     WebBrowser *This = OLEOBJ_THIS(iface);
112     FIXME("(%p)->(%ld, %p)\n", This, dwReserved, ppDataObject);
113     return E_NOTIMPL;
114 }
115
116 static HRESULT WINAPI OleObject_DoVerb(IOleObject *iface, LONG iVerb, struct tagMSG* lpmsg,
117         LPOLECLIENTSITE pActiveSite, LONG lindex, HWND hwndParent, LPCRECT lprcPosRect)
118 {
119     WebBrowser *This = OLEOBJ_THIS(iface);
120     FIXME("(%p)->(%ld %p %p %ld %p %p)\n", This, iVerb, lpmsg, pActiveSite, lindex, hwndParent,
121             lprcPosRect);
122     switch (iVerb)
123     {
124     case OLEIVERB_INPLACEACTIVATE:
125         FIXME ("stub for OLEIVERB_INPLACEACTIVATE\n");
126         break;
127     case OLEIVERB_HIDE:
128         FIXME ("stub for OLEIVERB_HIDE\n");
129         break;
130     }
131
132     return E_NOTIMPL;
133 }
134
135 static HRESULT WINAPI OleObject_EnumVerbs(IOleObject *iface, IEnumOLEVERB **ppEnumOleVerb)
136 {
137     WebBrowser *This = OLEOBJ_THIS(iface);
138     TRACE("(%p)->(%p)\n", This, ppEnumOleVerb);
139     return OleRegEnumVerbs(&CLSID_WebBrowser, ppEnumOleVerb);
140 }
141
142 static HRESULT WINAPI OleObject_Update(IOleObject *iface)
143 {
144     WebBrowser *This = OLEOBJ_THIS(iface);
145     FIXME("(%p)\n", This);
146     return E_NOTIMPL;
147 }
148
149 static HRESULT WINAPI OleObject_IsUpToDate(IOleObject *iface)
150 {
151     WebBrowser *This = OLEOBJ_THIS(iface);
152     FIXME("(%p)\n", This);
153     return E_NOTIMPL;
154 }
155
156 static HRESULT WINAPI OleObject_GetUserClassID(IOleObject *iface, CLSID* pClsid)
157 {
158     WebBrowser *This = OLEOBJ_THIS(iface);
159     FIXME("(%p)->(%p)\n", This, pClsid);
160     return E_NOTIMPL;
161 }
162
163 static HRESULT WINAPI OleObject_GetUserType(IOleObject *iface, DWORD dwFormOfType,
164         LPOLESTR* pszUserType)
165 {
166     WebBrowser *This = OLEOBJ_THIS(iface);
167     TRACE("(%p, %ld, %p)\n", This, dwFormOfType, pszUserType);
168     return OleRegGetUserType(&CLSID_WebBrowser, dwFormOfType, pszUserType);
169 }
170
171 static HRESULT WINAPI OleObject_SetExtent(IOleObject *iface, DWORD dwDrawAspect, SIZEL *psizel)
172 {
173     WebBrowser *This = OLEOBJ_THIS(iface);
174     FIXME("(%p)->(%lx %p)\n", This, dwDrawAspect, psizel);
175     return E_NOTIMPL;
176 }
177
178 static HRESULT WINAPI OleObject_GetExtent(IOleObject *iface, DWORD dwDrawAspect, SIZEL *psizel)
179 {
180     WebBrowser *This = OLEOBJ_THIS(iface);
181     FIXME("(%p)->(%lx, %p)\n", This, dwDrawAspect, psizel);
182     return E_NOTIMPL;
183 }
184
185 static HRESULT WINAPI OleObject_Advise(IOleObject *iface, IAdviseSink *pAdvSink,
186         DWORD* pdwConnection)
187 {
188     WebBrowser *This = OLEOBJ_THIS(iface);
189     FIXME("(%p)->(%p, %p)\n", This, pAdvSink, pdwConnection);
190     return E_NOTIMPL;
191 }
192
193 static HRESULT WINAPI OleObject_Unadvise(IOleObject *iface, DWORD dwConnection)
194 {
195     WebBrowser *This = OLEOBJ_THIS(iface);
196     FIXME("(%p)->(%ld)\n", This, dwConnection);
197     return E_NOTIMPL;
198 }
199
200 static HRESULT WINAPI OleObject_EnumAdvise(IOleObject *iface, IEnumSTATDATA **ppenumAdvise)
201 {
202     WebBrowser *This = OLEOBJ_THIS(iface);
203     FIXME("(%p)->(%p)\n", This, ppenumAdvise);
204     return S_OK;
205 }
206
207 static HRESULT WINAPI OleObject_GetMiscStatus(IOleObject *iface, DWORD dwAspect, DWORD *pdwStatus)
208 {
209     WebBrowser *This = OLEOBJ_THIS(iface);
210     HRESULT hres;
211
212     TRACE("(%p)->(%lx, %p)\n", This, dwAspect, pdwStatus);
213
214     hres = OleRegGetMiscStatus(&CLSID_WebBrowser, dwAspect, pdwStatus);
215
216     if (FAILED(hres))
217         *pdwStatus = 0;
218
219     return S_OK;
220 }
221
222 static HRESULT WINAPI OleObject_SetColorScheme(IOleObject *iface, LOGPALETTE* pLogpal)
223 {
224     WebBrowser *This = OLEOBJ_THIS(iface);
225     FIXME("(%p)->(%p)\n", This, pLogpal);
226     return E_NOTIMPL;
227 }
228
229 #undef OLEOBJ_THIS
230
231 static const IOleObjectVtbl OleObjectVtbl =
232 {
233     OleObject_QueryInterface,
234     OleObject_AddRef,
235     OleObject_Release,
236     OleObject_SetClientSite,
237     OleObject_GetClientSite,
238     OleObject_SetHostNames,
239     OleObject_Close,
240     OleObject_SetMoniker,
241     OleObject_GetMoniker,
242     OleObject_InitFromData,
243     OleObject_GetClipboardData,
244     OleObject_DoVerb,
245     OleObject_EnumVerbs,
246     OleObject_Update,
247     OleObject_IsUpToDate,
248     OleObject_GetUserClassID,
249     OleObject_GetUserType,
250     OleObject_SetExtent,
251     OleObject_GetExtent,
252     OleObject_Advise,
253     OleObject_Unadvise,
254     OleObject_EnumAdvise,
255     OleObject_GetMiscStatus,
256     OleObject_SetColorScheme
257 };
258
259 /**********************************************************************
260  * Implement the IOleInPlaceObject interface
261  */
262
263 #define INPLACEOBJ_THIS(iface) DEFINE_THIS(WebBrowser, OleInPlaceObject, iface)
264
265 static HRESULT WINAPI OleInPlaceObject_QueryInterface(IOleInPlaceObject *iface,
266         REFIID riid, LPVOID *ppobj)
267 {
268     WebBrowser *This = INPLACEOBJ_THIS(iface);
269     return IWebBrowser_QueryInterface(WEBBROWSER(This), riid, ppobj);
270 }
271
272 static ULONG WINAPI OleInPlaceObject_AddRef(IOleInPlaceObject *iface)
273 {
274     WebBrowser *This = INPLACEOBJ_THIS(iface);
275     return IWebBrowser_AddRef(WEBBROWSER(This));
276 }
277
278 static ULONG WINAPI OleInPlaceObject_Release(IOleInPlaceObject *iface)
279 {
280     WebBrowser *This = INPLACEOBJ_THIS(iface);
281     return IWebBrowser_Release(WEBBROWSER(This));
282 }
283
284 static HRESULT WINAPI OleInPlaceObject_GetWindow(IOleInPlaceObject *iface, HWND* phwnd)
285 {
286     WebBrowser *This = INPLACEOBJ_THIS(iface);
287
288     FIXME("(%p)->(%p)\n", This, phwnd);
289
290 #if 0
291     /* Create a fake window to fool MFC into believing that we actually
292      * have an implemented browser control.  Avoids the assertion.
293      */
294     HWND hwnd;
295     hwnd = CreateWindowA("BUTTON", "Web Control",
296                         WS_HSCROLL | WS_VSCROLL | WS_OVERLAPPEDWINDOW,
297                         CW_USEDEFAULT, CW_USEDEFAULT, 600,
298                         400, NULL, NULL, NULL, NULL);
299
300     *phwnd = hwnd;
301     TRACE ("Returning hwnd = %d\n", hwnd);
302 #endif
303
304     return S_OK;
305 }
306
307 static HRESULT WINAPI OleInPlaceObject_ContextSensitiveHelp(IOleInPlaceObject *iface,
308         BOOL fEnterMode)
309 {
310     WebBrowser *This = INPLACEOBJ_THIS(iface);
311     FIXME("(%p)->(%x)\n", This, fEnterMode);
312     return E_NOTIMPL;
313 }
314
315 static HRESULT WINAPI OleInPlaceObject_InPlaceDeactivate(IOleInPlaceObject *iface)
316 {
317     WebBrowser *This = INPLACEOBJ_THIS(iface);
318     FIXME("(%p)\n", This);
319     return E_NOTIMPL;
320 }
321
322 static HRESULT WINAPI OleInPlaceObject_UIDeactivate(IOleInPlaceObject *iface)
323 {
324     WebBrowser *This = INPLACEOBJ_THIS(iface);
325     FIXME("(%p)\n", This);
326     return E_NOTIMPL;
327 }
328
329 static HRESULT WINAPI OleInPlaceObject_SetObjectRects(IOleInPlaceObject *iface,
330         LPCRECT lprcPosRect, LPCRECT lprcClipRect)
331 {
332     WebBrowser *This = INPLACEOBJ_THIS(iface);
333     FIXME("(%p)->(%p %p)\n", This, lprcPosRect, lprcClipRect);
334     return E_NOTIMPL;
335 }
336
337 static HRESULT WINAPI OleInPlaceObject_ReactivateAndUndo(IOleInPlaceObject *iface)
338 {
339     WebBrowser *This = INPLACEOBJ_THIS(iface);
340     FIXME("(%p)\n", This);
341     return E_NOTIMPL;
342 }
343
344 #undef INPLACEOBJ_THIS
345
346 static const IOleInPlaceObjectVtbl OleInPlaceObjectVtbl =
347 {
348     OleInPlaceObject_QueryInterface,
349     OleInPlaceObject_AddRef,
350     OleInPlaceObject_Release,
351     OleInPlaceObject_GetWindow,
352     OleInPlaceObject_ContextSensitiveHelp,
353     OleInPlaceObject_InPlaceDeactivate,
354     OleInPlaceObject_UIDeactivate,
355     OleInPlaceObject_SetObjectRects,
356     OleInPlaceObject_ReactivateAndUndo
357 };
358
359 /**********************************************************************
360  * Implement the IOleControl interface
361  */
362
363 #define CONTROL_THIS(iface) DEFINE_THIS(WebBrowser, OleControl, iface)
364
365 static HRESULT WINAPI OleControl_QueryInterface(IOleControl *iface,
366         REFIID riid, LPVOID *ppobj)
367 {
368     WebBrowser *This = CONTROL_THIS(iface);
369     return IWebBrowser_QueryInterface(WEBBROWSER(This), riid, ppobj);
370 }
371
372 static ULONG WINAPI OleControl_AddRef(IOleControl *iface)
373 {
374     WebBrowser *This = CONTROL_THIS(iface);
375     return IWebBrowser_AddRef(WEBBROWSER(This));
376 }
377
378 static ULONG WINAPI OleControl_Release(IOleControl *iface)
379 {
380     WebBrowser *This = CONTROL_THIS(iface);
381     return IWebBrowser_Release(WEBBROWSER(This));
382 }
383
384 static HRESULT WINAPI OleControl_GetControlInfo(IOleControl *iface, LPCONTROLINFO pCI)
385 {
386     WebBrowser *This = CONTROL_THIS(iface);
387     FIXME("(%p)->(%p)\n", This, pCI);
388     return E_NOTIMPL;
389 }
390
391 static HRESULT WINAPI OleControl_OnMnemonic(IOleControl *iface, struct tagMSG *pMsg)
392 {
393     WebBrowser *This = CONTROL_THIS(iface);
394     FIXME("(%p)->(%p)\n", This, pMsg);
395     return E_NOTIMPL;
396 }
397
398 static HRESULT WINAPI OleControl_OnAmbientPropertyChange(IOleControl *iface, DISPID dispID)
399 {
400     WebBrowser *This = CONTROL_THIS(iface);
401     FIXME("(%p)->(%ld)\n", This, dispID);
402     return E_NOTIMPL;
403 }
404
405 static HRESULT WINAPI OleControl_FreezeEvents(IOleControl *iface, BOOL bFreeze)
406 {
407     WebBrowser *This = CONTROL_THIS(iface);
408     FIXME("(%p)->(%x)\n", This, bFreeze);
409     return E_NOTIMPL;
410 }
411
412 #undef CONTROL_THIS
413
414 static const IOleControlVtbl OleControlVtbl =
415 {
416     OleControl_QueryInterface,
417     OleControl_AddRef,
418     OleControl_Release,
419     OleControl_GetControlInfo,
420     OleControl_OnMnemonic,
421     OleControl_OnAmbientPropertyChange,
422     OleControl_FreezeEvents
423 };
424
425 void WebBrowser_OleObject_Init(WebBrowser *This)
426 {
427     This->lpOleObjectVtbl        = &OleObjectVtbl;
428     This->lpOleInPlaceObjectVtbl = &OleInPlaceObjectVtbl;
429     This->lpOleControlVtbl       = &OleControlVtbl;
430 }