mshtml: Use wide-char string literals.
[wine.git] / dlls / mshtml / view.c
blob0f3371c069f980571c196d16280d74bdcc04a1f3
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) %x\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: %08x\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: %08x\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: %08x\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: %08x\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 (%d,%d)\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)->(%d %d %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->basedoc.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->basedoc.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,
616 &This->basedoc.IOleInPlaceActiveObject_iface);
617 }else {
618 FIXME("OnUIActivate failed: %08x\n", hres);
619 IOleInPlaceFrame_Release(This->frame);
620 This->frame = NULL;
621 This->ui_active = FALSE;
622 return hres;
625 if(This->hostui) {
626 hres = IDocHostUIHandler_ShowUI(This->hostui,
627 This->nscontainer->usermode == EDITMODE ? DOCHOSTUITYPE_AUTHOR : DOCHOSTUITYPE_BROWSE,
628 &This->basedoc.IOleInPlaceActiveObject_iface, &This->basedoc.IOleCommandTarget_iface,
629 This->frame, This->ip_window);
630 if(FAILED(hres))
631 IDocHostUIHandler_HideUI(This->hostui);
634 if(This->ip_window)
635 call_set_active_object(This->ip_window, &This->basedoc.IOleInPlaceActiveObject_iface);
637 SetRectEmpty(&rcBorderWidths);
638 IOleInPlaceFrame_SetBorderSpace(This->frame, &rcBorderWidths);
640 This->ui_active = TRUE;
641 }else {
642 This->focus = FALSE;
643 nsIWebBrowserFocus_Deactivate(This->nscontainer->focus);
644 if(This->ui_active) {
645 This->ui_active = FALSE;
646 if(This->ip_window)
647 call_set_active_object(This->ip_window, NULL);
648 if(This->frame)
649 call_set_active_object((IOleInPlaceUIWindow*)This->frame, NULL);
650 if(This->hostui)
651 IDocHostUIHandler_HideUI(This->hostui);
652 if(This->ipsite)
653 IOleInPlaceSite_OnUIDeactivate(This->ipsite, FALSE);
656 return S_OK;
659 static HRESULT WINAPI OleDocumentView_Open(IOleDocumentView *iface)
661 HTMLDocumentObj *This = impl_from_IOleDocumentView(iface);
662 FIXME("(%p)\n", This);
663 return E_NOTIMPL;
666 static HRESULT WINAPI OleDocumentView_CloseView(IOleDocumentView *iface, DWORD dwReserved)
668 HTMLDocumentObj *This = impl_from_IOleDocumentView(iface);
669 TRACE("(%p)->(%x)\n", This, dwReserved);
671 if(dwReserved)
672 WARN("dwReserved = %d\n", dwReserved);
674 IOleDocumentView_Show(iface, FALSE);
675 return S_OK;
678 static HRESULT WINAPI OleDocumentView_SaveViewState(IOleDocumentView *iface, IStream *pstm)
680 HTMLDocumentObj *This = impl_from_IOleDocumentView(iface);
681 FIXME("(%p)->(%p)\n", This, pstm);
682 return E_NOTIMPL;
685 static HRESULT WINAPI OleDocumentView_ApplyViewState(IOleDocumentView *iface, IStream *pstm)
687 HTMLDocumentObj *This = impl_from_IOleDocumentView(iface);
688 FIXME("(%p)->(%p)\n", This, pstm);
689 return E_NOTIMPL;
692 static HRESULT WINAPI OleDocumentView_Clone(IOleDocumentView *iface, IOleInPlaceSite *pIPSiteNew,
693 IOleDocumentView **ppViewNew)
695 HTMLDocumentObj *This = impl_from_IOleDocumentView(iface);
696 FIXME("(%p)->(%p %p)\n", This, pIPSiteNew, ppViewNew);
697 return E_NOTIMPL;
700 static const IOleDocumentViewVtbl OleDocumentViewVtbl = {
701 OleDocumentView_QueryInterface,
702 OleDocumentView_AddRef,
703 OleDocumentView_Release,
704 OleDocumentView_SetInPlaceSite,
705 OleDocumentView_GetInPlaceSite,
706 OleDocumentView_GetDocument,
707 OleDocumentView_SetRect,
708 OleDocumentView_GetRect,
709 OleDocumentView_SetRectComplex,
710 OleDocumentView_Show,
711 OleDocumentView_UIActivate,
712 OleDocumentView_Open,
713 OleDocumentView_CloseView,
714 OleDocumentView_SaveViewState,
715 OleDocumentView_ApplyViewState,
716 OleDocumentView_Clone
719 /**********************************************************
720 * IViewObject implementation
723 static inline HTMLDocumentObj *impl_from_IViewObjectEx(IViewObjectEx *iface)
725 return CONTAINING_RECORD(iface, HTMLDocumentObj, IViewObjectEx_iface);
728 static HRESULT WINAPI ViewObject_QueryInterface(IViewObjectEx *iface, REFIID riid, void **ppv)
730 HTMLDocumentObj *This = impl_from_IViewObjectEx(iface);
731 return htmldoc_query_interface(&This->basedoc, riid, ppv);
734 static ULONG WINAPI ViewObject_AddRef(IViewObjectEx *iface)
736 HTMLDocumentObj *This = impl_from_IViewObjectEx(iface);
737 return htmldoc_addref(&This->basedoc);
740 static ULONG WINAPI ViewObject_Release(IViewObjectEx *iface)
742 HTMLDocumentObj *This = impl_from_IViewObjectEx(iface);
743 return htmldoc_release(&This->basedoc);
746 static HRESULT WINAPI ViewObject_Draw(IViewObjectEx *iface, DWORD dwDrawAspect, LONG lindex, void *pvAspect,
747 DVTARGETDEVICE *ptd, HDC hdcTargetDev, HDC hdcDraw, LPCRECTL lprcBounds,
748 LPCRECTL lprcWBounds, BOOL (CALLBACK *pfnContinue)(ULONG_PTR dwContinue), ULONG_PTR dwContinue)
750 HTMLDocumentObj *This = impl_from_IViewObjectEx(iface);
751 FIXME("(%p)->(%d %d %p %p %p %p %p %p %p %ld)\n", This, dwDrawAspect, lindex, pvAspect,
752 ptd, hdcTargetDev, hdcDraw, lprcBounds, lprcWBounds, pfnContinue, dwContinue);
753 return E_NOTIMPL;
756 static HRESULT WINAPI ViewObject_GetColorSet(IViewObjectEx *iface, DWORD dwDrawAspect, LONG lindex, void *pvAspect,
757 DVTARGETDEVICE *ptd, HDC hicTargetDev, LOGPALETTE **ppColorSet)
759 HTMLDocumentObj *This = impl_from_IViewObjectEx(iface);
760 FIXME("(%p)->(%d %d %p %p %p %p)\n", This, dwDrawAspect, lindex, pvAspect, ptd, hicTargetDev, ppColorSet);
761 return E_NOTIMPL;
764 static HRESULT WINAPI ViewObject_Freeze(IViewObjectEx *iface, DWORD dwDrawAspect, LONG lindex,
765 void *pvAspect, DWORD *pdwFreeze)
767 HTMLDocumentObj *This = impl_from_IViewObjectEx(iface);
768 FIXME("(%p)->(%d %d %p %p)\n", This, dwDrawAspect, lindex, pvAspect, pdwFreeze);
769 return E_NOTIMPL;
772 static HRESULT WINAPI ViewObject_Unfreeze(IViewObjectEx *iface, DWORD dwFreeze)
774 HTMLDocumentObj *This = impl_from_IViewObjectEx(iface);
775 FIXME("(%p)->(%d)\n", This, dwFreeze);
776 return E_NOTIMPL;
779 static HRESULT WINAPI ViewObject_SetAdvise(IViewObjectEx *iface, DWORD aspects, DWORD advf, IAdviseSink *pAdvSink)
781 HTMLDocumentObj *This = impl_from_IViewObjectEx(iface);
783 TRACE("(%p)->(%d %d %p)\n", This, aspects, advf, pAdvSink);
785 if(aspects != DVASPECT_CONTENT || advf != ADVF_PRIMEFIRST)
786 FIXME("unsupported arguments\n");
788 if(This->view_sink)
789 IAdviseSink_Release(This->view_sink);
790 if(pAdvSink)
791 IAdviseSink_AddRef(pAdvSink);
793 This->view_sink = pAdvSink;
794 return S_OK;
797 static HRESULT WINAPI ViewObject_GetAdvise(IViewObjectEx *iface, DWORD *pAspects, DWORD *pAdvf, IAdviseSink **ppAdvSink)
799 HTMLDocumentObj *This = impl_from_IViewObjectEx(iface);
800 FIXME("(%p)->(%p %p %p)\n", This, pAspects, pAdvf, ppAdvSink);
801 return E_NOTIMPL;
804 static HRESULT WINAPI ViewObject_GetExtent(IViewObjectEx *iface, DWORD dwDrawAspect, LONG lindex,
805 DVTARGETDEVICE* ptd, LPSIZEL lpsizel)
807 HTMLDocumentObj *This = impl_from_IViewObjectEx(iface);
808 FIXME("(%p)->(%d %d %p %p)\n", This, dwDrawAspect, lindex, ptd, lpsizel);
809 return E_NOTIMPL;
812 static HRESULT WINAPI ViewObject_GetRect(IViewObjectEx *iface, DWORD dwAspect, LPRECTL pRect)
814 HTMLDocumentObj *This = impl_from_IViewObjectEx(iface);
815 FIXME("(%p)->(%d %p)\n", This, dwAspect, pRect);
816 return E_NOTIMPL;
819 static HRESULT WINAPI ViewObject_GetViewStatus(IViewObjectEx *iface, DWORD *pdwStatus)
821 HTMLDocumentObj *This = impl_from_IViewObjectEx(iface);
822 FIXME("(%p)->(%p)\n", This, pdwStatus);
823 return E_NOTIMPL;
826 static HRESULT WINAPI ViewObject_QueryHitPoint(IViewObjectEx* iface, DWORD dwAspect,
827 LPCRECT pRectBounds, POINT ptlLoc, LONG lCloseHint, DWORD *pHitResult)
829 HTMLDocumentObj *This = impl_from_IViewObjectEx(iface);
830 FIXME("(%p)->(%d %p (%d %d) %d %p)\n", This, dwAspect, pRectBounds, ptlLoc.x,
831 ptlLoc.y, lCloseHint, pHitResult);
832 return E_NOTIMPL;
835 static HRESULT WINAPI ViewObject_QueryHitRect(IViewObjectEx *iface, DWORD dwAspect,
836 LPCRECT pRectBounds, LPCRECT pRectLoc, LONG lCloseHint, DWORD *pHitResult)
838 HTMLDocumentObj *This = impl_from_IViewObjectEx(iface);
839 FIXME("(%p)->(%d %p %p %d %p)\n", This, dwAspect, pRectBounds, pRectLoc, lCloseHint, pHitResult);
840 return E_NOTIMPL;
843 static HRESULT WINAPI ViewObject_GetNaturalExtent(IViewObjectEx *iface, DWORD dwAspect, LONG lindex,
844 DVTARGETDEVICE *ptd, HDC hicTargetDev, DVEXTENTINFO *pExtentInfo, LPSIZEL pSizel)
846 HTMLDocumentObj *This = impl_from_IViewObjectEx(iface);
847 FIXME("(%p)->(%d %d %p %p %p %p\n", This, dwAspect,lindex, ptd,
848 hicTargetDev, pExtentInfo, pSizel);
849 return E_NOTIMPL;
852 static const IViewObjectExVtbl ViewObjectVtbl = {
853 ViewObject_QueryInterface,
854 ViewObject_AddRef,
855 ViewObject_Release,
856 ViewObject_Draw,
857 ViewObject_GetColorSet,
858 ViewObject_Freeze,
859 ViewObject_Unfreeze,
860 ViewObject_SetAdvise,
861 ViewObject_GetAdvise,
862 ViewObject_GetExtent,
863 ViewObject_GetRect,
864 ViewObject_GetViewStatus,
865 ViewObject_QueryHitPoint,
866 ViewObject_QueryHitRect,
867 ViewObject_GetNaturalExtent
870 static inline HTMLDocumentObj *impl_from_IWindowForBindingUI(IWindowForBindingUI *iface)
872 return CONTAINING_RECORD(iface, HTMLDocumentObj, IWindowForBindingUI_iface);
875 static HRESULT WINAPI WindowForBindingUI_QueryInterface(IWindowForBindingUI *iface, REFIID riid, void **ppv)
877 HTMLDocumentObj *This = impl_from_IWindowForBindingUI(iface);
879 if(IsEqualGUID(&IID_IUnknown, riid)) {
880 TRACE("(%p)->(IID_IUnknown %p)\n", This, ppv);
881 *ppv = &This->IWindowForBindingUI_iface;
882 }else if(IsEqualGUID(&IID_IWindowForBindingUI, riid)) {
883 TRACE("(%p)->(IID_IWindowForBindingUI %p)\n", This, ppv);
884 *ppv = &This->IWindowForBindingUI_iface;
885 }else {
886 WARN("(%p)->(%s %p)\n", This, debugstr_guid(riid), ppv);
887 *ppv = NULL;
888 return E_NOINTERFACE;
891 IUnknown_AddRef((IUnknown*)*ppv);
892 return S_OK;
895 static ULONG WINAPI WindowForBindingUI_AddRef(IWindowForBindingUI *iface)
897 HTMLDocumentObj *This = impl_from_IWindowForBindingUI(iface);
898 return htmldoc_addref(&This->basedoc);
901 static ULONG WINAPI WindowForBindingUI_Release(IWindowForBindingUI *iface)
903 HTMLDocumentObj *This = impl_from_IWindowForBindingUI(iface);
904 return htmldoc_release(&This->basedoc);
907 static HRESULT WINAPI WindowForBindingUI_GetWindow(IWindowForBindingUI *iface, REFGUID rguidReason, HWND *phwnd)
909 HTMLDocumentObj *This = impl_from_IWindowForBindingUI(iface);
911 TRACE("(%p)->(%s %p)\n", This, debugstr_guid(rguidReason), phwnd);
913 *phwnd = This->hwnd;
914 return S_OK;
917 static const IWindowForBindingUIVtbl WindowForBindingUIVtbl = {
918 WindowForBindingUI_QueryInterface,
919 WindowForBindingUI_AddRef,
920 WindowForBindingUI_Release,
921 WindowForBindingUI_GetWindow
924 void HTMLDocument_View_Init(HTMLDocumentObj *doc)
926 doc->IOleDocumentView_iface.lpVtbl = &OleDocumentViewVtbl;
927 doc->IViewObjectEx_iface.lpVtbl = &ViewObjectVtbl;
928 doc->IWindowForBindingUI_iface.lpVtbl = &WindowForBindingUIVtbl;