2 * Copyright 2005 Jacek Caban
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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
32 #include "wine/debug.h"
34 #include "mshtml_private.h"
36 WINE_DEFAULT_DEBUG_CHANNEL(mshtml
);
38 static const WCHAR wszInternetExplorer_Server
[] =
39 {'I','n','t','e','r','n','e','t',' ','E','x','p','l','o','r','e','r','_','S','e','r','v','e','r',0};
40 static const WCHAR wszHTML_Document
[] =
41 {'H','T','M','L',' ','D','o','c','u','m','e','n','t',0};
43 static ATOM serverwnd_class
= 0;
45 static void paint_disabled(HWND hwnd
) {
52 font
= CreateFontA(25,0,0,0,400,0,0,0,ANSI_CHARSET
,0,0,DEFAULT_QUALITY
,DEFAULT_PITCH
,NULL
);
53 brush
= CreateSolidBrush(RGB(255,255,255));
54 GetClientRect(hwnd
, &rect
);
56 hdc
= BeginPaint(hwnd
, &ps
);
57 SelectObject(hdc
, font
);
58 SelectObject(hdc
, brush
);
59 Rectangle(hdc
, rect
.left
, rect
.top
, rect
.right
, rect
.bottom
);
60 DrawTextA(hdc
, "HTML rendering is currently disabled.",-1, &rect
,
61 DT_CENTER
| DT_SINGLELINE
| DT_VCENTER
);
68 static void activate_gecko(HTMLDocument
*This
)
70 TRACE("(%p) %p\n", This
, This
->nscontainer
->window
);
72 SetParent(This
->nscontainer
->hwnd
, This
->hwnd
);
73 ShowWindow(This
->nscontainer
->hwnd
, SW_SHOW
);
75 nsIBaseWindow_SetVisibility(This
->nscontainer
->window
, TRUE
);
76 nsIBaseWindow_SetEnabled(This
->nscontainer
->window
, TRUE
);
79 static LRESULT WINAPI
serverwnd_proc(HWND hwnd
, UINT msg
, WPARAM wParam
, LPARAM lParam
)
83 static const WCHAR wszTHIS
[] = {'T','H','I','S',0};
85 if(msg
== WM_CREATE
) {
86 This
= *(HTMLDocument
**)lParam
;
87 SetPropW(hwnd
, wszTHIS
, This
);
89 This
= (HTMLDocument
*)GetPropW(hwnd
, wszTHIS
);
99 if(!This
->nscontainer
)
100 paint_disabled(hwnd
);
103 TRACE("(%p)->(WM_SIZE)\n", This
);
104 if(This
->nscontainer
)
105 SetWindowPos(This
->nscontainer
->hwnd
, NULL
, 0, 0, LOWORD(lParam
), HIWORD(lParam
),
106 SWP_NOZORDER
| SWP_NOACTIVATE
);
109 return DefWindowProcW(hwnd
, msg
, wParam
, lParam
);
112 static void register_serverwnd_class(void)
114 static WNDCLASSEXW wndclass
= {
118 0, 0, NULL
, NULL
, NULL
, NULL
, NULL
,
119 wszInternetExplorer_Server
,
122 wndclass
.hInstance
= hInst
;
123 serverwnd_class
= RegisterClassExW(&wndclass
);
126 /**********************************************************
127 * IOleDocumentView implementation
130 #define DOCVIEW_THIS(iface) DEFINE_THIS(HTMLDocument, OleDocumentView, iface)
132 static HRESULT WINAPI
OleDocumentView_QueryInterface(IOleDocumentView
*iface
, REFIID riid
, void **ppvObject
)
134 HTMLDocument
*This
= DOCVIEW_THIS(iface
);
135 return IHTMLDocument2_QueryInterface(HTMLDOC(This
), riid
, ppvObject
);
138 static ULONG WINAPI
OleDocumentView_AddRef(IOleDocumentView
*iface
)
140 HTMLDocument
*This
= DOCVIEW_THIS(iface
);
141 return IHTMLDocument2_AddRef(HTMLDOC(This
));
144 static ULONG WINAPI
OleDocumentView_Release(IOleDocumentView
*iface
)
146 HTMLDocument
*This
= DOCVIEW_THIS(iface
);
147 return IHTMLDocument2_Release(HTMLDOC(This
));
150 static HRESULT WINAPI
OleDocumentView_SetInPlaceSite(IOleDocumentView
*iface
, IOleInPlaceSite
*pIPSite
)
152 HTMLDocument
*This
= DOCVIEW_THIS(iface
);
153 TRACE("(%p)->(%p)\n", This
, pIPSite
);
156 IOleInPlaceSite_AddRef(pIPSite
);
159 IOleInPlaceSite_Release(This
->ipsite
);
161 This
->ipsite
= pIPSite
;
165 static HRESULT WINAPI
OleDocumentView_GetInPlaceSite(IOleDocumentView
*iface
, IOleInPlaceSite
**ppIPSite
)
167 HTMLDocument
*This
= DOCVIEW_THIS(iface
);
168 TRACE("(%p)->(%p)\n", This
, ppIPSite
);
174 IOleInPlaceSite_AddRef(This
->ipsite
);
176 *ppIPSite
= This
->ipsite
;
180 static HRESULT WINAPI
OleDocumentView_GetDocument(IOleDocumentView
*iface
, IUnknown
**ppunk
)
182 HTMLDocument
*This
= DOCVIEW_THIS(iface
);
183 TRACE("(%p)->(%p)\n", This
, ppunk
);
188 IHTMLDocument2_AddRef(HTMLDOC(This
));
189 *ppunk
= (IUnknown
*)HTMLDOC(This
);
193 static HRESULT WINAPI
OleDocumentView_SetRect(IOleDocumentView
*iface
, LPRECT prcView
)
195 HTMLDocument
*This
= DOCVIEW_THIS(iface
);
198 TRACE("(%p)->(%p)\n", This
, prcView
);
204 GetClientRect(This
->hwnd
, &rect
);
205 if(memcmp(prcView
, &rect
, sizeof(RECT
))) {
206 InvalidateRect(This
->hwnd
,NULL
,TRUE
);
207 SetWindowPos(This
->hwnd
, NULL
, prcView
->left
, prcView
->top
, prcView
->right
,
208 prcView
->bottom
, SWP_NOZORDER
| SWP_NOACTIVATE
);
215 static HRESULT WINAPI
OleDocumentView_GetRect(IOleDocumentView
*iface
, LPRECT prcView
)
217 HTMLDocument
*This
= DOCVIEW_THIS(iface
);
219 TRACE("(%p)->(%p)\n", This
, prcView
);
224 GetClientRect(This
->hwnd
, prcView
);
228 static HRESULT WINAPI
OleDocumentView_SetRectComplex(IOleDocumentView
*iface
, LPRECT prcView
,
229 LPRECT prcHScroll
, LPRECT prcVScroll
, LPRECT prcSizeBox
)
231 HTMLDocument
*This
= DOCVIEW_THIS(iface
);
232 FIXME("(%p)->(%p %p %p %p)\n", This
, prcView
, prcHScroll
, prcVScroll
, prcSizeBox
);
236 static HRESULT WINAPI
OleDocumentView_Show(IOleDocumentView
*iface
, BOOL fShow
)
238 HTMLDocument
*This
= DOCVIEW_THIS(iface
);
239 TRACE("(%p)->(%x)\n", This
, fShow
);
242 ShowWindow(This
->hwnd
, fShow
);
247 static HRESULT WINAPI
OleDocumentView_UIActivate(IOleDocumentView
*iface
, BOOL fUIActivate
)
249 HTMLDocument
*This
= DOCVIEW_THIS(iface
);
251 IOleInPlaceUIWindow
*pIPWnd
;
252 IOleInPlaceFrame
*pIPFrame
;
253 RECT posrect
, cliprect
;
254 OLEINPLACEFRAMEINFO frameinfo
;
257 TRACE("(%p)->(%x)\n", This
, fUIActivate
);
260 FIXME("This->ipsite = NULL\n");
268 register_serverwnd_class();
270 hres
= IOleInPlaceSite_CanInPlaceActivate(This
->ipsite
);
272 WARN("CanInPlaceActivate returned: %08lx\n", hres
);
273 return FAILED(hres
) ? hres
: E_FAIL
;
276 hres
= IOleInPlaceSite_GetWindowContext(This
->ipsite
, &pIPFrame
, &pIPWnd
, &posrect
, &cliprect
, &frameinfo
);
278 WARN("GetWindowContext failed: %08lx\n", hres
);
282 IOleInPlaceUIWindow_Release(pIPWnd
);
283 TRACE("got window context: %p %p {%ld %ld %ld %ld} {%ld %ld %ld %ld} {%d %x %p %p %d}\n",
284 pIPFrame
, pIPWnd
, posrect
.left
, posrect
.top
, posrect
.right
, posrect
.bottom
,
285 cliprect
.left
, cliprect
.top
, cliprect
.right
, cliprect
.bottom
,
286 frameinfo
.cb
, frameinfo
.fMDIApp
, frameinfo
.hwndFrame
, frameinfo
.haccel
, frameinfo
.cAccelEntries
);
288 hres
= IOleInPlaceSite_GetWindow(This
->ipsite
, &parent_hwnd
);
290 WARN("GetWindow failed: %08lx\n", hres
);
294 TRACE("got parent window %p\n", parent_hwnd
);
297 if(GetParent(This
->hwnd
) != parent_hwnd
)
298 SetParent(This
->hwnd
, parent_hwnd
);
299 SetWindowPos(This
->hwnd
, HWND_TOP
,
300 posrect
.left
, posrect
.top
, posrect
.right
-posrect
.left
, posrect
.bottom
-posrect
.top
,
301 SWP_NOACTIVATE
| SWP_SHOWWINDOW
);
303 CreateWindowExW(0, wszInternetExplorer_Server
, NULL
,
304 WS_CHILD
| WS_CLIPSIBLINGS
| WS_CLIPCHILDREN
,
305 posrect
.left
, posrect
.top
, posrect
.right
-posrect
.left
, posrect
.bottom
-posrect
.top
,
306 parent_hwnd
, NULL
, hInst
, This
);
308 TRACE("Created window %p\n", This
->hwnd
);
310 SetWindowPos(This
->hwnd
, NULL
, 0, 0, 0, 0,
311 SWP_NOSIZE
| SWP_NOMOVE
| SWP_NOZORDER
| SWP_NOREDRAW
| SWP_NOACTIVATE
| SWP_SHOWWINDOW
);
312 RedrawWindow(This
->hwnd
, NULL
, NULL
, RDW_INVALIDATE
| RDW_NOERASE
| RDW_ALLCHILDREN
);
313 SetFocus(This
->hwnd
);
316 This
->in_place_active
= TRUE
;
317 hres
= IOleInPlaceSite_OnInPlaceActivate(This
->ipsite
);
319 WARN("OnInPlaceActivate failed: %08lx\n", hres
);
320 This
->in_place_active
= FALSE
;
325 * Windows implementation calls:
326 * RegisterWindowMessage("MSWHEEL_ROLLMSG");
327 * SetTimer(This->hwnd, TIMER_ID, 100, NULL);
330 This
->ui_active
= TRUE
;
331 hres
= IOleInPlaceSite_OnUIActivate(This
->ipsite
);
332 if(SUCCEEDED(hres
)) {
333 IOleInPlaceFrame_SetActiveObject(pIPFrame
, ACTOBJ(This
), wszHTML_Document
);
335 FIXME("OnUIActivate failed: %08lx\n", hres
);
336 This
->ui_active
= FALSE
;
340 IOleInPlaceFrame_Release(This
->frame
);
341 This
->frame
= pIPFrame
;
343 hres
= IDocHostUIHandler_ShowUI(This
->hostui
, 0, ACTOBJ(This
), CMDTARGET(This
),
346 IDocHostUIHandler_HideUI(This
->hostui
);
348 This
->ui_active
= FALSE
;
350 IOleInPlaceFrame_SetActiveObject(This
->frame
, NULL
, NULL
);
352 IDocHostUIHandler_HideUI(This
->hostui
);
354 IOleInPlaceSite_OnUIDeactivate(This
->ipsite
, FALSE
);
359 static HRESULT WINAPI
OleDocumentView_Open(IOleDocumentView
*iface
)
361 HTMLDocument
*This
= DOCVIEW_THIS(iface
);
362 FIXME("(%p)\n", This
);
366 static HRESULT WINAPI
OleDocumentView_CloseView(IOleDocumentView
*iface
, DWORD dwReserved
)
368 HTMLDocument
*This
= DOCVIEW_THIS(iface
);
369 TRACE("(%p)->(%lx)\n", This
, dwReserved
);
372 WARN("dwReserved = %ld\n", dwReserved
);
375 * Windows implementation calls QueryInterface(IID_IOleCommandTarget),
376 * QueryInterface(IID_IOleControlSite) and KillTimer
379 IOleDocumentView_Show(iface
, FALSE
);
384 static HRESULT WINAPI
OleDocumentView_SaveViewState(IOleDocumentView
*iface
, LPSTREAM pstm
)
386 HTMLDocument
*This
= DOCVIEW_THIS(iface
);
387 FIXME("(%p)->(%p)\n", This
, pstm
);
391 static HRESULT WINAPI
OleDocumentView_ApplyViewState(IOleDocumentView
*iface
, LPSTREAM pstm
)
393 HTMLDocument
*This
= DOCVIEW_THIS(iface
);
394 FIXME("(%p)->(%p)\n", This
, pstm
);
398 static HRESULT WINAPI
OleDocumentView_Clone(IOleDocumentView
*iface
, IOleInPlaceSite
*pIPSiteNew
,
399 IOleDocumentView
**ppViewNew
)
401 HTMLDocument
*This
= DOCVIEW_THIS(iface
);
402 FIXME("(%p)->(%p %p)\n", This
, pIPSiteNew
, ppViewNew
);
408 static const IOleDocumentViewVtbl OleDocumentViewVtbl
= {
409 OleDocumentView_QueryInterface
,
410 OleDocumentView_AddRef
,
411 OleDocumentView_Release
,
412 OleDocumentView_SetInPlaceSite
,
413 OleDocumentView_GetInPlaceSite
,
414 OleDocumentView_GetDocument
,
415 OleDocumentView_SetRect
,
416 OleDocumentView_GetRect
,
417 OleDocumentView_SetRectComplex
,
418 OleDocumentView_Show
,
419 OleDocumentView_UIActivate
,
420 OleDocumentView_Open
,
421 OleDocumentView_CloseView
,
422 OleDocumentView_SaveViewState
,
423 OleDocumentView_ApplyViewState
,
424 OleDocumentView_Clone
427 /**********************************************************
428 * IViewObject implementation
431 #define VIEWOBJ_THIS(iface) DEFINE_THIS(HTMLDocument, ViewObject2, iface)
433 static HRESULT WINAPI
ViewObject_QueryInterface(IViewObject2
*iface
, REFIID riid
, void **ppvObject
)
435 HTMLDocument
*This
= VIEWOBJ_THIS(iface
);
436 return IHTMLDocument2_QueryInterface(HTMLDOC(This
), riid
, ppvObject
);
439 static ULONG WINAPI
ViewObject_AddRef(IViewObject2
*iface
)
441 HTMLDocument
*This
= VIEWOBJ_THIS(iface
);
442 return IHTMLDocument2_AddRef(HTMLDOC(This
));
445 static ULONG WINAPI
ViewObject_Release(IViewObject2
*iface
)
447 HTMLDocument
*This
= VIEWOBJ_THIS(iface
);
448 return IHTMLDocument2_Release(HTMLDOC(This
));
451 static HRESULT WINAPI
ViewObject_Draw(IViewObject2
*iface
, DWORD dwDrawAspect
, LONG lindex
, void *pvAspect
,
452 DVTARGETDEVICE
*ptd
, HDC hdcTargetDev
, HDC hdcDraw
, LPCRECTL lprcBounds
,
453 LPCRECTL lprcWBounds
, BOOL (CALLBACK
*pfnContinue
)(ULONG_PTR dwContinue
), ULONG_PTR dwContinue
)
455 HTMLDocument
*This
= VIEWOBJ_THIS(iface
);
456 FIXME("(%p)->(%ld %ld %p %p %p %p %p %p %p %ld)\n", This
, dwDrawAspect
, lindex
, pvAspect
,
457 ptd
, hdcTargetDev
, hdcDraw
, lprcBounds
, lprcWBounds
, pfnContinue
, dwContinue
);
461 static HRESULT WINAPI
ViewObject_GetColorSet(IViewObject2
*iface
, DWORD dwDrawAspect
, LONG lindex
, void *pvAspect
,
462 DVTARGETDEVICE
*ptd
, HDC hicTargetDev
, LOGPALETTE
**ppColorSet
)
464 HTMLDocument
*This
= VIEWOBJ_THIS(iface
);
465 FIXME("(%p)->(%ld %ld %p %p %p %p)\n", This
, dwDrawAspect
, lindex
, pvAspect
, ptd
, hicTargetDev
, ppColorSet
);
469 static HRESULT WINAPI
ViewObject_Freeze(IViewObject2
*iface
, DWORD dwDrawAspect
, LONG lindex
,
470 void *pvAspect
, DWORD
*pdwFreeze
)
472 HTMLDocument
*This
= VIEWOBJ_THIS(iface
);
473 FIXME("(%p)->(%ld %ld %p %p)\n", This
, dwDrawAspect
, lindex
, pvAspect
, pdwFreeze
);
477 static HRESULT WINAPI
ViewObject_Unfreeze(IViewObject2
*iface
, DWORD dwFreeze
)
479 HTMLDocument
*This
= VIEWOBJ_THIS(iface
);
480 FIXME("(%p)->(%ld)\n", This
, dwFreeze
);
484 static HRESULT WINAPI
ViewObject_SetAdvise(IViewObject2
*iface
, DWORD aspects
, DWORD advf
, IAdviseSink
*pAdvSink
)
486 HTMLDocument
*This
= VIEWOBJ_THIS(iface
);
487 FIXME("(%p)->(%ld %ld %p)\n", This
, aspects
, advf
, pAdvSink
);
491 static HRESULT WINAPI
ViewObject_GetAdvise(IViewObject2
*iface
, DWORD
*pAspects
, DWORD
*pAdvf
, IAdviseSink
**ppAdvSink
)
493 HTMLDocument
*This
= VIEWOBJ_THIS(iface
);
494 FIXME("(%p)->(%p %p %p)\n", This
, pAspects
, pAdvf
, ppAdvSink
);
498 static HRESULT WINAPI
ViewObject_GetExtent(IViewObject2
*iface
, DWORD dwDrawAspect
, LONG lindex
,
499 DVTARGETDEVICE
* ptd
, LPSIZEL lpsizel
)
501 HTMLDocument
*This
= VIEWOBJ_THIS(iface
);
502 FIXME("(%p)->(%ld %ld %p %p)\n", This
, dwDrawAspect
, lindex
, ptd
, lpsizel
);
508 static const IViewObject2Vtbl ViewObjectVtbl
= {
509 ViewObject_QueryInterface
,
513 ViewObject_GetColorSet
,
516 ViewObject_SetAdvise
,
517 ViewObject_GetAdvise
,
521 void HTMLDocument_View_Init(HTMLDocument
*This
)
523 This
->lpOleDocumentViewVtbl
= &OleDocumentViewVtbl
;
524 This
->lpViewObject2Vtbl
= &ViewObjectVtbl
;
530 This
->in_place_active
= FALSE
;
531 This
->ui_active
= FALSE
;