~ [ source navigation ] ~ [ diff markup ] ~ [ identifier search ] ~ [ freetext search ] ~ [ file search ] ~

Wine Cross Reference
wine/dlls/shdocvw/oleobject.c

Version: ~ [ wine-1.1.33 ] ~ [ wine-1.1.32 ] ~ [ wine-1.1.31 ] ~ [ wine-1.1.30 ] ~ [ wine-1.1.29 ] ~ [ wine-1.1.28 ] ~ [ wine-1.1.27 ] ~ [ wine-1.1.26 ] ~ [ wine-1.1.25 ] ~ [ wine-1.1.24 ] ~ [ wine-1.1.23 ] ~ [ wine-1.1.22 ] ~ [ wine-1.1.21 ] ~ [ wine-1.1.20 ] ~ [ wine-1.1.19 ] ~ [ wine-1.1.18 ] ~ [ wine-1.1.17 ] ~ [ wine-1.1.16 ] ~ [ wine-1.1.15 ] ~ [ wine-1.1.14 ] ~ [ wine-1.1.13 ] ~ [ wine-1.1.12 ] ~ [ wine-1.1.11 ] ~ [ wine-1.1.10 ] ~ [ wine-1.1.9 ] ~ [ wine-1.1.8 ] ~ [ wine-1.1.7 ] ~ [ wine-1.0.1 ] ~ [ wine-1.1.6 ] ~ [ wine-1.1.5 ] ~ [ wine-1.1.4 ] ~ [ wine-1.1.3 ] ~ [ wine-1.1.2 ] ~ [ wine-1.1.1 ] ~ [ wine-1.1.0 ] ~ [ wine-1.0 ] ~

  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., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
 24  */
 25 
 26 #include <string.h>
 27 #include "wine/debug.h"
 28 #include "shdocvw.h"
 29 #include "htiframe.h"
 30 #include "idispids.h"
 31 
 32 WINE_DEFAULT_DEBUG_CHANNEL(shdocvw);
 33 
 34 /* shlwapi.dll */
 35 HWND WINAPI SHSetParentHwnd(HWND hWnd, HWND hWndParent);
 36 
 37 static ATOM shell_embedding_atom = 0;
 38 
 39 static LRESULT resize_window(WebBrowser *This, LONG width, LONG height)
 40 {
 41     if(This->doc_host.hwnd)
 42         SetWindowPos(This->doc_host.hwnd, NULL, 0, 0, width, height,
 43                      SWP_NOZORDER | SWP_NOACTIVATE);
 44 
 45     return 0;
 46 }
 47 
 48 static LRESULT WINAPI shell_embedding_proc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)
 49 {
 50     WebBrowser *This;
 51 
 52     static const WCHAR wszTHIS[] = {'T','H','I','S',0};
 53 
 54     if(msg == WM_CREATE) {
 55         This = *(WebBrowser**)lParam;
 56         SetPropW(hwnd, wszTHIS, This);
 57     }else {
 58         This = GetPropW(hwnd, wszTHIS);
 59     }
 60 
 61     switch(msg) {
 62     case WM_SIZE:
 63         return resize_window(This, LOWORD(lParam), HIWORD(lParam));
 64     case WM_DOCHOSTTASK:
 65         return process_dochost_task(&This->doc_host, lParam);
 66     }
 67 
 68     return DefWindowProcW(hwnd, msg, wParam, lParam);
 69 }
 70 
 71 static void create_shell_embedding_hwnd(WebBrowser *This)
 72 {
 73     IOleInPlaceSite *inplace;
 74     HWND parent = NULL;
 75     HRESULT hres;
 76 
 77     static const WCHAR wszShellEmbedding[] =
 78         {'S','h','e','l','l',' ','E','m','b','e','d','d','i','n','g',0};
 79 
 80     if(!shell_embedding_atom) {
 81         static WNDCLASSEXW wndclass = {
 82             sizeof(wndclass),
 83             CS_DBLCLKS,
 84             shell_embedding_proc,
 85             0, 0 /* native uses 8 */, NULL, NULL, NULL,
 86             (HBRUSH)(COLOR_WINDOW + 1), NULL,
 87             wszShellEmbedding,
 88             NULL
 89         };
 90         wndclass.hInstance = shdocvw_hinstance;
 91 
 92         RegisterClassExW(&wndclass);
 93     }
 94 
 95     hres = IOleClientSite_QueryInterface(This->client, &IID_IOleInPlaceSite, (void**)&inplace);
 96     if(SUCCEEDED(hres)) {
 97         IOleInPlaceSite_GetWindow(inplace, &parent);
 98         IOleInPlaceSite_Release(inplace);
 99     }
100 
101     This->doc_host.frame_hwnd = This->shell_embedding_hwnd = CreateWindowExW(
102             WS_EX_WINDOWEDGE,
103             wszShellEmbedding, wszShellEmbedding,
104             WS_CLIPSIBLINGS | WS_CLIPCHILDREN
105             | (parent ? WS_CHILD | WS_TABSTOP : WS_POPUP | WS_MAXIMIZEBOX),
106             0, 0, 0, 0, parent,
107             NULL, shdocvw_hinstance, This);
108 
109     TRACE("parent=%p hwnd=%p\n", parent, This->shell_embedding_hwnd);
110 }
111 
112 static HRESULT activate_inplace(WebBrowser *This, IOleClientSite *active_site)
113 {
114     HWND parent_hwnd;
115     HRESULT hres;
116 
117     if(This->inplace)
118         return S_OK;
119 
120     if(!active_site)
121         return E_INVALIDARG;
122 
123     hres = IOleClientSite_QueryInterface(active_site, &IID_IOleInPlaceSite,
124                                          (void**)&This->inplace);
125     if(FAILED(hres)) {
126         WARN("Could not get IOleInPlaceSite\n");
127         return hres;
128     }
129 
130     hres = IOleInPlaceSite_CanInPlaceActivate(This->inplace);
131     if(hres != S_OK) {
132         WARN("CanInPlaceActivate returned: %08x\n", hres);
133         IOleInPlaceSite_Release(This->inplace);
134         return E_FAIL;
135     }
136 
137     hres = IOleInPlaceSite_GetWindow(This->inplace, &parent_hwnd);
138     if(SUCCEEDED(hres))
139         SHSetParentHwnd(This->shell_embedding_hwnd, parent_hwnd);
140 
141     IOleInPlaceSite_OnInPlaceActivate(This->inplace);
142 
143     IOleInPlaceSite_GetWindowContext(This->inplace, &This->doc_host.frame, &This->uiwindow,
144                                      &This->pos_rect, &This->clip_rect,
145                                      &This->frameinfo);
146 
147     SetWindowPos(This->shell_embedding_hwnd, NULL,
148                  This->pos_rect.left, This->pos_rect.top,
149                  This->pos_rect.right-This->pos_rect.left,
150                  This->pos_rect.bottom-This->pos_rect.top,
151                  SWP_NOZORDER | SWP_SHOWWINDOW);
152 
153     if(This->client) {
154         IOleClientSite_ShowObject(This->client);
155         IOleClientSite_GetContainer(This->client, &This->container);
156     }
157 
158     if(This->doc_host.frame)
159         IOleInPlaceFrame_GetWindow(This->doc_host.frame, &This->frame_hwnd);
160 
161     return S_OK;
162 }
163 
164 static HRESULT activate_ui(WebBrowser *This, IOleClientSite *active_site)
165 {
166     HRESULT hres;
167 
168     static const WCHAR wszitem[] = {'i','t','e','m',0};
169 
170     if(This->inplace)
171     {
172         if(This->shell_embedding_hwnd)
173             ShowWindow(This->shell_embedding_hwnd, SW_SHOW);
174         return S_OK;
175     }
176 
177     hres = activate_inplace(This, active_site);
178     if(FAILED(hres))
179         return hres;
180 
181     IOleInPlaceSite_OnUIActivate(This->inplace);
182 
183     if(This->doc_host.frame)
184         IOleInPlaceFrame_SetActiveObject(This->doc_host.frame, ACTIVEOBJ(This), wszitem);
185     if(This->uiwindow)
186         IOleInPlaceUIWindow_SetActiveObject(This->uiwindow, ACTIVEOBJ(This), wszitem);
187 
188     if(This->doc_host.frame)
189         IOleInPlaceFrame_SetMenu(This->doc_host.frame, NULL, NULL, This->shell_embedding_hwnd);
190 
191     SetFocus(This->shell_embedding_hwnd);
192 
193     return S_OK;
194 }
195 
196 static HRESULT get_client_disp_property(IOleClientSite *client, DISPID dispid, VARIANT *res)
197 {
198     IDispatch *disp = NULL;
199     DISPPARAMS dispparams = {NULL, 0};
200     HRESULT hres;
201 
202     VariantInit(res);
203 
204     if(!client)
205         return S_OK;
206 
207     hres = IOleClientSite_QueryInterface(client, &IID_IDispatch, (void**)&disp);
208     if(FAILED(hres)) {
209         TRACE("Could not get IDispatch\n");
210         return hres;
211     }
212 
213     hres = IDispatch_Invoke(disp, dispid, &IID_NULL, LOCALE_SYSTEM_DEFAULT,
214             DISPATCH_PROPERTYGET, &dispparams, res, NULL, NULL);
215 
216     IDispatch_Release(disp);
217 
218     return hres;
219 }
220 
221 static HRESULT on_offlineconnected_change(WebBrowser *This)
222 {
223     VARIANT offline;
224 
225     get_client_disp_property(This->client, DISPID_AMBIENT_OFFLINEIFNOTCONNECTED, &offline);
226 
227     if(V_VT(&offline) == VT_BOOL)
228         IWebBrowser2_put_Offline(WEBBROWSER2(This), V_BOOL(&offline));
229     else if(V_VT(&offline) != VT_EMPTY)
230         WARN("wrong V_VT(silent) %d\n", V_VT(&offline));
231 
232     return S_OK;
233 }
234 
235 static HRESULT on_silent_change(WebBrowser *This)
236 {
237     VARIANT silent;
238 
239     get_client_disp_property(This->client, DISPID_AMBIENT_SILENT, &silent);
240 
241     if(V_VT(&silent) == VT_BOOL)
242         IWebBrowser2_put_Silent(WEBBROWSER2(This), V_BOOL(&silent));
243     else if(V_VT(&silent) != VT_EMPTY)
244         WARN("wrong V_VT(silent) %d\n", V_VT(&silent));
245 
246     return S_OK;
247 }
248 
249 /**********************************************************************
250  * Implement the IOleObject interface for the WebBrowser control
251  */
252 
253 #define OLEOBJ_THIS(iface) DEFINE_THIS(WebBrowser, OleObject, iface)
254 
255 static HRESULT WINAPI OleObject_QueryInterface(IOleObject *iface, REFIID riid, void **ppv)
256 {
257     WebBrowser *This = OLEOBJ_THIS(iface);
258     return IWebBrowser_QueryInterface(WEBBROWSER(This), riid, ppv);
259 }
260 
261 static ULONG WINAPI OleObject_AddRef(IOleObject *iface)
262 {
263     WebBrowser *This = OLEOBJ_THIS(iface);
264     return IWebBrowser_AddRef(WEBBROWSER(This));
265 }
266 
267 static ULONG WINAPI OleObject_Release(IOleObject *iface)
268 {
269     WebBrowser *This = OLEOBJ_THIS(iface);
270     return IWebBrowser_Release(WEBBROWSER(This));
271 }
272 
273 static HRESULT WINAPI OleObject_SetClientSite(IOleObject *iface, LPOLECLIENTSITE pClientSite)
274 {
275     WebBrowser *This = OLEOBJ_THIS(iface);
276     IOleContainer *container;
277     HRESULT hres;
278 
279     TRACE("(%p)->(%p)\n", This, pClientSite);
280 
281     if(This->client == pClientSite)
282         return S_OK;
283 
284     if(This->doc_host.hwnd) {
285         DestroyWindow(This->doc_host.hwnd);
286         This->doc_host.hwnd = NULL;
287     }
288     if(This->shell_embedding_hwnd) {
289         DestroyWindow(This->shell_embedding_hwnd);
290         This->shell_embedding_hwnd = NULL;
291     }
292 
293     if(This->inplace) {
294         IOleInPlaceSite_Release(This->inplace);
295         This->inplace = NULL;
296     }
297 
298     if(This->doc_host.hostui) {
299         IDocHostUIHandler_Release(This->doc_host.hostui);
300         This->doc_host.hostui = NULL;
301     }
302 
303     if(This->client)
304         IOleClientSite_Release(This->client);
305 
306     This->client = pClientSite;
307 
308     if(!pClientSite) {
309         if(This->doc_host.document)
310             deactivate_document(&This->doc_host);
311         return S_OK;
312     }
313 
314     IOleClientSite_AddRef(pClientSite);
315 
316     IOleClientSite_QueryInterface(This->client, &IID_IDispatch,
317                                   (void**)&This->doc_host.client_disp);
318 
319     IOleClientSite_QueryInterface(This->client, &IID_IDocHostUIHandler,
320                                   (void**)&This->doc_host.hostui);
321 
322     hres = IOleClientSite_GetContainer(This->client, &container);
323     if(SUCCEEDED(hres)) {
324         ITargetContainer *target_container;
325 
326         hres = IOleContainer_QueryInterface(container, &IID_ITargetContainer,
327                                             (void**)&target_container);
328         if(SUCCEEDED(hres)) {
329             FIXME("Unsupported ITargetContainer\n");
330             ITargetContainer_Release(target_container);
331         }
332 
333         IOleContainer_Release(container);
334     }
335 
336     create_shell_embedding_hwnd(This);
337 
338     on_offlineconnected_change(This);
339     on_silent_change(This);
340 
341     return S_OK;
342 }
343 
344 static HRESULT WINAPI OleObject_GetClientSite(IOleObject *iface, LPOLECLIENTSITE *ppClientSite)
345 {
346     WebBrowser *This = OLEOBJ_THIS(iface);
347 
348     TRACE("(%p)->(%p)\n", This, ppClientSite);
349 
350     if(!ppClientSite)
351         return E_INVALIDARG;
352 
353     if(This->client)
354         IOleClientSite_AddRef(This->client);
355     *ppClientSite = This->client;
356 
357     return S_OK;
358 }
359 
360 static HRESULT WINAPI OleObject_SetHostNames(IOleObject *iface, LPCOLESTR szContainerApp,
361         LPCOLESTR szContainerObj)
362 {
363     WebBrowser *This = OLEOBJ_THIS(iface);
364 
365     TRACE("(%p)->(%s, %s)\n", This, debugstr_w(szContainerApp), debugstr_w(szContainerObj));
366 
367     /* We have nothing to do here. */
368     return S_OK;
369 }
370 
371 static HRESULT WINAPI OleObject_Close(IOleObject *iface, DWORD dwSaveOption)
372 {
373     WebBrowser *This = OLEOBJ_THIS(iface);
374     FIXME("(%p)->(%d)\n", This, dwSaveOption);
375     return E_NOTIMPL;
376 }
377 
378 static HRESULT WINAPI OleObject_SetMoniker(IOleObject *iface, DWORD dwWhichMoniker, IMoniker* pmk)
379 {
380     WebBrowser *This = OLEOBJ_THIS(iface);
381     FIXME("(%p)->(%d, %p)\n", This, dwWhichMoniker, pmk);
382     return E_NOTIMPL;
383 }
384 
385 static HRESULT WINAPI OleObject_GetMoniker(IOleObject *iface, DWORD dwAssign,
386         DWORD dwWhichMoniker, LPMONIKER *ppmk)
387 {
388     WebBrowser *This = OLEOBJ_THIS(iface);
389     FIXME("(%p)->(%d, %d, %p)\n", This, dwAssign, dwWhichMoniker, ppmk);
390     return E_NOTIMPL;
391 }
392 
393 static HRESULT WINAPI OleObject_InitFromData(IOleObject *iface, LPDATAOBJECT pDataObject,
394         BOOL fCreation, DWORD dwReserved)
395 {
396     WebBrowser *This = OLEOBJ_THIS(iface);
397     FIXME("(%p)->(%p, %d, %d)\n", This, pDataObject, fCreation, dwReserved);
398     return E_NOTIMPL;
399 }
400 
401 static HRESULT WINAPI OleObject_GetClipboardData(IOleObject *iface, DWORD dwReserved,
402         LPDATAOBJECT *ppDataObject)
403 {
404     WebBrowser *This = OLEOBJ_THIS(iface);
405     FIXME("(%p)->(%d, %p)\n", This, dwReserved, ppDataObject);
406     return E_NOTIMPL;
407 }
408 
409 static HRESULT WINAPI OleObject_DoVerb(IOleObject *iface, LONG iVerb, struct tagMSG* lpmsg,
410         LPOLECLIENTSITE pActiveSite, LONG lindex, HWND hwndParent, LPCRECT lprcPosRect)
411 {
412     WebBrowser *This = OLEOBJ_THIS(iface);
413 
414     TRACE("(%p)->(%d %p %p %d %p %p)\n", This, iVerb, lpmsg, pActiveSite, lindex, hwndParent,
415             lprcPosRect);
416 
417     switch (iVerb)
418     {
419     case OLEIVERB_SHOW:
420         TRACE("OLEIVERB_SHOW\n");
421         return activate_ui(This, pActiveSite);
422     case OLEIVERB_UIACTIVATE:
423         TRACE("OLEIVERB_UIACTIVATE\n");
424         return activate_ui(This, pActiveSite);
425     case OLEIVERB_INPLACEACTIVATE:
426         TRACE("OLEIVERB_INPLACEACTIVATE\n");
427         return activate_inplace(This, pActiveSite);
428     case OLEIVERB_HIDE:
429         TRACE("OLEIVERB_HIDE\n");
430         if(This->shell_embedding_hwnd)
431             ShowWindow(This->shell_embedding_hwnd, SW_HIDE);
432         return S_OK;
433     default:
434         FIXME("stub for %d\n", iVerb);
435         break;
436     }
437 
438     return E_NOTIMPL;
439 }
440 
441 static HRESULT WINAPI OleObject_EnumVerbs(IOleObject *iface, IEnumOLEVERB **ppEnumOleVerb)
442 {
443     WebBrowser *This = OLEOBJ_THIS(iface);
444     TRACE("(%p)->(%p)\n", This, ppEnumOleVerb);
445     return OleRegEnumVerbs(&CLSID_WebBrowser, ppEnumOleVerb);
446 }
447 
448 static HRESULT WINAPI OleObject_Update(IOleObject *iface)
449 {
450     WebBrowser *This = OLEOBJ_THIS(iface);
451     FIXME("(%p)\n", This);
452     return E_NOTIMPL;
453 }
454 
455 static HRESULT WINAPI OleObject_IsUpToDate(IOleObject *iface)
456 {
457     WebBrowser *This = OLEOBJ_THIS(iface);
458     FIXME("(%p)\n", This);
459     return E_NOTIMPL;
460 }
461 
462 static HRESULT WINAPI OleObject_GetUserClassID(IOleObject *iface, CLSID* pClsid)
463 {
464     WebBrowser *This = OLEOBJ_THIS(iface);
465     FIXME("(%p)->(%p)\n", This, pClsid);
466     return E_NOTIMPL;
467 }
468 
469 static HRESULT WINAPI OleObject_GetUserType(IOleObject *iface, DWORD dwFormOfType,
470         LPOLESTR* pszUserType)
471 {
472     WebBrowser *This = OLEOBJ_THIS(iface);
473     TRACE("(%p, %d, %p)\n", This, dwFormOfType, pszUserType);
474     return OleRegGetUserType(&CLSID_WebBrowser, dwFormOfType, pszUserType);
475 }
476 
477 static HRESULT WINAPI OleObject_SetExtent(IOleObject *iface, DWORD dwDrawAspect, SIZEL *psizel)
478 {
479     WebBrowser *This = OLEOBJ_THIS(iface);
480 
481     TRACE("(%p)->(%x %p)\n", This, dwDrawAspect, psizel);
482 
483     /* Tests show that dwDrawAspect is ignored */
484     This->extent = *psizel;
485     return S_OK;
486 }
487 
488 static HRESULT WINAPI OleObject_GetExtent(IOleObject *iface, DWORD dwDrawAspect, SIZEL *psizel)
489 {
490     WebBrowser *This = OLEOBJ_THIS(iface);
491 
492     TRACE("(%p)->(%x, %p)\n", This, dwDrawAspect, psizel);
493 
494     /* Tests show that dwDrawAspect is ignored */
495     *psizel = This->extent;
496     return S_OK;
497 }
498 
499 static HRESULT WINAPI OleObject_Advise(IOleObject *iface, IAdviseSink *pAdvSink,
500         DWORD* pdwConnection)
501 {
502     WebBrowser *This = OLEOBJ_THIS(iface);
503     FIXME("(%p)->(%p, %p)\n", This, pAdvSink, pdwConnection);
504     return E_NOTIMPL;
505 }
506 
507 static HRESULT WINAPI OleObject_Unadvise(IOleObject *iface, DWORD dwConnection)
508 {
509     WebBrowser *This = OLEOBJ_THIS(iface);
510     FIXME("(%p)->(%d)\n", This, dwConnection);
511     return E_NOTIMPL;
512 }
513 
514 static HRESULT WINAPI OleObject_EnumAdvise(IOleObject *iface, IEnumSTATDATA **ppenumAdvise)
515 {
516     WebBrowser *This = OLEOBJ_THIS(iface);
517     FIXME("(%p)->(%p)\n", This, ppenumAdvise);
518     return S_OK;
519 }
520 
521 static HRESULT WINAPI OleObject_GetMiscStatus(IOleObject *iface, DWORD dwAspect, DWORD *pdwStatus)
522 {
523     WebBrowser *This = OLEOBJ_THIS(iface);
524 
525     TRACE("(%p)->(%x, %p)\n", This, dwAspect, pdwStatus);
526 
527     *pdwStatus = OLEMISC_SETCLIENTSITEFIRST|OLEMISC_ACTIVATEWHENVISIBLE|OLEMISC_INSIDEOUT
528         |OLEMISC_CANTLINKINSIDE|OLEMISC_RECOMPOSEONRESIZE;
529 
530     return S_OK;
531 }
532 
533 static HRESULT WINAPI OleObject_SetColorScheme(IOleObject *iface, LOGPALETTE* pLogpal)
534 {
535     WebBrowser *This = OLEOBJ_THIS(iface);
536     FIXME("(%p)->(%p)\n", This, pLogpal);
537     return E_NOTIMPL;
538 }
539 
540 #undef OLEOBJ_THIS
541 
542 static const IOleObjectVtbl OleObjectVtbl =
543 {
544     OleObject_QueryInterface,
545     OleObject_AddRef,
546     OleObject_Release,
547     OleObject_SetClientSite,
548     OleObject_GetClientSite,
549     OleObject_SetHostNames,
550     OleObject_Close,
551     OleObject_SetMoniker,
552     OleObject_GetMoniker,
553     OleObject_InitFromData,
554     OleObject_GetClipboardData,
555     OleObject_DoVerb,
556     OleObject_EnumVerbs,
557     OleObject_Update,
558     OleObject_IsUpToDate,
559     OleObject_GetUserClassID,
560     OleObject_GetUserType,
561     OleObject_SetExtent,
562     OleObject_GetExtent,
563     OleObject_Advise,
564     OleObject_Unadvise,
565     OleObject_EnumAdvise,
566     OleObject_GetMiscStatus,
567     OleObject_SetColorScheme
568 };
569 
570 /**********************************************************************
571  * Implement the IOleInPlaceObject interface
572  */
573 
574 #define INPLACEOBJ_THIS(iface) DEFINE_THIS(WebBrowser, OleInPlaceObject, iface)
575 
576 static HRESULT WINAPI OleInPlaceObject_QueryInterface(IOleInPlaceObject *iface,
577         REFIID riid, LPVOID *ppobj)
578 {
579     WebBrowser *This = INPLACEOBJ_THIS(iface);
580     return IWebBrowser_QueryInterface(WEBBROWSER(This), riid, ppobj);
581 }
582 
583 static ULONG WINAPI OleInPlaceObject_AddRef(IOleInPlaceObject *iface)
584 {
585     WebBrowser *This = INPLACEOBJ_THIS(iface);
586     return IWebBrowser_AddRef(WEBBROWSER(This));
587 }
588 
589 static ULONG WINAPI OleInPlaceObject_Release(IOleInPlaceObject *iface)
590 {
591     WebBrowser *This = INPLACEOBJ_THIS(iface);
592     return IWebBrowser_Release(WEBBROWSER(This));
593 }
594 
595 static HRESULT WINAPI OleInPlaceObject_GetWindow(IOleInPlaceObject *iface, HWND* phwnd)
596 {
597     WebBrowser *This = INPLACEOBJ_THIS(iface);
598 
599     TRACE("(%p)->(%p)\n", This, phwnd);
600 
601     *phwnd = This->shell_embedding_hwnd;
602     return S_OK;
603 }
604 
605 static HRESULT WINAPI OleInPlaceObject_ContextSensitiveHelp(IOleInPlaceObject *iface,
606         BOOL fEnterMode)
607 {
608     WebBrowser *This = INPLACEOBJ_THIS(iface);
609     FIXME("(%p)->(%x)\n", This, fEnterMode);
610     return E_NOTIMPL;
611 }
612 
613 static HRESULT WINAPI OleInPlaceObject_InPlaceDeactivate(IOleInPlaceObject *iface)
614 {
615     WebBrowser *This = INPLACEOBJ_THIS(iface);
616     FIXME("(%p)\n", This);
617     return E_NOTIMPL;
618 }
619 
620 static HRESULT WINAPI OleInPlaceObject_UIDeactivate(IOleInPlaceObject *iface)
621 {
622     WebBrowser *This = INPLACEOBJ_THIS(iface);
623     FIXME("(%p)\n", This);
624     return E_NOTIMPL;
625 }
626 
627 static HRESULT WINAPI OleInPlaceObject_SetObjectRects(IOleInPlaceObject *iface,
628         LPCRECT lprcPosRect, LPCRECT lprcClipRect)
629 {
630     WebBrowser *This = INPLACEOBJ_THIS(iface);
631 
632     TRACE("(%p)->(%p %p)\n", This, lprcPosRect, lprcClipRect);
633 
634     This->pos_rect = *lprcPosRect;
635 
636     if(lprcClipRect)
637         This->clip_rect = *lprcClipRect;
638 
639     if(This->shell_embedding_hwnd) {
640         SetWindowPos(This->shell_embedding_hwnd, NULL,
641                      lprcPosRect->left, lprcPosRect->top,
642                      lprcPosRect->right-lprcPosRect->left,
643                      lprcPosRect->bottom-lprcPosRect->top,
644                      SWP_NOZORDER | SWP_NOACTIVATE);
645     }
646 
647     return S_OK;
648 }
649 
650 static HRESULT WINAPI OleInPlaceObject_ReactivateAndUndo(IOleInPlaceObject *iface)
651 {
652     WebBrowser *This = INPLACEOBJ_THIS(iface);
653     FIXME("(%p)\n", This);
654     return E_NOTIMPL;
655 }
656 
657 #undef INPLACEOBJ_THIS
658 
659 static const IOleInPlaceObjectVtbl OleInPlaceObjectVtbl =
660 {
661     OleInPlaceObject_QueryInterface,
662     OleInPlaceObject_AddRef,
663     OleInPlaceObject_Release,
664     OleInPlaceObject_GetWindow,
665     OleInPlaceObject_ContextSensitiveHelp,
666     OleInPlaceObject_InPlaceDeactivate,
667     OleInPlaceObject_UIDeactivate,
668     OleInPlaceObject_SetObjectRects,
669     OleInPlaceObject_ReactivateAndUndo
670 };
671 
672 /**********************************************************************
673  * Implement the IOleControl interface
674  */
675 
676 #define CONTROL_THIS(iface) DEFINE_THIS(WebBrowser, OleControl, iface)
677 
678 static HRESULT WINAPI OleControl_QueryInterface(IOleControl *iface,
679         REFIID riid, LPVOID *ppobj)
680 {
681     WebBrowser *This = CONTROL_THIS(iface);
682     return IWebBrowser_QueryInterface(WEBBROWSER(This), riid, ppobj);
683 }
684 
685 static ULONG WINAPI OleControl_AddRef(IOleControl *iface)
686 {
687     WebBrowser *This = CONTROL_THIS(iface);
688     return IWebBrowser_AddRef(WEBBROWSER(This));
689 }
690 
691 static ULONG WINAPI OleControl_Release(IOleControl *iface)
692 {
693     WebBrowser *This = CONTROL_THIS(iface);
694     return IWebBrowser_Release(WEBBROWSER(This));
695 }
696 
697 static HRESULT WINAPI OleControl_GetControlInfo(IOleControl *iface, LPCONTROLINFO pCI)
698 {
699     WebBrowser *This = CONTROL_THIS(iface);
700 
701     TRACE("(%p)->(%p)\n", This, pCI);
702 
703     /* Tests show that this function should be not implemented */
704     return E_NOTIMPL;
705 }
706 
707 static HRESULT WINAPI OleControl_OnMnemonic(IOleControl *iface, struct tagMSG *pMsg)
708 {
709     WebBrowser *This = CONTROL_THIS(iface);
710     FIXME("(%p)->(%p)\n", This, pMsg);
711     return E_NOTIMPL;
712 }
713 
714 static HRESULT WINAPI OleControl_OnAmbientPropertyChange(IOleControl *iface, DISPID dispID)
715 {
716     WebBrowser *This = CONTROL_THIS(iface);
717 
718     TRACE("(%p)->(%d)\n", This, dispID);
719 
720     switch(dispID) {
721     case DISPID_UNKNOWN:
722         /* Unknown means multiple properties changed, so check them all.
723          * BUT the Webbrowser OleControl object doesn't appear to do this.
724          */
725         return S_OK;
726     case DISPID_AMBIENT_OFFLINEIFNOTCONNECTED:
727         return on_offlineconnected_change(This);
728     case DISPID_AMBIENT_SILENT:
729         return on_silent_change(This);
730     }
731 
732     FIXME("Unknown dispID %d\n", dispID);
733     return E_NOTIMPL;
734 }
735 
736 static HRESULT WINAPI OleControl_FreezeEvents(IOleControl *iface, BOOL bFreeze)
737 {
738     WebBrowser *This = CONTROL_THIS(iface);
739     FIXME("(%p)->(%x)\n", This, bFreeze);
740     return E_NOTIMPL;
741 }
742 
743 #undef CONTROL_THIS
744 
745 static const IOleControlVtbl OleControlVtbl =
746 {
747     OleControl_QueryInterface,
748     OleControl_AddRef,
749     OleControl_Release,
750     OleControl_GetControlInfo,
751     OleControl_OnMnemonic,
752     OleControl_OnAmbientPropertyChange,
753     OleControl_FreezeEvents
754 };
755 
756 #define ACTIVEOBJ_THIS(iface) DEFINE_THIS(WebBrowser, OleInPlaceActiveObject, iface)
757 
758 static HRESULT WINAPI InPlaceActiveObject_QueryInterface(IOleInPlaceActiveObject *iface,
759                                                             REFIID riid, void **ppv)
760 {
761     WebBrowser *This = ACTIVEOBJ_THIS(iface);
762     return IWebBrowser2_QueryInterface(WEBBROWSER2(This), riid, ppv);
763 }
764 
765 static ULONG WINAPI InPlaceActiveObject_AddRef(IOleInPlaceActiveObject *iface)
766 {
767     WebBrowser *This = ACTIVEOBJ_THIS(iface);
768     return IWebBrowser2_AddRef(WEBBROWSER2(This));
769 }
770 
771 static ULONG WINAPI InPlaceActiveObject_Release(IOleInPlaceActiveObject *iface)
772 {
773     WebBrowser *This = ACTIVEOBJ_THIS(iface);
774     return IWebBrowser2_Release(WEBBROWSER2(This));
775 }
776 
777 static HRESULT WINAPI InPlaceActiveObject_GetWindow(IOleInPlaceActiveObject *iface,
778                                                     HWND *phwnd)
779 {
780     WebBrowser *This = ACTIVEOBJ_THIS(iface);
781     return IOleInPlaceObject_GetWindow(INPLACEOBJ(This), phwnd);
782 }
783 
784 static HRESULT WINAPI InPlaceActiveObject_ContextSensitiveHelp(IOleInPlaceActiveObject *iface,
785                                                                BOOL fEnterMode)
786 {
787     WebBrowser *This = ACTIVEOBJ_THIS(iface);
788     return IOleInPlaceObject_ContextSensitiveHelp(INPLACEOBJ(This), fEnterMode);
789 }
790 
791 static HRESULT WINAPI InPlaceActiveObject_TranslateAccelerator(IOleInPlaceActiveObject *iface,
792                                                                LPMSG lpmsg)
793 {
794     WebBrowser *This = ACTIVEOBJ_THIS(iface);
795     FIXME("(%p)->(%p)\n", This, lpmsg);
796     return E_NOTIMPL;
797 }
798 
799 static HRESULT WINAPI InPlaceActiveObject_OnFrameWindowActivate(IOleInPlaceActiveObject *iface,
800                                                                 BOOL fActivate)
801 {
802     WebBrowser *This = ACTIVEOBJ_THIS(iface);
803     FIXME("(%p)->(%x)\n", This, fActivate);
804     return E_NOTIMPL;
805 }
806 
807 static HRESULT WINAPI InPlaceActiveObject_OnDocWindowActivate(IOleInPlaceActiveObject *iface,
808                                                               BOOL fActivate)
809 {
810     WebBrowser *This = ACTIVEOBJ_THIS(iface);
811     FIXME("(%p)->(%x)\n", This, fActivate);
812     return E_NOTIMPL;
813 }
814 
815 static HRESULT WINAPI InPlaceActiveObject_ResizeBorder(IOleInPlaceActiveObject *iface,
816         LPCRECT lprcBorder, IOleInPlaceUIWindow *pUIWindow, BOOL fFrameWindow)
817 {
818     WebBrowser *This = ACTIVEOBJ_THIS(iface);
819     FIXME("(%p)->(%p %p %x)\n", This, lprcBorder, pUIWindow, fFrameWindow);
820     return E_NOTIMPL;
821 }
822 
823 static HRESULT WINAPI InPlaceActiveObject_EnableModeless(IOleInPlaceActiveObject *iface,
824                                                          BOOL fEnable)
825 {
826     WebBrowser *This = ACTIVEOBJ_THIS(iface);
827     FIXME("(%p)->(%x)\n", This, fEnable);
828     return E_NOTIMPL;
829 }
830 
831 #undef ACTIVEOBJ_THIS
832 
833 static const IOleInPlaceActiveObjectVtbl OleInPlaceActiveObjectVtbl = {
834     InPlaceActiveObject_QueryInterface,
835     InPlaceActiveObject_AddRef,
836     InPlaceActiveObject_Release,
837     InPlaceActiveObject_GetWindow,
838     InPlaceActiveObject_ContextSensitiveHelp,
839     InPlaceActiveObject_TranslateAccelerator,
840     InPlaceActiveObject_OnFrameWindowActivate,
841     InPlaceActiveObject_OnDocWindowActivate,
842     InPlaceActiveObject_ResizeBorder,
843     InPlaceActiveObject_EnableModeless
844 };
845 
846 #define OLECMD_THIS(iface) DEFINE_THIS(WebBrowser, OleCommandTarget, iface)
847 
848 static HRESULT WINAPI WBOleCommandTarget_QueryInterface(IOleCommandTarget *iface,
849         REFIID riid, void **ppv)
850 {
851     WebBrowser *This = OLECMD_THIS(iface);
852     return IWebBrowser2_QueryInterface(WEBBROWSER(This), riid, ppv);
853 }
854 
855 static ULONG WINAPI WBOleCommandTarget_AddRef(IOleCommandTarget *iface)
856 {
857     WebBrowser *This = OLECMD_THIS(iface);
858     return IWebBrowser2_AddRef(WEBBROWSER(This));
859 }
860 
861 static ULONG WINAPI WBOleCommandTarget_Release(IOleCommandTarget *iface)
862 {
863     WebBrowser *This = OLECMD_THIS(iface);
864     return IWebBrowser2_Release(WEBBROWSER(This));
865 }
866 
867 static HRESULT WINAPI WBOleCommandTarget_QueryStatus(IOleCommandTarget *iface,
868         const GUID *pguidCmdGroup, ULONG cCmds, OLECMD prgCmds[], OLECMDTEXT *pCmdText)
869 {
870     WebBrowser *This = OLECMD_THIS(iface);
871     IOleCommandTarget *cmdtrg;
872     HRESULT hres;
873 
874     TRACE("(%p)->(%s %u %p %p)\n", This, debugstr_guid(pguidCmdGroup), cCmds, prgCmds,
875           pCmdText);
876 
877     if(!This->doc_host.document)
878         return 0x80040104;
879 
880     /* NOTE: There are probably some commands that we should handle here
881      * instead of forwarding to document object. */
882 
883     hres = IUnknown_QueryInterface(This->doc_host.document, &IID_IOleCommandTarget, (void**)&cmdtrg);
884     if(FAILED(hres))
885         return hres;
886 
887     hres = IOleCommandTarget_QueryStatus(cmdtrg, pguidCmdGroup, cCmds, prgCmds, pCmdText);
888     IOleCommandTarget_Release(cmdtrg);
889 
890     return hres;
891 }
892 
893 static HRESULT WINAPI WBOleCommandTarget_Exec(IOleCommandTarget *iface,
894         const GUID *pguidCmdGroup, DWORD nCmdID, DWORD nCmdexecopt, VARIANT *pvaIn,
895         VARIANT *pvaOut)
896 {
897     WebBrowser *This = OLECMD_THIS(iface);
898     FIXME("(%p)->(%s %d %d %p %p)\n", This, debugstr_guid(pguidCmdGroup), nCmdID,
899           nCmdexecopt, pvaIn, pvaOut);
900     return E_NOTIMPL;
901 }
902 
903 #undef OLECMD_THIS
904 
905 static const IOleCommandTargetVtbl OleCommandTargetVtbl = {
906     WBOleCommandTarget_QueryInterface,
907     WBOleCommandTarget_AddRef,
908     WBOleCommandTarget_Release,
909     WBOleCommandTarget_QueryStatus,
910     WBOleCommandTarget_Exec
911 };
912 
913 void WebBrowser_OleObject_Init(WebBrowser *This)
914 {
915     DWORD dpi_x;
916     DWORD dpi_y;
917     HDC hdc;
918 
919     /* default aspect ratio is 96dpi / 96dpi */
920     hdc = GetDC(0);
921     dpi_x = GetDeviceCaps(hdc, LOGPIXELSX);
922     dpi_y = GetDeviceCaps(hdc, LOGPIXELSY);
923     ReleaseDC(0, hdc);
924 
925     This->lpOleObjectVtbl              = &OleObjectVtbl;
926     This->lpOleInPlaceObjectVtbl       = &OleInPlaceObjectVtbl;
927     This->lpOleControlVtbl             = &OleControlVtbl;
928     This->lpOleInPlaceActiveObjectVtbl = &OleInPlaceActiveObjectVtbl;
929     This->lpOleCommandTargetVtbl     = &OleCommandTargetVtbl;
930 
931     This->client = NULL;
932     This->inplace = NULL;
933     This->container = NULL;
934     This->frame_hwnd = NULL;
935     This->uiwindow = NULL;
936     This->shell_embedding_hwnd = NULL;
937 
938     memset(&This->pos_rect, 0, sizeof(RECT));
939     memset(&This->clip_rect, 0, sizeof(RECT));
940     memset(&This->frameinfo, 0, sizeof(OLEINPLACEFRAMEINFO));
941 
942     /* Default size is 50x20 pixels, in himetric units */
943     This->extent.cx = MulDiv( 50, 2540, dpi_x );
944     This->extent.cy = MulDiv( 20, 2540, dpi_y );
945 }
946 
947 void WebBrowser_OleObject_Destroy(WebBrowser *This)
948 {
949     if(This->client)
950         IOleObject_SetClientSite(OLEOBJ(This), NULL);
951     if(This->container)
952         IOleContainer_Release(This->container);
953     if(This->uiwindow)
954         IOleInPlaceUIWindow_Release(This->uiwindow);
955 }
956 

~ [ source navigation ] ~ [ diff markup ] ~ [ identifier search ] ~ [ freetext search ] ~ [ file search ] ~

This page was automatically generated by the LXR engine.
Visit the LXR main site for more information.