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
35 #include "wine/debug.h"
37 #include "mshtml_private.h"
39 WINE_DEFAULT_DEBUG_CHANNEL(mshtml);
41 static const WCHAR wszInternetExplorer_Server[] =
42 {'I','n','t','e','r','n','e','t',' ','E','x','p','l','o','r','e','r','_','S','e','r','v','e','r',0};
43 static const WCHAR wszHTML_Document[] =
44 {'H','T','M','L',' ','D','o','c','u','m','e','n','t',0};
46 static ATOM serverwnd_class = 0;
48 static void paint_disabled(HWND hwnd) {
55 font = CreateFontA(25,0,0,0,400,0,0,0,ANSI_CHARSET,0,0,DEFAULT_QUALITY,DEFAULT_PITCH,NULL);
56 brush = CreateSolidBrush(RGB(255,255,255));
57 GetClientRect(hwnd, &rect);
59 hdc = BeginPaint(hwnd, &ps);
60 SelectObject(hdc, font);
61 SelectObject(hdc, brush);
62 Rectangle(hdc, rect.left, rect.top, rect.right, rect.bottom);
63 DrawTextA(hdc, "HTML rendering is currently disabled.",-1, &rect,
64 DT_CENTER | DT_SINGLELINE | DT_VCENTER);
71 static LRESULT WINAPI serverwnd_proc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)
76 return DefWindowProcW(hwnd, msg, wParam, lParam);
79 static void register_serverwnd_class(void)
81 static WNDCLASSEXW wndclass = {
85 0, 0, NULL, NULL, NULL, NULL, NULL,
86 wszInternetExplorer_Server,
89 wndclass.hInstance = hInst;
90 serverwnd_class = RegisterClassExW(&wndclass);
94 /**********************************************************
95 * IOleDocumentView implementation
98 #define DOCVIEW_THIS \
99 HTMLDocument* const This=(HTMLDocument*)((char*)(iface)-offsetof(HTMLDocument,lpOleDocumentViewVtbl));
101 static HRESULT WINAPI OleDocumentView_QueryInterface(IOleDocumentView *iface, REFIID riid, void **ppvObject)
104 return IHTMLDocument2_QueryInterface(HTMLDOC(This), riid, ppvObject);
107 static ULONG WINAPI OleDocumentView_AddRef(IOleDocumentView *iface)
110 return IHTMLDocument2_AddRef(HTMLDOC(This));
113 static ULONG WINAPI OleDocumentView_Release(IOleDocumentView *iface)
116 return IHTMLDocument2_Release(HTMLDOC(This));
119 static HRESULT WINAPI OleDocumentView_SetInPlaceSite(IOleDocumentView *iface, IOleInPlaceSite *pIPSite)
122 TRACE("(%p)->(%p)\n", This, pIPSite);
128 IOleInPlaceSite_AddRef(pIPSite);
131 IOleInPlaceSite_Release(This->ipsite);
133 This->ipsite = pIPSite;
137 static HRESULT WINAPI OleDocumentView_GetInPlaceSite(IOleDocumentView *iface, IOleInPlaceSite **ppIPSite)
140 TRACE("(%p)->(%p)\n", This, ppIPSite);
146 IOleInPlaceSite_AddRef(This->ipsite);
148 *ppIPSite = This->ipsite;
152 static HRESULT WINAPI OleDocumentView_GetDocument(IOleDocumentView *iface, IUnknown **ppunk)
155 TRACE("(%p)->(%p)\n", This, ppunk);
160 IHTMLDocument2_AddRef(HTMLDOC(This));
161 *ppunk = (IUnknown*)HTMLDOC(This);
165 static HRESULT WINAPI OleDocumentView_SetRect(IOleDocumentView *iface, LPRECT prcView)
170 TRACE("(%p)->(%p)\n", This, prcView);
176 GetClientRect(This->hwnd, &rect);
177 if(memcmp(prcView, &rect, sizeof(RECT))) {
178 InvalidateRect(This->hwnd,NULL,TRUE);
179 SetWindowPos(This->hwnd, NULL, prcView->left, prcView->top, prcView->right,
180 prcView->bottom, SWP_NOZORDER | SWP_NOACTIVATE);
187 static HRESULT WINAPI OleDocumentView_GetRect(IOleDocumentView *iface, LPRECT prcView)
191 TRACE("(%p)->(%p)\n", This, prcView);
196 GetClientRect(This->hwnd, prcView);
200 static HRESULT WINAPI OleDocumentView_SetRectComplex(IOleDocumentView *iface, LPRECT prcView,
201 LPRECT prcHScroll, LPRECT prcVScroll, LPRECT prcSizeBox)
204 FIXME("(%p)->(%p %p %p %p)\n", This, prcView, prcHScroll, prcVScroll, prcSizeBox);
208 static HRESULT WINAPI OleDocumentView_Show(IOleDocumentView *iface, BOOL fShow)
211 TRACE("(%p)->(%x)\n", This, fShow);
214 ShowWindow(This->hwnd, fShow);
219 static HRESULT WINAPI OleDocumentView_UIActivate(IOleDocumentView *iface, BOOL fUIActivate)
223 IOleInPlaceUIWindow *pIPWnd;
224 IOleInPlaceFrame *pIPFrame;
225 RECT posrect, cliprect;
226 OLEINPLACEFRAMEINFO frameinfo;
227 HWND parent_hwnd, hwnd;
229 TRACE("(%p)->(%x)\n", This, fUIActivate);
232 FIXME("This->ipsite = NULL\n");
240 register_serverwnd_class();
242 hres = IOleInPlaceSite_CanInPlaceActivate(This->ipsite);
244 WARN("CanInPlaceActivate returned: %08lx\n", hres);
245 return FAILED(hres) ? hres : E_FAIL;
248 hres = IOleInPlaceSite_GetWindowContext(This->ipsite, &pIPFrame, &pIPWnd, &posrect, &cliprect, &frameinfo);
250 WARN("GetWindowContext failed: %08lx\n", hres);
254 IOleInPlaceUIWindow_Release(pIPWnd);
255 TRACE("got window context: %p %p {%ld %ld %ld %ld} {%ld %ld %ld %ld} {%d %x %p %p %d}\n",
256 pIPFrame, pIPWnd, posrect.left, posrect.top, posrect.right, posrect.bottom,
257 cliprect.left, cliprect.top, cliprect.right, cliprect.bottom,
258 frameinfo.cb, frameinfo.fMDIApp, frameinfo.hwndFrame, frameinfo.haccel, frameinfo.cAccelEntries);
260 hres = IOleInPlaceSite_GetWindow(This->ipsite, &parent_hwnd);
262 WARN("GetWindow failed: %08lx\n", hres);
266 hwnd = CreateWindowExW(0, wszInternetExplorer_Server, NULL,
267 WS_CHILD | WS_CLIPSIBLINGS | WS_CLIPCHILDREN,
268 posrect.left, posrect.top, posrect.right-posrect.left, posrect.bottom-posrect.top,
269 parent_hwnd, NULL, hInst, This);
271 hres = IOleInPlaceSite_OnInPlaceActivate(This->ipsite);
273 WARN("OnInPlaceActivate failed: %08lx\n", hres);
277 SetWindowPos(hwnd, NULL, 0, 0, 0, 0,
278 SWP_NOSIZE | SWP_NOMOVE | SWP_NOZORDER | SWP_NOREDRAW | SWP_NOACTIVATE | SWP_SHOWWINDOW);
279 RedrawWindow(hwnd, NULL, NULL, RDW_INVALIDATE | RDW_NOERASE | RDW_ALLCHILDREN);
283 * Windows implementation calls:
284 * RegisterWindowMessage("MSWHEEL_ROLLMSG");
285 * SetTimer(This->hwnd, TIMER_ID, 100, NULL);
288 hres = IOleInPlaceSite_OnUIActivate(This->ipsite);
289 if(SUCCEEDED(hres)) {
290 IOleInPlaceFrame_SetActiveObject(pIPFrame, ACTOBJ(This), wszHTML_Document);
292 FIXME("OnUIActivate failed: %08lx\n", hres);
297 IOleInPlaceFrame_Release(This->frame);
298 This->frame = pIPFrame;
301 static const WCHAR wszEmpty[] = {0};
304 IOleInPlaceFrame_SetActiveObject(This->frame, NULL, wszEmpty);
306 IOleInPlaceSite_OnUIDeactivate(This->ipsite, FALSE);
311 static HRESULT WINAPI OleDocumentView_Open(IOleDocumentView *iface)
314 FIXME("(%p)\n", This);
318 static HRESULT WINAPI OleDocumentView_CloseView(IOleDocumentView *iface, DWORD dwReserved)
321 TRACE("(%p)->(%lx)\n", This, dwReserved);
324 WARN("dwReserved = %ld\n", dwReserved);
327 * Windows implementation calls QueryInterface(IID_IOleCommandTarget),
328 * QueryInterface(IID_IOleControlSite) and KillTimer
331 IOleDocumentView_Show(iface, FALSE);
336 static HRESULT WINAPI OleDocumentView_SaveViewState(IOleDocumentView *iface, LPSTREAM pstm)
339 FIXME("(%p)->(%p)\n", This, pstm);
343 static HRESULT WINAPI OleDocumentView_ApplyViewState(IOleDocumentView *iface, LPSTREAM pstm)
346 FIXME("(%p)->(%p)\n", This, pstm);
350 static HRESULT WINAPI OleDocumentView_Clone(IOleDocumentView *iface, IOleInPlaceSite *pIPSiteNew,
351 IOleDocumentView **ppViewNew)
354 FIXME("(%p)->(%p %p)\n", This, pIPSiteNew, ppViewNew);
358 static const IOleDocumentViewVtbl OleDocumentViewVtbl = {
359 OleDocumentView_QueryInterface,
360 OleDocumentView_AddRef,
361 OleDocumentView_Release,
362 OleDocumentView_SetInPlaceSite,
363 OleDocumentView_GetInPlaceSite,
364 OleDocumentView_GetDocument,
365 OleDocumentView_SetRect,
366 OleDocumentView_GetRect,
367 OleDocumentView_SetRectComplex,
368 OleDocumentView_Show,
369 OleDocumentView_UIActivate,
370 OleDocumentView_Open,
371 OleDocumentView_CloseView,
372 OleDocumentView_SaveViewState,
373 OleDocumentView_ApplyViewState,
374 OleDocumentView_Clone
377 /**********************************************************
378 * IViewObject implementation
381 #define VIEWOBJ_THIS \
382 HTMLDocument* const This=(HTMLDocument*)((char*)(iface)-offsetof(HTMLDocument,lpViewObject2Vtbl));
384 static HRESULT WINAPI ViewObject_QueryInterface(IViewObject2 *iface, REFIID riid, void **ppvObject)
387 return IHTMLDocument2_QueryInterface(HTMLDOC(This), riid, ppvObject);
390 static ULONG WINAPI ViewObject_AddRef(IViewObject2 *iface)
393 return IHTMLDocument2_AddRef(HTMLDOC(This));
396 static ULONG WINAPI ViewObject_Release(IViewObject2 *iface)
399 return IHTMLDocument2_Release(HTMLDOC(This));
402 static HRESULT WINAPI ViewObject_Draw(IViewObject2 *iface, DWORD dwDrawAspect, LONG lindex, void *pvAspect,
403 DVTARGETDEVICE *ptd, HDC hdcTargetDev, HDC hdcDraw, LPCRECTL lprcBounds,
404 LPCRECTL lprcWBounds, BOOL (CALLBACK *pfnContinue)(ULONG_PTR dwContinue), ULONG_PTR dwContinue)
407 FIXME("(%p)->(%ld %ld %p %p %p %p %p %p %p %ld)\n", This, dwDrawAspect, lindex, pvAspect,
408 ptd, hdcTargetDev, hdcDraw, lprcBounds, lprcWBounds, pfnContinue, dwContinue);
412 static HRESULT WINAPI ViewObject_GetColorSet(IViewObject2 *iface, DWORD dwDrawAspect, LONG lindex, void *pvAspect,
413 DVTARGETDEVICE *ptd, HDC hicTargetDev, LOGPALETTE **ppColorSet)
416 FIXME("(%p)->(%ld %ld %p %p %p %p)\n", This, dwDrawAspect, lindex, pvAspect, ptd, hicTargetDev, ppColorSet);
420 static HRESULT WINAPI ViewObject_Freeze(IViewObject2 *iface, DWORD dwDrawAspect, LONG lindex,
421 void *pvAspect, DWORD *pdwFreeze)
424 FIXME("(%p)->(%ld %ld %p %p)\n", This, dwDrawAspect, lindex, pvAspect, pdwFreeze);
428 static HRESULT WINAPI ViewObject_Unfreeze(IViewObject2 *iface, DWORD dwFreeze)
431 FIXME("(%p)->(%ld)\n", This, dwFreeze);
435 static HRESULT WINAPI ViewObject_SetAdvise(IViewObject2 *iface, DWORD aspects, DWORD advf, IAdviseSink *pAdvSink)
438 FIXME("(%p)->(%ld %ld %p)\n", This, aspects, advf, pAdvSink);
442 static HRESULT WINAPI ViewObject_GetAdvise(IViewObject2 *iface, DWORD *pAspects, DWORD *pAdvf, IAdviseSink **ppAdvSink)
445 FIXME("(%p)->(%p %p %p)\n", This, pAspects, pAdvf, ppAdvSink);
449 static HRESULT WINAPI ViewObject_GetExtent(IViewObject2 *iface, DWORD dwDrawAspect, LONG lindex,
450 DVTARGETDEVICE* ptd, LPSIZEL lpsizel)
453 FIXME("(%p)->(%ld %ld %p %p)\n", This, dwDrawAspect, lindex, ptd, lpsizel);
457 static const IViewObject2Vtbl ViewObjectVtbl = {
458 ViewObject_QueryInterface,
462 ViewObject_GetColorSet,
465 ViewObject_SetAdvise,
466 ViewObject_GetAdvise,
470 void HTMLDocument_View_Init(HTMLDocument *This)
472 This->lpOleDocumentViewVtbl = &OleDocumentViewVtbl;
473 This->lpViewObject2Vtbl = &ViewObjectVtbl;