shell32/autocomplete: Remove the property after replacing the callback instead of...
[wine.git] / dlls / mshtml / view.c
blob442b07d89af4eb088fc0f6f79e9471cf8b748d11
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(HTMLDocumentObj *This, DWORD flags)
82 if(!This->update && This->hwnd)
83 SetTimer(This->hwnd, TIMER_ID, 100, NULL);
85 This->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 %s %s {%d %x %p %p %d}\n",
254 pIPFrame, This->ip_window, wine_dbgstr_rect(&posrect), wine_dbgstr_rect(&cliprect),
255 frameinfo.cb, frameinfo.fMDIApp, frameinfo.hwndFrame, frameinfo.haccel, frameinfo.cAccelEntries);
257 hres = IOleInPlaceSite_GetWindow(This->ipsite, &parent_hwnd);
258 if(FAILED(hres)) {
259 WARN("GetWindow failed: %08x\n", hres);
260 return hres;
263 TRACE("got parent window %p\n", parent_hwnd);
265 if(This->hwnd) {
266 if(GetParent(This->hwnd) != parent_hwnd)
267 SetParent(This->hwnd, parent_hwnd);
268 SetWindowPos(This->hwnd, HWND_TOP,
269 posrect.left, posrect.top, posrect.right-posrect.left, posrect.bottom-posrect.top,
270 SWP_NOACTIVATE | SWP_SHOWWINDOW);
271 }else {
272 CreateWindowExW(0, wszInternetExplorer_Server, NULL,
273 WS_CHILD | WS_CLIPSIBLINGS | WS_CLIPCHILDREN,
274 posrect.left, posrect.top, posrect.right-posrect.left, posrect.bottom-posrect.top,
275 parent_hwnd, NULL, hInst, This);
277 TRACE("Created window %p\n", This->hwnd);
279 SetWindowPos(This->hwnd, NULL, 0, 0, 0, 0,
280 SWP_NOSIZE | SWP_NOMOVE | SWP_NOZORDER | SWP_NOREDRAW | SWP_NOACTIVATE | SWP_SHOWWINDOW);
281 RedrawWindow(This->hwnd, NULL, NULL, RDW_INVALIDATE | RDW_NOERASE | RDW_ALLCHILDREN);
282 SetTimer(This->hwnd, TIMER_ID, 100, NULL);
285 if(This->nscontainer)
286 activate_gecko(This->nscontainer);
288 This->in_place_active = TRUE;
289 hres = IOleInPlaceSite_QueryInterface(This->ipsite, &IID_IOleInPlaceSiteEx, (void**)&ipsiteex);
290 if(SUCCEEDED(hres)) {
291 BOOL redraw = FALSE;
293 hres = IOleInPlaceSiteEx_OnInPlaceActivateEx(ipsiteex, &redraw, 0);
294 IOleInPlaceSiteEx_Release(ipsiteex);
295 if(redraw)
296 FIXME("unsupported redraw\n");
297 }else{
298 hres = IOleInPlaceSite_OnInPlaceActivate(This->ipsite);
300 if(FAILED(hres)) {
301 WARN("OnInPlaceActivate failed: %08x\n", hres);
302 This->in_place_active = FALSE;
303 return hres;
306 hres = IOleClientSite_QueryInterface(This->client, &IID_IOleCommandTarget, (void**)&cmdtrg);
307 if(SUCCEEDED(hres)) {
308 VARIANT var;
310 IOleInPlaceFrame_SetStatusText(pIPFrame, NULL);
312 V_VT(&var) = VT_I4;
313 V_I4(&var) = 0;
314 IOleCommandTarget_Exec(cmdtrg, NULL, OLECMDID_SETPROGRESSMAX,
315 OLECMDEXECOPT_DONTPROMPTUSER, &var, NULL);
316 IOleCommandTarget_Exec(cmdtrg, NULL, OLECMDID_SETPROGRESSPOS,
317 OLECMDEXECOPT_DONTPROMPTUSER, &var, NULL);
319 IOleCommandTarget_Release(cmdtrg);
322 if(This->frame)
323 IOleInPlaceFrame_Release(This->frame);
324 This->frame = pIPFrame;
326 if(!This->request_uiactivate) {
327 hres = IOleInPlaceSite_QueryInterface(This->ipsite, &IID_IOleInPlaceSiteEx, (void**)&ipsiteex);
328 if(SUCCEEDED(hres)) {
329 IOleInPlaceSiteEx_RequestUIActivate(ipsiteex);
330 IOleInPlaceSiteEx_Release(ipsiteex);
334 This->window_active = TRUE;
336 return S_OK;
339 static LRESULT WINAPI tooltips_proc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)
341 tooltip_data *data = GetPropW(hwnd, wszTooltipData);
343 TRACE("%d %p\n", msg, data);
345 if(msg == TTM_WINDOWFROMPOINT) {
346 RECT rect;
347 POINT *pt = (POINT*)lParam;
349 TRACE("TTM_WINDOWFROMPOINT (%d,%d)\n", pt->x, pt->y);
351 GetWindowRect(data->doc->hwnd, &rect);
353 if(rect.left <= pt->x && pt->x <= rect.right
354 && rect.top <= pt->y && pt->y <= rect.bottom)
355 return (LPARAM)data->doc->hwnd;
358 return CallWindowProcW(data->proc, hwnd, msg, wParam, lParam);
361 static void create_tooltips_window(HTMLDocumentObj *This)
363 tooltip_data *data = heap_alloc(sizeof(*data));
365 This->tooltips_hwnd = CreateWindowExW(0, TOOLTIPS_CLASSW, NULL, TTS_NOPREFIX | WS_POPUP,
366 CW_USEDEFAULT, CW_USEDEFAULT, 10, 10, This->hwnd, NULL, hInst, NULL);
368 data->doc = This;
369 data->proc = (WNDPROC)GetWindowLongPtrW(This->tooltips_hwnd, GWLP_WNDPROC);
371 SetPropW(This->tooltips_hwnd, wszTooltipData, data);
373 SetWindowLongPtrW(This->tooltips_hwnd, GWLP_WNDPROC, (LONG_PTR)tooltips_proc);
375 SetWindowPos(This->tooltips_hwnd, HWND_TOPMOST,0, 0, 0, 0,
376 SWP_NOMOVE | SWP_NOSIZE | SWP_NOACTIVATE);
380 void show_tooltip(HTMLDocumentObj *This, DWORD x, DWORD y, LPCWSTR text)
382 TTTOOLINFOW toolinfo = {
383 sizeof(TTTOOLINFOW), 0, This->hwnd, 0xdeadbeef,
384 {x>2 ? x-2 : 0, y>0 ? y-2 : 0, x+2, y+2}, /* FIXME */
385 NULL, (LPWSTR)text, 0};
386 MSG msg = {This->hwnd, WM_MOUSEMOVE, 0, MAKELPARAM(x,y), 0, {x,y}};
388 TRACE("(%p)->(%d %d %s)\n", This, x, y, debugstr_w(text));
390 if(!This->tooltips_hwnd)
391 create_tooltips_window(This);
393 SendMessageW(This->tooltips_hwnd, TTM_ADDTOOLW, 0, (LPARAM)&toolinfo);
394 SendMessageW(This->tooltips_hwnd, TTM_ACTIVATE, TRUE, 0);
395 SendMessageW(This->tooltips_hwnd, TTM_RELAYEVENT, 0, (LPARAM)&msg);
398 void hide_tooltip(HTMLDocumentObj *This)
400 TTTOOLINFOW toolinfo = {
401 sizeof(TTTOOLINFOW), 0, This->hwnd, 0xdeadbeef,
402 {0,0,0,0}, NULL, NULL, 0};
404 TRACE("(%p)\n", This);
406 SendMessageW(This->tooltips_hwnd, TTM_DELTOOLW, 0, (LPARAM)&toolinfo);
407 SendMessageW(This->tooltips_hwnd, TTM_ACTIVATE, FALSE, 0);
410 HRESULT call_set_active_object(IOleInPlaceUIWindow *window, IOleInPlaceActiveObject *act_obj)
412 static WCHAR html_documentW[30];
414 if(act_obj && !html_documentW[0])
415 LoadStringW(hInst, IDS_HTMLDOCUMENT, html_documentW, ARRAY_SIZE(html_documentW));
417 return IOleInPlaceUIWindow_SetActiveObject(window, act_obj, act_obj ? html_documentW : NULL);
420 /**********************************************************
421 * IOleDocumentView implementation
424 static inline HTMLDocumentObj *impl_from_IOleDocumentView(IOleDocumentView *iface)
426 return CONTAINING_RECORD(iface, HTMLDocumentObj, IOleDocumentView_iface);
429 static HRESULT WINAPI OleDocumentView_QueryInterface(IOleDocumentView *iface, REFIID riid, void **ppvObject)
431 HTMLDocumentObj *This = impl_from_IOleDocumentView(iface);
432 return htmldoc_query_interface(&This->basedoc, riid, ppvObject);
435 static ULONG WINAPI OleDocumentView_AddRef(IOleDocumentView *iface)
437 HTMLDocumentObj *This = impl_from_IOleDocumentView(iface);
438 return htmldoc_addref(&This->basedoc);
441 static ULONG WINAPI OleDocumentView_Release(IOleDocumentView *iface)
443 HTMLDocumentObj *This = impl_from_IOleDocumentView(iface);
444 return htmldoc_release(&This->basedoc);
447 static HRESULT WINAPI OleDocumentView_SetInPlaceSite(IOleDocumentView *iface, IOleInPlaceSite *pIPSite)
449 HTMLDocumentObj *This = impl_from_IOleDocumentView(iface);
450 TRACE("(%p)->(%p)\n", This, pIPSite);
452 if(pIPSite)
453 IOleInPlaceSite_AddRef(pIPSite);
455 if(This->ipsite)
456 IOleInPlaceSite_Release(This->ipsite);
458 This->ipsite = pIPSite;
459 This->request_uiactivate = TRUE;
460 return S_OK;
463 static HRESULT WINAPI OleDocumentView_GetInPlaceSite(IOleDocumentView *iface, IOleInPlaceSite **ppIPSite)
465 HTMLDocumentObj *This = impl_from_IOleDocumentView(iface);
466 TRACE("(%p)->(%p)\n", This, ppIPSite);
468 if(!ppIPSite)
469 return E_INVALIDARG;
471 if(This->ipsite)
472 IOleInPlaceSite_AddRef(This->ipsite);
474 *ppIPSite = This->ipsite;
475 return S_OK;
478 static HRESULT WINAPI OleDocumentView_GetDocument(IOleDocumentView *iface, IUnknown **ppunk)
480 HTMLDocumentObj *This = impl_from_IOleDocumentView(iface);
481 TRACE("(%p)->(%p)\n", This, ppunk);
483 if(!ppunk)
484 return E_INVALIDARG;
486 *ppunk = (IUnknown*)&This->basedoc.IHTMLDocument2_iface;
487 IUnknown_AddRef(*ppunk);
488 return S_OK;
491 static HRESULT WINAPI OleDocumentView_SetRect(IOleDocumentView *iface, LPRECT prcView)
493 HTMLDocumentObj *This = impl_from_IOleDocumentView(iface);
494 RECT rect;
496 TRACE("(%p)->(%p)\n", This, prcView);
498 if(!prcView)
499 return E_INVALIDARG;
501 if(This->hwnd) {
502 GetClientRect(This->hwnd, &rect);
503 if(!EqualRect(prcView, &rect)) {
504 InvalidateRect(This->hwnd, NULL, TRUE);
505 SetWindowPos(This->hwnd, NULL, prcView->left, prcView->top, prcView->right,
506 prcView->bottom, SWP_NOZORDER | SWP_NOACTIVATE);
510 return S_OK;
513 static HRESULT WINAPI OleDocumentView_GetRect(IOleDocumentView *iface, LPRECT prcView)
515 HTMLDocumentObj *This = impl_from_IOleDocumentView(iface);
517 TRACE("(%p)->(%p)\n", This, prcView);
519 if(!prcView)
520 return E_INVALIDARG;
522 GetClientRect(This->hwnd, prcView);
523 return S_OK;
526 static HRESULT WINAPI OleDocumentView_SetRectComplex(IOleDocumentView *iface, LPRECT prcView,
527 LPRECT prcHScroll, LPRECT prcVScroll, LPRECT prcSizeBox)
529 HTMLDocumentObj *This = impl_from_IOleDocumentView(iface);
530 FIXME("(%p)->(%p %p %p %p)\n", This, prcView, prcHScroll, prcVScroll, prcSizeBox);
531 return E_NOTIMPL;
534 static HRESULT WINAPI OleDocumentView_Show(IOleDocumentView *iface, BOOL fShow)
536 HTMLDocumentObj *This = impl_from_IOleDocumentView(iface);
537 HRESULT hres;
539 TRACE("(%p)->(%x)\n", This, fShow);
541 if(fShow) {
542 if(!This->ui_active) {
543 hres = activate_window(This);
544 if(FAILED(hres))
545 return hres;
547 update_doc(This, UPDATE_UI);
548 ShowWindow(This->hwnd, SW_SHOW);
549 }else {
550 ShowWindow(This->hwnd, SW_HIDE);
552 if(This->in_place_active)
553 IOleInPlaceObjectWindowless_InPlaceDeactivate(&This->basedoc.IOleInPlaceObjectWindowless_iface);
555 if(This->ip_window) {
556 IOleInPlaceUIWindow_Release(This->ip_window);
557 This->ip_window = NULL;
561 return S_OK;
564 static HRESULT WINAPI OleDocumentView_UIActivate(IOleDocumentView *iface, BOOL fUIActivate)
566 HTMLDocumentObj *This = impl_from_IOleDocumentView(iface);
567 HRESULT hres;
569 TRACE("(%p)->(%x)\n", This, fUIActivate);
571 if(!This->ipsite) {
572 IOleClientSite *cs = This->client;
573 IOleInPlaceSite *ips;
575 if(!cs) {
576 WARN("this->ipsite = NULL\n");
577 return E_UNEXPECTED;
580 hres = IOleClientSite_QueryInterface(cs, &IID_IOleInPlaceSiteWindowless, (void**)&ips);
581 if(SUCCEEDED(hres))
582 This->ipsite = ips;
583 else {
584 hres = IOleClientSite_QueryInterface(cs, &IID_IOleInPlaceSiteEx, (void**)&ips);
585 if(SUCCEEDED(hres))
586 This->ipsite = ips;
587 else {
588 hres = IOleClientSite_QueryInterface(cs, &IID_IOleInPlaceSite, (void**)&ips);
589 if(SUCCEEDED(hres))
590 This->ipsite = ips;
591 else {
592 WARN("this->ipsite = NULL\n");
593 return E_NOINTERFACE;
598 IOleInPlaceSite_AddRef(This->ipsite);
599 This->request_uiactivate = FALSE;
600 HTMLDocument_LockContainer(This, TRUE);
603 if(fUIActivate) {
604 RECT rcBorderWidths;
606 if(This->ui_active)
607 return S_OK;
609 if(!This->window_active) {
610 hres = activate_window(This);
611 if(FAILED(hres))
612 return hres;
615 This->focus = TRUE;
616 if(This->nscontainer)
617 nsIWebBrowserFocus_Activate(This->nscontainer->focus);
618 notif_focus(This);
620 update_doc(This, UPDATE_UI);
622 hres = IOleInPlaceSite_OnUIActivate(This->ipsite);
623 if(SUCCEEDED(hres)) {
624 call_set_active_object((IOleInPlaceUIWindow*)This->frame,
625 &This->basedoc.IOleInPlaceActiveObject_iface);
626 }else {
627 FIXME("OnUIActivate failed: %08x\n", hres);
628 IOleInPlaceFrame_Release(This->frame);
629 This->frame = NULL;
630 This->ui_active = FALSE;
631 return hres;
634 if(This->hostui) {
635 hres = IDocHostUIHandler_ShowUI(This->hostui,
636 This->usermode == EDITMODE ? DOCHOSTUITYPE_AUTHOR : DOCHOSTUITYPE_BROWSE,
637 &This->basedoc.IOleInPlaceActiveObject_iface, &This->basedoc.IOleCommandTarget_iface,
638 This->frame, This->ip_window);
639 if(FAILED(hres))
640 IDocHostUIHandler_HideUI(This->hostui);
643 if(This->ip_window)
644 call_set_active_object(This->ip_window, &This->basedoc.IOleInPlaceActiveObject_iface);
646 SetRectEmpty(&rcBorderWidths);
647 IOleInPlaceFrame_SetBorderSpace(This->frame, &rcBorderWidths);
649 This->ui_active = TRUE;
650 }else {
651 This->focus = FALSE;
652 nsIWebBrowserFocus_Deactivate(This->nscontainer->focus);
653 if(This->ui_active) {
654 This->ui_active = FALSE;
655 if(This->ip_window)
656 call_set_active_object(This->ip_window, NULL);
657 if(This->frame)
658 call_set_active_object((IOleInPlaceUIWindow*)This->frame, NULL);
659 if(This->hostui)
660 IDocHostUIHandler_HideUI(This->hostui);
661 if(This->ipsite)
662 IOleInPlaceSite_OnUIDeactivate(This->ipsite, FALSE);
665 return S_OK;
668 static HRESULT WINAPI OleDocumentView_Open(IOleDocumentView *iface)
670 HTMLDocumentObj *This = impl_from_IOleDocumentView(iface);
671 FIXME("(%p)\n", This);
672 return E_NOTIMPL;
675 static HRESULT WINAPI OleDocumentView_CloseView(IOleDocumentView *iface, DWORD dwReserved)
677 HTMLDocumentObj *This = impl_from_IOleDocumentView(iface);
678 TRACE("(%p)->(%x)\n", This, dwReserved);
680 if(dwReserved)
681 WARN("dwReserved = %d\n", dwReserved);
683 IOleDocumentView_Show(iface, FALSE);
684 return S_OK;
687 static HRESULT WINAPI OleDocumentView_SaveViewState(IOleDocumentView *iface, IStream *pstm)
689 HTMLDocumentObj *This = impl_from_IOleDocumentView(iface);
690 FIXME("(%p)->(%p)\n", This, pstm);
691 return E_NOTIMPL;
694 static HRESULT WINAPI OleDocumentView_ApplyViewState(IOleDocumentView *iface, IStream *pstm)
696 HTMLDocumentObj *This = impl_from_IOleDocumentView(iface);
697 FIXME("(%p)->(%p)\n", This, pstm);
698 return E_NOTIMPL;
701 static HRESULT WINAPI OleDocumentView_Clone(IOleDocumentView *iface, IOleInPlaceSite *pIPSiteNew,
702 IOleDocumentView **ppViewNew)
704 HTMLDocumentObj *This = impl_from_IOleDocumentView(iface);
705 FIXME("(%p)->(%p %p)\n", This, pIPSiteNew, ppViewNew);
706 return E_NOTIMPL;
709 static const IOleDocumentViewVtbl OleDocumentViewVtbl = {
710 OleDocumentView_QueryInterface,
711 OleDocumentView_AddRef,
712 OleDocumentView_Release,
713 OleDocumentView_SetInPlaceSite,
714 OleDocumentView_GetInPlaceSite,
715 OleDocumentView_GetDocument,
716 OleDocumentView_SetRect,
717 OleDocumentView_GetRect,
718 OleDocumentView_SetRectComplex,
719 OleDocumentView_Show,
720 OleDocumentView_UIActivate,
721 OleDocumentView_Open,
722 OleDocumentView_CloseView,
723 OleDocumentView_SaveViewState,
724 OleDocumentView_ApplyViewState,
725 OleDocumentView_Clone
728 /**********************************************************
729 * IViewObject implementation
732 static inline HTMLDocumentObj *impl_from_IViewObjectEx(IViewObjectEx *iface)
734 return CONTAINING_RECORD(iface, HTMLDocumentObj, IViewObjectEx_iface);
737 static HRESULT WINAPI ViewObject_QueryInterface(IViewObjectEx *iface, REFIID riid, void **ppv)
739 HTMLDocumentObj *This = impl_from_IViewObjectEx(iface);
740 return htmldoc_query_interface(&This->basedoc, riid, ppv);
743 static ULONG WINAPI ViewObject_AddRef(IViewObjectEx *iface)
745 HTMLDocumentObj *This = impl_from_IViewObjectEx(iface);
746 return htmldoc_addref(&This->basedoc);
749 static ULONG WINAPI ViewObject_Release(IViewObjectEx *iface)
751 HTMLDocumentObj *This = impl_from_IViewObjectEx(iface);
752 return htmldoc_release(&This->basedoc);
755 static HRESULT WINAPI ViewObject_Draw(IViewObjectEx *iface, DWORD dwDrawAspect, LONG lindex, void *pvAspect,
756 DVTARGETDEVICE *ptd, HDC hdcTargetDev, HDC hdcDraw, LPCRECTL lprcBounds,
757 LPCRECTL lprcWBounds, BOOL (CALLBACK *pfnContinue)(ULONG_PTR dwContinue), ULONG_PTR dwContinue)
759 HTMLDocumentObj *This = impl_from_IViewObjectEx(iface);
760 FIXME("(%p)->(%d %d %p %p %p %p %p %p %p %ld)\n", This, dwDrawAspect, lindex, pvAspect,
761 ptd, hdcTargetDev, hdcDraw, lprcBounds, lprcWBounds, pfnContinue, dwContinue);
762 return E_NOTIMPL;
765 static HRESULT WINAPI ViewObject_GetColorSet(IViewObjectEx *iface, DWORD dwDrawAspect, LONG lindex, void *pvAspect,
766 DVTARGETDEVICE *ptd, HDC hicTargetDev, LOGPALETTE **ppColorSet)
768 HTMLDocumentObj *This = impl_from_IViewObjectEx(iface);
769 FIXME("(%p)->(%d %d %p %p %p %p)\n", This, dwDrawAspect, lindex, pvAspect, ptd, hicTargetDev, ppColorSet);
770 return E_NOTIMPL;
773 static HRESULT WINAPI ViewObject_Freeze(IViewObjectEx *iface, DWORD dwDrawAspect, LONG lindex,
774 void *pvAspect, DWORD *pdwFreeze)
776 HTMLDocumentObj *This = impl_from_IViewObjectEx(iface);
777 FIXME("(%p)->(%d %d %p %p)\n", This, dwDrawAspect, lindex, pvAspect, pdwFreeze);
778 return E_NOTIMPL;
781 static HRESULT WINAPI ViewObject_Unfreeze(IViewObjectEx *iface, DWORD dwFreeze)
783 HTMLDocumentObj *This = impl_from_IViewObjectEx(iface);
784 FIXME("(%p)->(%d)\n", This, dwFreeze);
785 return E_NOTIMPL;
788 static HRESULT WINAPI ViewObject_SetAdvise(IViewObjectEx *iface, DWORD aspects, DWORD advf, IAdviseSink *pAdvSink)
790 HTMLDocumentObj *This = impl_from_IViewObjectEx(iface);
792 TRACE("(%p)->(%d %d %p)\n", This, aspects, advf, pAdvSink);
794 if(aspects != DVASPECT_CONTENT || advf != ADVF_PRIMEFIRST)
795 FIXME("unsupported arguments\n");
797 if(This->view_sink)
798 IAdviseSink_Release(This->view_sink);
799 if(pAdvSink)
800 IAdviseSink_AddRef(pAdvSink);
802 This->view_sink = pAdvSink;
803 return S_OK;
806 static HRESULT WINAPI ViewObject_GetAdvise(IViewObjectEx *iface, DWORD *pAspects, DWORD *pAdvf, IAdviseSink **ppAdvSink)
808 HTMLDocumentObj *This = impl_from_IViewObjectEx(iface);
809 FIXME("(%p)->(%p %p %p)\n", This, pAspects, pAdvf, ppAdvSink);
810 return E_NOTIMPL;
813 static HRESULT WINAPI ViewObject_GetExtent(IViewObjectEx *iface, DWORD dwDrawAspect, LONG lindex,
814 DVTARGETDEVICE* ptd, LPSIZEL lpsizel)
816 HTMLDocumentObj *This = impl_from_IViewObjectEx(iface);
817 FIXME("(%p)->(%d %d %p %p)\n", This, dwDrawAspect, lindex, ptd, lpsizel);
818 return E_NOTIMPL;
821 static HRESULT WINAPI ViewObject_GetRect(IViewObjectEx *iface, DWORD dwAspect, LPRECTL pRect)
823 HTMLDocumentObj *This = impl_from_IViewObjectEx(iface);
824 FIXME("(%p)->(%d %p)\n", This, dwAspect, pRect);
825 return E_NOTIMPL;
828 static HRESULT WINAPI ViewObject_GetViewStatus(IViewObjectEx *iface, DWORD *pdwStatus)
830 HTMLDocumentObj *This = impl_from_IViewObjectEx(iface);
831 FIXME("(%p)->(%p)\n", This, pdwStatus);
832 return E_NOTIMPL;
835 static HRESULT WINAPI ViewObject_QueryHitPoint(IViewObjectEx* iface, DWORD dwAspect,
836 LPCRECT pRectBounds, POINT ptlLoc, LONG lCloseHint, DWORD *pHitResult)
838 HTMLDocumentObj *This = impl_from_IViewObjectEx(iface);
839 FIXME("(%p)->(%d %p (%d %d) %d %p)\n", This, dwAspect, pRectBounds, ptlLoc.x,
840 ptlLoc.y, lCloseHint, pHitResult);
841 return E_NOTIMPL;
844 static HRESULT WINAPI ViewObject_QueryHitRect(IViewObjectEx *iface, DWORD dwAspect,
845 LPCRECT pRectBounds, LPCRECT pRectLoc, LONG lCloseHint, DWORD *pHitResult)
847 HTMLDocumentObj *This = impl_from_IViewObjectEx(iface);
848 FIXME("(%p)->(%d %p %p %d %p)\n", This, dwAspect, pRectBounds, pRectLoc, lCloseHint, pHitResult);
849 return E_NOTIMPL;
852 static HRESULT WINAPI ViewObject_GetNaturalExtent(IViewObjectEx *iface, DWORD dwAspect, LONG lindex,
853 DVTARGETDEVICE *ptd, HDC hicTargetDev, DVEXTENTINFO *pExtentInfo, LPSIZEL pSizel)
855 HTMLDocumentObj *This = impl_from_IViewObjectEx(iface);
856 FIXME("(%p)->(%d %d %p %p %p %p\n", This, dwAspect,lindex, ptd,
857 hicTargetDev, pExtentInfo, pSizel);
858 return E_NOTIMPL;
861 static const IViewObjectExVtbl ViewObjectVtbl = {
862 ViewObject_QueryInterface,
863 ViewObject_AddRef,
864 ViewObject_Release,
865 ViewObject_Draw,
866 ViewObject_GetColorSet,
867 ViewObject_Freeze,
868 ViewObject_Unfreeze,
869 ViewObject_SetAdvise,
870 ViewObject_GetAdvise,
871 ViewObject_GetExtent,
872 ViewObject_GetRect,
873 ViewObject_GetViewStatus,
874 ViewObject_QueryHitPoint,
875 ViewObject_QueryHitRect,
876 ViewObject_GetNaturalExtent
879 static inline HTMLDocumentObj *impl_from_IWindowForBindingUI(IWindowForBindingUI *iface)
881 return CONTAINING_RECORD(iface, HTMLDocumentObj, IWindowForBindingUI_iface);
884 static HRESULT WINAPI WindowForBindingUI_QueryInterface(IWindowForBindingUI *iface, REFIID riid, void **ppv)
886 HTMLDocumentObj *This = impl_from_IWindowForBindingUI(iface);
888 if(IsEqualGUID(&IID_IUnknown, riid)) {
889 TRACE("(%p)->(IID_IUnknown %p)\n", This, ppv);
890 *ppv = &This->IWindowForBindingUI_iface;
891 }else if(IsEqualGUID(&IID_IWindowForBindingUI, riid)) {
892 TRACE("(%p)->(IID_IWindowForBindingUI %p)\n", This, ppv);
893 *ppv = &This->IWindowForBindingUI_iface;
894 }else {
895 WARN("(%p)->(%s %p)\n", This, debugstr_guid(riid), ppv);
896 *ppv = NULL;
897 return E_NOINTERFACE;
900 IUnknown_AddRef((IUnknown*)*ppv);
901 return S_OK;
904 static ULONG WINAPI WindowForBindingUI_AddRef(IWindowForBindingUI *iface)
906 HTMLDocumentObj *This = impl_from_IWindowForBindingUI(iface);
907 return htmldoc_addref(&This->basedoc);
910 static ULONG WINAPI WindowForBindingUI_Release(IWindowForBindingUI *iface)
912 HTMLDocumentObj *This = impl_from_IWindowForBindingUI(iface);
913 return htmldoc_release(&This->basedoc);
916 static HRESULT WINAPI WindowForBindingUI_GetWindow(IWindowForBindingUI *iface, REFGUID rguidReason, HWND *phwnd)
918 HTMLDocumentObj *This = impl_from_IWindowForBindingUI(iface);
920 TRACE("(%p)->(%s %p)\n", This, debugstr_guid(rguidReason), phwnd);
922 *phwnd = This->hwnd;
923 return S_OK;
926 static const IWindowForBindingUIVtbl WindowForBindingUIVtbl = {
927 WindowForBindingUI_QueryInterface,
928 WindowForBindingUI_AddRef,
929 WindowForBindingUI_Release,
930 WindowForBindingUI_GetWindow
933 void HTMLDocument_View_Init(HTMLDocumentObj *doc)
935 doc->IOleDocumentView_iface.lpVtbl = &OleDocumentViewVtbl;
936 doc->IViewObjectEx_iface.lpVtbl = &ViewObjectVtbl;
937 doc->IWindowForBindingUI_iface.lpVtbl = &WindowForBindingUIVtbl;