loader: Add the CFBundleAllowMixedLocalizations key to the embedded Info.plist to...
[wine/multimedia.git] / dlls / mshtml / view.c
blob43ea3e31f6236d3c03ba150400ddeb7c944747e7
1 /*
2 * Copyright 2005-2006 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 "config.h"
21 #include <stdarg.h>
22 #include <stdio.h>
24 #define COBJMACROS
26 #include "windef.h"
27 #include "winbase.h"
28 #include "winuser.h"
29 #include "commctrl.h"
30 #include "ole2.h"
31 #include "resource.h"
33 #include "wine/debug.h"
35 #include "mshtml_private.h"
37 WINE_DEFAULT_DEBUG_CHANNEL(mshtml);
39 #define TIMER_ID 0x1000
41 static const WCHAR wszInternetExplorer_Server[] =
42 {'I','n','t','e','r','n','e','t',' ','E','x','p','l','o','r','e','r','_','S','e','r','v','e','r',0};
44 static const WCHAR wszTooltipData[] = {'t','o','o','l','t','i','p','_','d','a','t','a',0};
46 static ATOM serverwnd_class = 0;
48 typedef struct {
49 HTMLDocumentObj *doc;
50 WNDPROC proc;
51 } tooltip_data;
53 static void paint_document(HTMLDocumentObj *This)
55 PAINTSTRUCT ps;
56 RECT rect;
57 HDC hdc;
59 GetClientRect(This->hwnd, &rect);
61 hdc = BeginPaint(This->hwnd, &ps);
63 if(!(This->hostinfo.dwFlags & (DOCHOSTUIFLAG_NO3DOUTERBORDER|DOCHOSTUIFLAG_NO3DBORDER)))
64 DrawEdge(hdc, &rect, EDGE_SUNKEN, BF_RECT|BF_ADJUST);
66 EndPaint(This->hwnd, &ps);
69 static void activate_gecko(NSContainer *This)
71 TRACE("(%p) %p\n", This, This->window);
73 SetParent(This->hwnd, This->doc->hwnd);
74 ShowWindow(This->hwnd, SW_SHOW);
76 nsIBaseWindow_SetVisibility(This->window, TRUE);
77 nsIBaseWindow_SetEnabled(This->window, TRUE);
80 void update_doc(HTMLDocument *This, DWORD flags)
82 if(!This->doc_obj->update && This->doc_obj->hwnd)
83 SetTimer(This->doc_obj->hwnd, TIMER_ID, 100, NULL);
85 This->doc_obj->update |= flags;
88 void update_title(HTMLDocumentObj *This)
90 IOleCommandTarget *olecmd;
91 HRESULT hres;
93 if(!(This->update & UPDATE_TITLE))
94 return;
96 This->update &= ~UPDATE_TITLE;
98 if(!This->client)
99 return;
101 hres = IOleClientSite_QueryInterface(This->client, &IID_IOleCommandTarget, (void**)&olecmd);
102 if(SUCCEEDED(hres)) {
103 VARIANT title;
104 WCHAR empty[] = {0};
106 V_VT(&title) = VT_BSTR;
107 V_BSTR(&title) = SysAllocString(empty);
108 IOleCommandTarget_Exec(olecmd, NULL, OLECMDID_SETTITLE, OLECMDEXECOPT_DONTPROMPTUSER,
109 &title, NULL);
110 SysFreeString(V_BSTR(&title));
112 IOleCommandTarget_Release(olecmd);
116 static LRESULT on_timer(HTMLDocumentObj *This)
118 TRACE("(%p) %x\n", This, This->update);
120 KillTimer(This->hwnd, TIMER_ID);
122 if(!This->update)
123 return 0;
125 if(This->update & UPDATE_UI) {
126 if(This->hostui)
127 IDocHostUIHandler_UpdateUI(This->hostui);
129 if(This->client) {
130 IOleCommandTarget *cmdtrg;
131 HRESULT hres;
133 hres = IOleClientSite_QueryInterface(This->client, &IID_IOleCommandTarget,
134 (void**)&cmdtrg);
135 if(SUCCEEDED(hres)) {
136 IOleCommandTarget_Exec(cmdtrg, NULL, OLECMDID_UPDATECOMMANDS,
137 OLECMDEXECOPT_DONTPROMPTUSER, NULL, NULL);
138 IOleCommandTarget_Release(cmdtrg);
143 update_title(This);
144 This->update = 0;
145 return 0;
148 void notif_focus(HTMLDocumentObj *This)
150 IOleControlSite *site;
151 HRESULT hres;
153 if(!This->client)
154 return;
156 hres = IOleClientSite_QueryInterface(This->client, &IID_IOleControlSite, (void**)&site);
157 if(FAILED(hres))
158 return;
160 IOleControlSite_OnFocus(site, This->focus);
161 IOleControlSite_Release(site);
164 static LRESULT WINAPI serverwnd_proc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)
166 HTMLDocumentObj *This;
168 static const WCHAR wszTHIS[] = {'T','H','I','S',0};
170 if(msg == WM_CREATE) {
171 This = *(HTMLDocumentObj**)lParam;
172 SetPropW(hwnd, wszTHIS, This);
173 }else {
174 This = GetPropW(hwnd, wszTHIS);
177 switch(msg) {
178 case WM_CREATE:
179 This->hwnd = hwnd;
180 break;
181 case WM_PAINT:
182 paint_document(This);
183 break;
184 case WM_SIZE:
185 TRACE("(%p)->(WM_SIZE)\n", This);
186 if(This->nscontainer) {
187 INT ew=0, eh=0;
189 if(!(This->hostinfo.dwFlags & (DOCHOSTUIFLAG_NO3DOUTERBORDER|DOCHOSTUIFLAG_NO3DBORDER))) {
190 ew = GetSystemMetrics(SM_CXEDGE);
191 eh = GetSystemMetrics(SM_CYEDGE);
194 SetWindowPos(This->nscontainer->hwnd, NULL, ew, eh,
195 LOWORD(lParam) - 2*ew, HIWORD(lParam) - 2*eh,
196 SWP_NOZORDER | SWP_NOACTIVATE);
198 break;
199 case WM_TIMER:
200 return on_timer(This);
201 case WM_SETFOCUS:
202 TRACE("(%p) WM_SETFOCUS\n", This);
203 nsIWebBrowserFocus_Activate(This->nscontainer->focus);
204 break;
205 case WM_MOUSEACTIVATE:
206 return MA_ACTIVATE;
209 return DefWindowProcW(hwnd, msg, wParam, lParam);
212 static void register_serverwnd_class(void)
214 static WNDCLASSEXW wndclass = {
215 sizeof(WNDCLASSEXW),
216 CS_DBLCLKS,
217 serverwnd_proc,
218 0, 0, NULL, NULL, NULL, NULL, NULL,
219 wszInternetExplorer_Server,
220 NULL,
222 wndclass.hInstance = hInst;
223 serverwnd_class = RegisterClassExW(&wndclass);
226 static HRESULT activate_window(HTMLDocumentObj *This)
228 IOleInPlaceFrame *pIPFrame;
229 IOleCommandTarget *cmdtrg;
230 IOleInPlaceSiteEx *ipsiteex;
231 RECT posrect, cliprect;
232 OLEINPLACEFRAMEINFO frameinfo;
233 HWND parent_hwnd;
234 HRESULT hres;
236 if(!serverwnd_class)
237 register_serverwnd_class();
239 hres = IOleInPlaceSite_CanInPlaceActivate(This->ipsite);
240 if(hres != S_OK) {
241 WARN("CanInPlaceActivate returned: %08x\n", hres);
242 return FAILED(hres) ? hres : E_FAIL;
245 frameinfo.cb = sizeof(OLEINPLACEFRAMEINFO);
246 hres = IOleInPlaceSite_GetWindowContext(This->ipsite, &pIPFrame, &This->ip_window,
247 &posrect, &cliprect, &frameinfo);
248 if(FAILED(hres)) {
249 WARN("GetWindowContext failed: %08x\n", hres);
250 return hres;
253 TRACE("got window context: %p %p {%d %d %d %d} {%d %d %d %d} {%d %x %p %p %d}\n",
254 pIPFrame, This->ip_window, posrect.left, posrect.top, posrect.right, posrect.bottom,
255 cliprect.left, cliprect.top, cliprect.right, cliprect.bottom,
256 frameinfo.cb, frameinfo.fMDIApp, frameinfo.hwndFrame, frameinfo.haccel, frameinfo.cAccelEntries);
258 hres = IOleInPlaceSite_GetWindow(This->ipsite, &parent_hwnd);
259 if(FAILED(hres)) {
260 WARN("GetWindow failed: %08x\n", hres);
261 return hres;
264 TRACE("got parent window %p\n", parent_hwnd);
266 if(This->hwnd) {
267 if(GetParent(This->hwnd) != parent_hwnd)
268 SetParent(This->hwnd, parent_hwnd);
269 SetWindowPos(This->hwnd, HWND_TOP,
270 posrect.left, posrect.top, posrect.right-posrect.left, posrect.bottom-posrect.top,
271 SWP_NOACTIVATE | SWP_SHOWWINDOW);
272 }else {
273 CreateWindowExW(0, wszInternetExplorer_Server, NULL,
274 WS_CHILD | WS_CLIPSIBLINGS | WS_CLIPCHILDREN,
275 posrect.left, posrect.top, posrect.right-posrect.left, posrect.bottom-posrect.top,
276 parent_hwnd, NULL, hInst, This);
278 TRACE("Created window %p\n", This->hwnd);
280 SetWindowPos(This->hwnd, NULL, 0, 0, 0, 0,
281 SWP_NOSIZE | SWP_NOMOVE | SWP_NOZORDER | SWP_NOREDRAW | SWP_NOACTIVATE | SWP_SHOWWINDOW);
282 RedrawWindow(This->hwnd, NULL, NULL, RDW_INVALIDATE | RDW_NOERASE | RDW_ALLCHILDREN);
284 /* NOTE:
285 * Windows implementation calls:
286 * RegisterWindowMessage("MSWHEEL_ROLLMSG");
288 SetTimer(This->hwnd, TIMER_ID, 100, NULL);
291 if(This->nscontainer)
292 activate_gecko(This->nscontainer);
294 This->in_place_active = TRUE;
295 hres = IOleInPlaceSite_QueryInterface(This->ipsite, &IID_IOleInPlaceSiteEx, (void**)&ipsiteex);
296 if(SUCCEEDED(hres)) {
297 BOOL redraw = FALSE;
299 hres = IOleInPlaceSiteEx_OnInPlaceActivateEx(ipsiteex, &redraw, 0);
300 IOleInPlaceSiteEx_Release(ipsiteex);
301 if(redraw)
302 FIXME("unsupported redraw\n");
303 }else{
304 hres = IOleInPlaceSite_OnInPlaceActivate(This->ipsite);
306 if(FAILED(hres)) {
307 WARN("OnInPlaceActivate failed: %08x\n", hres);
308 This->in_place_active = FALSE;
309 return hres;
312 hres = IOleClientSite_QueryInterface(This->client, &IID_IOleCommandTarget, (void**)&cmdtrg);
313 if(SUCCEEDED(hres)) {
314 VARIANT var;
316 IOleInPlaceFrame_SetStatusText(pIPFrame, NULL);
318 V_VT(&var) = VT_I4;
319 V_I4(&var) = 0;
320 IOleCommandTarget_Exec(cmdtrg, NULL, OLECMDID_SETPROGRESSMAX,
321 OLECMDEXECOPT_DONTPROMPTUSER, &var, NULL);
322 IOleCommandTarget_Exec(cmdtrg, NULL, OLECMDID_SETPROGRESSPOS,
323 OLECMDEXECOPT_DONTPROMPTUSER, &var, NULL);
325 IOleCommandTarget_Release(cmdtrg);
328 if(This->frame)
329 IOleInPlaceFrame_Release(This->frame);
330 This->frame = pIPFrame;
332 if(!This->request_uiactivate) {
333 hres = IOleInPlaceSite_QueryInterface(This->ipsite, &IID_IOleInPlaceSiteEx, (void**)&ipsiteex);
334 if(SUCCEEDED(hres)) {
335 IOleInPlaceSiteEx_RequestUIActivate(ipsiteex);
336 IOleInPlaceSiteEx_Release(ipsiteex);
340 This->window_active = TRUE;
342 return S_OK;
345 static LRESULT WINAPI tooltips_proc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)
347 tooltip_data *data = GetPropW(hwnd, wszTooltipData);
349 TRACE("%d %p\n", msg, data);
351 if(msg == TTM_WINDOWFROMPOINT) {
352 RECT rect;
353 POINT *pt = (POINT*)lParam;
355 TRACE("TTM_WINDOWFROMPOINT (%d,%d)\n", pt->x, pt->y);
357 GetWindowRect(data->doc->hwnd, &rect);
359 if(rect.left <= pt->x && pt->x <= rect.right
360 && rect.top <= pt->y && pt->y <= rect.bottom)
361 return (LPARAM)data->doc->hwnd;
364 return CallWindowProcW(data->proc, hwnd, msg, wParam, lParam);
367 static void create_tooltips_window(HTMLDocumentObj *This)
369 tooltip_data *data = heap_alloc(sizeof(*data));
371 This->tooltips_hwnd = CreateWindowExW(0, TOOLTIPS_CLASSW, NULL, TTS_NOPREFIX | WS_POPUP,
372 CW_USEDEFAULT, CW_USEDEFAULT, 10, 10, This->hwnd, NULL, hInst, NULL);
374 data->doc = This;
375 data->proc = (WNDPROC)GetWindowLongPtrW(This->tooltips_hwnd, GWLP_WNDPROC);
377 SetPropW(This->tooltips_hwnd, wszTooltipData, data);
379 SetWindowLongPtrW(This->tooltips_hwnd, GWLP_WNDPROC, (LONG_PTR)tooltips_proc);
381 SetWindowPos(This->tooltips_hwnd, HWND_TOPMOST,0, 0, 0, 0,
382 SWP_NOMOVE | SWP_NOSIZE | SWP_NOACTIVATE);
386 void show_tooltip(HTMLDocumentObj *This, DWORD x, DWORD y, LPCWSTR text)
388 TTTOOLINFOW toolinfo = {
389 sizeof(TTTOOLINFOW), 0, This->hwnd, 0xdeadbeef,
390 {x>2 ? x-2 : 0, y>0 ? y-2 : 0, x+2, y+2}, /* FIXME */
391 NULL, (LPWSTR)text, 0};
392 MSG msg = {This->hwnd, WM_MOUSEMOVE, 0, MAKELPARAM(x,y), 0, {x,y}};
394 TRACE("(%p)->(%d %d %s)\n", This, x, y, debugstr_w(text));
396 if(!This->tooltips_hwnd)
397 create_tooltips_window(This);
399 SendMessageW(This->tooltips_hwnd, TTM_ADDTOOLW, 0, (LPARAM)&toolinfo);
400 SendMessageW(This->tooltips_hwnd, TTM_ACTIVATE, TRUE, 0);
401 SendMessageW(This->tooltips_hwnd, TTM_RELAYEVENT, 0, (LPARAM)&msg);
404 void hide_tooltip(HTMLDocumentObj *This)
406 TTTOOLINFOW toolinfo = {
407 sizeof(TTTOOLINFOW), 0, This->hwnd, 0xdeadbeef,
408 {0,0,0,0}, NULL, NULL, 0};
410 TRACE("(%p)\n", This);
412 SendMessageW(This->tooltips_hwnd, TTM_DELTOOLW, 0, (LPARAM)&toolinfo);
413 SendMessageW(This->tooltips_hwnd, TTM_ACTIVATE, FALSE, 0);
416 HRESULT call_set_active_object(IOleInPlaceUIWindow *window, IOleInPlaceActiveObject *act_obj)
418 static WCHAR html_documentW[30];
420 if(act_obj && !html_documentW[0]) {
421 LoadStringW(hInst, IDS_HTMLDOCUMENT, html_documentW,
422 sizeof(html_documentW)/sizeof(WCHAR));
425 return IOleInPlaceUIWindow_SetActiveObject(window, act_obj, act_obj ? html_documentW : NULL);
428 /**********************************************************
429 * IOleDocumentView implementation
432 static inline HTMLDocument *impl_from_IOleDocumentView(IOleDocumentView *iface)
434 return CONTAINING_RECORD(iface, HTMLDocument, IOleDocumentView_iface);
437 static HRESULT WINAPI OleDocumentView_QueryInterface(IOleDocumentView *iface, REFIID riid, void **ppvObject)
439 HTMLDocument *This = impl_from_IOleDocumentView(iface);
440 return htmldoc_query_interface(This, riid, ppvObject);
443 static ULONG WINAPI OleDocumentView_AddRef(IOleDocumentView *iface)
445 HTMLDocument *This = impl_from_IOleDocumentView(iface);
446 return htmldoc_addref(This);
449 static ULONG WINAPI OleDocumentView_Release(IOleDocumentView *iface)
451 HTMLDocument *This = impl_from_IOleDocumentView(iface);
452 return htmldoc_release(This);
455 static HRESULT WINAPI OleDocumentView_SetInPlaceSite(IOleDocumentView *iface, IOleInPlaceSite *pIPSite)
457 HTMLDocument *This = impl_from_IOleDocumentView(iface);
458 TRACE("(%p)->(%p)\n", This, pIPSite);
460 if(pIPSite)
461 IOleInPlaceSite_AddRef(pIPSite);
463 if(This->doc_obj->ipsite)
464 IOleInPlaceSite_Release(This->doc_obj->ipsite);
466 This->doc_obj->ipsite = pIPSite;
467 This->doc_obj->request_uiactivate = TRUE;
468 return S_OK;
471 static HRESULT WINAPI OleDocumentView_GetInPlaceSite(IOleDocumentView *iface, IOleInPlaceSite **ppIPSite)
473 HTMLDocument *This = impl_from_IOleDocumentView(iface);
474 TRACE("(%p)->(%p)\n", This, ppIPSite);
476 if(!ppIPSite)
477 return E_INVALIDARG;
479 if(This->doc_obj->ipsite)
480 IOleInPlaceSite_AddRef(This->doc_obj->ipsite);
482 *ppIPSite = This->doc_obj->ipsite;
483 return S_OK;
486 static HRESULT WINAPI OleDocumentView_GetDocument(IOleDocumentView *iface, IUnknown **ppunk)
488 HTMLDocument *This = impl_from_IOleDocumentView(iface);
489 TRACE("(%p)->(%p)\n", This, ppunk);
491 if(!ppunk)
492 return E_INVALIDARG;
494 htmldoc_addref(This);
495 *ppunk = (IUnknown*)&This->IHTMLDocument2_iface;
496 return S_OK;
499 static HRESULT WINAPI OleDocumentView_SetRect(IOleDocumentView *iface, LPRECT prcView)
501 HTMLDocument *This = impl_from_IOleDocumentView(iface);
502 RECT rect;
504 TRACE("(%p)->(%p)\n", This, prcView);
506 if(!prcView)
507 return E_INVALIDARG;
509 if(This->doc_obj->hwnd) {
510 GetClientRect(This->doc_obj->hwnd, &rect);
511 if(memcmp(prcView, &rect, sizeof(RECT))) {
512 InvalidateRect(This->doc_obj->hwnd, NULL, TRUE);
513 SetWindowPos(This->doc_obj->hwnd, NULL, prcView->left, prcView->top, prcView->right,
514 prcView->bottom, SWP_NOZORDER | SWP_NOACTIVATE);
518 return S_OK;
521 static HRESULT WINAPI OleDocumentView_GetRect(IOleDocumentView *iface, LPRECT prcView)
523 HTMLDocument *This = impl_from_IOleDocumentView(iface);
525 TRACE("(%p)->(%p)\n", This, prcView);
527 if(!prcView)
528 return E_INVALIDARG;
530 GetClientRect(This->doc_obj->hwnd, prcView);
531 return S_OK;
534 static HRESULT WINAPI OleDocumentView_SetRectComplex(IOleDocumentView *iface, LPRECT prcView,
535 LPRECT prcHScroll, LPRECT prcVScroll, LPRECT prcSizeBox)
537 HTMLDocument *This = impl_from_IOleDocumentView(iface);
538 FIXME("(%p)->(%p %p %p %p)\n", This, prcView, prcHScroll, prcVScroll, prcSizeBox);
539 return E_NOTIMPL;
542 static HRESULT WINAPI OleDocumentView_Show(IOleDocumentView *iface, BOOL fShow)
544 HTMLDocument *This = impl_from_IOleDocumentView(iface);
545 HRESULT hres;
547 TRACE("(%p)->(%x)\n", This, fShow);
549 if(fShow) {
550 if(!This->doc_obj->ui_active) {
551 hres = activate_window(This->doc_obj);
552 if(FAILED(hres))
553 return hres;
555 update_doc(This, UPDATE_UI);
556 ShowWindow(This->doc_obj->hwnd, SW_SHOW);
557 }else {
558 ShowWindow(This->doc_obj->hwnd, SW_HIDE);
560 if(This->doc_obj->in_place_active)
561 IOleInPlaceObjectWindowless_InPlaceDeactivate(&This->IOleInPlaceObjectWindowless_iface);
563 if(This->doc_obj->ip_window) {
564 IOleInPlaceUIWindow_Release(This->doc_obj->ip_window);
565 This->doc_obj->ip_window = NULL;
569 return S_OK;
572 static HRESULT WINAPI OleDocumentView_UIActivate(IOleDocumentView *iface, BOOL fUIActivate)
574 HTMLDocument *This = impl_from_IOleDocumentView(iface);
575 HRESULT hres;
577 TRACE("(%p)->(%x)\n", This, fUIActivate);
579 if(!This->doc_obj->ipsite) {
580 IOleClientSite *cs = This->doc_obj->client;
581 IOleInPlaceSite *ips;
583 if(!cs) {
584 WARN("this->ipsite = NULL\n");
585 return E_UNEXPECTED;
588 hres = IOleClientSite_QueryInterface(cs, &IID_IOleInPlaceSiteWindowless, (void**)&ips);
589 if(SUCCEEDED(hres))
590 This->doc_obj->ipsite = ips;
591 else {
592 hres = IOleClientSite_QueryInterface(cs, &IID_IOleInPlaceSiteEx, (void**)&ips);
593 if(SUCCEEDED(hres))
594 This->doc_obj->ipsite = ips;
595 else {
596 hres = IOleClientSite_QueryInterface(cs, &IID_IOleInPlaceSite, (void**)&ips);
597 if(SUCCEEDED(hres))
598 This->doc_obj->ipsite = ips;
599 else {
600 WARN("this->ipsite = NULL\n");
601 return E_NOINTERFACE;
606 IOleInPlaceSite_AddRef(This->doc_obj->ipsite);
607 This->doc_obj->request_uiactivate = FALSE;
608 HTMLDocument_LockContainer(This->doc_obj, TRUE);
611 if(fUIActivate) {
612 RECT rcBorderWidths;
614 if(This->doc_obj->ui_active)
615 return S_OK;
617 if(!This->doc_obj->window_active) {
618 hres = activate_window(This->doc_obj);
619 if(FAILED(hres))
620 return hres;
623 This->doc_obj->focus = TRUE;
624 if(This->doc_obj->nscontainer)
625 nsIWebBrowserFocus_Activate(This->doc_obj->nscontainer->focus);
626 notif_focus(This->doc_obj);
628 update_doc(This, UPDATE_UI);
630 hres = IOleInPlaceSite_OnUIActivate(This->doc_obj->ipsite);
631 if(SUCCEEDED(hres)) {
632 call_set_active_object((IOleInPlaceUIWindow*)This->doc_obj->frame,
633 &This->IOleInPlaceActiveObject_iface);
634 }else {
635 FIXME("OnUIActivate failed: %08x\n", hres);
636 IOleInPlaceFrame_Release(This->doc_obj->frame);
637 This->doc_obj->frame = NULL;
638 This->doc_obj->ui_active = FALSE;
639 return hres;
642 if(This->doc_obj->hostui) {
643 hres = IDocHostUIHandler_ShowUI(This->doc_obj->hostui,
644 This->doc_obj->usermode == EDITMODE ? DOCHOSTUITYPE_AUTHOR : DOCHOSTUITYPE_BROWSE,
645 &This->IOleInPlaceActiveObject_iface, &This->IOleCommandTarget_iface,
646 This->doc_obj->frame, This->doc_obj->ip_window);
647 if(FAILED(hres))
648 IDocHostUIHandler_HideUI(This->doc_obj->hostui);
651 if(This->doc_obj->ip_window)
652 call_set_active_object(This->doc_obj->ip_window, &This->IOleInPlaceActiveObject_iface);
654 memset(&rcBorderWidths, 0, sizeof(rcBorderWidths));
655 IOleInPlaceFrame_SetBorderSpace(This->doc_obj->frame, &rcBorderWidths);
657 This->doc_obj->ui_active = TRUE;
658 }else {
659 This->doc_obj->focus = FALSE;
660 nsIWebBrowserFocus_Deactivate(This->doc_obj->nscontainer->focus);
661 if(This->doc_obj->ui_active) {
662 This->doc_obj->ui_active = FALSE;
663 if(This->doc_obj->ip_window)
664 call_set_active_object(This->doc_obj->ip_window, NULL);
665 if(This->doc_obj->frame)
666 call_set_active_object((IOleInPlaceUIWindow*)This->doc_obj->frame, NULL);
667 if(This->doc_obj->hostui)
668 IDocHostUIHandler_HideUI(This->doc_obj->hostui);
669 if(This->doc_obj->ipsite)
670 IOleInPlaceSite_OnUIDeactivate(This->doc_obj->ipsite, FALSE);
673 return S_OK;
676 static HRESULT WINAPI OleDocumentView_Open(IOleDocumentView *iface)
678 HTMLDocument *This = impl_from_IOleDocumentView(iface);
679 FIXME("(%p)\n", This);
680 return E_NOTIMPL;
683 static HRESULT WINAPI OleDocumentView_CloseView(IOleDocumentView *iface, DWORD dwReserved)
685 HTMLDocument *This = impl_from_IOleDocumentView(iface);
686 TRACE("(%p)->(%x)\n", This, dwReserved);
688 if(dwReserved)
689 WARN("dwReserved = %d\n", dwReserved);
691 /* NOTE:
692 * Windows implementation calls QueryInterface(IID_IOleCommandTarget),
693 * QueryInterface(IID_IOleControlSite) and KillTimer
696 IOleDocumentView_Show(iface, FALSE);
698 return S_OK;
701 static HRESULT WINAPI OleDocumentView_SaveViewState(IOleDocumentView *iface, LPSTREAM pstm)
703 HTMLDocument *This = impl_from_IOleDocumentView(iface);
704 FIXME("(%p)->(%p)\n", This, pstm);
705 return E_NOTIMPL;
708 static HRESULT WINAPI OleDocumentView_ApplyViewState(IOleDocumentView *iface, LPSTREAM pstm)
710 HTMLDocument *This = impl_from_IOleDocumentView(iface);
711 FIXME("(%p)->(%p)\n", This, pstm);
712 return E_NOTIMPL;
715 static HRESULT WINAPI OleDocumentView_Clone(IOleDocumentView *iface, IOleInPlaceSite *pIPSiteNew,
716 IOleDocumentView **ppViewNew)
718 HTMLDocument *This = impl_from_IOleDocumentView(iface);
719 FIXME("(%p)->(%p %p)\n", This, pIPSiteNew, ppViewNew);
720 return E_NOTIMPL;
723 static const IOleDocumentViewVtbl OleDocumentViewVtbl = {
724 OleDocumentView_QueryInterface,
725 OleDocumentView_AddRef,
726 OleDocumentView_Release,
727 OleDocumentView_SetInPlaceSite,
728 OleDocumentView_GetInPlaceSite,
729 OleDocumentView_GetDocument,
730 OleDocumentView_SetRect,
731 OleDocumentView_GetRect,
732 OleDocumentView_SetRectComplex,
733 OleDocumentView_Show,
734 OleDocumentView_UIActivate,
735 OleDocumentView_Open,
736 OleDocumentView_CloseView,
737 OleDocumentView_SaveViewState,
738 OleDocumentView_ApplyViewState,
739 OleDocumentView_Clone
742 /**********************************************************
743 * IViewObject implementation
746 static inline HTMLDocument *impl_from_IViewObjectEx(IViewObjectEx *iface)
748 return CONTAINING_RECORD(iface, HTMLDocument, IViewObjectEx_iface);
751 static HRESULT WINAPI ViewObject_QueryInterface(IViewObjectEx *iface, REFIID riid, void **ppv)
753 HTMLDocument *This = impl_from_IViewObjectEx(iface);
754 return htmldoc_query_interface(This, riid, ppv);
757 static ULONG WINAPI ViewObject_AddRef(IViewObjectEx *iface)
759 HTMLDocument *This = impl_from_IViewObjectEx(iface);
760 return htmldoc_addref(This);
763 static ULONG WINAPI ViewObject_Release(IViewObjectEx *iface)
765 HTMLDocument *This = impl_from_IViewObjectEx(iface);
766 return htmldoc_release(This);
769 static HRESULT WINAPI ViewObject_Draw(IViewObjectEx *iface, DWORD dwDrawAspect, LONG lindex, void *pvAspect,
770 DVTARGETDEVICE *ptd, HDC hdcTargetDev, HDC hdcDraw, LPCRECTL lprcBounds,
771 LPCRECTL lprcWBounds, BOOL (CALLBACK *pfnContinue)(ULONG_PTR dwContinue), ULONG_PTR dwContinue)
773 HTMLDocument *This = impl_from_IViewObjectEx(iface);
774 FIXME("(%p)->(%d %d %p %p %p %p %p %p %p %ld)\n", This, dwDrawAspect, lindex, pvAspect,
775 ptd, hdcTargetDev, hdcDraw, lprcBounds, lprcWBounds, pfnContinue, dwContinue);
776 return E_NOTIMPL;
779 static HRESULT WINAPI ViewObject_GetColorSet(IViewObjectEx *iface, DWORD dwDrawAspect, LONG lindex, void *pvAspect,
780 DVTARGETDEVICE *ptd, HDC hicTargetDev, LOGPALETTE **ppColorSet)
782 HTMLDocument *This = impl_from_IViewObjectEx(iface);
783 FIXME("(%p)->(%d %d %p %p %p %p)\n", This, dwDrawAspect, lindex, pvAspect, ptd, hicTargetDev, ppColorSet);
784 return E_NOTIMPL;
787 static HRESULT WINAPI ViewObject_Freeze(IViewObjectEx *iface, DWORD dwDrawAspect, LONG lindex,
788 void *pvAspect, DWORD *pdwFreeze)
790 HTMLDocument *This = impl_from_IViewObjectEx(iface);
791 FIXME("(%p)->(%d %d %p %p)\n", This, dwDrawAspect, lindex, pvAspect, pdwFreeze);
792 return E_NOTIMPL;
795 static HRESULT WINAPI ViewObject_Unfreeze(IViewObjectEx *iface, DWORD dwFreeze)
797 HTMLDocument *This = impl_from_IViewObjectEx(iface);
798 FIXME("(%p)->(%d)\n", This, dwFreeze);
799 return E_NOTIMPL;
802 static HRESULT WINAPI ViewObject_SetAdvise(IViewObjectEx *iface, DWORD aspects, DWORD advf, IAdviseSink *pAdvSink)
804 HTMLDocument *This = impl_from_IViewObjectEx(iface);
806 TRACE("(%p)->(%d %d %p)\n", This, aspects, advf, pAdvSink);
808 if(aspects != DVASPECT_CONTENT || advf != ADVF_PRIMEFIRST)
809 FIXME("unsupported arguments\n");
811 if(This->doc_obj->view_sink)
812 IAdviseSink_Release(This->doc_obj->view_sink);
813 if(pAdvSink)
814 IAdviseSink_AddRef(pAdvSink);
816 This->doc_obj->view_sink = pAdvSink;
817 return S_OK;
820 static HRESULT WINAPI ViewObject_GetAdvise(IViewObjectEx *iface, DWORD *pAspects, DWORD *pAdvf, IAdviseSink **ppAdvSink)
822 HTMLDocument *This = impl_from_IViewObjectEx(iface);
823 FIXME("(%p)->(%p %p %p)\n", This, pAspects, pAdvf, ppAdvSink);
824 return E_NOTIMPL;
827 static HRESULT WINAPI ViewObject_GetExtent(IViewObjectEx *iface, DWORD dwDrawAspect, LONG lindex,
828 DVTARGETDEVICE* ptd, LPSIZEL lpsizel)
830 HTMLDocument *This = impl_from_IViewObjectEx(iface);
831 FIXME("(%p)->(%d %d %p %p)\n", This, dwDrawAspect, lindex, ptd, lpsizel);
832 return E_NOTIMPL;
835 static HRESULT WINAPI ViewObject_GetRect(IViewObjectEx *iface, DWORD dwAspect, LPRECTL pRect)
837 HTMLDocument *This = impl_from_IViewObjectEx(iface);
838 FIXME("(%p)->(%d %p)\n", This, dwAspect, pRect);
839 return E_NOTIMPL;
842 static HRESULT WINAPI ViewObject_GetViewStatus(IViewObjectEx *iface, DWORD *pdwStatus)
844 HTMLDocument *This = impl_from_IViewObjectEx(iface);
845 FIXME("(%p)->(%p)\n", This, pdwStatus);
846 return E_NOTIMPL;
849 static HRESULT WINAPI ViewObject_QueryHitPoint(IViewObjectEx* iface, DWORD dwAspect,
850 LPCRECT pRectBounds, POINT ptlLoc, LONG lCloseHint, DWORD *pHitResult)
852 HTMLDocument *This = impl_from_IViewObjectEx(iface);
853 FIXME("(%p)->(%d %p (%d %d) %d %p)\n", This, dwAspect, pRectBounds, ptlLoc.x,
854 ptlLoc.y, lCloseHint, pHitResult);
855 return E_NOTIMPL;
858 static HRESULT WINAPI ViewObject_QueryHitRect(IViewObjectEx *iface, DWORD dwAspect,
859 LPCRECT pRectBounds, LPCRECT pRectLoc, LONG lCloseHint, DWORD *pHitResult)
861 HTMLDocument *This = impl_from_IViewObjectEx(iface);
862 FIXME("(%p)->(%d %p %p %d %p)\n", This, dwAspect, pRectBounds, pRectLoc, lCloseHint, pHitResult);
863 return E_NOTIMPL;
866 static HRESULT WINAPI ViewObject_GetNaturalExtent(IViewObjectEx *iface, DWORD dwAspect, LONG lindex,
867 DVTARGETDEVICE *ptd, HDC hicTargetDev, DVEXTENTINFO *pExtentInfo, LPSIZEL pSizel)
869 HTMLDocument *This = impl_from_IViewObjectEx(iface);
870 FIXME("(%p)->(%d %d %p %p %p %p\n", This, dwAspect,lindex, ptd,
871 hicTargetDev, pExtentInfo, pSizel);
872 return E_NOTIMPL;
875 static const IViewObjectExVtbl ViewObjectVtbl = {
876 ViewObject_QueryInterface,
877 ViewObject_AddRef,
878 ViewObject_Release,
879 ViewObject_Draw,
880 ViewObject_GetColorSet,
881 ViewObject_Freeze,
882 ViewObject_Unfreeze,
883 ViewObject_SetAdvise,
884 ViewObject_GetAdvise,
885 ViewObject_GetExtent,
886 ViewObject_GetRect,
887 ViewObject_GetViewStatus,
888 ViewObject_QueryHitPoint,
889 ViewObject_QueryHitRect,
890 ViewObject_GetNaturalExtent
893 void HTMLDocument_View_Init(HTMLDocument *This)
895 This->IOleDocumentView_iface.lpVtbl = &OleDocumentViewVtbl;
896 This->IViewObjectEx_iface.lpVtbl = &ViewObjectVtbl;
899 static inline HTMLDocumentObj *impl_from_IWindowForBindingUI(IWindowForBindingUI *iface)
901 return CONTAINING_RECORD(iface, HTMLDocumentObj, IWindowForBindingUI_iface);
904 static HRESULT WINAPI WindowForBindingUI_QueryInterface(IWindowForBindingUI *iface, REFIID riid, void **ppv)
906 HTMLDocumentObj *This = impl_from_IWindowForBindingUI(iface);
908 if(IsEqualGUID(&IID_IUnknown, riid)) {
909 TRACE("(%p)->(IID_IUnknown %p)\n", This, ppv);
910 *ppv = &This->IWindowForBindingUI_iface;
911 }else if(IsEqualGUID(&IID_IWindowForBindingUI, riid)) {
912 TRACE("(%p)->(IID_IWindowForBindingUI %p)\n", This, ppv);
913 *ppv = &This->IWindowForBindingUI_iface;
914 }else {
915 WARN("(%p)->(%s %p)\n", This, debugstr_guid(riid), ppv);
916 *ppv = NULL;
917 return E_NOINTERFACE;
920 IUnknown_AddRef((IUnknown*)*ppv);
921 return S_OK;
924 static ULONG WINAPI WindowForBindingUI_AddRef(IWindowForBindingUI *iface)
926 HTMLDocumentObj *This = impl_from_IWindowForBindingUI(iface);
927 return htmldoc_addref(&This->basedoc);
930 static ULONG WINAPI WindowForBindingUI_Release(IWindowForBindingUI *iface)
932 HTMLDocumentObj *This = impl_from_IWindowForBindingUI(iface);
933 return htmldoc_release(&This->basedoc);
936 static HRESULT WINAPI WindowForBindingUI_GetWindow(IWindowForBindingUI *iface, REFGUID rguidReason, HWND *phwnd)
938 HTMLDocumentObj *This = impl_from_IWindowForBindingUI(iface);
940 TRACE("(%p)->(%s %p)\n", This, debugstr_guid(rguidReason), phwnd);
942 *phwnd = This->hwnd;
943 return S_OK;
946 static const IWindowForBindingUIVtbl WindowForBindingUIVtbl = {
947 WindowForBindingUI_QueryInterface,
948 WindowForBindingUI_AddRef,
949 WindowForBindingUI_Release,
950 WindowForBindingUI_GetWindow
953 void init_binding_ui(HTMLDocumentObj *doc)
955 doc->IWindowForBindingUI_iface.lpVtbl = &WindowForBindingUIVtbl;