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
36 #include "wine/debug.h"
38 #include "mshtml_private.h"
40 WINE_DEFAULT_DEBUG_CHANNEL(mshtml);
42 static const WCHAR wszInternetExplorer_Server[] =
43 {'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 wszHTML_Document[] =
45 {'H','T','M','L',' ','D','o','c','u','m','e','n','t',0};
47 static ATOM serverwnd_class = 0;
49 static void paint_disabled(HWND hwnd) {
56 font = CreateFontA(25,0,0,0,400,0,0,0,ANSI_CHARSET,0,0,DEFAULT_QUALITY,DEFAULT_PITCH,NULL);
57 brush = CreateSolidBrush(RGB(255,255,255));
58 GetClientRect(hwnd, &rect);
60 hdc = BeginPaint(hwnd, &ps);
61 SelectObject(hdc, font);
62 SelectObject(hdc, brush);
63 Rectangle(hdc, rect.left, rect.top, rect.right, rect.bottom);
64 DrawTextA(hdc, "HTML rendering is currently disabled.",-1, &rect,
65 DT_CENTER | DT_SINGLELINE | DT_VCENTER);
72 static LRESULT WINAPI serverwnd_proc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)
77 return DefWindowProcW(hwnd, msg, wParam, lParam);
80 static void register_serverwnd_class(void)
82 static WNDCLASSEXW wndclass = {
86 0, 0, NULL, NULL, NULL, NULL, NULL,
87 wszInternetExplorer_Server,
90 wndclass.hInstance = hInst;
91 serverwnd_class = RegisterClassExW(&wndclass);
95 /**********************************************************
96 * IOleDocumentView implementation
99 #define DOCVIEW_THIS(iface) DEFINE_THIS(HTMLDocument, OleDocumentView, iface)
101 static HRESULT WINAPI OleDocumentView_QueryInterface(IOleDocumentView *iface, REFIID riid, void **ppvObject)
103 HTMLDocument *This = DOCVIEW_THIS(iface);
104 return IHTMLDocument2_QueryInterface(HTMLDOC(This), riid, ppvObject);
107 static ULONG WINAPI OleDocumentView_AddRef(IOleDocumentView *iface)
109 HTMLDocument *This = DOCVIEW_THIS(iface);
110 return IHTMLDocument2_AddRef(HTMLDOC(This));
113 static ULONG WINAPI OleDocumentView_Release(IOleDocumentView *iface)
115 HTMLDocument *This = DOCVIEW_THIS(iface);
116 return IHTMLDocument2_Release(HTMLDOC(This));
119 static HRESULT WINAPI OleDocumentView_SetInPlaceSite(IOleDocumentView *iface, IOleInPlaceSite *pIPSite)
121 HTMLDocument *This = DOCVIEW_THIS(iface);
122 TRACE("(%p)->(%p)\n", This, pIPSite);
125 IOleInPlaceSite_AddRef(pIPSite);
128 IOleInPlaceSite_Release(This->ipsite);
130 This->ipsite = pIPSite;
134 static HRESULT WINAPI OleDocumentView_GetInPlaceSite(IOleDocumentView *iface, IOleInPlaceSite **ppIPSite)
136 HTMLDocument *This = DOCVIEW_THIS(iface);
137 TRACE("(%p)->(%p)\n", This, ppIPSite);
143 IOleInPlaceSite_AddRef(This->ipsite);
145 *ppIPSite = This->ipsite;
149 static HRESULT WINAPI OleDocumentView_GetDocument(IOleDocumentView *iface, IUnknown **ppunk)
151 HTMLDocument *This = DOCVIEW_THIS(iface);
152 TRACE("(%p)->(%p)\n", This, ppunk);
157 IHTMLDocument2_AddRef(HTMLDOC(This));
158 *ppunk = (IUnknown*)HTMLDOC(This);
162 static HRESULT WINAPI OleDocumentView_SetRect(IOleDocumentView *iface, LPRECT prcView)
164 HTMLDocument *This = DOCVIEW_THIS(iface);
167 TRACE("(%p)->(%p)\n", This, prcView);
173 GetClientRect(This->hwnd, &rect);
174 if(memcmp(prcView, &rect, sizeof(RECT))) {
175 InvalidateRect(This->hwnd,NULL,TRUE);
176 SetWindowPos(This->hwnd, NULL, prcView->left, prcView->top, prcView->right,
177 prcView->bottom, SWP_NOZORDER | SWP_NOACTIVATE);
184 static HRESULT WINAPI OleDocumentView_GetRect(IOleDocumentView *iface, LPRECT prcView)
186 HTMLDocument *This = DOCVIEW_THIS(iface);
188 TRACE("(%p)->(%p)\n", This, prcView);
193 GetClientRect(This->hwnd, prcView);
197 static HRESULT WINAPI OleDocumentView_SetRectComplex(IOleDocumentView *iface, LPRECT prcView,
198 LPRECT prcHScroll, LPRECT prcVScroll, LPRECT prcSizeBox)
200 HTMLDocument *This = DOCVIEW_THIS(iface);
201 FIXME("(%p)->(%p %p %p %p)\n", This, prcView, prcHScroll, prcVScroll, prcSizeBox);
205 static HRESULT WINAPI OleDocumentView_Show(IOleDocumentView *iface, BOOL fShow)
207 HTMLDocument *This = DOCVIEW_THIS(iface);
208 TRACE("(%p)->(%x)\n", This, fShow);
211 ShowWindow(This->hwnd, fShow);
216 static HRESULT WINAPI OleDocumentView_UIActivate(IOleDocumentView *iface, BOOL fUIActivate)
218 HTMLDocument *This = DOCVIEW_THIS(iface);
220 IOleInPlaceUIWindow *pIPWnd;
221 IOleInPlaceFrame *pIPFrame;
222 RECT posrect, cliprect;
223 OLEINPLACEFRAMEINFO frameinfo;
226 TRACE("(%p)->(%x)\n", This, fUIActivate);
229 FIXME("This->ipsite = NULL\n");
237 register_serverwnd_class();
239 hres = IOleInPlaceSite_CanInPlaceActivate(This->ipsite);
241 WARN("CanInPlaceActivate returned: %08lx\n", hres);
242 return FAILED(hres) ? hres : E_FAIL;
245 hres = IOleInPlaceSite_GetWindowContext(This->ipsite, &pIPFrame, &pIPWnd, &posrect, &cliprect, &frameinfo);
247 WARN("GetWindowContext failed: %08lx\n", hres);
251 IOleInPlaceUIWindow_Release(pIPWnd);
252 TRACE("got window context: %p %p {%ld %ld %ld %ld} {%ld %ld %ld %ld} {%d %x %p %p %d}\n",
253 pIPFrame, pIPWnd, posrect.left, posrect.top, posrect.right, posrect.bottom,
254 cliprect.left, cliprect.top, cliprect.right, cliprect.bottom,
255 frameinfo.cb, frameinfo.fMDIApp, frameinfo.hwndFrame, frameinfo.haccel, frameinfo.cAccelEntries);
257 hres = IOleInPlaceSite_GetWindow(This->ipsite, &parent_hwnd);
259 WARN("GetWindow failed: %08lx\n", hres);
263 TRACE("got parent window %p\n", parent_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);
272 This->hwnd = 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);
276 SetWindowPos(This->hwnd, NULL, 0, 0, 0, 0,
277 SWP_NOSIZE | SWP_NOMOVE | SWP_NOZORDER | SWP_NOREDRAW | SWP_NOACTIVATE | SWP_SHOWWINDOW);
278 RedrawWindow(This->hwnd, NULL, NULL, RDW_INVALIDATE | RDW_NOERASE | RDW_ALLCHILDREN);
279 SetFocus(This->hwnd);
282 This->in_place_active = TRUE;
283 hres = IOleInPlaceSite_OnInPlaceActivate(This->ipsite);
285 WARN("OnInPlaceActivate failed: %08lx\n", hres);
286 This->in_place_active = FALSE;
291 * Windows implementation calls:
292 * RegisterWindowMessage("MSWHEEL_ROLLMSG");
293 * SetTimer(This->hwnd, TIMER_ID, 100, NULL);
296 This->ui_active = TRUE;
297 hres = IOleInPlaceSite_OnUIActivate(This->ipsite);
298 if(SUCCEEDED(hres)) {
299 IOleInPlaceFrame_SetActiveObject(pIPFrame, ACTOBJ(This), wszHTML_Document);
301 FIXME("OnUIActivate failed: %08lx\n", hres);
302 This->ui_active = FALSE;
306 IOleInPlaceFrame_Release(This->frame);
307 This->frame = pIPFrame;
309 hres = IDocHostUIHandler_ShowUI(This->hostui, 0, ACTOBJ(This), CMDTARGET(This),
312 IDocHostUIHandler_HideUI(This->hostui);
314 This->ui_active = FALSE;
316 IOleInPlaceFrame_SetActiveObject(This->frame, NULL, NULL);
318 IDocHostUIHandler_HideUI(This->hostui);
320 IOleInPlaceSite_OnUIDeactivate(This->ipsite, FALSE);
325 static HRESULT WINAPI OleDocumentView_Open(IOleDocumentView *iface)
327 HTMLDocument *This = DOCVIEW_THIS(iface);
328 FIXME("(%p)\n", This);
332 static HRESULT WINAPI OleDocumentView_CloseView(IOleDocumentView *iface, DWORD dwReserved)
334 HTMLDocument *This = DOCVIEW_THIS(iface);
335 TRACE("(%p)->(%lx)\n", This, dwReserved);
338 WARN("dwReserved = %ld\n", dwReserved);
341 * Windows implementation calls QueryInterface(IID_IOleCommandTarget),
342 * QueryInterface(IID_IOleControlSite) and KillTimer
345 IOleDocumentView_Show(iface, FALSE);
350 static HRESULT WINAPI OleDocumentView_SaveViewState(IOleDocumentView *iface, LPSTREAM pstm)
352 HTMLDocument *This = DOCVIEW_THIS(iface);
353 FIXME("(%p)->(%p)\n", This, pstm);
357 static HRESULT WINAPI OleDocumentView_ApplyViewState(IOleDocumentView *iface, LPSTREAM pstm)
359 HTMLDocument *This = DOCVIEW_THIS(iface);
360 FIXME("(%p)->(%p)\n", This, pstm);
364 static HRESULT WINAPI OleDocumentView_Clone(IOleDocumentView *iface, IOleInPlaceSite *pIPSiteNew,
365 IOleDocumentView **ppViewNew)
367 HTMLDocument *This = DOCVIEW_THIS(iface);
368 FIXME("(%p)->(%p %p)\n", This, pIPSiteNew, ppViewNew);
374 static const IOleDocumentViewVtbl OleDocumentViewVtbl = {
375 OleDocumentView_QueryInterface,
376 OleDocumentView_AddRef,
377 OleDocumentView_Release,
378 OleDocumentView_SetInPlaceSite,
379 OleDocumentView_GetInPlaceSite,
380 OleDocumentView_GetDocument,
381 OleDocumentView_SetRect,
382 OleDocumentView_GetRect,
383 OleDocumentView_SetRectComplex,
384 OleDocumentView_Show,
385 OleDocumentView_UIActivate,
386 OleDocumentView_Open,
387 OleDocumentView_CloseView,
388 OleDocumentView_SaveViewState,
389 OleDocumentView_ApplyViewState,
390 OleDocumentView_Clone
393 /**********************************************************
394 * IViewObject implementation
397 #define VIEWOBJ_THIS(iface) DEFINE_THIS(HTMLDocument, ViewObject2, iface)
399 static HRESULT WINAPI ViewObject_QueryInterface(IViewObject2 *iface, REFIID riid, void **ppvObject)
401 HTMLDocument *This = VIEWOBJ_THIS(iface);
402 return IHTMLDocument2_QueryInterface(HTMLDOC(This), riid, ppvObject);
405 static ULONG WINAPI ViewObject_AddRef(IViewObject2 *iface)
407 HTMLDocument *This = VIEWOBJ_THIS(iface);
408 return IHTMLDocument2_AddRef(HTMLDOC(This));
411 static ULONG WINAPI ViewObject_Release(IViewObject2 *iface)
413 HTMLDocument *This = VIEWOBJ_THIS(iface);
414 return IHTMLDocument2_Release(HTMLDOC(This));
417 static HRESULT WINAPI ViewObject_Draw(IViewObject2 *iface, DWORD dwDrawAspect, LONG lindex, void *pvAspect,
418 DVTARGETDEVICE *ptd, HDC hdcTargetDev, HDC hdcDraw, LPCRECTL lprcBounds,
419 LPCRECTL lprcWBounds, BOOL (CALLBACK *pfnContinue)(ULONG_PTR dwContinue), ULONG_PTR dwContinue)
421 HTMLDocument *This = VIEWOBJ_THIS(iface);
422 FIXME("(%p)->(%ld %ld %p %p %p %p %p %p %p %ld)\n", This, dwDrawAspect, lindex, pvAspect,
423 ptd, hdcTargetDev, hdcDraw, lprcBounds, lprcWBounds, pfnContinue, dwContinue);
427 static HRESULT WINAPI ViewObject_GetColorSet(IViewObject2 *iface, DWORD dwDrawAspect, LONG lindex, void *pvAspect,
428 DVTARGETDEVICE *ptd, HDC hicTargetDev, LOGPALETTE **ppColorSet)
430 HTMLDocument *This = VIEWOBJ_THIS(iface);
431 FIXME("(%p)->(%ld %ld %p %p %p %p)\n", This, dwDrawAspect, lindex, pvAspect, ptd, hicTargetDev, ppColorSet);
435 static HRESULT WINAPI ViewObject_Freeze(IViewObject2 *iface, DWORD dwDrawAspect, LONG lindex,
436 void *pvAspect, DWORD *pdwFreeze)
438 HTMLDocument *This = VIEWOBJ_THIS(iface);
439 FIXME("(%p)->(%ld %ld %p %p)\n", This, dwDrawAspect, lindex, pvAspect, pdwFreeze);
443 static HRESULT WINAPI ViewObject_Unfreeze(IViewObject2 *iface, DWORD dwFreeze)
445 HTMLDocument *This = VIEWOBJ_THIS(iface);
446 FIXME("(%p)->(%ld)\n", This, dwFreeze);
450 static HRESULT WINAPI ViewObject_SetAdvise(IViewObject2 *iface, DWORD aspects, DWORD advf, IAdviseSink *pAdvSink)
452 HTMLDocument *This = VIEWOBJ_THIS(iface);
453 FIXME("(%p)->(%ld %ld %p)\n", This, aspects, advf, pAdvSink);
457 static HRESULT WINAPI ViewObject_GetAdvise(IViewObject2 *iface, DWORD *pAspects, DWORD *pAdvf, IAdviseSink **ppAdvSink)
459 HTMLDocument *This = VIEWOBJ_THIS(iface);
460 FIXME("(%p)->(%p %p %p)\n", This, pAspects, pAdvf, ppAdvSink);
464 static HRESULT WINAPI ViewObject_GetExtent(IViewObject2 *iface, DWORD dwDrawAspect, LONG lindex,
465 DVTARGETDEVICE* ptd, LPSIZEL lpsizel)
467 HTMLDocument *This = VIEWOBJ_THIS(iface);
468 FIXME("(%p)->(%ld %ld %p %p)\n", This, dwDrawAspect, lindex, ptd, lpsizel);
474 static const IViewObject2Vtbl ViewObjectVtbl = {
475 ViewObject_QueryInterface,
479 ViewObject_GetColorSet,
482 ViewObject_SetAdvise,
483 ViewObject_GetAdvise,
487 void HTMLDocument_View_Init(HTMLDocument *This)
489 This->lpOleDocumentViewVtbl = &OleDocumentViewVtbl;
490 This->lpViewObject2Vtbl = &ViewObjectVtbl;
496 This->in_place_active = FALSE;
497 This->ui_active = FALSE;