wrc: Use ARRAY_SIZE instead of open coding it.
[wine.git] / dlls / mshtml / view.c
blob96d3372174e05594f267d76064a94bb6a83536d6
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 <stdarg.h>
20 #include <stdio.h>
22 #define COBJMACROS
24 #include "windef.h"
25 #include "winbase.h"
26 #include "winuser.h"
27 #include "commctrl.h"
28 #include "ole2.h"
29 #include "resource.h"
31 #include "wine/debug.h"
33 #include "mshtml_private.h"
35 WINE_DEFAULT_DEBUG_CHANNEL(mshtml);
37 #define TIMER_ID 0x1000
39 static ATOM serverwnd_class = 0;
41 typedef struct {
42 HTMLDocumentObj *doc;
43 WNDPROC proc;
44 } tooltip_data;
46 static void paint_document(HTMLDocumentObj *This)
48 PAINTSTRUCT ps;
49 RECT rect;
50 HDC hdc;
52 GetClientRect(This->hwnd, &rect);
54 hdc = BeginPaint(This->hwnd, &ps);
56 if(!(This->hostinfo.dwFlags & (DOCHOSTUIFLAG_NO3DOUTERBORDER|DOCHOSTUIFLAG_NO3DBORDER)))
57 DrawEdge(hdc, &rect, EDGE_SUNKEN, BF_RECT|BF_ADJUST);
59 EndPaint(This->hwnd, &ps);
62 static void activate_gecko(GeckoBrowser *This)
64 TRACE("(%p) %p\n", This, This->window);
66 SetParent(This->hwnd, This->doc->hwnd);
67 ShowWindow(This->hwnd, SW_SHOW);
69 nsIBaseWindow_SetVisibility(This->window, TRUE);
70 nsIBaseWindow_SetEnabled(This->window, TRUE);
73 void update_doc(HTMLDocumentObj *This, DWORD flags)
75 if(!This->update && This->hwnd)
76 SetTimer(This->hwnd, TIMER_ID, 100, NULL);
78 This->update |= flags;
81 void update_title(HTMLDocumentObj *This)
83 IOleCommandTarget *olecmd;
84 HRESULT hres;
86 if(!(This->update & UPDATE_TITLE))
87 return;
89 This->update &= ~UPDATE_TITLE;
91 if(!This->client)
92 return;
94 hres = IOleClientSite_QueryInterface(This->client, &IID_IOleCommandTarget, (void**)&olecmd);
95 if(SUCCEEDED(hres)) {
96 VARIANT title;
98 V_VT(&title) = VT_BSTR;
99 V_BSTR(&title) = SysAllocString(L"");
100 IOleCommandTarget_Exec(olecmd, NULL, OLECMDID_SETTITLE, OLECMDEXECOPT_DONTPROMPTUSER,
101 &title, NULL);
102 SysFreeString(V_BSTR(&title));
104 IOleCommandTarget_Release(olecmd);
108 static LRESULT on_timer(HTMLDocumentObj *This)
110 TRACE("(%p) %lx\n", This, This->update);
112 KillTimer(This->hwnd, TIMER_ID);
114 if(!This->update)
115 return 0;
117 if(This->update & UPDATE_UI) {
118 if(This->hostui)
119 IDocHostUIHandler_UpdateUI(This->hostui);
121 if(This->client) {
122 IOleCommandTarget *cmdtrg;
123 HRESULT hres;
125 hres = IOleClientSite_QueryInterface(This->client, &IID_IOleCommandTarget,
126 (void**)&cmdtrg);
127 if(SUCCEEDED(hres)) {
128 IOleCommandTarget_Exec(cmdtrg, NULL, OLECMDID_UPDATECOMMANDS,
129 OLECMDEXECOPT_DONTPROMPTUSER, NULL, NULL);
130 IOleCommandTarget_Release(cmdtrg);
135 update_title(This);
136 This->update = 0;
137 return 0;
140 void notif_focus(HTMLDocumentObj *This)
142 IOleControlSite *site;
143 HRESULT hres;
145 if(!This->client)
146 return;
148 hres = IOleClientSite_QueryInterface(This->client, &IID_IOleControlSite, (void**)&site);
149 if(FAILED(hres))
150 return;
152 IOleControlSite_OnFocus(site, This->focus);
153 IOleControlSite_Release(site);
156 static LRESULT WINAPI serverwnd_proc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)
158 HTMLDocumentObj *This;
160 if(msg == WM_CREATE) {
161 This = *(HTMLDocumentObj**)lParam;
162 SetPropW(hwnd, L"THIS", This);
163 }else {
164 This = GetPropW(hwnd, L"THIS");
167 switch(msg) {
168 case WM_CREATE:
169 This->hwnd = hwnd;
170 break;
171 case WM_PAINT:
172 paint_document(This);
173 break;
174 case WM_SIZE:
175 TRACE("(%p)->(WM_SIZE)\n", This);
176 if(This->nscontainer) {
177 INT ew=0, eh=0;
179 if(!(This->hostinfo.dwFlags & (DOCHOSTUIFLAG_NO3DOUTERBORDER|DOCHOSTUIFLAG_NO3DBORDER))) {
180 ew = GetSystemMetrics(SM_CXEDGE);
181 eh = GetSystemMetrics(SM_CYEDGE);
184 SetWindowPos(This->nscontainer->hwnd, NULL, ew, eh,
185 LOWORD(lParam) - 2*ew, HIWORD(lParam) - 2*eh,
186 SWP_NOZORDER | SWP_NOACTIVATE);
188 break;
189 case WM_TIMER:
190 return on_timer(This);
191 case WM_SETFOCUS:
192 TRACE("(%p) WM_SETFOCUS\n", This);
193 nsIWebBrowserFocus_Activate(This->nscontainer->focus);
194 break;
195 case WM_MOUSEACTIVATE:
196 return MA_ACTIVATE;
199 return DefWindowProcW(hwnd, msg, wParam, lParam);
202 static void register_serverwnd_class(void)
204 static WNDCLASSEXW wndclass = {
205 sizeof(WNDCLASSEXW),
206 CS_DBLCLKS,
207 serverwnd_proc,
208 0, 0, NULL, NULL, NULL, NULL, NULL,
209 L"Internet Explorer_Server",
210 NULL,
212 wndclass.hInstance = hInst;
213 serverwnd_class = RegisterClassExW(&wndclass);
216 static HRESULT activate_window(HTMLDocumentObj *This)
218 IOleInPlaceFrame *pIPFrame;
219 IOleCommandTarget *cmdtrg;
220 IOleInPlaceSiteEx *ipsiteex;
221 RECT posrect, cliprect;
222 OLEINPLACEFRAMEINFO frameinfo;
223 HWND parent_hwnd;
224 HRESULT hres;
226 if(!serverwnd_class)
227 register_serverwnd_class();
229 hres = IOleInPlaceSite_CanInPlaceActivate(This->ipsite);
230 if(hres != S_OK) {
231 WARN("CanInPlaceActivate returned: %08lx\n", hres);
232 return FAILED(hres) ? hres : E_FAIL;
235 frameinfo.cb = sizeof(OLEINPLACEFRAMEINFO);
236 hres = IOleInPlaceSite_GetWindowContext(This->ipsite, &pIPFrame, &This->ip_window,
237 &posrect, &cliprect, &frameinfo);
238 if(FAILED(hres)) {
239 WARN("GetWindowContext failed: %08lx\n", hres);
240 return hres;
243 TRACE("got window context: %p %p %s %s {%d %x %p %p %d}\n",
244 pIPFrame, This->ip_window, wine_dbgstr_rect(&posrect), wine_dbgstr_rect(&cliprect),
245 frameinfo.cb, frameinfo.fMDIApp, frameinfo.hwndFrame, frameinfo.haccel, frameinfo.cAccelEntries);
247 hres = IOleInPlaceSite_GetWindow(This->ipsite, &parent_hwnd);
248 if(FAILED(hres)) {
249 WARN("GetWindow failed: %08lx\n", hres);
250 return hres;
253 TRACE("got parent window %p\n", parent_hwnd);
255 if(This->hwnd) {
256 if(GetParent(This->hwnd) != parent_hwnd)
257 SetParent(This->hwnd, parent_hwnd);
258 SetWindowPos(This->hwnd, HWND_TOP,
259 posrect.left, posrect.top, posrect.right-posrect.left, posrect.bottom-posrect.top,
260 SWP_NOACTIVATE | SWP_SHOWWINDOW);
261 }else {
262 CreateWindowExW(0, L"Internet Explorer_Server", NULL,
263 WS_CHILD | WS_CLIPSIBLINGS | WS_CLIPCHILDREN,
264 posrect.left, posrect.top, posrect.right-posrect.left, posrect.bottom-posrect.top,
265 parent_hwnd, NULL, hInst, This);
267 TRACE("Created window %p\n", This->hwnd);
269 SetWindowPos(This->hwnd, NULL, 0, 0, 0, 0,
270 SWP_NOSIZE | SWP_NOMOVE | SWP_NOZORDER | SWP_NOREDRAW | SWP_NOACTIVATE | SWP_SHOWWINDOW);
271 RedrawWindow(This->hwnd, NULL, NULL, RDW_INVALIDATE | RDW_NOERASE | RDW_ALLCHILDREN);
272 SetTimer(This->hwnd, TIMER_ID, 100, NULL);
275 if(This->nscontainer)
276 activate_gecko(This->nscontainer);
278 This->in_place_active = TRUE;
279 hres = IOleInPlaceSite_QueryInterface(This->ipsite, &IID_IOleInPlaceSiteEx, (void**)&ipsiteex);
280 if(SUCCEEDED(hres)) {
281 BOOL redraw = FALSE;
283 hres = IOleInPlaceSiteEx_OnInPlaceActivateEx(ipsiteex, &redraw, 0);
284 IOleInPlaceSiteEx_Release(ipsiteex);
285 if(redraw)
286 FIXME("unsupported redraw\n");
287 }else{
288 hres = IOleInPlaceSite_OnInPlaceActivate(This->ipsite);
290 if(FAILED(hres)) {
291 WARN("OnInPlaceActivate failed: %08lx\n", hres);
292 This->in_place_active = FALSE;
293 return hres;
296 hres = IOleClientSite_QueryInterface(This->client, &IID_IOleCommandTarget, (void**)&cmdtrg);
297 if(SUCCEEDED(hres)) {
298 VARIANT var;
300 IOleInPlaceFrame_SetStatusText(pIPFrame, NULL);
302 V_VT(&var) = VT_I4;
303 V_I4(&var) = 0;
304 IOleCommandTarget_Exec(cmdtrg, NULL, OLECMDID_SETPROGRESSMAX,
305 OLECMDEXECOPT_DONTPROMPTUSER, &var, NULL);
306 IOleCommandTarget_Exec(cmdtrg, NULL, OLECMDID_SETPROGRESSPOS,
307 OLECMDEXECOPT_DONTPROMPTUSER, &var, NULL);
309 IOleCommandTarget_Release(cmdtrg);
312 if(This->frame)
313 IOleInPlaceFrame_Release(This->frame);
314 This->frame = pIPFrame;
316 if(!This->request_uiactivate) {
317 hres = IOleInPlaceSite_QueryInterface(This->ipsite, &IID_IOleInPlaceSiteEx, (void**)&ipsiteex);
318 if(SUCCEEDED(hres)) {
319 IOleInPlaceSiteEx_RequestUIActivate(ipsiteex);
320 IOleInPlaceSiteEx_Release(ipsiteex);
324 This->window_active = TRUE;
326 return S_OK;
329 static LRESULT WINAPI tooltips_proc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)
331 tooltip_data *data = GetPropW(hwnd, L"tooltip_data");
333 TRACE("%d %p\n", msg, data);
335 if(msg == TTM_WINDOWFROMPOINT) {
336 RECT rect;
337 POINT *pt = (POINT*)lParam;
339 TRACE("TTM_WINDOWFROMPOINT (%ld,%ld)\n", pt->x, pt->y);
341 GetWindowRect(data->doc->hwnd, &rect);
343 if(rect.left <= pt->x && pt->x <= rect.right
344 && rect.top <= pt->y && pt->y <= rect.bottom)
345 return (LPARAM)data->doc->hwnd;
348 return CallWindowProcW(data->proc, hwnd, msg, wParam, lParam);
351 static void create_tooltips_window(HTMLDocumentObj *This)
353 tooltip_data *data = heap_alloc(sizeof(*data));
355 This->tooltips_hwnd = CreateWindowExW(0, TOOLTIPS_CLASSW, NULL, TTS_NOPREFIX | WS_POPUP,
356 CW_USEDEFAULT, CW_USEDEFAULT, 10, 10, This->hwnd, NULL, hInst, NULL);
358 data->doc = This;
359 data->proc = (WNDPROC)GetWindowLongPtrW(This->tooltips_hwnd, GWLP_WNDPROC);
361 SetPropW(This->tooltips_hwnd, L"tooltip_data", data);
363 SetWindowLongPtrW(This->tooltips_hwnd, GWLP_WNDPROC, (LONG_PTR)tooltips_proc);
365 SetWindowPos(This->tooltips_hwnd, HWND_TOPMOST,0, 0, 0, 0,
366 SWP_NOMOVE | SWP_NOSIZE | SWP_NOACTIVATE);
370 void show_tooltip(HTMLDocumentObj *This, DWORD x, DWORD y, LPCWSTR text)
372 TTTOOLINFOW toolinfo = {
373 sizeof(TTTOOLINFOW), 0, This->hwnd, 0xdeadbeef,
374 {x>2 ? x-2 : 0, y>0 ? y-2 : 0, x+2, y+2}, /* FIXME */
375 NULL, (LPWSTR)text, 0};
376 MSG msg = {This->hwnd, WM_MOUSEMOVE, 0, MAKELPARAM(x,y), 0, {x,y}};
378 TRACE("(%p)->(%ld %ld %s)\n", This, x, y, debugstr_w(text));
380 if(!This->tooltips_hwnd)
381 create_tooltips_window(This);
383 SendMessageW(This->tooltips_hwnd, TTM_ADDTOOLW, 0, (LPARAM)&toolinfo);
384 SendMessageW(This->tooltips_hwnd, TTM_ACTIVATE, TRUE, 0);
385 SendMessageW(This->tooltips_hwnd, TTM_RELAYEVENT, 0, (LPARAM)&msg);
388 void hide_tooltip(HTMLDocumentObj *This)
390 TTTOOLINFOW toolinfo = {
391 sizeof(TTTOOLINFOW), 0, This->hwnd, 0xdeadbeef,
392 {0,0,0,0}, NULL, NULL, 0};
394 TRACE("(%p)\n", This);
396 SendMessageW(This->tooltips_hwnd, TTM_DELTOOLW, 0, (LPARAM)&toolinfo);
397 SendMessageW(This->tooltips_hwnd, TTM_ACTIVATE, FALSE, 0);
400 HRESULT call_set_active_object(IOleInPlaceUIWindow *window, IOleInPlaceActiveObject *act_obj)
402 static WCHAR html_documentW[30];
404 if(act_obj && !html_documentW[0])
405 LoadStringW(hInst, IDS_HTMLDOCUMENT, html_documentW, ARRAY_SIZE(html_documentW));
407 return IOleInPlaceUIWindow_SetActiveObject(window, act_obj, act_obj ? html_documentW : NULL);
410 /**********************************************************
411 * IOleDocumentView implementation
414 static inline HTMLDocumentObj *impl_from_IOleDocumentView(IOleDocumentView *iface)
416 return CONTAINING_RECORD(iface, HTMLDocumentObj, IOleDocumentView_iface);
419 static HRESULT WINAPI OleDocumentView_QueryInterface(IOleDocumentView *iface, REFIID riid, void **ppvObject)
421 HTMLDocumentObj *This = impl_from_IOleDocumentView(iface);
422 return htmldoc_query_interface(&This->basedoc, riid, ppvObject);
425 static ULONG WINAPI OleDocumentView_AddRef(IOleDocumentView *iface)
427 HTMLDocumentObj *This = impl_from_IOleDocumentView(iface);
428 return htmldoc_addref(&This->basedoc);
431 static ULONG WINAPI OleDocumentView_Release(IOleDocumentView *iface)
433 HTMLDocumentObj *This = impl_from_IOleDocumentView(iface);
434 return htmldoc_release(&This->basedoc);
437 static HRESULT WINAPI OleDocumentView_SetInPlaceSite(IOleDocumentView *iface, IOleInPlaceSite *pIPSite)
439 HTMLDocumentObj *This = impl_from_IOleDocumentView(iface);
440 TRACE("(%p)->(%p)\n", This, pIPSite);
442 if(pIPSite)
443 IOleInPlaceSite_AddRef(pIPSite);
445 if(This->ipsite)
446 IOleInPlaceSite_Release(This->ipsite);
448 This->ipsite = pIPSite;
449 This->request_uiactivate = TRUE;
450 return S_OK;
453 static HRESULT WINAPI OleDocumentView_GetInPlaceSite(IOleDocumentView *iface, IOleInPlaceSite **ppIPSite)
455 HTMLDocumentObj *This = impl_from_IOleDocumentView(iface);
456 TRACE("(%p)->(%p)\n", This, ppIPSite);
458 if(!ppIPSite)
459 return E_INVALIDARG;
461 if(This->ipsite)
462 IOleInPlaceSite_AddRef(This->ipsite);
464 *ppIPSite = This->ipsite;
465 return S_OK;
468 static HRESULT WINAPI OleDocumentView_GetDocument(IOleDocumentView *iface, IUnknown **ppunk)
470 HTMLDocumentObj *This = impl_from_IOleDocumentView(iface);
471 TRACE("(%p)->(%p)\n", This, ppunk);
473 if(!ppunk)
474 return E_INVALIDARG;
476 *ppunk = (IUnknown*)&This->IHTMLDocument2_iface;
477 IUnknown_AddRef(*ppunk);
478 return S_OK;
481 static HRESULT WINAPI OleDocumentView_SetRect(IOleDocumentView *iface, LPRECT prcView)
483 HTMLDocumentObj *This = impl_from_IOleDocumentView(iface);
484 RECT rect;
486 TRACE("(%p)->(%p)\n", This, prcView);
488 if(!prcView)
489 return E_INVALIDARG;
491 if(This->hwnd) {
492 GetClientRect(This->hwnd, &rect);
493 if(!EqualRect(prcView, &rect)) {
494 InvalidateRect(This->hwnd, NULL, TRUE);
495 SetWindowPos(This->hwnd, NULL, prcView->left, prcView->top, prcView->right - prcView->left,
496 prcView->bottom - prcView->top, SWP_NOZORDER | SWP_NOACTIVATE);
500 return S_OK;
503 static HRESULT WINAPI OleDocumentView_GetRect(IOleDocumentView *iface, LPRECT prcView)
505 HTMLDocumentObj *This = impl_from_IOleDocumentView(iface);
507 TRACE("(%p)->(%p)\n", This, prcView);
509 if(!prcView)
510 return E_INVALIDARG;
512 GetClientRect(This->hwnd, prcView);
513 MapWindowPoints(This->hwnd, GetParent(This->hwnd), (POINT*)prcView, 2);
514 return S_OK;
517 static HRESULT WINAPI OleDocumentView_SetRectComplex(IOleDocumentView *iface, LPRECT prcView,
518 LPRECT prcHScroll, LPRECT prcVScroll, LPRECT prcSizeBox)
520 HTMLDocumentObj *This = impl_from_IOleDocumentView(iface);
521 FIXME("(%p)->(%p %p %p %p)\n", This, prcView, prcHScroll, prcVScroll, prcSizeBox);
522 return E_NOTIMPL;
525 static HRESULT WINAPI OleDocumentView_Show(IOleDocumentView *iface, BOOL fShow)
527 HTMLDocumentObj *This = impl_from_IOleDocumentView(iface);
528 HRESULT hres;
530 TRACE("(%p)->(%x)\n", This, fShow);
532 if(fShow) {
533 if(!This->ui_active) {
534 hres = activate_window(This);
535 if(FAILED(hres))
536 return hres;
538 update_doc(This, UPDATE_UI);
539 ShowWindow(This->hwnd, SW_SHOW);
540 }else {
541 ShowWindow(This->hwnd, SW_HIDE);
543 if(This->in_place_active)
544 IOleInPlaceObjectWindowless_InPlaceDeactivate(&This->IOleInPlaceObjectWindowless_iface);
546 if(This->ip_window) {
547 IOleInPlaceUIWindow_Release(This->ip_window);
548 This->ip_window = NULL;
552 return S_OK;
555 static HRESULT WINAPI OleDocumentView_UIActivate(IOleDocumentView *iface, BOOL fUIActivate)
557 HTMLDocumentObj *This = impl_from_IOleDocumentView(iface);
558 HRESULT hres;
560 TRACE("(%p)->(%x)\n", This, fUIActivate);
562 if(!This->ipsite) {
563 IOleClientSite *cs = This->client;
564 IOleInPlaceSite *ips;
566 if(!cs) {
567 WARN("this->ipsite = NULL\n");
568 return E_UNEXPECTED;
571 hres = IOleClientSite_QueryInterface(cs, &IID_IOleInPlaceSiteWindowless, (void**)&ips);
572 if(SUCCEEDED(hres))
573 This->ipsite = ips;
574 else {
575 hres = IOleClientSite_QueryInterface(cs, &IID_IOleInPlaceSiteEx, (void**)&ips);
576 if(SUCCEEDED(hres))
577 This->ipsite = ips;
578 else {
579 hres = IOleClientSite_QueryInterface(cs, &IID_IOleInPlaceSite, (void**)&ips);
580 if(SUCCEEDED(hres))
581 This->ipsite = ips;
582 else {
583 WARN("this->ipsite = NULL\n");
584 return E_NOINTERFACE;
589 IOleInPlaceSite_AddRef(This->ipsite);
590 This->request_uiactivate = FALSE;
591 HTMLDocument_LockContainer(This, TRUE);
594 if(fUIActivate) {
595 RECT rcBorderWidths;
597 if(This->ui_active)
598 return S_OK;
600 if(!This->window_active) {
601 hres = activate_window(This);
602 if(FAILED(hres))
603 return hres;
606 This->focus = TRUE;
607 if(This->nscontainer)
608 nsIWebBrowserFocus_Activate(This->nscontainer->focus);
609 notif_focus(This);
611 update_doc(This, UPDATE_UI);
613 hres = IOleInPlaceSite_OnUIActivate(This->ipsite);
614 if(SUCCEEDED(hres)) {
615 call_set_active_object((IOleInPlaceUIWindow*)This->frame, &This->IOleInPlaceActiveObject_iface);
616 }else {
617 FIXME("OnUIActivate failed: %08lx\n", hres);
618 IOleInPlaceFrame_Release(This->frame);
619 This->frame = NULL;
620 This->ui_active = FALSE;
621 return hres;
624 if(This->hostui) {
625 hres = IDocHostUIHandler_ShowUI(This->hostui,
626 This->nscontainer->usermode == EDITMODE ? DOCHOSTUITYPE_AUTHOR : DOCHOSTUITYPE_BROWSE,
627 &This->IOleInPlaceActiveObject_iface, &This->IOleCommandTarget_iface,
628 This->frame, This->ip_window);
629 if(FAILED(hres))
630 IDocHostUIHandler_HideUI(This->hostui);
633 if(This->ip_window)
634 call_set_active_object(This->ip_window, &This->IOleInPlaceActiveObject_iface);
636 SetRectEmpty(&rcBorderWidths);
637 IOleInPlaceFrame_SetBorderSpace(This->frame, &rcBorderWidths);
639 This->ui_active = TRUE;
640 }else {
641 This->focus = FALSE;
642 nsIWebBrowserFocus_Deactivate(This->nscontainer->focus);
643 if(This->ui_active) {
644 This->ui_active = FALSE;
645 if(This->ip_window)
646 call_set_active_object(This->ip_window, NULL);
647 if(This->frame)
648 call_set_active_object((IOleInPlaceUIWindow*)This->frame, NULL);
649 if(This->hostui)
650 IDocHostUIHandler_HideUI(This->hostui);
651 if(This->ipsite)
652 IOleInPlaceSite_OnUIDeactivate(This->ipsite, FALSE);
655 return S_OK;
658 static HRESULT WINAPI OleDocumentView_Open(IOleDocumentView *iface)
660 HTMLDocumentObj *This = impl_from_IOleDocumentView(iface);
661 FIXME("(%p)\n", This);
662 return E_NOTIMPL;
665 static HRESULT WINAPI OleDocumentView_CloseView(IOleDocumentView *iface, DWORD dwReserved)
667 HTMLDocumentObj *This = impl_from_IOleDocumentView(iface);
668 TRACE("(%p)->(%lx)\n", This, dwReserved);
670 if(dwReserved)
671 WARN("dwReserved = %ld\n", dwReserved);
673 IOleDocumentView_Show(iface, FALSE);
674 return S_OK;
677 static HRESULT WINAPI OleDocumentView_SaveViewState(IOleDocumentView *iface, IStream *pstm)
679 HTMLDocumentObj *This = impl_from_IOleDocumentView(iface);
680 FIXME("(%p)->(%p)\n", This, pstm);
681 return E_NOTIMPL;
684 static HRESULT WINAPI OleDocumentView_ApplyViewState(IOleDocumentView *iface, IStream *pstm)
686 HTMLDocumentObj *This = impl_from_IOleDocumentView(iface);
687 FIXME("(%p)->(%p)\n", This, pstm);
688 return E_NOTIMPL;
691 static HRESULT WINAPI OleDocumentView_Clone(IOleDocumentView *iface, IOleInPlaceSite *pIPSiteNew,
692 IOleDocumentView **ppViewNew)
694 HTMLDocumentObj *This = impl_from_IOleDocumentView(iface);
695 FIXME("(%p)->(%p %p)\n", This, pIPSiteNew, ppViewNew);
696 return E_NOTIMPL;
699 static const IOleDocumentViewVtbl OleDocumentViewVtbl = {
700 OleDocumentView_QueryInterface,
701 OleDocumentView_AddRef,
702 OleDocumentView_Release,
703 OleDocumentView_SetInPlaceSite,
704 OleDocumentView_GetInPlaceSite,
705 OleDocumentView_GetDocument,
706 OleDocumentView_SetRect,
707 OleDocumentView_GetRect,
708 OleDocumentView_SetRectComplex,
709 OleDocumentView_Show,
710 OleDocumentView_UIActivate,
711 OleDocumentView_Open,
712 OleDocumentView_CloseView,
713 OleDocumentView_SaveViewState,
714 OleDocumentView_ApplyViewState,
715 OleDocumentView_Clone
718 /**********************************************************
719 * IViewObject implementation
722 static inline HTMLDocumentObj *impl_from_IViewObjectEx(IViewObjectEx *iface)
724 return CONTAINING_RECORD(iface, HTMLDocumentObj, IViewObjectEx_iface);
727 static HRESULT WINAPI ViewObject_QueryInterface(IViewObjectEx *iface, REFIID riid, void **ppv)
729 HTMLDocumentObj *This = impl_from_IViewObjectEx(iface);
730 return htmldoc_query_interface(&This->basedoc, riid, ppv);
733 static ULONG WINAPI ViewObject_AddRef(IViewObjectEx *iface)
735 HTMLDocumentObj *This = impl_from_IViewObjectEx(iface);
736 return htmldoc_addref(&This->basedoc);
739 static ULONG WINAPI ViewObject_Release(IViewObjectEx *iface)
741 HTMLDocumentObj *This = impl_from_IViewObjectEx(iface);
742 return htmldoc_release(&This->basedoc);
745 static HRESULT WINAPI ViewObject_Draw(IViewObjectEx *iface, DWORD dwDrawAspect, LONG lindex, void *pvAspect,
746 DVTARGETDEVICE *ptd, HDC hdcTargetDev, HDC hdcDraw, LPCRECTL lprcBounds,
747 LPCRECTL lprcWBounds, BOOL (CALLBACK *pfnContinue)(ULONG_PTR dwContinue), ULONG_PTR dwContinue)
749 HTMLDocumentObj *This = impl_from_IViewObjectEx(iface);
750 FIXME("(%p)->(%ld %ld %p %p %p %p %p %p %p %Id)\n", This, dwDrawAspect, lindex, pvAspect,
751 ptd, hdcTargetDev, hdcDraw, lprcBounds, lprcWBounds, pfnContinue, dwContinue);
752 return E_NOTIMPL;
755 static HRESULT WINAPI ViewObject_GetColorSet(IViewObjectEx *iface, DWORD dwDrawAspect, LONG lindex, void *pvAspect,
756 DVTARGETDEVICE *ptd, HDC hicTargetDev, LOGPALETTE **ppColorSet)
758 HTMLDocumentObj *This = impl_from_IViewObjectEx(iface);
759 FIXME("(%p)->(%ld %ld %p %p %p %p)\n", This, dwDrawAspect, lindex, pvAspect, ptd, hicTargetDev, ppColorSet);
760 return E_NOTIMPL;
763 static HRESULT WINAPI ViewObject_Freeze(IViewObjectEx *iface, DWORD dwDrawAspect, LONG lindex,
764 void *pvAspect, DWORD *pdwFreeze)
766 HTMLDocumentObj *This = impl_from_IViewObjectEx(iface);
767 FIXME("(%p)->(%ld %ld %p %p)\n", This, dwDrawAspect, lindex, pvAspect, pdwFreeze);
768 return E_NOTIMPL;
771 static HRESULT WINAPI ViewObject_Unfreeze(IViewObjectEx *iface, DWORD dwFreeze)
773 HTMLDocumentObj *This = impl_from_IViewObjectEx(iface);
774 FIXME("(%p)->(%ld)\n", This, dwFreeze);
775 return E_NOTIMPL;
778 static HRESULT WINAPI ViewObject_SetAdvise(IViewObjectEx *iface, DWORD aspects, DWORD advf, IAdviseSink *pAdvSink)
780 HTMLDocumentObj *This = impl_from_IViewObjectEx(iface);
782 TRACE("(%p)->(%ld %ld %p)\n", This, aspects, advf, pAdvSink);
784 if(aspects != DVASPECT_CONTENT || advf != ADVF_PRIMEFIRST)
785 FIXME("unsupported arguments\n");
787 if(This->view_sink)
788 IAdviseSink_Release(This->view_sink);
789 if(pAdvSink)
790 IAdviseSink_AddRef(pAdvSink);
792 This->view_sink = pAdvSink;
793 return S_OK;
796 static HRESULT WINAPI ViewObject_GetAdvise(IViewObjectEx *iface, DWORD *pAspects, DWORD *pAdvf, IAdviseSink **ppAdvSink)
798 HTMLDocumentObj *This = impl_from_IViewObjectEx(iface);
799 FIXME("(%p)->(%p %p %p)\n", This, pAspects, pAdvf, ppAdvSink);
800 return E_NOTIMPL;
803 static HRESULT WINAPI ViewObject_GetExtent(IViewObjectEx *iface, DWORD dwDrawAspect, LONG lindex,
804 DVTARGETDEVICE* ptd, LPSIZEL lpsizel)
806 HTMLDocumentObj *This = impl_from_IViewObjectEx(iface);
807 FIXME("(%p)->(%ld %ld %p %p)\n", This, dwDrawAspect, lindex, ptd, lpsizel);
808 return E_NOTIMPL;
811 static HRESULT WINAPI ViewObject_GetRect(IViewObjectEx *iface, DWORD dwAspect, LPRECTL pRect)
813 HTMLDocumentObj *This = impl_from_IViewObjectEx(iface);
814 FIXME("(%p)->(%ld %p)\n", This, dwAspect, pRect);
815 return E_NOTIMPL;
818 static HRESULT WINAPI ViewObject_GetViewStatus(IViewObjectEx *iface, DWORD *pdwStatus)
820 HTMLDocumentObj *This = impl_from_IViewObjectEx(iface);
821 FIXME("(%p)->(%p)\n", This, pdwStatus);
822 return E_NOTIMPL;
825 static HRESULT WINAPI ViewObject_QueryHitPoint(IViewObjectEx* iface, DWORD dwAspect,
826 LPCRECT pRectBounds, POINT ptlLoc, LONG lCloseHint, DWORD *pHitResult)
828 HTMLDocumentObj *This = impl_from_IViewObjectEx(iface);
829 FIXME("(%p)->(%ld %p (%ld %ld) %ld %p)\n", This, dwAspect, pRectBounds, ptlLoc.x,
830 ptlLoc.y, lCloseHint, pHitResult);
831 return E_NOTIMPL;
834 static HRESULT WINAPI ViewObject_QueryHitRect(IViewObjectEx *iface, DWORD dwAspect,
835 LPCRECT pRectBounds, LPCRECT pRectLoc, LONG lCloseHint, DWORD *pHitResult)
837 HTMLDocumentObj *This = impl_from_IViewObjectEx(iface);
838 FIXME("(%p)->(%ld %p %p %ld %p)\n", This, dwAspect, pRectBounds, pRectLoc, lCloseHint, pHitResult);
839 return E_NOTIMPL;
842 static HRESULT WINAPI ViewObject_GetNaturalExtent(IViewObjectEx *iface, DWORD dwAspect, LONG lindex,
843 DVTARGETDEVICE *ptd, HDC hicTargetDev, DVEXTENTINFO *pExtentInfo, LPSIZEL pSizel)
845 HTMLDocumentObj *This = impl_from_IViewObjectEx(iface);
846 FIXME("(%p)->(%ld %ld %p %p %p %p\n", This, dwAspect,lindex, ptd,
847 hicTargetDev, pExtentInfo, pSizel);
848 return E_NOTIMPL;
851 static const IViewObjectExVtbl ViewObjectVtbl = {
852 ViewObject_QueryInterface,
853 ViewObject_AddRef,
854 ViewObject_Release,
855 ViewObject_Draw,
856 ViewObject_GetColorSet,
857 ViewObject_Freeze,
858 ViewObject_Unfreeze,
859 ViewObject_SetAdvise,
860 ViewObject_GetAdvise,
861 ViewObject_GetExtent,
862 ViewObject_GetRect,
863 ViewObject_GetViewStatus,
864 ViewObject_QueryHitPoint,
865 ViewObject_QueryHitRect,
866 ViewObject_GetNaturalExtent
869 static inline HTMLDocumentObj *impl_from_IWindowForBindingUI(IWindowForBindingUI *iface)
871 return CONTAINING_RECORD(iface, HTMLDocumentObj, IWindowForBindingUI_iface);
874 static HRESULT WINAPI WindowForBindingUI_QueryInterface(IWindowForBindingUI *iface, REFIID riid, void **ppv)
876 HTMLDocumentObj *This = impl_from_IWindowForBindingUI(iface);
878 if(IsEqualGUID(&IID_IUnknown, riid)) {
879 TRACE("(%p)->(IID_IUnknown %p)\n", This, ppv);
880 *ppv = &This->IWindowForBindingUI_iface;
881 }else if(IsEqualGUID(&IID_IWindowForBindingUI, riid)) {
882 TRACE("(%p)->(IID_IWindowForBindingUI %p)\n", This, ppv);
883 *ppv = &This->IWindowForBindingUI_iface;
884 }else {
885 WARN("(%p)->(%s %p)\n", This, debugstr_guid(riid), ppv);
886 *ppv = NULL;
887 return E_NOINTERFACE;
890 IUnknown_AddRef((IUnknown*)*ppv);
891 return S_OK;
894 static ULONG WINAPI WindowForBindingUI_AddRef(IWindowForBindingUI *iface)
896 HTMLDocumentObj *This = impl_from_IWindowForBindingUI(iface);
897 return htmldoc_addref(&This->basedoc);
900 static ULONG WINAPI WindowForBindingUI_Release(IWindowForBindingUI *iface)
902 HTMLDocumentObj *This = impl_from_IWindowForBindingUI(iface);
903 return htmldoc_release(&This->basedoc);
906 static HRESULT WINAPI WindowForBindingUI_GetWindow(IWindowForBindingUI *iface, REFGUID rguidReason, HWND *phwnd)
908 HTMLDocumentObj *This = impl_from_IWindowForBindingUI(iface);
910 TRACE("(%p)->(%s %p)\n", This, debugstr_guid(rguidReason), phwnd);
912 *phwnd = This->hwnd;
913 return S_OK;
916 static const IWindowForBindingUIVtbl WindowForBindingUIVtbl = {
917 WindowForBindingUI_QueryInterface,
918 WindowForBindingUI_AddRef,
919 WindowForBindingUI_Release,
920 WindowForBindingUI_GetWindow
923 void HTMLDocument_View_Init(HTMLDocumentObj *doc)
925 doc->IOleDocumentView_iface.lpVtbl = &OleDocumentViewVtbl;
926 doc->IViewObjectEx_iface.lpVtbl = &ViewObjectVtbl;
927 doc->IWindowForBindingUI_iface.lpVtbl = &WindowForBindingUIVtbl;