Release 20050930.
[wine/gsoc-2012-control.git] / dlls / shdocvw / oleobject.c
blob8fb4a48ceef878836084597b7e9527705aa085b7
1 /*
2 * Implementation of IOleObject interfaces for WebBrowser control
4 * - IOleObject
5 * - IOleInPlaceObject
6 * - IOleControl
8 * Copyright 2001 John R. Sheets (for CodeWeavers)
9 * Copyright 2005 Jacek Caban
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.
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.
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
26 #include <string.h>
27 #include "wine/debug.h"
28 #include "shdocvw.h"
30 WINE_DEFAULT_DEBUG_CHANNEL(shdocvw);
32 /**********************************************************************
33 * Implement the IOleObject interface for the WebBrowser control
36 #define OLEOBJ_THIS(iface) DEFINE_THIS(WebBrowser, OleObject, iface)
38 static HRESULT WINAPI OleObject_QueryInterface(IOleObject *iface, REFIID riid, void **ppv)
40 WebBrowser *This = OLEOBJ_THIS(iface);
41 return IWebBrowser_QueryInterface(WEBBROWSER(This), riid, ppv);
44 static ULONG WINAPI OleObject_AddRef(IOleObject *iface)
46 WebBrowser *This = OLEOBJ_THIS(iface);
47 return IWebBrowser_AddRef(WEBBROWSER(This));
50 static ULONG WINAPI OleObject_Release(IOleObject *iface)
52 WebBrowser *This = OLEOBJ_THIS(iface);
53 return IWebBrowser_Release(WEBBROWSER(This));
56 static HRESULT WINAPI OleObject_SetClientSite(IOleObject *iface, LPOLECLIENTSITE pClientSite)
58 WebBrowser *This = OLEOBJ_THIS(iface);
60 TRACE("(%p)->(%p)\n", This, pClientSite);
62 if(This->client == pClientSite)
63 return S_OK;
65 if(This->client)
66 IOleClientSite_Release(This->client);
68 if(pClientSite)
69 IOleClientSite_AddRef(pClientSite);
71 This->client = pClientSite;
72 return S_OK;
75 static HRESULT WINAPI OleObject_GetClientSite(IOleObject *iface, LPOLECLIENTSITE *ppClientSite)
77 WebBrowser *This = OLEOBJ_THIS(iface);
79 TRACE("(%p)->(%p)\n", This, ppClientSite);
81 if(!ppClientSite)
82 return E_INVALIDARG;
84 if(This->client)
85 IOleClientSite_AddRef(This->client);
86 *ppClientSite = This->client;
88 return S_OK;
91 static HRESULT WINAPI OleObject_SetHostNames(IOleObject *iface, LPCOLESTR szContainerApp,
92 LPCOLESTR szContainerObj)
94 WebBrowser *This = OLEOBJ_THIS(iface);
95 FIXME("(%p)->(%s, %s)\n", This, debugstr_w(szContainerApp), debugstr_w(szContainerObj));
96 return E_NOTIMPL;
99 static HRESULT WINAPI OleObject_Close(IOleObject *iface, DWORD dwSaveOption)
101 WebBrowser *This = OLEOBJ_THIS(iface);
102 FIXME("(%p)->(%ld)\n", This, dwSaveOption);
103 return E_NOTIMPL;
106 static HRESULT WINAPI OleObject_SetMoniker(IOleObject *iface, DWORD dwWhichMoniker, IMoniker* pmk)
108 WebBrowser *This = OLEOBJ_THIS(iface);
109 FIXME("(%p)->(%ld, %p)\n", This, dwWhichMoniker, pmk);
110 return E_NOTIMPL;
113 static HRESULT WINAPI OleObject_GetMoniker(IOleObject *iface, DWORD dwAssign,
114 DWORD dwWhichMoniker, LPMONIKER *ppmk)
116 WebBrowser *This = OLEOBJ_THIS(iface);
117 FIXME("(%p)->(%ld, %ld, %p)\n", This, dwAssign, dwWhichMoniker, ppmk);
118 return E_NOTIMPL;
121 static HRESULT WINAPI OleObject_InitFromData(IOleObject *iface, LPDATAOBJECT pDataObject,
122 BOOL fCreation, DWORD dwReserved)
124 WebBrowser *This = OLEOBJ_THIS(iface);
125 FIXME("(%p)->(%p, %d, %ld)\n", This, pDataObject, fCreation, dwReserved);
126 return E_NOTIMPL;
129 static HRESULT WINAPI OleObject_GetClipboardData(IOleObject *iface, DWORD dwReserved,
130 LPDATAOBJECT *ppDataObject)
132 WebBrowser *This = OLEOBJ_THIS(iface);
133 FIXME("(%p)->(%ld, %p)\n", This, dwReserved, ppDataObject);
134 return E_NOTIMPL;
137 static HRESULT WINAPI OleObject_DoVerb(IOleObject *iface, LONG iVerb, struct tagMSG* lpmsg,
138 LPOLECLIENTSITE pActiveSite, LONG lindex, HWND hwndParent, LPCRECT lprcPosRect)
140 WebBrowser *This = OLEOBJ_THIS(iface);
141 FIXME("(%p)->(%ld %p %p %ld %p %p)\n", This, iVerb, lpmsg, pActiveSite, lindex, hwndParent,
142 lprcPosRect);
143 switch (iVerb)
145 case OLEIVERB_INPLACEACTIVATE:
146 FIXME ("stub for OLEIVERB_INPLACEACTIVATE\n");
147 break;
148 case OLEIVERB_HIDE:
149 FIXME ("stub for OLEIVERB_HIDE\n");
150 break;
153 return E_NOTIMPL;
156 static HRESULT WINAPI OleObject_EnumVerbs(IOleObject *iface, IEnumOLEVERB **ppEnumOleVerb)
158 WebBrowser *This = OLEOBJ_THIS(iface);
159 TRACE("(%p)->(%p)\n", This, ppEnumOleVerb);
160 return OleRegEnumVerbs(&CLSID_WebBrowser, ppEnumOleVerb);
163 static HRESULT WINAPI OleObject_Update(IOleObject *iface)
165 WebBrowser *This = OLEOBJ_THIS(iface);
166 FIXME("(%p)\n", This);
167 return E_NOTIMPL;
170 static HRESULT WINAPI OleObject_IsUpToDate(IOleObject *iface)
172 WebBrowser *This = OLEOBJ_THIS(iface);
173 FIXME("(%p)\n", This);
174 return E_NOTIMPL;
177 static HRESULT WINAPI OleObject_GetUserClassID(IOleObject *iface, CLSID* pClsid)
179 WebBrowser *This = OLEOBJ_THIS(iface);
180 FIXME("(%p)->(%p)\n", This, pClsid);
181 return E_NOTIMPL;
184 static HRESULT WINAPI OleObject_GetUserType(IOleObject *iface, DWORD dwFormOfType,
185 LPOLESTR* pszUserType)
187 WebBrowser *This = OLEOBJ_THIS(iface);
188 TRACE("(%p, %ld, %p)\n", This, dwFormOfType, pszUserType);
189 return OleRegGetUserType(&CLSID_WebBrowser, dwFormOfType, pszUserType);
192 static HRESULT WINAPI OleObject_SetExtent(IOleObject *iface, DWORD dwDrawAspect, SIZEL *psizel)
194 WebBrowser *This = OLEOBJ_THIS(iface);
195 FIXME("(%p)->(%lx %p)\n", This, dwDrawAspect, psizel);
196 return E_NOTIMPL;
199 static HRESULT WINAPI OleObject_GetExtent(IOleObject *iface, DWORD dwDrawAspect, SIZEL *psizel)
201 WebBrowser *This = OLEOBJ_THIS(iface);
202 FIXME("(%p)->(%lx, %p)\n", This, dwDrawAspect, psizel);
203 return E_NOTIMPL;
206 static HRESULT WINAPI OleObject_Advise(IOleObject *iface, IAdviseSink *pAdvSink,
207 DWORD* pdwConnection)
209 WebBrowser *This = OLEOBJ_THIS(iface);
210 FIXME("(%p)->(%p, %p)\n", This, pAdvSink, pdwConnection);
211 return E_NOTIMPL;
214 static HRESULT WINAPI OleObject_Unadvise(IOleObject *iface, DWORD dwConnection)
216 WebBrowser *This = OLEOBJ_THIS(iface);
217 FIXME("(%p)->(%ld)\n", This, dwConnection);
218 return E_NOTIMPL;
221 static HRESULT WINAPI OleObject_EnumAdvise(IOleObject *iface, IEnumSTATDATA **ppenumAdvise)
223 WebBrowser *This = OLEOBJ_THIS(iface);
224 FIXME("(%p)->(%p)\n", This, ppenumAdvise);
225 return S_OK;
228 static HRESULT WINAPI OleObject_GetMiscStatus(IOleObject *iface, DWORD dwAspect, DWORD *pdwStatus)
230 WebBrowser *This = OLEOBJ_THIS(iface);
231 HRESULT hres;
233 TRACE("(%p)->(%lx, %p)\n", This, dwAspect, pdwStatus);
235 hres = OleRegGetMiscStatus(&CLSID_WebBrowser, dwAspect, pdwStatus);
237 if (FAILED(hres))
238 *pdwStatus = 0;
240 return S_OK;
243 static HRESULT WINAPI OleObject_SetColorScheme(IOleObject *iface, LOGPALETTE* pLogpal)
245 WebBrowser *This = OLEOBJ_THIS(iface);
246 FIXME("(%p)->(%p)\n", This, pLogpal);
247 return E_NOTIMPL;
250 #undef OLEOBJ_THIS
252 static const IOleObjectVtbl OleObjectVtbl =
254 OleObject_QueryInterface,
255 OleObject_AddRef,
256 OleObject_Release,
257 OleObject_SetClientSite,
258 OleObject_GetClientSite,
259 OleObject_SetHostNames,
260 OleObject_Close,
261 OleObject_SetMoniker,
262 OleObject_GetMoniker,
263 OleObject_InitFromData,
264 OleObject_GetClipboardData,
265 OleObject_DoVerb,
266 OleObject_EnumVerbs,
267 OleObject_Update,
268 OleObject_IsUpToDate,
269 OleObject_GetUserClassID,
270 OleObject_GetUserType,
271 OleObject_SetExtent,
272 OleObject_GetExtent,
273 OleObject_Advise,
274 OleObject_Unadvise,
275 OleObject_EnumAdvise,
276 OleObject_GetMiscStatus,
277 OleObject_SetColorScheme
280 /**********************************************************************
281 * Implement the IOleInPlaceObject interface
284 #define INPLACEOBJ_THIS(iface) DEFINE_THIS(WebBrowser, OleInPlaceObject, iface)
286 static HRESULT WINAPI OleInPlaceObject_QueryInterface(IOleInPlaceObject *iface,
287 REFIID riid, LPVOID *ppobj)
289 WebBrowser *This = INPLACEOBJ_THIS(iface);
290 return IWebBrowser_QueryInterface(WEBBROWSER(This), riid, ppobj);
293 static ULONG WINAPI OleInPlaceObject_AddRef(IOleInPlaceObject *iface)
295 WebBrowser *This = INPLACEOBJ_THIS(iface);
296 return IWebBrowser_AddRef(WEBBROWSER(This));
299 static ULONG WINAPI OleInPlaceObject_Release(IOleInPlaceObject *iface)
301 WebBrowser *This = INPLACEOBJ_THIS(iface);
302 return IWebBrowser_Release(WEBBROWSER(This));
305 static HRESULT WINAPI OleInPlaceObject_GetWindow(IOleInPlaceObject *iface, HWND* phwnd)
307 WebBrowser *This = INPLACEOBJ_THIS(iface);
309 FIXME("(%p)->(%p)\n", This, phwnd);
311 #if 0
312 /* Create a fake window to fool MFC into believing that we actually
313 * have an implemented browser control. Avoids the assertion.
315 HWND hwnd;
316 hwnd = CreateWindowA("BUTTON", "Web Control",
317 WS_HSCROLL | WS_VSCROLL | WS_OVERLAPPEDWINDOW,
318 CW_USEDEFAULT, CW_USEDEFAULT, 600,
319 400, NULL, NULL, NULL, NULL);
321 *phwnd = hwnd;
322 TRACE ("Returning hwnd = %d\n", hwnd);
323 #endif
325 return S_OK;
328 static HRESULT WINAPI OleInPlaceObject_ContextSensitiveHelp(IOleInPlaceObject *iface,
329 BOOL fEnterMode)
331 WebBrowser *This = INPLACEOBJ_THIS(iface);
332 FIXME("(%p)->(%x)\n", This, fEnterMode);
333 return E_NOTIMPL;
336 static HRESULT WINAPI OleInPlaceObject_InPlaceDeactivate(IOleInPlaceObject *iface)
338 WebBrowser *This = INPLACEOBJ_THIS(iface);
339 FIXME("(%p)\n", This);
340 return E_NOTIMPL;
343 static HRESULT WINAPI OleInPlaceObject_UIDeactivate(IOleInPlaceObject *iface)
345 WebBrowser *This = INPLACEOBJ_THIS(iface);
346 FIXME("(%p)\n", This);
347 return E_NOTIMPL;
350 static HRESULT WINAPI OleInPlaceObject_SetObjectRects(IOleInPlaceObject *iface,
351 LPCRECT lprcPosRect, LPCRECT lprcClipRect)
353 WebBrowser *This = INPLACEOBJ_THIS(iface);
354 FIXME("(%p)->(%p %p)\n", This, lprcPosRect, lprcClipRect);
355 return E_NOTIMPL;
358 static HRESULT WINAPI OleInPlaceObject_ReactivateAndUndo(IOleInPlaceObject *iface)
360 WebBrowser *This = INPLACEOBJ_THIS(iface);
361 FIXME("(%p)\n", This);
362 return E_NOTIMPL;
365 #undef INPLACEOBJ_THIS
367 static const IOleInPlaceObjectVtbl OleInPlaceObjectVtbl =
369 OleInPlaceObject_QueryInterface,
370 OleInPlaceObject_AddRef,
371 OleInPlaceObject_Release,
372 OleInPlaceObject_GetWindow,
373 OleInPlaceObject_ContextSensitiveHelp,
374 OleInPlaceObject_InPlaceDeactivate,
375 OleInPlaceObject_UIDeactivate,
376 OleInPlaceObject_SetObjectRects,
377 OleInPlaceObject_ReactivateAndUndo
380 /**********************************************************************
381 * Implement the IOleControl interface
384 #define CONTROL_THIS(iface) DEFINE_THIS(WebBrowser, OleControl, iface)
386 static HRESULT WINAPI OleControl_QueryInterface(IOleControl *iface,
387 REFIID riid, LPVOID *ppobj)
389 WebBrowser *This = CONTROL_THIS(iface);
390 return IWebBrowser_QueryInterface(WEBBROWSER(This), riid, ppobj);
393 static ULONG WINAPI OleControl_AddRef(IOleControl *iface)
395 WebBrowser *This = CONTROL_THIS(iface);
396 return IWebBrowser_AddRef(WEBBROWSER(This));
399 static ULONG WINAPI OleControl_Release(IOleControl *iface)
401 WebBrowser *This = CONTROL_THIS(iface);
402 return IWebBrowser_Release(WEBBROWSER(This));
405 static HRESULT WINAPI OleControl_GetControlInfo(IOleControl *iface, LPCONTROLINFO pCI)
407 WebBrowser *This = CONTROL_THIS(iface);
408 FIXME("(%p)->(%p)\n", This, pCI);
409 return E_NOTIMPL;
412 static HRESULT WINAPI OleControl_OnMnemonic(IOleControl *iface, struct tagMSG *pMsg)
414 WebBrowser *This = CONTROL_THIS(iface);
415 FIXME("(%p)->(%p)\n", This, pMsg);
416 return E_NOTIMPL;
419 static HRESULT WINAPI OleControl_OnAmbientPropertyChange(IOleControl *iface, DISPID dispID)
421 WebBrowser *This = CONTROL_THIS(iface);
422 FIXME("(%p)->(%ld)\n", This, dispID);
423 return E_NOTIMPL;
426 static HRESULT WINAPI OleControl_FreezeEvents(IOleControl *iface, BOOL bFreeze)
428 WebBrowser *This = CONTROL_THIS(iface);
429 FIXME("(%p)->(%x)\n", This, bFreeze);
430 return E_NOTIMPL;
433 #undef CONTROL_THIS
435 static const IOleControlVtbl OleControlVtbl =
437 OleControl_QueryInterface,
438 OleControl_AddRef,
439 OleControl_Release,
440 OleControl_GetControlInfo,
441 OleControl_OnMnemonic,
442 OleControl_OnAmbientPropertyChange,
443 OleControl_FreezeEvents
446 void WebBrowser_OleObject_Init(WebBrowser *This)
448 This->lpOleObjectVtbl = &OleObjectVtbl;
449 This->lpOleInPlaceObjectVtbl = &OleInPlaceObjectVtbl;
450 This->lpOleControlVtbl = &OleControlVtbl;
452 This->client = NULL;