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 hres
= IOleInPlaceSite_GetWindowContext(This
->ipsite
, &pIPFrame
, &This
->ip_window
,
263 &posrect
, &cliprect
, &frameinfo
);
265 WARN("GetWindowContext failed: %08x\n", hres
);
269 TRACE("got window context: %p %p {%d %d %d %d} {%d %d %d %d} {%d %x %p %p %d}\n",
270 pIPFrame
, This
->ip_window
, posrect
.left
, posrect
.top
, posrect
.right
, posrect
.bottom
,
271 cliprect
.left
, cliprect
.top
, cliprect
.right
, cliprect
.bottom
,
272 frameinfo
.cb
, frameinfo
.fMDIApp
, frameinfo
.hwndFrame
, frameinfo
.haccel
, frameinfo
.cAccelEntries
);
274 hres
= IOleInPlaceSite_GetWindow(This
->ipsite
, &parent_hwnd
);
276 WARN("GetWindow failed: %08x\n", hres
);
280 TRACE("got parent window %p\n", parent_hwnd
);
283 if(GetParent(This
->hwnd
) != parent_hwnd
)
284 SetParent(This
->hwnd
, parent_hwnd
);
285 SetWindowPos(This
->hwnd
, HWND_TOP
,
286 posrect
.left
, posrect
.top
, posrect
.right
-posrect
.left
, posrect
.bottom
-posrect
.top
,
287 SWP_NOACTIVATE
| SWP_SHOWWINDOW
);
289 CreateWindowExW(0, wszInternetExplorer_Server
, NULL
,
290 WS_CHILD
| WS_CLIPSIBLINGS
| WS_CLIPCHILDREN
,
291 posrect
.left
, posrect
.top
, posrect
.right
-posrect
.left
, posrect
.bottom
-posrect
.top
,
292 parent_hwnd
, NULL
, hInst
, This
);
294 TRACE("Created window %p\n", This
->hwnd
);
296 SetWindowPos(This
->hwnd
, NULL
, 0, 0, 0, 0,
297 SWP_NOSIZE
| SWP_NOMOVE
| SWP_NOZORDER
| SWP_NOREDRAW
| SWP_NOACTIVATE
| SWP_SHOWWINDOW
);
298 RedrawWindow(This
->hwnd
, NULL
, NULL
, RDW_INVALIDATE
| RDW_NOERASE
| RDW_ALLCHILDREN
);
301 * Windows implementation calls:
302 * RegisterWindowMessage("MSWHEEL_ROLLMSG");
304 SetTimer(This
->hwnd
, TIMER_ID
, 100, NULL
);
307 if(This
->nscontainer
)
308 activate_gecko(This
->nscontainer
);
310 This
->in_place_active
= TRUE
;
311 hres
= IOleInPlaceSite_QueryInterface(This
->ipsite
, &IID_IOleInPlaceSiteEx
, (void**)&ipsiteex
);
312 if(SUCCEEDED(hres
)) {
315 hres
= IOleInPlaceSiteEx_OnInPlaceActivateEx(ipsiteex
, &redraw
, 0);
316 IOleInPlaceSiteEx_Release(ipsiteex
);
318 FIXME("unsupported redraw\n");
320 hres
= IOleInPlaceSite_OnInPlaceActivate(This
->ipsite
);
323 WARN("OnInPlaceActivate failed: %08x\n", hres
);
324 This
->in_place_active
= FALSE
;
328 hres
= IOleClientSite_QueryInterface(This
->client
, &IID_IOleCommandTarget
, (void**)&cmdtrg
);
329 if(SUCCEEDED(hres
)) {
332 IOleInPlaceFrame_SetStatusText(pIPFrame
, NULL
);
336 IOleCommandTarget_Exec(cmdtrg
, NULL
, OLECMDID_SETPROGRESSMAX
,
337 OLECMDEXECOPT_DONTPROMPTUSER
, &var
, NULL
);
338 IOleCommandTarget_Exec(cmdtrg
, NULL
, OLECMDID_SETPROGRESSPOS
,
339 OLECMDEXECOPT_DONTPROMPTUSER
, &var
, NULL
);
341 IOleCommandTarget_Release(cmdtrg
);
345 IOleInPlaceFrame_Release(This
->frame
);
346 This
->frame
= pIPFrame
;
348 if(!This
->request_uiactivate
) {
349 hres
= IOleInPlaceSite_QueryInterface(This
->ipsite
, &IID_IOleInPlaceSiteEx
, (void**)&ipsiteex
);
350 if(SUCCEEDED(hres
)) {
351 IOleInPlaceSiteEx_RequestUIActivate(ipsiteex
);
352 IOleInPlaceSiteEx_Release(ipsiteex
);
356 This
->window_active
= TRUE
;
361 static LRESULT WINAPI
tooltips_proc(HWND hwnd
, UINT msg
, WPARAM wParam
, LPARAM lParam
)
363 tooltip_data
*data
= GetPropW(hwnd
, wszTooltipData
);
365 TRACE("%d %p\n", msg
, data
);
367 if(msg
== TTM_WINDOWFROMPOINT
) {
369 POINT
*pt
= (POINT
*)lParam
;
371 TRACE("TTM_WINDOWFROMPOINT (%d,%d)\n", pt
->x
, pt
->y
);
373 GetWindowRect(data
->doc
->hwnd
, &rect
);
375 if(rect
.left
<= pt
->x
&& pt
->x
<= rect
.right
376 && rect
.top
<= pt
->y
&& pt
->y
<= rect
.bottom
)
377 return (LPARAM
)data
->doc
->hwnd
;
380 return CallWindowProcW(data
->proc
, hwnd
, msg
, wParam
, lParam
);
383 static void create_tooltips_window(HTMLDocumentObj
*This
)
385 tooltip_data
*data
= heap_alloc(sizeof(*data
));
387 This
->tooltips_hwnd
= CreateWindowExW(0, TOOLTIPS_CLASSW
, NULL
, TTS_NOPREFIX
| WS_POPUP
,
388 CW_USEDEFAULT
, CW_USEDEFAULT
, 10, 10, This
->hwnd
, NULL
, hInst
, NULL
);
391 data
->proc
= (WNDPROC
)GetWindowLongPtrW(This
->tooltips_hwnd
, GWLP_WNDPROC
);
393 SetPropW(This
->tooltips_hwnd
, wszTooltipData
, data
);
395 SetWindowLongPtrW(This
->tooltips_hwnd
, GWLP_WNDPROC
, (LONG_PTR
)tooltips_proc
);
397 SetWindowPos(This
->tooltips_hwnd
, HWND_TOPMOST
,0, 0, 0, 0,
398 SWP_NOMOVE
| SWP_NOSIZE
| SWP_NOACTIVATE
);
402 void show_tooltip(HTMLDocumentObj
*This
, DWORD x
, DWORD y
, LPCWSTR text
)
404 TTTOOLINFOW toolinfo
= {
405 sizeof(TTTOOLINFOW
), 0, This
->hwnd
, 0xdeadbeef,
406 {x
>2 ? x
-2 : 0, y
>0 ? y
-2 : 0, x
+2, y
+2}, /* FIXME */
407 NULL
, (LPWSTR
)text
, 0};
408 MSG msg
= {This
->hwnd
, WM_MOUSEMOVE
, 0, MAKELPARAM(x
,y
), 0, {x
,y
}};
410 TRACE("(%p)->(%d %d %s)\n", This
, x
, y
, debugstr_w(text
));
412 if(!This
->tooltips_hwnd
)
413 create_tooltips_window(This
);
415 SendMessageW(This
->tooltips_hwnd
, TTM_ADDTOOLW
, 0, (LPARAM
)&toolinfo
);
416 SendMessageW(This
->tooltips_hwnd
, TTM_ACTIVATE
, TRUE
, 0);
417 SendMessageW(This
->tooltips_hwnd
, TTM_RELAYEVENT
, 0, (LPARAM
)&msg
);
420 void hide_tooltip(HTMLDocumentObj
*This
)
422 TTTOOLINFOW toolinfo
= {
423 sizeof(TTTOOLINFOW
), 0, This
->hwnd
, 0xdeadbeef,
424 {0,0,0,0}, NULL
, NULL
, 0};
426 TRACE("(%p)\n", This
);
428 SendMessageW(This
->tooltips_hwnd
, TTM_DELTOOLW
, 0, (LPARAM
)&toolinfo
);
429 SendMessageW(This
->tooltips_hwnd
, TTM_ACTIVATE
, FALSE
, 0);
432 HRESULT
call_set_active_object(IOleInPlaceUIWindow
*window
, IOleInPlaceActiveObject
*act_obj
)
434 static WCHAR html_documentW
[30];
436 if(act_obj
&& !html_documentW
[0]) {
437 LoadStringW(hInst
, IDS_HTMLDOCUMENT
, html_documentW
,
438 sizeof(html_documentW
)/sizeof(WCHAR
));
441 return IOleInPlaceFrame_SetActiveObject(window
, act_obj
, act_obj
? html_documentW
: NULL
);
444 /**********************************************************
445 * IOleDocumentView implementation
448 static inline HTMLDocument
*impl_from_IOleDocumentView(IOleDocumentView
*iface
)
450 return CONTAINING_RECORD(iface
, HTMLDocument
, IOleDocumentView_iface
);
453 static HRESULT WINAPI
OleDocumentView_QueryInterface(IOleDocumentView
*iface
, REFIID riid
, void **ppvObject
)
455 HTMLDocument
*This
= impl_from_IOleDocumentView(iface
);
456 return htmldoc_query_interface(This
, riid
, ppvObject
);
459 static ULONG WINAPI
OleDocumentView_AddRef(IOleDocumentView
*iface
)
461 HTMLDocument
*This
= impl_from_IOleDocumentView(iface
);
462 return htmldoc_addref(This
);
465 static ULONG WINAPI
OleDocumentView_Release(IOleDocumentView
*iface
)
467 HTMLDocument
*This
= impl_from_IOleDocumentView(iface
);
468 return htmldoc_release(This
);
471 static HRESULT WINAPI
OleDocumentView_SetInPlaceSite(IOleDocumentView
*iface
, IOleInPlaceSite
*pIPSite
)
473 HTMLDocument
*This
= impl_from_IOleDocumentView(iface
);
474 TRACE("(%p)->(%p)\n", This
, pIPSite
);
477 IOleInPlaceSite_AddRef(pIPSite
);
479 if(This
->doc_obj
->ipsite
)
480 IOleInPlaceSite_Release(This
->doc_obj
->ipsite
);
482 This
->doc_obj
->ipsite
= pIPSite
;
483 This
->doc_obj
->request_uiactivate
= TRUE
;
487 static HRESULT WINAPI
OleDocumentView_GetInPlaceSite(IOleDocumentView
*iface
, IOleInPlaceSite
**ppIPSite
)
489 HTMLDocument
*This
= impl_from_IOleDocumentView(iface
);
490 TRACE("(%p)->(%p)\n", This
, ppIPSite
);
495 if(This
->doc_obj
->ipsite
)
496 IOleInPlaceSite_AddRef(This
->doc_obj
->ipsite
);
498 *ppIPSite
= This
->doc_obj
->ipsite
;
502 static HRESULT WINAPI
OleDocumentView_GetDocument(IOleDocumentView
*iface
, IUnknown
**ppunk
)
504 HTMLDocument
*This
= impl_from_IOleDocumentView(iface
);
505 TRACE("(%p)->(%p)\n", This
, ppunk
);
510 htmldoc_addref(This
);
511 *ppunk
= (IUnknown
*)&This
->IHTMLDocument2_iface
;
515 static HRESULT WINAPI
OleDocumentView_SetRect(IOleDocumentView
*iface
, LPRECT prcView
)
517 HTMLDocument
*This
= impl_from_IOleDocumentView(iface
);
520 TRACE("(%p)->(%p)\n", This
, prcView
);
525 if(This
->doc_obj
->hwnd
) {
526 GetClientRect(This
->doc_obj
->hwnd
, &rect
);
527 if(memcmp(prcView
, &rect
, sizeof(RECT
))) {
528 InvalidateRect(This
->doc_obj
->hwnd
, NULL
, TRUE
);
529 SetWindowPos(This
->doc_obj
->hwnd
, NULL
, prcView
->left
, prcView
->top
, prcView
->right
,
530 prcView
->bottom
, SWP_NOZORDER
| SWP_NOACTIVATE
);
537 static HRESULT WINAPI
OleDocumentView_GetRect(IOleDocumentView
*iface
, LPRECT prcView
)
539 HTMLDocument
*This
= impl_from_IOleDocumentView(iface
);
541 TRACE("(%p)->(%p)\n", This
, prcView
);
546 GetClientRect(This
->doc_obj
->hwnd
, prcView
);
550 static HRESULT WINAPI
OleDocumentView_SetRectComplex(IOleDocumentView
*iface
, LPRECT prcView
,
551 LPRECT prcHScroll
, LPRECT prcVScroll
, LPRECT prcSizeBox
)
553 HTMLDocument
*This
= impl_from_IOleDocumentView(iface
);
554 FIXME("(%p)->(%p %p %p %p)\n", This
, prcView
, prcHScroll
, prcVScroll
, prcSizeBox
);
558 static HRESULT WINAPI
OleDocumentView_Show(IOleDocumentView
*iface
, BOOL fShow
)
560 HTMLDocument
*This
= impl_from_IOleDocumentView(iface
);
563 TRACE("(%p)->(%x)\n", This
, fShow
);
566 if(!This
->doc_obj
->ui_active
) {
567 hres
= activate_window(This
->doc_obj
);
571 update_doc(This
, UPDATE_UI
);
572 ShowWindow(This
->doc_obj
->hwnd
, SW_SHOW
);
574 ShowWindow(This
->doc_obj
->hwnd
, SW_HIDE
);
576 if(This
->doc_obj
->in_place_active
)
577 IOleInPlaceObjectWindowless_InPlaceDeactivate(&This
->IOleInPlaceObjectWindowless_iface
);
579 if(This
->doc_obj
->ip_window
) {
580 IOleInPlaceUIWindow_Release(This
->doc_obj
->ip_window
);
581 This
->doc_obj
->ip_window
= NULL
;
588 static HRESULT WINAPI
OleDocumentView_UIActivate(IOleDocumentView
*iface
, BOOL fUIActivate
)
590 HTMLDocument
*This
= impl_from_IOleDocumentView(iface
);
593 TRACE("(%p)->(%x)\n", This
, fUIActivate
);
595 if(!This
->doc_obj
->ipsite
) {
596 IOleClientSite
*cs
= This
->doc_obj
->client
;
597 IOleInPlaceSite
*ips
;
600 WARN("this->ipsite = NULL\n");
604 hres
= IOleClientSite_QueryInterface(cs
, &IID_IOleInPlaceSiteWindowless
, (void**)&ips
);
606 This
->doc_obj
->ipsite
= ips
;
608 hres
= IOleClientSite_QueryInterface(cs
, &IID_IOleInPlaceSiteEx
, (void**)&ips
);
610 This
->doc_obj
->ipsite
= ips
;
612 hres
= IOleClientSite_QueryInterface(cs
, &IID_IOleInPlaceSite
, (void**)&ips
);
614 This
->doc_obj
->ipsite
= ips
;
616 WARN("this->ipsite = NULL\n");
617 return E_NOINTERFACE
;
622 IOleClientSite_AddRef(This
->doc_obj
->ipsite
);
623 This
->doc_obj
->request_uiactivate
= FALSE
;
624 HTMLDocument_LockContainer(This
->doc_obj
, TRUE
);
630 if(This
->doc_obj
->ui_active
)
633 if(!This
->doc_obj
->window_active
) {
634 hres
= activate_window(This
->doc_obj
);
639 This
->doc_obj
->focus
= TRUE
;
640 if(This
->doc_obj
->nscontainer
)
641 nsIWebBrowserFocus_Activate(This
->doc_obj
->nscontainer
->focus
);
642 notif_focus(This
->doc_obj
);
644 update_doc(This
, UPDATE_UI
);
646 hres
= IOleInPlaceSite_OnUIActivate(This
->doc_obj
->ipsite
);
647 if(SUCCEEDED(hres
)) {
648 call_set_active_object((IOleInPlaceUIWindow
*)This
->doc_obj
->frame
,
649 &This
->IOleInPlaceActiveObject_iface
);
651 FIXME("OnUIActivate failed: %08x\n", hres
);
652 IOleInPlaceFrame_Release(This
->doc_obj
->frame
);
653 This
->doc_obj
->frame
= NULL
;
654 This
->doc_obj
->ui_active
= FALSE
;
658 if(This
->doc_obj
->hostui
) {
659 hres
= IDocHostUIHandler_ShowUI(This
->doc_obj
->hostui
,
660 This
->doc_obj
->usermode
== EDITMODE
? DOCHOSTUITYPE_AUTHOR
: DOCHOSTUITYPE_BROWSE
,
661 &This
->IOleInPlaceActiveObject_iface
, &This
->IOleCommandTarget_iface
,
662 This
->doc_obj
->frame
, This
->doc_obj
->ip_window
);
664 IDocHostUIHandler_HideUI(This
->doc_obj
->hostui
);
667 if(This
->doc_obj
->ip_window
)
668 call_set_active_object(This
->doc_obj
->ip_window
, &This
->IOleInPlaceActiveObject_iface
);
670 memset(&rcBorderWidths
, 0, sizeof(rcBorderWidths
));
671 IOleInPlaceFrame_SetBorderSpace(This
->doc_obj
->frame
, &rcBorderWidths
);
673 This
->doc_obj
->ui_active
= TRUE
;
675 This
->doc_obj
->focus
= FALSE
;
676 nsIWebBrowserFocus_Deactivate(This
->doc_obj
->nscontainer
->focus
);
677 if(This
->doc_obj
->ui_active
) {
678 This
->doc_obj
->ui_active
= FALSE
;
679 if(This
->doc_obj
->ip_window
)
680 call_set_active_object(This
->doc_obj
->ip_window
, NULL
);
681 if(This
->doc_obj
->frame
)
682 call_set_active_object((IOleInPlaceUIWindow
*)This
->doc_obj
->frame
, NULL
);
683 if(This
->doc_obj
->hostui
)
684 IDocHostUIHandler_HideUI(This
->doc_obj
->hostui
);
685 if(This
->doc_obj
->ipsite
)
686 IOleInPlaceSite_OnUIDeactivate(This
->doc_obj
->ipsite
, FALSE
);
692 static HRESULT WINAPI
OleDocumentView_Open(IOleDocumentView
*iface
)
694 HTMLDocument
*This
= impl_from_IOleDocumentView(iface
);
695 FIXME("(%p)\n", This
);
699 static HRESULT WINAPI
OleDocumentView_CloseView(IOleDocumentView
*iface
, DWORD dwReserved
)
701 HTMLDocument
*This
= impl_from_IOleDocumentView(iface
);
702 TRACE("(%p)->(%x)\n", This
, dwReserved
);
705 WARN("dwReserved = %d\n", dwReserved
);
708 * Windows implementation calls QueryInterface(IID_IOleCommandTarget),
709 * QueryInterface(IID_IOleControlSite) and KillTimer
712 IOleDocumentView_Show(iface
, FALSE
);
717 static HRESULT WINAPI
OleDocumentView_SaveViewState(IOleDocumentView
*iface
, LPSTREAM pstm
)
719 HTMLDocument
*This
= impl_from_IOleDocumentView(iface
);
720 FIXME("(%p)->(%p)\n", This
, pstm
);
724 static HRESULT WINAPI
OleDocumentView_ApplyViewState(IOleDocumentView
*iface
, LPSTREAM pstm
)
726 HTMLDocument
*This
= impl_from_IOleDocumentView(iface
);
727 FIXME("(%p)->(%p)\n", This
, pstm
);
731 static HRESULT WINAPI
OleDocumentView_Clone(IOleDocumentView
*iface
, IOleInPlaceSite
*pIPSiteNew
,
732 IOleDocumentView
**ppViewNew
)
734 HTMLDocument
*This
= impl_from_IOleDocumentView(iface
);
735 FIXME("(%p)->(%p %p)\n", This
, pIPSiteNew
, ppViewNew
);
739 static const IOleDocumentViewVtbl OleDocumentViewVtbl
= {
740 OleDocumentView_QueryInterface
,
741 OleDocumentView_AddRef
,
742 OleDocumentView_Release
,
743 OleDocumentView_SetInPlaceSite
,
744 OleDocumentView_GetInPlaceSite
,
745 OleDocumentView_GetDocument
,
746 OleDocumentView_SetRect
,
747 OleDocumentView_GetRect
,
748 OleDocumentView_SetRectComplex
,
749 OleDocumentView_Show
,
750 OleDocumentView_UIActivate
,
751 OleDocumentView_Open
,
752 OleDocumentView_CloseView
,
753 OleDocumentView_SaveViewState
,
754 OleDocumentView_ApplyViewState
,
755 OleDocumentView_Clone
758 /**********************************************************
759 * IViewObject implementation
762 static inline HTMLDocument
*impl_from_IViewObjectEx(IViewObjectEx
*iface
)
764 return CONTAINING_RECORD(iface
, HTMLDocument
, IViewObjectEx_iface
);
767 static HRESULT WINAPI
ViewObject_QueryInterface(IViewObjectEx
*iface
, REFIID riid
, void **ppv
)
769 HTMLDocument
*This
= impl_from_IViewObjectEx(iface
);
770 return htmldoc_query_interface(This
, riid
, ppv
);
773 static ULONG WINAPI
ViewObject_AddRef(IViewObjectEx
*iface
)
775 HTMLDocument
*This
= impl_from_IViewObjectEx(iface
);
776 return htmldoc_addref(This
);
779 static ULONG WINAPI
ViewObject_Release(IViewObjectEx
*iface
)
781 HTMLDocument
*This
= impl_from_IViewObjectEx(iface
);
782 return htmldoc_release(This
);
785 static HRESULT WINAPI
ViewObject_Draw(IViewObjectEx
*iface
, DWORD dwDrawAspect
, LONG lindex
, void *pvAspect
,
786 DVTARGETDEVICE
*ptd
, HDC hdcTargetDev
, HDC hdcDraw
, LPCRECTL lprcBounds
,
787 LPCRECTL lprcWBounds
, BOOL (CALLBACK
*pfnContinue
)(ULONG_PTR dwContinue
), ULONG_PTR dwContinue
)
789 HTMLDocument
*This
= impl_from_IViewObjectEx(iface
);
790 FIXME("(%p)->(%d %d %p %p %p %p %p %p %p %ld)\n", This
, dwDrawAspect
, lindex
, pvAspect
,
791 ptd
, hdcTargetDev
, hdcDraw
, lprcBounds
, lprcWBounds
, pfnContinue
, dwContinue
);
795 static HRESULT WINAPI
ViewObject_GetColorSet(IViewObjectEx
*iface
, DWORD dwDrawAspect
, LONG lindex
, void *pvAspect
,
796 DVTARGETDEVICE
*ptd
, HDC hicTargetDev
, LOGPALETTE
**ppColorSet
)
798 HTMLDocument
*This
= impl_from_IViewObjectEx(iface
);
799 FIXME("(%p)->(%d %d %p %p %p %p)\n", This
, dwDrawAspect
, lindex
, pvAspect
, ptd
, hicTargetDev
, ppColorSet
);
803 static HRESULT WINAPI
ViewObject_Freeze(IViewObjectEx
*iface
, DWORD dwDrawAspect
, LONG lindex
,
804 void *pvAspect
, DWORD
*pdwFreeze
)
806 HTMLDocument
*This
= impl_from_IViewObjectEx(iface
);
807 FIXME("(%p)->(%d %d %p %p)\n", This
, dwDrawAspect
, lindex
, pvAspect
, pdwFreeze
);
811 static HRESULT WINAPI
ViewObject_Unfreeze(IViewObjectEx
*iface
, DWORD dwFreeze
)
813 HTMLDocument
*This
= impl_from_IViewObjectEx(iface
);
814 FIXME("(%p)->(%d)\n", This
, dwFreeze
);
818 static HRESULT WINAPI
ViewObject_SetAdvise(IViewObjectEx
*iface
, DWORD aspects
, DWORD advf
, IAdviseSink
*pAdvSink
)
820 HTMLDocument
*This
= impl_from_IViewObjectEx(iface
);
822 TRACE("(%p)->(%d %d %p)\n", This
, aspects
, advf
, pAdvSink
);
824 if(aspects
!= DVASPECT_CONTENT
|| advf
!= ADVF_PRIMEFIRST
)
825 FIXME("unsupported arguments\n");
827 if(This
->doc_obj
->view_sink
)
828 IAdviseSink_Release(This
->doc_obj
->view_sink
);
830 IAdviseSink_AddRef(pAdvSink
);
832 This
->doc_obj
->view_sink
= pAdvSink
;
836 static HRESULT WINAPI
ViewObject_GetAdvise(IViewObjectEx
*iface
, DWORD
*pAspects
, DWORD
*pAdvf
, IAdviseSink
**ppAdvSink
)
838 HTMLDocument
*This
= impl_from_IViewObjectEx(iface
);
839 FIXME("(%p)->(%p %p %p)\n", This
, pAspects
, pAdvf
, ppAdvSink
);
843 static HRESULT WINAPI
ViewObject_GetExtent(IViewObjectEx
*iface
, DWORD dwDrawAspect
, LONG lindex
,
844 DVTARGETDEVICE
* ptd
, LPSIZEL lpsizel
)
846 HTMLDocument
*This
= impl_from_IViewObjectEx(iface
);
847 FIXME("(%p)->(%d %d %p %p)\n", This
, dwDrawAspect
, lindex
, ptd
, lpsizel
);
851 static HRESULT WINAPI
ViewObject_GetRect(IViewObjectEx
*iface
, DWORD dwAspect
, LPRECTL pRect
)
853 HTMLDocument
*This
= impl_from_IViewObjectEx(iface
);
854 FIXME("(%p)->(%d %p)\n", This
, dwAspect
, pRect
);
858 static HRESULT WINAPI
ViewObject_GetViewStatus(IViewObjectEx
*iface
, DWORD
*pdwStatus
)
860 HTMLDocument
*This
= impl_from_IViewObjectEx(iface
);
861 FIXME("(%p)->(%p)\n", This
, pdwStatus
);
865 static HRESULT WINAPI
ViewObject_QueryHitPoint(IViewObjectEx
* iface
, DWORD dwAspect
,
866 LPCRECT pRectBounds
, POINT ptlLoc
, LONG lCloseHint
, DWORD
*pHitResult
)
868 HTMLDocument
*This
= impl_from_IViewObjectEx(iface
);
869 FIXME("(%p)->(%d %p (%d %d) %d %p)\n", This
, dwAspect
, pRectBounds
, ptlLoc
.x
,
870 ptlLoc
.y
, lCloseHint
, pHitResult
);
874 static HRESULT WINAPI
ViewObject_QueryHitRect(IViewObjectEx
*iface
, DWORD dwAspect
,
875 LPCRECT pRectBounds
, LPCRECT pRectLoc
, LONG lCloseHint
, DWORD
*pHitResult
)
877 HTMLDocument
*This
= impl_from_IViewObjectEx(iface
);
878 FIXME("(%p)->(%d %p %p %d %p)\n", This
, dwAspect
, pRectBounds
, pRectLoc
, lCloseHint
, pHitResult
);
882 static HRESULT WINAPI
ViewObject_GetNaturalExtent(IViewObjectEx
*iface
, DWORD dwAspect
, LONG lindex
,
883 DVTARGETDEVICE
*ptd
, HDC hicTargetDev
, DVEXTENTINFO
*pExtentInfo
, LPSIZEL pSizel
)
885 HTMLDocument
*This
= impl_from_IViewObjectEx(iface
);
886 FIXME("(%p)->(%d %d %p %p %p %p\n", This
, dwAspect
,lindex
, ptd
,
887 hicTargetDev
, pExtentInfo
, pSizel
);
891 static const IViewObjectExVtbl ViewObjectVtbl
= {
892 ViewObject_QueryInterface
,
896 ViewObject_GetColorSet
,
899 ViewObject_SetAdvise
,
900 ViewObject_GetAdvise
,
901 ViewObject_GetExtent
,
903 ViewObject_GetViewStatus
,
904 ViewObject_QueryHitPoint
,
905 ViewObject_QueryHitRect
,
906 ViewObject_GetNaturalExtent
909 void HTMLDocument_View_Init(HTMLDocument
*This
)
911 This
->IOleDocumentView_iface
.lpVtbl
= &OleDocumentViewVtbl
;
912 This
->IViewObjectEx_iface
.lpVtbl
= &ViewObjectVtbl
;