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;
224 HWND parent_hwnd, hwnd;
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);
265 hwnd = CreateWindowExW(0, wszInternetExplorer_Server, NULL,
266 WS_CHILD | WS_CLIPSIBLINGS | WS_CLIPCHILDREN,
267 posrect.left, posrect.top, posrect.right-posrect.left, posrect.bottom-posrect.top,
268 parent_hwnd, NULL, hInst, This);
270 This->in_place_active = TRUE;
271 hres = IOleInPlaceSite_OnInPlaceActivate(This->ipsite);
273 WARN("OnInPlaceActivate failed: %08lx\n", hres);
274 This->in_place_active = FALSE;
278 SetWindowPos(hwnd, NULL, 0, 0, 0, 0,
279 SWP_NOSIZE | SWP_NOMOVE | SWP_NOZORDER | SWP_NOREDRAW | SWP_NOACTIVATE | SWP_SHOWWINDOW);
280 RedrawWindow(hwnd, NULL, NULL, RDW_INVALIDATE | RDW_NOERASE | RDW_ALLCHILDREN);
284 * Windows implementation calls:
285 * RegisterWindowMessage("MSWHEEL_ROLLMSG");
286 * SetTimer(This->hwnd, TIMER_ID, 100, NULL);
289 This->ui_active = TRUE;
290 hres = IOleInPlaceSite_OnUIActivate(This->ipsite);
291 if(SUCCEEDED(hres)) {
292 IOleInPlaceFrame_SetActiveObject(pIPFrame, ACTOBJ(This), wszHTML_Document);
294 FIXME("OnUIActivate failed: %08lx\n", hres);
295 This->ui_active = FALSE;
300 IOleInPlaceFrame_Release(This->frame);
301 This->frame = pIPFrame;
304 hres = IDocHostUIHandler_ShowUI(This->hostui, 0, ACTOBJ(This), CMDTARGET(This),
307 IDocHostUIHandler_HideUI(This->hostui);
309 This->ui_active = FALSE;
311 IOleInPlaceFrame_SetActiveObject(This->frame, NULL, NULL);
313 IDocHostUIHandler_HideUI(This->hostui);
315 IOleInPlaceSite_OnUIDeactivate(This->ipsite, FALSE);
320 static HRESULT WINAPI OleDocumentView_Open(IOleDocumentView *iface)
322 HTMLDocument *This = DOCVIEW_THIS(iface);
323 FIXME("(%p)\n", This);
327 static HRESULT WINAPI OleDocumentView_CloseView(IOleDocumentView *iface, DWORD dwReserved)
329 HTMLDocument *This = DOCVIEW_THIS(iface);
330 TRACE("(%p)->(%lx)\n", This, dwReserved);
333 WARN("dwReserved = %ld\n", dwReserved);
336 * Windows implementation calls QueryInterface(IID_IOleCommandTarget),
337 * QueryInterface(IID_IOleControlSite) and KillTimer
340 IOleDocumentView_Show(iface, FALSE);
345 static HRESULT WINAPI OleDocumentView_SaveViewState(IOleDocumentView *iface, LPSTREAM pstm)
347 HTMLDocument *This = DOCVIEW_THIS(iface);
348 FIXME("(%p)->(%p)\n", This, pstm);
352 static HRESULT WINAPI OleDocumentView_ApplyViewState(IOleDocumentView *iface, LPSTREAM pstm)
354 HTMLDocument *This = DOCVIEW_THIS(iface);
355 FIXME("(%p)->(%p)\n", This, pstm);
359 static HRESULT WINAPI OleDocumentView_Clone(IOleDocumentView *iface, IOleInPlaceSite *pIPSiteNew,
360 IOleDocumentView **ppViewNew)
362 HTMLDocument *This = DOCVIEW_THIS(iface);
363 FIXME("(%p)->(%p %p)\n", This, pIPSiteNew, ppViewNew);
369 static const IOleDocumentViewVtbl OleDocumentViewVtbl = {
370 OleDocumentView_QueryInterface,
371 OleDocumentView_AddRef,
372 OleDocumentView_Release,
373 OleDocumentView_SetInPlaceSite,
374 OleDocumentView_GetInPlaceSite,
375 OleDocumentView_GetDocument,
376 OleDocumentView_SetRect,
377 OleDocumentView_GetRect,
378 OleDocumentView_SetRectComplex,
379 OleDocumentView_Show,
380 OleDocumentView_UIActivate,
381 OleDocumentView_Open,
382 OleDocumentView_CloseView,
383 OleDocumentView_SaveViewState,
384 OleDocumentView_ApplyViewState,
385 OleDocumentView_Clone
388 /**********************************************************
389 * IViewObject implementation
392 #define VIEWOBJ_THIS(iface) DEFINE_THIS(HTMLDocument, ViewObject2, iface)
394 static HRESULT WINAPI ViewObject_QueryInterface(IViewObject2 *iface, REFIID riid, void **ppvObject)
396 HTMLDocument *This = VIEWOBJ_THIS(iface);
397 return IHTMLDocument2_QueryInterface(HTMLDOC(This), riid, ppvObject);
400 static ULONG WINAPI ViewObject_AddRef(IViewObject2 *iface)
402 HTMLDocument *This = VIEWOBJ_THIS(iface);
403 return IHTMLDocument2_AddRef(HTMLDOC(This));
406 static ULONG WINAPI ViewObject_Release(IViewObject2 *iface)
408 HTMLDocument *This = VIEWOBJ_THIS(iface);
409 return IHTMLDocument2_Release(HTMLDOC(This));
412 static HRESULT WINAPI ViewObject_Draw(IViewObject2 *iface, DWORD dwDrawAspect, LONG lindex, void *pvAspect,
413 DVTARGETDEVICE *ptd, HDC hdcTargetDev, HDC hdcDraw, LPCRECTL lprcBounds,
414 LPCRECTL lprcWBounds, BOOL (CALLBACK *pfnContinue)(ULONG_PTR dwContinue), ULONG_PTR dwContinue)
416 HTMLDocument *This = VIEWOBJ_THIS(iface);
417 FIXME("(%p)->(%ld %ld %p %p %p %p %p %p %p %ld)\n", This, dwDrawAspect, lindex, pvAspect,
418 ptd, hdcTargetDev, hdcDraw, lprcBounds, lprcWBounds, pfnContinue, dwContinue);
422 static HRESULT WINAPI ViewObject_GetColorSet(IViewObject2 *iface, DWORD dwDrawAspect, LONG lindex, void *pvAspect,
423 DVTARGETDEVICE *ptd, HDC hicTargetDev, LOGPALETTE **ppColorSet)
425 HTMLDocument *This = VIEWOBJ_THIS(iface);
426 FIXME("(%p)->(%ld %ld %p %p %p %p)\n", This, dwDrawAspect, lindex, pvAspect, ptd, hicTargetDev, ppColorSet);
430 static HRESULT WINAPI ViewObject_Freeze(IViewObject2 *iface, DWORD dwDrawAspect, LONG lindex,
431 void *pvAspect, DWORD *pdwFreeze)
433 HTMLDocument *This = VIEWOBJ_THIS(iface);
434 FIXME("(%p)->(%ld %ld %p %p)\n", This, dwDrawAspect, lindex, pvAspect, pdwFreeze);
438 static HRESULT WINAPI ViewObject_Unfreeze(IViewObject2 *iface, DWORD dwFreeze)
440 HTMLDocument *This = VIEWOBJ_THIS(iface);
441 FIXME("(%p)->(%ld)\n", This, dwFreeze);
445 static HRESULT WINAPI ViewObject_SetAdvise(IViewObject2 *iface, DWORD aspects, DWORD advf, IAdviseSink *pAdvSink)
447 HTMLDocument *This = VIEWOBJ_THIS(iface);
448 FIXME("(%p)->(%ld %ld %p)\n", This, aspects, advf, pAdvSink);
452 static HRESULT WINAPI ViewObject_GetAdvise(IViewObject2 *iface, DWORD *pAspects, DWORD *pAdvf, IAdviseSink **ppAdvSink)
454 HTMLDocument *This = VIEWOBJ_THIS(iface);
455 FIXME("(%p)->(%p %p %p)\n", This, pAspects, pAdvf, ppAdvSink);
459 static HRESULT WINAPI ViewObject_GetExtent(IViewObject2 *iface, DWORD dwDrawAspect, LONG lindex,
460 DVTARGETDEVICE* ptd, LPSIZEL lpsizel)
462 HTMLDocument *This = VIEWOBJ_THIS(iface);
463 FIXME("(%p)->(%ld %ld %p %p)\n", This, dwDrawAspect, lindex, ptd, lpsizel);
469 static const IViewObject2Vtbl ViewObjectVtbl = {
470 ViewObject_QueryInterface,
474 ViewObject_GetColorSet,
477 ViewObject_SetAdvise,
478 ViewObject_GetAdvise,
482 void HTMLDocument_View_Init(HTMLDocument *This)
484 This->lpOleDocumentViewVtbl = &OleDocumentViewVtbl;
485 This->lpViewObject2Vtbl = &ViewObjectVtbl;
491 This->in_place_active = FALSE;
492 This->ui_active = FALSE;