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
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;
53 static void paint_document(HTMLDocumentObj
*This
)
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 if(!This
->nscontainer
) {
67 WCHAR wszHTMLDisabled
[100];
70 LoadStringW(hInst
, IDS_HTMLDISABLED
, wszHTMLDisabled
, sizeof(wszHTMLDisabled
)/sizeof(WCHAR
));
72 font
= CreateFontA(25,0,0,0,400,0,0,0,ANSI_CHARSET
,0,0,DEFAULT_QUALITY
,DEFAULT_PITCH
,NULL
);
74 SelectObject(hdc
, font
);
75 SelectObject(hdc
, GetSysColorBrush(COLOR_WINDOW
));
77 Rectangle(hdc
, rect
.left
, rect
.top
, rect
.right
, rect
.bottom
);
78 DrawTextW(hdc
, wszHTMLDisabled
,-1, &rect
, DT_CENTER
| DT_SINGLELINE
| DT_VCENTER
);
83 EndPaint(This
->hwnd
, &ps
);
86 static void activate_gecko(NSContainer
*This
)
88 TRACE("(%p) %p\n", This
, This
->window
);
90 SetParent(This
->hwnd
, This
->doc
->hwnd
);
91 ShowWindow(This
->hwnd
, SW_SHOW
);
93 nsIBaseWindow_SetVisibility(This
->window
, TRUE
);
94 nsIBaseWindow_SetEnabled(This
->window
, TRUE
);
97 void update_doc(HTMLDocument
*This
, DWORD flags
)
99 if(!This
->doc_obj
->update
&& This
->doc_obj
->hwnd
)
100 SetTimer(This
->doc_obj
->hwnd
, TIMER_ID
, 100, NULL
);
102 This
->doc_obj
->update
|= flags
;
105 void update_title(HTMLDocumentObj
*This
)
107 IOleCommandTarget
*olecmd
;
110 if(!(This
->update
& UPDATE_TITLE
))
113 This
->update
&= ~UPDATE_TITLE
;
118 hres
= IOleClientSite_QueryInterface(This
->client
, &IID_IOleCommandTarget
, (void**)&olecmd
);
119 if(SUCCEEDED(hres
)) {
123 V_VT(&title
) = VT_BSTR
;
124 V_BSTR(&title
) = SysAllocString(empty
);
125 IOleCommandTarget_Exec(olecmd
, NULL
, OLECMDID_SETTITLE
, OLECMDEXECOPT_DONTPROMPTUSER
,
127 SysFreeString(V_BSTR(&title
));
129 IOleCommandTarget_Release(olecmd
);
133 static LRESULT
on_timer(HTMLDocumentObj
*This
)
135 TRACE("(%p) %x\n", This
, This
->update
);
137 KillTimer(This
->hwnd
, TIMER_ID
);
142 if(This
->update
& UPDATE_UI
) {
144 IDocHostUIHandler_UpdateUI(This
->hostui
);
147 IOleCommandTarget
*cmdtrg
;
150 hres
= IOleClientSite_QueryInterface(This
->client
, &IID_IOleCommandTarget
,
152 if(SUCCEEDED(hres
)) {
153 IOleCommandTarget_Exec(cmdtrg
, NULL
, OLECMDID_UPDATECOMMANDS
,
154 OLECMDEXECOPT_DONTPROMPTUSER
, NULL
, NULL
);
155 IOleCommandTarget_Release(cmdtrg
);
165 void notif_focus(HTMLDocumentObj
*This
)
167 IOleControlSite
*site
;
173 hres
= IOleClientSite_QueryInterface(This
->client
, &IID_IOleControlSite
, (void**)&site
);
177 IOleControlSite_OnFocus(site
, This
->focus
);
178 IOleControlSite_Release(site
);
181 static LRESULT WINAPI
serverwnd_proc(HWND hwnd
, UINT msg
, WPARAM wParam
, LPARAM lParam
)
183 HTMLDocumentObj
*This
;
185 static const WCHAR wszTHIS
[] = {'T','H','I','S',0};
187 if(msg
== WM_CREATE
) {
188 This
= *(HTMLDocumentObj
**)lParam
;
189 SetPropW(hwnd
, wszTHIS
, This
);
191 This
= GetPropW(hwnd
, wszTHIS
);
199 paint_document(This
);
202 TRACE("(%p)->(WM_SIZE)\n", This
);
203 if(This
->nscontainer
) {
206 if(!(This
->hostinfo
.dwFlags
& (DOCHOSTUIFLAG_NO3DOUTERBORDER
|DOCHOSTUIFLAG_NO3DBORDER
))) {
207 ew
= GetSystemMetrics(SM_CXEDGE
);
208 eh
= GetSystemMetrics(SM_CYEDGE
);
211 SetWindowPos(This
->nscontainer
->hwnd
, NULL
, ew
, eh
,
212 LOWORD(lParam
) - 2*ew
, HIWORD(lParam
) - 2*eh
,
213 SWP_NOZORDER
| SWP_NOACTIVATE
);
217 return on_timer(This
);
219 TRACE("(%p) WM_SETFOCUS\n", This
);
220 nsIWebBrowserFocus_Activate(This
->nscontainer
->focus
);
222 case WM_MOUSEACTIVATE
:
226 return DefWindowProcW(hwnd
, msg
, wParam
, lParam
);
229 static void register_serverwnd_class(void)
231 static WNDCLASSEXW wndclass
= {
235 0, 0, NULL
, NULL
, NULL
, NULL
, NULL
,
236 wszInternetExplorer_Server
,
239 wndclass
.hInstance
= hInst
;
240 serverwnd_class
= RegisterClassExW(&wndclass
);
243 static HRESULT
activate_window(HTMLDocumentObj
*This
)
245 IOleInPlaceFrame
*pIPFrame
;
246 IOleCommandTarget
*cmdtrg
;
247 IOleInPlaceSiteEx
*ipsiteex
;
248 RECT posrect
, cliprect
;
249 OLEINPLACEFRAMEINFO frameinfo
;
254 register_serverwnd_class();
256 hres
= IOleInPlaceSite_CanInPlaceActivate(This
->ipsite
);
258 WARN("CanInPlaceActivate returned: %08x\n", hres
);
259 return FAILED(hres
) ? hres
: E_FAIL
;
262 frameinfo
.cb
= sizeof(OLEINPLACEFRAMEINFO
);
263 hres
= IOleInPlaceSite_GetWindowContext(This
->ipsite
, &pIPFrame
, &This
->ip_window
,
264 &posrect
, &cliprect
, &frameinfo
);
266 WARN("GetWindowContext failed: %08x\n", hres
);
270 TRACE("got window context: %p %p {%d %d %d %d} {%d %d %d %d} {%d %x %p %p %d}\n",
271 pIPFrame
, This
->ip_window
, posrect
.left
, posrect
.top
, posrect
.right
, posrect
.bottom
,
272 cliprect
.left
, cliprect
.top
, cliprect
.right
, cliprect
.bottom
,
273 frameinfo
.cb
, frameinfo
.fMDIApp
, frameinfo
.hwndFrame
, frameinfo
.haccel
, frameinfo
.cAccelEntries
);
275 hres
= IOleInPlaceSite_GetWindow(This
->ipsite
, &parent_hwnd
);
277 WARN("GetWindow failed: %08x\n", hres
);
281 TRACE("got parent window %p\n", parent_hwnd
);
284 if(GetParent(This
->hwnd
) != parent_hwnd
)
285 SetParent(This
->hwnd
, parent_hwnd
);
286 SetWindowPos(This
->hwnd
, HWND_TOP
,
287 posrect
.left
, posrect
.top
, posrect
.right
-posrect
.left
, posrect
.bottom
-posrect
.top
,
288 SWP_NOACTIVATE
| SWP_SHOWWINDOW
);
290 CreateWindowExW(0, wszInternetExplorer_Server
, NULL
,
291 WS_CHILD
| WS_CLIPSIBLINGS
| WS_CLIPCHILDREN
,
292 posrect
.left
, posrect
.top
, posrect
.right
-posrect
.left
, posrect
.bottom
-posrect
.top
,
293 parent_hwnd
, NULL
, hInst
, This
);
295 TRACE("Created window %p\n", This
->hwnd
);
297 SetWindowPos(This
->hwnd
, NULL
, 0, 0, 0, 0,
298 SWP_NOSIZE
| SWP_NOMOVE
| SWP_NOZORDER
| SWP_NOREDRAW
| SWP_NOACTIVATE
| SWP_SHOWWINDOW
);
299 RedrawWindow(This
->hwnd
, NULL
, NULL
, RDW_INVALIDATE
| RDW_NOERASE
| RDW_ALLCHILDREN
);
302 * Windows implementation calls:
303 * RegisterWindowMessage("MSWHEEL_ROLLMSG");
305 SetTimer(This
->hwnd
, TIMER_ID
, 100, NULL
);
308 if(This
->nscontainer
)
309 activate_gecko(This
->nscontainer
);
311 This
->in_place_active
= TRUE
;
312 hres
= IOleInPlaceSite_QueryInterface(This
->ipsite
, &IID_IOleInPlaceSiteEx
, (void**)&ipsiteex
);
313 if(SUCCEEDED(hres
)) {
316 hres
= IOleInPlaceSiteEx_OnInPlaceActivateEx(ipsiteex
, &redraw
, 0);
317 IOleInPlaceSiteEx_Release(ipsiteex
);
319 FIXME("unsupported redraw\n");
321 hres
= IOleInPlaceSite_OnInPlaceActivate(This
->ipsite
);
324 WARN("OnInPlaceActivate failed: %08x\n", hres
);
325 This
->in_place_active
= FALSE
;
329 hres
= IOleClientSite_QueryInterface(This
->client
, &IID_IOleCommandTarget
, (void**)&cmdtrg
);
330 if(SUCCEEDED(hres
)) {
333 IOleInPlaceFrame_SetStatusText(pIPFrame
, NULL
);
337 IOleCommandTarget_Exec(cmdtrg
, NULL
, OLECMDID_SETPROGRESSMAX
,
338 OLECMDEXECOPT_DONTPROMPTUSER
, &var
, NULL
);
339 IOleCommandTarget_Exec(cmdtrg
, NULL
, OLECMDID_SETPROGRESSPOS
,
340 OLECMDEXECOPT_DONTPROMPTUSER
, &var
, NULL
);
342 IOleCommandTarget_Release(cmdtrg
);
346 IOleInPlaceFrame_Release(This
->frame
);
347 This
->frame
= pIPFrame
;
349 if(!This
->request_uiactivate
) {
350 hres
= IOleInPlaceSite_QueryInterface(This
->ipsite
, &IID_IOleInPlaceSiteEx
, (void**)&ipsiteex
);
351 if(SUCCEEDED(hres
)) {
352 IOleInPlaceSiteEx_RequestUIActivate(ipsiteex
);
353 IOleInPlaceSiteEx_Release(ipsiteex
);
357 This
->window_active
= TRUE
;
362 static LRESULT WINAPI
tooltips_proc(HWND hwnd
, UINT msg
, WPARAM wParam
, LPARAM lParam
)
364 tooltip_data
*data
= GetPropW(hwnd
, wszTooltipData
);
366 TRACE("%d %p\n", msg
, data
);
368 if(msg
== TTM_WINDOWFROMPOINT
) {
370 POINT
*pt
= (POINT
*)lParam
;
372 TRACE("TTM_WINDOWFROMPOINT (%d,%d)\n", pt
->x
, pt
->y
);
374 GetWindowRect(data
->doc
->hwnd
, &rect
);
376 if(rect
.left
<= pt
->x
&& pt
->x
<= rect
.right
377 && rect
.top
<= pt
->y
&& pt
->y
<= rect
.bottom
)
378 return (LPARAM
)data
->doc
->hwnd
;
381 return CallWindowProcW(data
->proc
, hwnd
, msg
, wParam
, lParam
);
384 static void create_tooltips_window(HTMLDocumentObj
*This
)
386 tooltip_data
*data
= heap_alloc(sizeof(*data
));
388 This
->tooltips_hwnd
= CreateWindowExW(0, TOOLTIPS_CLASSW
, NULL
, TTS_NOPREFIX
| WS_POPUP
,
389 CW_USEDEFAULT
, CW_USEDEFAULT
, 10, 10, This
->hwnd
, NULL
, hInst
, NULL
);
392 data
->proc
= (WNDPROC
)GetWindowLongPtrW(This
->tooltips_hwnd
, GWLP_WNDPROC
);
394 SetPropW(This
->tooltips_hwnd
, wszTooltipData
, data
);
396 SetWindowLongPtrW(This
->tooltips_hwnd
, GWLP_WNDPROC
, (LONG_PTR
)tooltips_proc
);
398 SetWindowPos(This
->tooltips_hwnd
, HWND_TOPMOST
,0, 0, 0, 0,
399 SWP_NOMOVE
| SWP_NOSIZE
| SWP_NOACTIVATE
);
403 void show_tooltip(HTMLDocumentObj
*This
, DWORD x
, DWORD y
, LPCWSTR text
)
405 TTTOOLINFOW toolinfo
= {
406 sizeof(TTTOOLINFOW
), 0, This
->hwnd
, 0xdeadbeef,
407 {x
>2 ? x
-2 : 0, y
>0 ? y
-2 : 0, x
+2, y
+2}, /* FIXME */
408 NULL
, (LPWSTR
)text
, 0};
409 MSG msg
= {This
->hwnd
, WM_MOUSEMOVE
, 0, MAKELPARAM(x
,y
), 0, {x
,y
}};
411 TRACE("(%p)->(%d %d %s)\n", This
, x
, y
, debugstr_w(text
));
413 if(!This
->tooltips_hwnd
)
414 create_tooltips_window(This
);
416 SendMessageW(This
->tooltips_hwnd
, TTM_ADDTOOLW
, 0, (LPARAM
)&toolinfo
);
417 SendMessageW(This
->tooltips_hwnd
, TTM_ACTIVATE
, TRUE
, 0);
418 SendMessageW(This
->tooltips_hwnd
, TTM_RELAYEVENT
, 0, (LPARAM
)&msg
);
421 void hide_tooltip(HTMLDocumentObj
*This
)
423 TTTOOLINFOW toolinfo
= {
424 sizeof(TTTOOLINFOW
), 0, This
->hwnd
, 0xdeadbeef,
425 {0,0,0,0}, NULL
, NULL
, 0};
427 TRACE("(%p)\n", This
);
429 SendMessageW(This
->tooltips_hwnd
, TTM_DELTOOLW
, 0, (LPARAM
)&toolinfo
);
430 SendMessageW(This
->tooltips_hwnd
, TTM_ACTIVATE
, FALSE
, 0);
433 HRESULT
call_set_active_object(IOleInPlaceUIWindow
*window
, IOleInPlaceActiveObject
*act_obj
)
435 static WCHAR html_documentW
[30];
437 if(act_obj
&& !html_documentW
[0]) {
438 LoadStringW(hInst
, IDS_HTMLDOCUMENT
, html_documentW
,
439 sizeof(html_documentW
)/sizeof(WCHAR
));
442 return IOleInPlaceUIWindow_SetActiveObject(window
, act_obj
, act_obj
? html_documentW
: NULL
);
445 /**********************************************************
446 * IOleDocumentView implementation
449 static inline HTMLDocument
*impl_from_IOleDocumentView(IOleDocumentView
*iface
)
451 return CONTAINING_RECORD(iface
, HTMLDocument
, IOleDocumentView_iface
);
454 static HRESULT WINAPI
OleDocumentView_QueryInterface(IOleDocumentView
*iface
, REFIID riid
, void **ppvObject
)
456 HTMLDocument
*This
= impl_from_IOleDocumentView(iface
);
457 return htmldoc_query_interface(This
, riid
, ppvObject
);
460 static ULONG WINAPI
OleDocumentView_AddRef(IOleDocumentView
*iface
)
462 HTMLDocument
*This
= impl_from_IOleDocumentView(iface
);
463 return htmldoc_addref(This
);
466 static ULONG WINAPI
OleDocumentView_Release(IOleDocumentView
*iface
)
468 HTMLDocument
*This
= impl_from_IOleDocumentView(iface
);
469 return htmldoc_release(This
);
472 static HRESULT WINAPI
OleDocumentView_SetInPlaceSite(IOleDocumentView
*iface
, IOleInPlaceSite
*pIPSite
)
474 HTMLDocument
*This
= impl_from_IOleDocumentView(iface
);
475 TRACE("(%p)->(%p)\n", This
, pIPSite
);
478 IOleInPlaceSite_AddRef(pIPSite
);
480 if(This
->doc_obj
->ipsite
)
481 IOleInPlaceSite_Release(This
->doc_obj
->ipsite
);
483 This
->doc_obj
->ipsite
= pIPSite
;
484 This
->doc_obj
->request_uiactivate
= TRUE
;
488 static HRESULT WINAPI
OleDocumentView_GetInPlaceSite(IOleDocumentView
*iface
, IOleInPlaceSite
**ppIPSite
)
490 HTMLDocument
*This
= impl_from_IOleDocumentView(iface
);
491 TRACE("(%p)->(%p)\n", This
, ppIPSite
);
496 if(This
->doc_obj
->ipsite
)
497 IOleInPlaceSite_AddRef(This
->doc_obj
->ipsite
);
499 *ppIPSite
= This
->doc_obj
->ipsite
;
503 static HRESULT WINAPI
OleDocumentView_GetDocument(IOleDocumentView
*iface
, IUnknown
**ppunk
)
505 HTMLDocument
*This
= impl_from_IOleDocumentView(iface
);
506 TRACE("(%p)->(%p)\n", This
, ppunk
);
511 htmldoc_addref(This
);
512 *ppunk
= (IUnknown
*)&This
->IHTMLDocument2_iface
;
516 static HRESULT WINAPI
OleDocumentView_SetRect(IOleDocumentView
*iface
, LPRECT prcView
)
518 HTMLDocument
*This
= impl_from_IOleDocumentView(iface
);
521 TRACE("(%p)->(%p)\n", This
, prcView
);
526 if(This
->doc_obj
->hwnd
) {
527 GetClientRect(This
->doc_obj
->hwnd
, &rect
);
528 if(memcmp(prcView
, &rect
, sizeof(RECT
))) {
529 InvalidateRect(This
->doc_obj
->hwnd
, NULL
, TRUE
);
530 SetWindowPos(This
->doc_obj
->hwnd
, NULL
, prcView
->left
, prcView
->top
, prcView
->right
,
531 prcView
->bottom
, SWP_NOZORDER
| SWP_NOACTIVATE
);
538 static HRESULT WINAPI
OleDocumentView_GetRect(IOleDocumentView
*iface
, LPRECT prcView
)
540 HTMLDocument
*This
= impl_from_IOleDocumentView(iface
);
542 TRACE("(%p)->(%p)\n", This
, prcView
);
547 GetClientRect(This
->doc_obj
->hwnd
, prcView
);
551 static HRESULT WINAPI
OleDocumentView_SetRectComplex(IOleDocumentView
*iface
, LPRECT prcView
,
552 LPRECT prcHScroll
, LPRECT prcVScroll
, LPRECT prcSizeBox
)
554 HTMLDocument
*This
= impl_from_IOleDocumentView(iface
);
555 FIXME("(%p)->(%p %p %p %p)\n", This
, prcView
, prcHScroll
, prcVScroll
, prcSizeBox
);
559 static HRESULT WINAPI
OleDocumentView_Show(IOleDocumentView
*iface
, BOOL fShow
)
561 HTMLDocument
*This
= impl_from_IOleDocumentView(iface
);
564 TRACE("(%p)->(%x)\n", This
, fShow
);
567 if(!This
->doc_obj
->ui_active
) {
568 hres
= activate_window(This
->doc_obj
);
572 update_doc(This
, UPDATE_UI
);
573 ShowWindow(This
->doc_obj
->hwnd
, SW_SHOW
);
575 ShowWindow(This
->doc_obj
->hwnd
, SW_HIDE
);
577 if(This
->doc_obj
->in_place_active
)
578 IOleInPlaceObjectWindowless_InPlaceDeactivate(&This
->IOleInPlaceObjectWindowless_iface
);
580 if(This
->doc_obj
->ip_window
) {
581 IOleInPlaceUIWindow_Release(This
->doc_obj
->ip_window
);
582 This
->doc_obj
->ip_window
= NULL
;
589 static HRESULT WINAPI
OleDocumentView_UIActivate(IOleDocumentView
*iface
, BOOL fUIActivate
)
591 HTMLDocument
*This
= impl_from_IOleDocumentView(iface
);
594 TRACE("(%p)->(%x)\n", This
, fUIActivate
);
596 if(!This
->doc_obj
->ipsite
) {
597 IOleClientSite
*cs
= This
->doc_obj
->client
;
598 IOleInPlaceSite
*ips
;
601 WARN("this->ipsite = NULL\n");
605 hres
= IOleClientSite_QueryInterface(cs
, &IID_IOleInPlaceSiteWindowless
, (void**)&ips
);
607 This
->doc_obj
->ipsite
= ips
;
609 hres
= IOleClientSite_QueryInterface(cs
, &IID_IOleInPlaceSiteEx
, (void**)&ips
);
611 This
->doc_obj
->ipsite
= ips
;
613 hres
= IOleClientSite_QueryInterface(cs
, &IID_IOleInPlaceSite
, (void**)&ips
);
615 This
->doc_obj
->ipsite
= ips
;
617 WARN("this->ipsite = NULL\n");
618 return E_NOINTERFACE
;
623 IOleInPlaceSite_AddRef(This
->doc_obj
->ipsite
);
624 This
->doc_obj
->request_uiactivate
= FALSE
;
625 HTMLDocument_LockContainer(This
->doc_obj
, TRUE
);
631 if(This
->doc_obj
->ui_active
)
634 if(!This
->doc_obj
->window_active
) {
635 hres
= activate_window(This
->doc_obj
);
640 This
->doc_obj
->focus
= TRUE
;
641 if(This
->doc_obj
->nscontainer
)
642 nsIWebBrowserFocus_Activate(This
->doc_obj
->nscontainer
->focus
);
643 notif_focus(This
->doc_obj
);
645 update_doc(This
, UPDATE_UI
);
647 hres
= IOleInPlaceSite_OnUIActivate(This
->doc_obj
->ipsite
);
648 if(SUCCEEDED(hres
)) {
649 call_set_active_object((IOleInPlaceUIWindow
*)This
->doc_obj
->frame
,
650 &This
->IOleInPlaceActiveObject_iface
);
652 FIXME("OnUIActivate failed: %08x\n", hres
);
653 IOleInPlaceFrame_Release(This
->doc_obj
->frame
);
654 This
->doc_obj
->frame
= NULL
;
655 This
->doc_obj
->ui_active
= FALSE
;
659 if(This
->doc_obj
->hostui
) {
660 hres
= IDocHostUIHandler_ShowUI(This
->doc_obj
->hostui
,
661 This
->doc_obj
->usermode
== EDITMODE
? DOCHOSTUITYPE_AUTHOR
: DOCHOSTUITYPE_BROWSE
,
662 &This
->IOleInPlaceActiveObject_iface
, &This
->IOleCommandTarget_iface
,
663 This
->doc_obj
->frame
, This
->doc_obj
->ip_window
);
665 IDocHostUIHandler_HideUI(This
->doc_obj
->hostui
);
668 if(This
->doc_obj
->ip_window
)
669 call_set_active_object(This
->doc_obj
->ip_window
, &This
->IOleInPlaceActiveObject_iface
);
671 memset(&rcBorderWidths
, 0, sizeof(rcBorderWidths
));
672 IOleInPlaceFrame_SetBorderSpace(This
->doc_obj
->frame
, &rcBorderWidths
);
674 This
->doc_obj
->ui_active
= TRUE
;
676 This
->doc_obj
->focus
= FALSE
;
677 nsIWebBrowserFocus_Deactivate(This
->doc_obj
->nscontainer
->focus
);
678 if(This
->doc_obj
->ui_active
) {
679 This
->doc_obj
->ui_active
= FALSE
;
680 if(This
->doc_obj
->ip_window
)
681 call_set_active_object(This
->doc_obj
->ip_window
, NULL
);
682 if(This
->doc_obj
->frame
)
683 call_set_active_object((IOleInPlaceUIWindow
*)This
->doc_obj
->frame
, NULL
);
684 if(This
->doc_obj
->hostui
)
685 IDocHostUIHandler_HideUI(This
->doc_obj
->hostui
);
686 if(This
->doc_obj
->ipsite
)
687 IOleInPlaceSite_OnUIDeactivate(This
->doc_obj
->ipsite
, FALSE
);
693 static HRESULT WINAPI
OleDocumentView_Open(IOleDocumentView
*iface
)
695 HTMLDocument
*This
= impl_from_IOleDocumentView(iface
);
696 FIXME("(%p)\n", This
);
700 static HRESULT WINAPI
OleDocumentView_CloseView(IOleDocumentView
*iface
, DWORD dwReserved
)
702 HTMLDocument
*This
= impl_from_IOleDocumentView(iface
);
703 TRACE("(%p)->(%x)\n", This
, dwReserved
);
706 WARN("dwReserved = %d\n", dwReserved
);
709 * Windows implementation calls QueryInterface(IID_IOleCommandTarget),
710 * QueryInterface(IID_IOleControlSite) and KillTimer
713 IOleDocumentView_Show(iface
, FALSE
);
718 static HRESULT WINAPI
OleDocumentView_SaveViewState(IOleDocumentView
*iface
, LPSTREAM pstm
)
720 HTMLDocument
*This
= impl_from_IOleDocumentView(iface
);
721 FIXME("(%p)->(%p)\n", This
, pstm
);
725 static HRESULT WINAPI
OleDocumentView_ApplyViewState(IOleDocumentView
*iface
, LPSTREAM pstm
)
727 HTMLDocument
*This
= impl_from_IOleDocumentView(iface
);
728 FIXME("(%p)->(%p)\n", This
, pstm
);
732 static HRESULT WINAPI
OleDocumentView_Clone(IOleDocumentView
*iface
, IOleInPlaceSite
*pIPSiteNew
,
733 IOleDocumentView
**ppViewNew
)
735 HTMLDocument
*This
= impl_from_IOleDocumentView(iface
);
736 FIXME("(%p)->(%p %p)\n", This
, pIPSiteNew
, ppViewNew
);
740 static const IOleDocumentViewVtbl OleDocumentViewVtbl
= {
741 OleDocumentView_QueryInterface
,
742 OleDocumentView_AddRef
,
743 OleDocumentView_Release
,
744 OleDocumentView_SetInPlaceSite
,
745 OleDocumentView_GetInPlaceSite
,
746 OleDocumentView_GetDocument
,
747 OleDocumentView_SetRect
,
748 OleDocumentView_GetRect
,
749 OleDocumentView_SetRectComplex
,
750 OleDocumentView_Show
,
751 OleDocumentView_UIActivate
,
752 OleDocumentView_Open
,
753 OleDocumentView_CloseView
,
754 OleDocumentView_SaveViewState
,
755 OleDocumentView_ApplyViewState
,
756 OleDocumentView_Clone
759 /**********************************************************
760 * IViewObject implementation
763 static inline HTMLDocument
*impl_from_IViewObjectEx(IViewObjectEx
*iface
)
765 return CONTAINING_RECORD(iface
, HTMLDocument
, IViewObjectEx_iface
);
768 static HRESULT WINAPI
ViewObject_QueryInterface(IViewObjectEx
*iface
, REFIID riid
, void **ppv
)
770 HTMLDocument
*This
= impl_from_IViewObjectEx(iface
);
771 return htmldoc_query_interface(This
, riid
, ppv
);
774 static ULONG WINAPI
ViewObject_AddRef(IViewObjectEx
*iface
)
776 HTMLDocument
*This
= impl_from_IViewObjectEx(iface
);
777 return htmldoc_addref(This
);
780 static ULONG WINAPI
ViewObject_Release(IViewObjectEx
*iface
)
782 HTMLDocument
*This
= impl_from_IViewObjectEx(iface
);
783 return htmldoc_release(This
);
786 static HRESULT WINAPI
ViewObject_Draw(IViewObjectEx
*iface
, DWORD dwDrawAspect
, LONG lindex
, void *pvAspect
,
787 DVTARGETDEVICE
*ptd
, HDC hdcTargetDev
, HDC hdcDraw
, LPCRECTL lprcBounds
,
788 LPCRECTL lprcWBounds
, BOOL (CALLBACK
*pfnContinue
)(ULONG_PTR dwContinue
), ULONG_PTR dwContinue
)
790 HTMLDocument
*This
= impl_from_IViewObjectEx(iface
);
791 FIXME("(%p)->(%d %d %p %p %p %p %p %p %p %ld)\n", This
, dwDrawAspect
, lindex
, pvAspect
,
792 ptd
, hdcTargetDev
, hdcDraw
, lprcBounds
, lprcWBounds
, pfnContinue
, dwContinue
);
796 static HRESULT WINAPI
ViewObject_GetColorSet(IViewObjectEx
*iface
, DWORD dwDrawAspect
, LONG lindex
, void *pvAspect
,
797 DVTARGETDEVICE
*ptd
, HDC hicTargetDev
, LOGPALETTE
**ppColorSet
)
799 HTMLDocument
*This
= impl_from_IViewObjectEx(iface
);
800 FIXME("(%p)->(%d %d %p %p %p %p)\n", This
, dwDrawAspect
, lindex
, pvAspect
, ptd
, hicTargetDev
, ppColorSet
);
804 static HRESULT WINAPI
ViewObject_Freeze(IViewObjectEx
*iface
, DWORD dwDrawAspect
, LONG lindex
,
805 void *pvAspect
, DWORD
*pdwFreeze
)
807 HTMLDocument
*This
= impl_from_IViewObjectEx(iface
);
808 FIXME("(%p)->(%d %d %p %p)\n", This
, dwDrawAspect
, lindex
, pvAspect
, pdwFreeze
);
812 static HRESULT WINAPI
ViewObject_Unfreeze(IViewObjectEx
*iface
, DWORD dwFreeze
)
814 HTMLDocument
*This
= impl_from_IViewObjectEx(iface
);
815 FIXME("(%p)->(%d)\n", This
, dwFreeze
);
819 static HRESULT WINAPI
ViewObject_SetAdvise(IViewObjectEx
*iface
, DWORD aspects
, DWORD advf
, IAdviseSink
*pAdvSink
)
821 HTMLDocument
*This
= impl_from_IViewObjectEx(iface
);
823 TRACE("(%p)->(%d %d %p)\n", This
, aspects
, advf
, pAdvSink
);
825 if(aspects
!= DVASPECT_CONTENT
|| advf
!= ADVF_PRIMEFIRST
)
826 FIXME("unsupported arguments\n");
828 if(This
->doc_obj
->view_sink
)
829 IAdviseSink_Release(This
->doc_obj
->view_sink
);
831 IAdviseSink_AddRef(pAdvSink
);
833 This
->doc_obj
->view_sink
= pAdvSink
;
837 static HRESULT WINAPI
ViewObject_GetAdvise(IViewObjectEx
*iface
, DWORD
*pAspects
, DWORD
*pAdvf
, IAdviseSink
**ppAdvSink
)
839 HTMLDocument
*This
= impl_from_IViewObjectEx(iface
);
840 FIXME("(%p)->(%p %p %p)\n", This
, pAspects
, pAdvf
, ppAdvSink
);
844 static HRESULT WINAPI
ViewObject_GetExtent(IViewObjectEx
*iface
, DWORD dwDrawAspect
, LONG lindex
,
845 DVTARGETDEVICE
* ptd
, LPSIZEL lpsizel
)
847 HTMLDocument
*This
= impl_from_IViewObjectEx(iface
);
848 FIXME("(%p)->(%d %d %p %p)\n", This
, dwDrawAspect
, lindex
, ptd
, lpsizel
);
852 static HRESULT WINAPI
ViewObject_GetRect(IViewObjectEx
*iface
, DWORD dwAspect
, LPRECTL pRect
)
854 HTMLDocument
*This
= impl_from_IViewObjectEx(iface
);
855 FIXME("(%p)->(%d %p)\n", This
, dwAspect
, pRect
);
859 static HRESULT WINAPI
ViewObject_GetViewStatus(IViewObjectEx
*iface
, DWORD
*pdwStatus
)
861 HTMLDocument
*This
= impl_from_IViewObjectEx(iface
);
862 FIXME("(%p)->(%p)\n", This
, pdwStatus
);
866 static HRESULT WINAPI
ViewObject_QueryHitPoint(IViewObjectEx
* iface
, DWORD dwAspect
,
867 LPCRECT pRectBounds
, POINT ptlLoc
, LONG lCloseHint
, DWORD
*pHitResult
)
869 HTMLDocument
*This
= impl_from_IViewObjectEx(iface
);
870 FIXME("(%p)->(%d %p (%d %d) %d %p)\n", This
, dwAspect
, pRectBounds
, ptlLoc
.x
,
871 ptlLoc
.y
, lCloseHint
, pHitResult
);
875 static HRESULT WINAPI
ViewObject_QueryHitRect(IViewObjectEx
*iface
, DWORD dwAspect
,
876 LPCRECT pRectBounds
, LPCRECT pRectLoc
, LONG lCloseHint
, DWORD
*pHitResult
)
878 HTMLDocument
*This
= impl_from_IViewObjectEx(iface
);
879 FIXME("(%p)->(%d %p %p %d %p)\n", This
, dwAspect
, pRectBounds
, pRectLoc
, lCloseHint
, pHitResult
);
883 static HRESULT WINAPI
ViewObject_GetNaturalExtent(IViewObjectEx
*iface
, DWORD dwAspect
, LONG lindex
,
884 DVTARGETDEVICE
*ptd
, HDC hicTargetDev
, DVEXTENTINFO
*pExtentInfo
, LPSIZEL pSizel
)
886 HTMLDocument
*This
= impl_from_IViewObjectEx(iface
);
887 FIXME("(%p)->(%d %d %p %p %p %p\n", This
, dwAspect
,lindex
, ptd
,
888 hicTargetDev
, pExtentInfo
, pSizel
);
892 static const IViewObjectExVtbl ViewObjectVtbl
= {
893 ViewObject_QueryInterface
,
897 ViewObject_GetColorSet
,
900 ViewObject_SetAdvise
,
901 ViewObject_GetAdvise
,
902 ViewObject_GetExtent
,
904 ViewObject_GetViewStatus
,
905 ViewObject_QueryHitPoint
,
906 ViewObject_QueryHitRect
,
907 ViewObject_GetNaturalExtent
910 void HTMLDocument_View_Init(HTMLDocument
*This
)
912 This
->IOleDocumentView_iface
.lpVtbl
= &OleDocumentViewVtbl
;
913 This
->IViewObjectEx_iface
.lpVtbl
= &ViewObjectVtbl
;
916 static inline HTMLDocumentObj
*impl_from_IWindowForBindingUI(IWindowForBindingUI
*iface
)
918 return CONTAINING_RECORD(iface
, HTMLDocumentObj
, IWindowForBindingUI_iface
);
921 static HRESULT WINAPI
WindowForBindingUI_QueryInterface(IWindowForBindingUI
*iface
, REFIID riid
, void **ppv
)
923 HTMLDocumentObj
*This
= impl_from_IWindowForBindingUI(iface
);
925 if(IsEqualGUID(&IID_IUnknown
, riid
)) {
926 TRACE("(%p)->(IID_IUnknown %p)\n", This
, ppv
);
927 *ppv
= &This
->IWindowForBindingUI_iface
;
928 }else if(IsEqualGUID(&IID_IWindowForBindingUI
, riid
)) {
929 TRACE("(%p)->(IID_IWindowForBindingUI %p)\n", This
, ppv
);
930 *ppv
= &This
->IWindowForBindingUI_iface
;
932 WARN("(%p)->(%s %p)\n", This
, debugstr_guid(riid
), ppv
);
934 return E_NOINTERFACE
;
937 IUnknown_AddRef((IUnknown
*)*ppv
);
941 static ULONG WINAPI
WindowForBindingUI_AddRef(IWindowForBindingUI
*iface
)
943 HTMLDocumentObj
*This
= impl_from_IWindowForBindingUI(iface
);
944 return htmldoc_addref(&This
->basedoc
);
947 static ULONG WINAPI
WindowForBindingUI_Release(IWindowForBindingUI
*iface
)
949 HTMLDocumentObj
*This
= impl_from_IWindowForBindingUI(iface
);
950 return htmldoc_release(&This
->basedoc
);
953 static HRESULT WINAPI
WindowForBindingUI_GetWindow(IWindowForBindingUI
*iface
, REFGUID rguidReason
, HWND
*phwnd
)
955 HTMLDocumentObj
*This
= impl_from_IWindowForBindingUI(iface
);
957 TRACE("(%p)->(%s %p)\n", This
, debugstr_guid(rguidReason
), phwnd
);
963 static const IWindowForBindingUIVtbl WindowForBindingUIVtbl
= {
964 WindowForBindingUI_QueryInterface
,
965 WindowForBindingUI_AddRef
,
966 WindowForBindingUI_Release
,
967 WindowForBindingUI_GetWindow
970 void init_binding_ui(HTMLDocumentObj
*doc
)
972 doc
->IWindowForBindingUI_iface
.lpVtbl
= &WindowForBindingUIVtbl
;