kernel32/profile: Add a few NULL checks (Coverity).
[wine] / dlls / mshtml / view.c
1 /*
2  * Copyright 2005-2006 Jacek Caban for CodeWeavers
3  *
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.
8  *
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.
13  *
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
17  */
18
19 #include "config.h"
20
21 #include <stdarg.h>
22 #include <stdio.h>
23
24 #define COBJMACROS
25
26 #include "windef.h"
27 #include "winbase.h"
28 #include "winuser.h"
29 #include "wingdi.h"
30 #include "commctrl.h"
31 #include "ole2.h"
32 #include "resource.h"
33
34 #include "wine/debug.h"
35
36 #include "mshtml_private.h"
37
38 WINE_DEFAULT_DEBUG_CHANNEL(mshtml);
39
40 static const WCHAR wszInternetExplorer_Server[] =
41     {'I','n','t','e','r','n','e','t',' ','E','x','p','l','o','r','e','r','_','S','e','r','v','e','r',0};
42
43 static const WCHAR wszTooltipData[] = {'t','o','o','l','t','i','p','_','d','a','t','a',0};
44
45 static ATOM serverwnd_class = 0;
46
47 typedef struct {
48     HTMLDocument *doc;
49     WNDPROC proc;
50 } tooltip_data;
51
52 static void paint_document(HTMLDocument *This)
53 {
54     PAINTSTRUCT ps;
55     RECT rect;
56     HDC hdc;
57
58     GetClientRect(This->hwnd, &rect);
59
60     hdc = BeginPaint(This->hwnd, &ps);
61
62     if(!(This->hostinfo.dwFlags & (DOCHOSTUIFLAG_NO3DOUTERBORDER|DOCHOSTUIFLAG_NO3DBORDER)))
63         DrawEdge(hdc, &rect, EDGE_SUNKEN, BF_RECT|BF_ADJUST);
64
65     if(!This->nscontainer) {
66         WCHAR wszHTMLDisabled[100];
67         HFONT font;
68
69         LoadStringW(hInst, IDS_HTMLDISABLED, wszHTMLDisabled, sizeof(wszHTMLDisabled)/sizeof(WCHAR));
70
71         font = CreateFontA(25,0,0,0,400,0,0,0,ANSI_CHARSET,0,0,DEFAULT_QUALITY,DEFAULT_PITCH,NULL);
72
73         SelectObject(hdc, font);
74         SelectObject(hdc, GetSysColorBrush(COLOR_WINDOW));
75
76         Rectangle(hdc, rect.left, rect.top, rect.right, rect.bottom);
77         DrawTextW(hdc, wszHTMLDisabled,-1, &rect, DT_CENTER | DT_SINGLELINE | DT_VCENTER);
78
79         DeleteObject(font);
80     }
81
82     EndPaint(This->hwnd, &ps);
83 }
84
85 static void activate_gecko(HTMLDocument *This)
86 {
87     TRACE("(%p) %p\n", This, This->nscontainer->window);
88
89     SetParent(This->nscontainer->hwnd, This->hwnd);
90     ShowWindow(This->nscontainer->hwnd, SW_SHOW);
91
92     nsIBaseWindow_SetVisibility(This->nscontainer->window, TRUE);
93     nsIBaseWindow_SetEnabled(This->nscontainer->window, TRUE);
94     nsIWebBrowserFocus_Activate(This->nscontainer->focus);
95 }
96
97 static LRESULT WINAPI serverwnd_proc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)
98 {
99     HTMLDocument *This;
100
101     static const WCHAR wszTHIS[] = {'T','H','I','S',0};
102
103     if(msg == WM_CREATE) {
104         This = *(HTMLDocument**)lParam;
105         SetPropW(hwnd, wszTHIS, This);
106     }else {
107         This = (HTMLDocument*)GetPropW(hwnd, wszTHIS);
108     }
109
110     switch(msg) {
111     case WM_CREATE:
112         This->hwnd = hwnd;
113         if(This->nscontainer)
114             activate_gecko(This);
115         break;
116     case WM_PAINT:
117         paint_document(This);
118         break;
119     case WM_SIZE:
120         TRACE("(%p)->(WM_SIZE)\n", This);
121         if(This->nscontainer) {
122             INT ew=0, eh=0;
123
124             if(!(This->hostinfo.dwFlags & (DOCHOSTUIFLAG_NO3DOUTERBORDER|DOCHOSTUIFLAG_NO3DBORDER))) {
125                 ew = GetSystemMetrics(SM_CXEDGE);
126                 eh = GetSystemMetrics(SM_CYEDGE);
127             }
128
129             SetWindowPos(This->nscontainer->hwnd, NULL, ew, eh,
130                          LOWORD(lParam) - 2*ew, HIWORD(lParam) - 2*eh,
131                          SWP_NOZORDER | SWP_NOACTIVATE);
132         }
133     }
134         
135     return DefWindowProcW(hwnd, msg, wParam, lParam);
136 }
137
138 static void register_serverwnd_class(void)
139 {
140     static WNDCLASSEXW wndclass = {
141         sizeof(WNDCLASSEXW),
142         CS_DBLCLKS,
143         serverwnd_proc,
144         0, 0, NULL, NULL, NULL, NULL, NULL,
145         wszInternetExplorer_Server,
146         NULL,
147     };
148     wndclass.hInstance = hInst;
149     serverwnd_class = RegisterClassExW(&wndclass);
150 }
151
152 static HRESULT activate_window(HTMLDocument *This)
153 {
154     IOleInPlaceUIWindow *pIPWnd;
155     IOleInPlaceFrame *pIPFrame;
156     IOleCommandTarget *cmdtrg;
157     RECT posrect, cliprect;
158     OLEINPLACEFRAMEINFO frameinfo;
159     HWND parent_hwnd;
160     HRESULT hres;
161
162     if(!serverwnd_class)
163         register_serverwnd_class();
164
165     hres = IOleInPlaceSite_CanInPlaceActivate(This->ipsite);
166     if(hres != S_OK) {
167         WARN("CanInPlaceActivate returned: %08x\n", hres);
168         return FAILED(hres) ? hres : E_FAIL;
169     }
170
171     hres = IOleInPlaceSite_GetWindowContext(This->ipsite, &pIPFrame, &pIPWnd, &posrect, &cliprect, &frameinfo);
172     if(FAILED(hres)) {
173         WARN("GetWindowContext failed: %08x\n", hres);
174         return hres;
175     }
176
177     if(pIPWnd)
178         IOleInPlaceUIWindow_Release(pIPWnd);
179     TRACE("got window context: %p %p {%d %d %d %d} {%d %d %d %d} {%d %x %p %p %d}\n",
180             pIPFrame, pIPWnd, posrect.left, posrect.top, posrect.right, posrect.bottom,
181             cliprect.left, cliprect.top, cliprect.right, cliprect.bottom,
182             frameinfo.cb, frameinfo.fMDIApp, frameinfo.hwndFrame, frameinfo.haccel, frameinfo.cAccelEntries);
183
184     hres = IOleInPlaceSite_GetWindow(This->ipsite, &parent_hwnd);
185     if(FAILED(hres)) {
186         WARN("GetWindow failed: %08x\n", hres);
187         return hres;
188     }
189
190     TRACE("got parent window %p\n", parent_hwnd);
191
192     if(This->hwnd) {
193         if(GetParent(This->hwnd) != parent_hwnd)
194             SetParent(This->hwnd, parent_hwnd);
195         SetWindowPos(This->hwnd, HWND_TOP,
196                 posrect.left, posrect.top, posrect.right-posrect.left, posrect.bottom-posrect.top,
197                 SWP_NOACTIVATE | SWP_SHOWWINDOW);
198     }else {
199         CreateWindowExW(0, wszInternetExplorer_Server, NULL,
200                 WS_CHILD | WS_CLIPSIBLINGS | WS_CLIPCHILDREN,
201                 posrect.left, posrect.top, posrect.right-posrect.left, posrect.bottom-posrect.top,
202                 parent_hwnd, NULL, hInst, This);
203
204         TRACE("Created window %p\n", This->hwnd);
205
206         SetWindowPos(This->hwnd, NULL, 0, 0, 0, 0,
207                 SWP_NOSIZE | SWP_NOMOVE | SWP_NOZORDER | SWP_NOREDRAW | SWP_NOACTIVATE | SWP_SHOWWINDOW);
208         RedrawWindow(This->hwnd, NULL, NULL, RDW_INVALIDATE | RDW_NOERASE | RDW_ALLCHILDREN);
209         SetFocus(This->hwnd);
210
211         /* NOTE:
212          * Windows implementation calls:
213          * RegisterWindowMessage("MSWHEEL_ROLLMSG");
214          * SetTimer(This->hwnd, TIMER_ID, 100, NULL);
215          */
216     }
217
218     This->in_place_active = TRUE;
219     hres = IOleInPlaceSite_OnInPlaceActivate(This->ipsite);
220     if(FAILED(hres)) {
221         WARN("OnInPlaceActivate failed: %08x\n", hres);
222         This->in_place_active = FALSE;
223         return hres;
224     }
225
226     hres = IOleClientSite_QueryInterface(This->client, &IID_IOleCommandTarget, (void**)&cmdtrg);
227     if(SUCCEEDED(hres)) {
228         VARIANT var;
229
230         IOleInPlaceFrame_SetStatusText(pIPFrame, NULL);
231
232         V_VT(&var) = VT_I4;
233         V_I4(&var) = 0;
234         IOleCommandTarget_Exec(cmdtrg, NULL, OLECMDID_SETPROGRESSMAX,
235                 OLECMDEXECOPT_DONTPROMPTUSER, &var, NULL);
236         IOleCommandTarget_Exec(cmdtrg, NULL, OLECMDID_SETPROGRESSPOS, 
237                 OLECMDEXECOPT_DONTPROMPTUSER, &var, NULL);
238
239         IOleCommandTarget_Release(cmdtrg);
240     }
241
242     if(This->frame)
243         IOleInPlaceFrame_Release(This->frame);
244     This->frame = pIPFrame;
245
246     This->window_active = TRUE;
247
248     return S_OK;
249 }
250
251 static LRESULT tooltips_proc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)
252 {
253     tooltip_data *data = GetPropW(hwnd, wszTooltipData);
254
255     TRACE("%d %p\n", msg, data);
256
257     if(msg == TTM_WINDOWFROMPOINT) {
258         RECT rect;
259         POINT *pt = (POINT*)lParam;
260
261         TRACE("TTM_WINDOWFROMPOINT (%d,%d)\n", pt->x, pt->y);
262
263         GetWindowRect(data->doc->hwnd, &rect);
264
265         if(rect.left <= pt->x && pt->x <= rect.right
266            && rect.top <= pt->y && pt->y <= rect.bottom)
267             return (LPARAM)data->doc->hwnd;
268     }
269
270     return CallWindowProcW(data->proc, hwnd, msg, wParam, lParam);
271 }
272
273 static void create_tooltips_window(HTMLDocument *This)
274 {
275     tooltip_data *data = mshtml_alloc(sizeof(*data));
276
277     This->tooltips_hwnd = CreateWindowExW(0, TOOLTIPS_CLASSW, NULL, TTS_NOPREFIX | WS_POPUP,
278             CW_USEDEFAULT, CW_USEDEFAULT, 10, 10, This->hwnd, NULL, hInst, NULL);
279
280     data->doc = This;
281     data->proc = (WNDPROC)GetWindowLongPtrW(This->tooltips_hwnd, GWLP_WNDPROC);
282
283     SetPropW(This->tooltips_hwnd, wszTooltipData, data);
284
285     SetWindowLongPtrW(This->tooltips_hwnd, GWLP_WNDPROC, (LONG_PTR)tooltips_proc);
286
287     SetWindowPos(This->tooltips_hwnd, HWND_TOPMOST,0, 0, 0, 0,
288                  SWP_NOMOVE | SWP_NOSIZE | SWP_NOACTIVATE);
289
290 }
291
292 void show_tooltip(HTMLDocument *This, DWORD x, DWORD y, LPCWSTR text)
293 {
294     TTTOOLINFOW toolinfo = {
295         sizeof(TTTOOLINFOW), 0, This->hwnd, 0xdeadbeef,
296         {x>2 ? x-2 : 0, y>0 ? y-2 : 0, x+2, y+2}, /* FIXME */
297         NULL, (LPWSTR)text, 0};
298     MSG msg = {This->hwnd, WM_MOUSEMOVE, 0, MAKELPARAM(x,y), 0, {x,y}};
299
300     TRACE("(%p)->(%d %d %s)\n", This, x, y, debugstr_w(text));
301
302     if(!This->tooltips_hwnd)
303         create_tooltips_window(This);
304
305     SendMessageW(This->tooltips_hwnd, TTM_ADDTOOLW, 0, (LPARAM)&toolinfo);
306     SendMessageW(This->tooltips_hwnd, TTM_ACTIVATE, TRUE, 0);
307     SendMessageW(This->tooltips_hwnd, TTM_RELAYEVENT, 0, (LPARAM)&msg);
308 }
309
310 void hide_tooltip(HTMLDocument *This)
311 {
312     TTTOOLINFOW toolinfo = {
313         sizeof(TTTOOLINFOW), 0, This->hwnd, 0xdeadbeef,
314         {0,0,0,0}, NULL, NULL, 0};
315
316     TRACE("(%p)\n", This);
317
318     SendMessageW(This->tooltips_hwnd, TTM_DELTOOLW, 0, (LPARAM)&toolinfo);
319     SendMessageW(This->tooltips_hwnd, TTM_ACTIVATE, FALSE, 0);
320 }
321
322 /**********************************************************
323  * IOleDocumentView implementation
324  */
325
326 #define DOCVIEW_THIS(iface) DEFINE_THIS(HTMLDocument, OleDocumentView, iface)
327
328 static HRESULT WINAPI OleDocumentView_QueryInterface(IOleDocumentView *iface, REFIID riid, void **ppvObject)
329 {
330     HTMLDocument *This = DOCVIEW_THIS(iface);
331     return IHTMLDocument2_QueryInterface(HTMLDOC(This), riid, ppvObject);
332 }
333
334 static ULONG WINAPI OleDocumentView_AddRef(IOleDocumentView *iface)
335 {
336     HTMLDocument *This = DOCVIEW_THIS(iface);
337     return IHTMLDocument2_AddRef(HTMLDOC(This));
338 }
339
340 static ULONG WINAPI OleDocumentView_Release(IOleDocumentView *iface)
341 {
342     HTMLDocument *This = DOCVIEW_THIS(iface);
343     return IHTMLDocument2_Release(HTMLDOC(This));
344 }
345
346 static HRESULT WINAPI OleDocumentView_SetInPlaceSite(IOleDocumentView *iface, IOleInPlaceSite *pIPSite)
347 {
348     HTMLDocument *This = DOCVIEW_THIS(iface);
349     TRACE("(%p)->(%p)\n", This, pIPSite);
350
351     if(pIPSite)
352         IOleInPlaceSite_AddRef(pIPSite);
353
354     if(This->ipsite)
355         IOleInPlaceSite_Release(This->ipsite);
356
357     This->ipsite = pIPSite;
358     return S_OK;
359 }
360
361 static HRESULT WINAPI OleDocumentView_GetInPlaceSite(IOleDocumentView *iface, IOleInPlaceSite **ppIPSite)
362 {
363     HTMLDocument *This = DOCVIEW_THIS(iface);
364     TRACE("(%p)->(%p)\n", This, ppIPSite);
365
366     if(!ppIPSite)
367         return E_INVALIDARG;
368
369     if(This->ipsite)
370         IOleInPlaceSite_AddRef(This->ipsite);
371
372     *ppIPSite = This->ipsite;
373     return S_OK;
374 }
375
376 static HRESULT WINAPI OleDocumentView_GetDocument(IOleDocumentView *iface, IUnknown **ppunk)
377 {
378     HTMLDocument *This = DOCVIEW_THIS(iface);
379     TRACE("(%p)->(%p)\n", This, ppunk);
380
381     if(!ppunk)
382         return E_INVALIDARG;
383
384     IHTMLDocument2_AddRef(HTMLDOC(This));
385     *ppunk = (IUnknown*)HTMLDOC(This);
386     return S_OK;
387 }
388
389 static HRESULT WINAPI OleDocumentView_SetRect(IOleDocumentView *iface, LPRECT prcView)
390 {
391     HTMLDocument *This = DOCVIEW_THIS(iface);
392     RECT rect;
393
394     TRACE("(%p)->(%p)\n", This, prcView);
395
396     if(!prcView)
397         return E_INVALIDARG;
398
399     if(This->hwnd) {
400         GetClientRect(This->hwnd, &rect);
401         if(memcmp(prcView, &rect, sizeof(RECT))) {
402             InvalidateRect(This->hwnd,NULL,TRUE);
403             SetWindowPos(This->hwnd, NULL, prcView->left, prcView->top, prcView->right,
404                     prcView->bottom, SWP_NOZORDER | SWP_NOACTIVATE);
405         }
406     }
407     
408     return S_OK;
409 }
410
411 static HRESULT WINAPI OleDocumentView_GetRect(IOleDocumentView *iface, LPRECT prcView)
412 {
413     HTMLDocument *This = DOCVIEW_THIS(iface);
414
415     TRACE("(%p)->(%p)\n", This, prcView);
416
417     if(!prcView)
418         return E_INVALIDARG;
419
420     GetClientRect(This->hwnd, prcView);
421     return S_OK;
422 }
423
424 static HRESULT WINAPI OleDocumentView_SetRectComplex(IOleDocumentView *iface, LPRECT prcView,
425                         LPRECT prcHScroll, LPRECT prcVScroll, LPRECT prcSizeBox)
426 {
427     HTMLDocument *This = DOCVIEW_THIS(iface);
428     FIXME("(%p)->(%p %p %p %p)\n", This, prcView, prcHScroll, prcVScroll, prcSizeBox);
429     return E_NOTIMPL;
430 }
431
432 static HRESULT WINAPI OleDocumentView_Show(IOleDocumentView *iface, BOOL fShow)
433 {
434     HTMLDocument *This = DOCVIEW_THIS(iface);
435     HRESULT hres;
436
437     TRACE("(%p)->(%x)\n", This, fShow);
438
439     if(fShow) {
440         if(!This->ui_active) {
441             hres = activate_window(This);
442             if(FAILED(hres))
443                 return hres;
444         }
445         ShowWindow(This->hwnd, SW_SHOW);
446     }else {
447         ShowWindow(This->hwnd, SW_HIDE);
448     }
449
450     return S_OK;
451 }
452
453 static HRESULT WINAPI OleDocumentView_UIActivate(IOleDocumentView *iface, BOOL fUIActivate)
454 {
455     HTMLDocument *This = DOCVIEW_THIS(iface);
456     HRESULT hres;
457
458     TRACE("(%p)->(%x)\n", This, fUIActivate);
459
460     if(!This->ipsite) {
461         FIXME("This->ipsite = NULL\n");
462         return E_FAIL;
463     }
464
465     if(fUIActivate) {
466         if(This->ui_active)
467             return S_OK;
468
469         if(!This->window_active) {
470             hres = activate_window(This);
471             if(FAILED(hres))
472                 return hres;
473         }
474
475         hres = IOleInPlaceSite_OnUIActivate(This->ipsite);
476         if(SUCCEEDED(hres)) {
477             OLECHAR wszHTMLDocument[30];
478             LoadStringW(hInst, IDS_HTMLDOCUMENT, wszHTMLDocument,
479                     sizeof(wszHTMLDocument)/sizeof(WCHAR));
480             IOleInPlaceFrame_SetActiveObject(This->frame, ACTOBJ(This), wszHTMLDocument);
481         }else {
482             FIXME("OnUIActivate failed: %08x\n", hres);
483             IOleInPlaceFrame_Release(This->frame);
484             This->frame = NULL;
485             This->ui_active = FALSE;
486             return hres;
487         }
488
489         hres = IDocHostUIHandler_ShowUI(This->hostui, 0, ACTOBJ(This), CMDTARGET(This),
490                 This->frame, NULL);
491         if(FAILED(hres))
492             IDocHostUIHandler_HideUI(This->hostui);
493
494         This->ui_active = TRUE;
495     }else {
496         This->window_active = FALSE;
497         if(This->ui_active) {
498             This->ui_active = FALSE;
499             if(This->frame)
500                 IOleInPlaceFrame_SetActiveObject(This->frame, NULL, NULL);
501             if(This->hostui)
502                 IDocHostUIHandler_HideUI(This->hostui);
503             if(This->ipsite)
504                 IOleInPlaceSite_OnUIDeactivate(This->ipsite, FALSE);
505         }
506     }
507     return S_OK;
508 }
509
510 static HRESULT WINAPI OleDocumentView_Open(IOleDocumentView *iface)
511 {
512     HTMLDocument *This = DOCVIEW_THIS(iface);
513     FIXME("(%p)\n", This);
514     return E_NOTIMPL;
515 }
516
517 static HRESULT WINAPI OleDocumentView_CloseView(IOleDocumentView *iface, DWORD dwReserved)
518 {
519     HTMLDocument *This = DOCVIEW_THIS(iface);
520     TRACE("(%p)->(%x)\n", This, dwReserved);
521
522     if(dwReserved)
523         WARN("dwReserved = %d\n", dwReserved);
524
525     /* NOTE:
526      * Windows implementation calls QueryInterface(IID_IOleCommandTarget),
527      * QueryInterface(IID_IOleControlSite) and KillTimer
528      */
529
530     IOleDocumentView_Show(iface, FALSE);
531
532     return S_OK;
533 }
534
535 static HRESULT WINAPI OleDocumentView_SaveViewState(IOleDocumentView *iface, LPSTREAM pstm)
536 {
537     HTMLDocument *This = DOCVIEW_THIS(iface);
538     FIXME("(%p)->(%p)\n", This, pstm);
539     return E_NOTIMPL;
540 }
541
542 static HRESULT WINAPI OleDocumentView_ApplyViewState(IOleDocumentView *iface, LPSTREAM pstm)
543 {
544     HTMLDocument *This = DOCVIEW_THIS(iface);
545     FIXME("(%p)->(%p)\n", This, pstm);
546     return E_NOTIMPL;
547 }
548
549 static HRESULT WINAPI OleDocumentView_Clone(IOleDocumentView *iface, IOleInPlaceSite *pIPSiteNew,
550                                         IOleDocumentView **ppViewNew)
551 {
552     HTMLDocument *This = DOCVIEW_THIS(iface);
553     FIXME("(%p)->(%p %p)\n", This, pIPSiteNew, ppViewNew);
554     return E_NOTIMPL;
555 }
556
557 #undef DOCVIEW_THIS
558
559 static const IOleDocumentViewVtbl OleDocumentViewVtbl = {
560     OleDocumentView_QueryInterface,
561     OleDocumentView_AddRef,
562     OleDocumentView_Release,
563     OleDocumentView_SetInPlaceSite,
564     OleDocumentView_GetInPlaceSite,
565     OleDocumentView_GetDocument,
566     OleDocumentView_SetRect,
567     OleDocumentView_GetRect,
568     OleDocumentView_SetRectComplex,
569     OleDocumentView_Show,
570     OleDocumentView_UIActivate,
571     OleDocumentView_Open,
572     OleDocumentView_CloseView,
573     OleDocumentView_SaveViewState,
574     OleDocumentView_ApplyViewState,
575     OleDocumentView_Clone
576 };
577
578 /**********************************************************
579  * IViewObject implementation
580  */
581
582 #define VIEWOBJ_THIS(iface) DEFINE_THIS(HTMLDocument, ViewObject2, iface)
583
584 static HRESULT WINAPI ViewObject_QueryInterface(IViewObject2 *iface, REFIID riid, void **ppvObject)
585 {
586     HTMLDocument *This = VIEWOBJ_THIS(iface);
587     return IHTMLDocument2_QueryInterface(HTMLDOC(This), riid, ppvObject);
588 }
589
590 static ULONG WINAPI ViewObject_AddRef(IViewObject2 *iface)
591 {
592     HTMLDocument *This = VIEWOBJ_THIS(iface);
593     return IHTMLDocument2_AddRef(HTMLDOC(This));
594 }
595
596 static ULONG WINAPI ViewObject_Release(IViewObject2 *iface)
597 {
598     HTMLDocument *This = VIEWOBJ_THIS(iface);
599     return IHTMLDocument2_Release(HTMLDOC(This));
600 }
601
602 static HRESULT WINAPI ViewObject_Draw(IViewObject2 *iface, DWORD dwDrawAspect, LONG lindex, void *pvAspect,
603         DVTARGETDEVICE *ptd, HDC hdcTargetDev, HDC hdcDraw, LPCRECTL lprcBounds,
604         LPCRECTL lprcWBounds, BOOL (CALLBACK *pfnContinue)(ULONG_PTR dwContinue), ULONG_PTR dwContinue)
605 {
606     HTMLDocument *This = VIEWOBJ_THIS(iface);
607     FIXME("(%p)->(%d %d %p %p %p %p %p %p %p %ld)\n", This, dwDrawAspect, lindex, pvAspect,
608             ptd, hdcTargetDev, hdcDraw, lprcBounds, lprcWBounds, pfnContinue, dwContinue);
609     return E_NOTIMPL;
610 }
611
612 static HRESULT WINAPI ViewObject_GetColorSet(IViewObject2 *iface, DWORD dwDrawAspect, LONG lindex, void *pvAspect,
613         DVTARGETDEVICE *ptd, HDC hicTargetDev, LOGPALETTE **ppColorSet)
614 {
615     HTMLDocument *This = VIEWOBJ_THIS(iface);
616     FIXME("(%p)->(%d %d %p %p %p %p)\n", This, dwDrawAspect, lindex, pvAspect, ptd, hicTargetDev, ppColorSet);
617     return E_NOTIMPL;
618 }
619
620 static HRESULT WINAPI ViewObject_Freeze(IViewObject2 *iface, DWORD dwDrawAspect, LONG lindex,
621         void *pvAspect, DWORD *pdwFreeze)
622 {
623     HTMLDocument *This = VIEWOBJ_THIS(iface);
624     FIXME("(%p)->(%d %d %p %p)\n", This, dwDrawAspect, lindex, pvAspect, pdwFreeze);
625     return E_NOTIMPL;
626 }
627
628 static HRESULT WINAPI ViewObject_Unfreeze(IViewObject2 *iface, DWORD dwFreeze)
629 {
630     HTMLDocument *This = VIEWOBJ_THIS(iface);
631     FIXME("(%p)->(%d)\n", This, dwFreeze);
632     return E_NOTIMPL;
633 }
634
635 static HRESULT WINAPI ViewObject_SetAdvise(IViewObject2 *iface, DWORD aspects, DWORD advf, IAdviseSink *pAdvSink)
636 {
637     HTMLDocument *This = VIEWOBJ_THIS(iface);
638     FIXME("(%p)->(%d %d %p)\n", This, aspects, advf, pAdvSink);
639     return E_NOTIMPL;
640 }
641
642 static HRESULT WINAPI ViewObject_GetAdvise(IViewObject2 *iface, DWORD *pAspects, DWORD *pAdvf, IAdviseSink **ppAdvSink)
643 {
644     HTMLDocument *This = VIEWOBJ_THIS(iface);
645     FIXME("(%p)->(%p %p %p)\n", This, pAspects, pAdvf, ppAdvSink);
646     return E_NOTIMPL;
647 }
648
649 static HRESULT WINAPI ViewObject_GetExtent(IViewObject2 *iface, DWORD dwDrawAspect, LONG lindex,
650                                 DVTARGETDEVICE* ptd, LPSIZEL lpsizel)
651 {
652     HTMLDocument *This = VIEWOBJ_THIS(iface);
653     FIXME("(%p)->(%d %d %p %p)\n", This, dwDrawAspect, lindex, ptd, lpsizel);
654     return E_NOTIMPL;
655 }
656
657 #undef VIEWOBJ_THIS
658
659 static const IViewObject2Vtbl ViewObjectVtbl = {
660     ViewObject_QueryInterface,
661     ViewObject_AddRef,
662     ViewObject_Release,
663     ViewObject_Draw,
664     ViewObject_GetColorSet,
665     ViewObject_Freeze,
666     ViewObject_Unfreeze,
667     ViewObject_SetAdvise,
668     ViewObject_GetAdvise,
669     ViewObject_GetExtent
670 };
671
672 void HTMLDocument_View_Init(HTMLDocument *This)
673 {
674     This->lpOleDocumentViewVtbl = &OleDocumentViewVtbl;
675     This->lpViewObject2Vtbl = &ViewObjectVtbl;
676
677     This->ipsite = NULL;
678     This->frame = NULL;
679     This->hwnd = NULL;
680     This->tooltips_hwnd = NULL;
681
682     This->in_place_active = FALSE;
683     This->ui_active = FALSE;
684     This->window_active = FALSE;
685 }