Jacek Caban | da56a9c | 2005-04-13 14:41:19 +0000 | [diff] [blame] | 1 | /* |
| 2 | * Copyright 2005 Jacek Caban |
| 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 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" |
Jacek Caban | 44d2da9 | 2005-04-14 11:30:50 +0000 | [diff] [blame] | 29 | #include "wingdi.h" |
Jacek Caban | da56a9c | 2005-04-13 14:41:19 +0000 | [diff] [blame] | 30 | #include "ole2.h" |
Jacek Caban | b5ec066 | 2005-08-29 10:15:17 +0000 | [diff] [blame^] | 31 | #include "resource.h" |
Jacek Caban | da56a9c | 2005-04-13 14:41:19 +0000 | [diff] [blame] | 32 | |
| 33 | #include "wine/debug.h" |
| 34 | |
| 35 | #include "mshtml_private.h" |
| 36 | |
| 37 | WINE_DEFAULT_DEBUG_CHANNEL(mshtml); |
| 38 | |
Jacek Caban | 44d2da9 | 2005-04-14 11:30:50 +0000 | [diff] [blame] | 39 | static const WCHAR wszInternetExplorer_Server[] = |
| 40 | {'I','n','t','e','r','n','e','t',' ','E','x','p','l','o','r','e','r','_','S','e','r','v','e','r',0}; |
| 41 | |
| 42 | static ATOM serverwnd_class = 0; |
| 43 | |
| 44 | static void paint_disabled(HWND hwnd) { |
| 45 | HDC hdc; |
| 46 | PAINTSTRUCT ps; |
| 47 | HBRUSH brush; |
| 48 | RECT rect; |
| 49 | HFONT font; |
Jacek Caban | b5ec066 | 2005-08-29 10:15:17 +0000 | [diff] [blame^] | 50 | WCHAR wszHTMLDisabled[100]; |
| 51 | |
| 52 | LoadStringW(hInst, IDS_HTMLDISABLED, wszHTMLDisabled, sizeof(wszHTMLDisabled)/sizeof(WCHAR)); |
Jacek Caban | 44d2da9 | 2005-04-14 11:30:50 +0000 | [diff] [blame] | 53 | |
| 54 | font = CreateFontA(25,0,0,0,400,0,0,0,ANSI_CHARSET,0,0,DEFAULT_QUALITY,DEFAULT_PITCH,NULL); |
| 55 | brush = CreateSolidBrush(RGB(255,255,255)); |
| 56 | GetClientRect(hwnd, &rect); |
| 57 | |
| 58 | hdc = BeginPaint(hwnd, &ps); |
| 59 | SelectObject(hdc, font); |
| 60 | SelectObject(hdc, brush); |
| 61 | Rectangle(hdc, rect.left, rect.top, rect.right, rect.bottom); |
Jacek Caban | b5ec066 | 2005-08-29 10:15:17 +0000 | [diff] [blame^] | 62 | DrawTextW(hdc, wszHTMLDisabled,-1, &rect, DT_CENTER | DT_SINGLELINE | DT_VCENTER); |
Jacek Caban | 44d2da9 | 2005-04-14 11:30:50 +0000 | [diff] [blame] | 63 | EndPaint(hwnd, &ps); |
| 64 | |
| 65 | DeleteObject(font); |
| 66 | DeleteObject(brush); |
| 67 | } |
| 68 | |
Jacek Caban | 068fa0a | 2005-08-01 10:59:45 +0000 | [diff] [blame] | 69 | static void activate_gecko(HTMLDocument *This) |
| 70 | { |
Jacek Caban | 068fa0a | 2005-08-01 10:59:45 +0000 | [diff] [blame] | 71 | TRACE("(%p) %p\n", This, This->nscontainer->window); |
| 72 | |
Jacek Caban | 2255e6f | 2005-08-10 09:54:02 +0000 | [diff] [blame] | 73 | SetParent(This->nscontainer->hwnd, This->hwnd); |
| 74 | ShowWindow(This->nscontainer->hwnd, SW_SHOW); |
Jacek Caban | 068fa0a | 2005-08-01 10:59:45 +0000 | [diff] [blame] | 75 | |
Jacek Caban | 2255e6f | 2005-08-10 09:54:02 +0000 | [diff] [blame] | 76 | nsIBaseWindow_SetVisibility(This->nscontainer->window, TRUE); |
| 77 | nsIBaseWindow_SetEnabled(This->nscontainer->window, TRUE); |
Jacek Caban | eb52044 | 2005-08-26 10:05:52 +0000 | [diff] [blame] | 78 | nsIWebBrowserFocus_Activate(This->nscontainer->focus); |
Jacek Caban | 068fa0a | 2005-08-01 10:59:45 +0000 | [diff] [blame] | 79 | } |
| 80 | |
Jacek Caban | 44d2da9 | 2005-04-14 11:30:50 +0000 | [diff] [blame] | 81 | static LRESULT WINAPI serverwnd_proc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam) |
| 82 | { |
Jacek Caban | 068fa0a | 2005-08-01 10:59:45 +0000 | [diff] [blame] | 83 | HTMLDocument *This; |
| 84 | |
| 85 | static const WCHAR wszTHIS[] = {'T','H','I','S',0}; |
| 86 | |
| 87 | if(msg == WM_CREATE) { |
| 88 | This = *(HTMLDocument**)lParam; |
| 89 | SetPropW(hwnd, wszTHIS, This); |
| 90 | }else { |
| 91 | This = (HTMLDocument*)GetPropW(hwnd, wszTHIS); |
| 92 | } |
| 93 | |
| 94 | switch(msg) { |
| 95 | case WM_CREATE: |
| 96 | This->hwnd = hwnd; |
| 97 | if(This->nscontainer) |
| 98 | activate_gecko(This); |
| 99 | break; |
| 100 | case WM_PAINT: |
| 101 | if(!This->nscontainer) |
| 102 | paint_disabled(hwnd); |
| 103 | break; |
| 104 | case WM_SIZE: |
| 105 | TRACE("(%p)->(WM_SIZE)\n", This); |
Jacek Caban | 2255e6f | 2005-08-10 09:54:02 +0000 | [diff] [blame] | 106 | if(This->nscontainer) |
| 107 | SetWindowPos(This->nscontainer->hwnd, NULL, 0, 0, LOWORD(lParam), HIWORD(lParam), |
| 108 | SWP_NOZORDER | SWP_NOACTIVATE); |
Jacek Caban | 068fa0a | 2005-08-01 10:59:45 +0000 | [diff] [blame] | 109 | } |
Jacek Caban | 44d2da9 | 2005-04-14 11:30:50 +0000 | [diff] [blame] | 110 | |
| 111 | return DefWindowProcW(hwnd, msg, wParam, lParam); |
| 112 | } |
| 113 | |
Stefan Huehner | 7120877 | 2005-06-16 15:52:44 +0000 | [diff] [blame] | 114 | static void register_serverwnd_class(void) |
Jacek Caban | 44d2da9 | 2005-04-14 11:30:50 +0000 | [diff] [blame] | 115 | { |
| 116 | static WNDCLASSEXW wndclass = { |
| 117 | sizeof(WNDCLASSEXW), |
| 118 | CS_DBLCLKS, |
| 119 | serverwnd_proc, |
| 120 | 0, 0, NULL, NULL, NULL, NULL, NULL, |
| 121 | wszInternetExplorer_Server, |
| 122 | NULL, |
| 123 | }; |
| 124 | wndclass.hInstance = hInst; |
| 125 | serverwnd_class = RegisterClassExW(&wndclass); |
| 126 | } |
| 127 | |
Jacek Caban | 76cc9f2 | 2005-08-15 09:41:30 +0000 | [diff] [blame] | 128 | static HRESULT activate_window(HTMLDocument *This) |
| 129 | { |
| 130 | IOleInPlaceUIWindow *pIPWnd; |
| 131 | IOleInPlaceFrame *pIPFrame; |
Jacek Caban | 944ff51 | 2005-08-18 10:50:05 +0000 | [diff] [blame] | 132 | IOleCommandTarget *cmdtrg; |
Jacek Caban | 76cc9f2 | 2005-08-15 09:41:30 +0000 | [diff] [blame] | 133 | RECT posrect, cliprect; |
| 134 | OLEINPLACEFRAMEINFO frameinfo; |
| 135 | HWND parent_hwnd; |
| 136 | HRESULT hres; |
| 137 | |
| 138 | if(!serverwnd_class) |
| 139 | register_serverwnd_class(); |
| 140 | |
| 141 | hres = IOleInPlaceSite_CanInPlaceActivate(This->ipsite); |
| 142 | if(hres != S_OK) { |
| 143 | WARN("CanInPlaceActivate returned: %08lx\n", hres); |
| 144 | return FAILED(hres) ? hres : E_FAIL; |
| 145 | } |
| 146 | |
| 147 | hres = IOleInPlaceSite_GetWindowContext(This->ipsite, &pIPFrame, &pIPWnd, &posrect, &cliprect, &frameinfo); |
| 148 | if(FAILED(hres)) { |
| 149 | WARN("GetWindowContext failed: %08lx\n", hres); |
| 150 | return hres; |
| 151 | } |
| 152 | if(pIPWnd) |
| 153 | IOleInPlaceUIWindow_Release(pIPWnd); |
| 154 | TRACE("got window context: %p %p {%ld %ld %ld %ld} {%ld %ld %ld %ld} {%d %x %p %p %d}\n", |
| 155 | pIPFrame, pIPWnd, posrect.left, posrect.top, posrect.right, posrect.bottom, |
| 156 | cliprect.left, cliprect.top, cliprect.right, cliprect.bottom, |
| 157 | frameinfo.cb, frameinfo.fMDIApp, frameinfo.hwndFrame, frameinfo.haccel, frameinfo.cAccelEntries); |
| 158 | |
| 159 | hres = IOleInPlaceSite_GetWindow(This->ipsite, &parent_hwnd); |
| 160 | if(FAILED(hres)) { |
| 161 | WARN("GetWindow failed: %08lx\n", hres); |
| 162 | return hres; |
| 163 | } |
| 164 | |
| 165 | TRACE("got parent window %p\n", parent_hwnd); |
| 166 | |
| 167 | if(This->hwnd) { |
| 168 | if(GetParent(This->hwnd) != parent_hwnd) |
| 169 | SetParent(This->hwnd, parent_hwnd); |
| 170 | SetWindowPos(This->hwnd, HWND_TOP, |
| 171 | posrect.left, posrect.top, posrect.right-posrect.left, posrect.bottom-posrect.top, |
| 172 | SWP_NOACTIVATE | SWP_SHOWWINDOW); |
| 173 | }else { |
| 174 | CreateWindowExW(0, wszInternetExplorer_Server, NULL, |
| 175 | WS_CHILD | WS_CLIPSIBLINGS | WS_CLIPCHILDREN, |
| 176 | posrect.left, posrect.top, posrect.right-posrect.left, posrect.bottom-posrect.top, |
| 177 | parent_hwnd, NULL, hInst, This); |
| 178 | |
| 179 | TRACE("Created window %p\n", This->hwnd); |
| 180 | |
| 181 | SetWindowPos(This->hwnd, NULL, 0, 0, 0, 0, |
| 182 | SWP_NOSIZE | SWP_NOMOVE | SWP_NOZORDER | SWP_NOREDRAW | SWP_NOACTIVATE | SWP_SHOWWINDOW); |
| 183 | RedrawWindow(This->hwnd, NULL, NULL, RDW_INVALIDATE | RDW_NOERASE | RDW_ALLCHILDREN); |
| 184 | SetFocus(This->hwnd); |
| 185 | |
| 186 | /* NOTE: |
| 187 | * Windows implementation calls: |
| 188 | * RegisterWindowMessage("MSWHEEL_ROLLMSG"); |
| 189 | * SetTimer(This->hwnd, TIMER_ID, 100, NULL); |
| 190 | */ |
| 191 | } |
| 192 | |
| 193 | This->in_place_active = TRUE; |
| 194 | hres = IOleInPlaceSite_OnInPlaceActivate(This->ipsite); |
| 195 | if(FAILED(hres)) { |
| 196 | WARN("OnInPlaceActivate failed: %08lx\n", hres); |
| 197 | This->in_place_active = FALSE; |
| 198 | return hres; |
| 199 | } |
| 200 | |
Jacek Caban | 944ff51 | 2005-08-18 10:50:05 +0000 | [diff] [blame] | 201 | hres = IOleClientSite_QueryInterface(This->client, &IID_IOleCommandTarget, (void**)&cmdtrg); |
| 202 | if(SUCCEEDED(hres)) { |
| 203 | VARIANT var; |
| 204 | |
| 205 | IOleInPlaceFrame_SetStatusText(pIPFrame, NULL); |
| 206 | |
| 207 | V_VT(&var) = VT_I4; |
| 208 | V_I4(&var) = 0; |
| 209 | IOleCommandTarget_Exec(cmdtrg, NULL, OLECMDID_SETPROGRESSMAX, 0, &var, NULL); |
| 210 | IOleCommandTarget_Exec(cmdtrg, NULL, OLECMDID_SETPROGRESSPOS, 0, &var, NULL); |
| 211 | |
| 212 | IOleCommandTarget_Release(cmdtrg); |
| 213 | } |
| 214 | |
Jacek Caban | 76cc9f2 | 2005-08-15 09:41:30 +0000 | [diff] [blame] | 215 | if(This->frame) |
| 216 | IOleInPlaceFrame_Release(This->frame); |
| 217 | This->frame = pIPFrame; |
| 218 | |
| 219 | This->window_active = TRUE; |
| 220 | |
| 221 | return S_OK; |
| 222 | } |
| 223 | |
Jacek Caban | da56a9c | 2005-04-13 14:41:19 +0000 | [diff] [blame] | 224 | /********************************************************** |
| 225 | * IOleDocumentView implementation |
| 226 | */ |
| 227 | |
Jacek Caban | 04a8cff | 2005-07-14 10:14:33 +0000 | [diff] [blame] | 228 | #define DOCVIEW_THIS(iface) DEFINE_THIS(HTMLDocument, OleDocumentView, iface) |
Jacek Caban | da56a9c | 2005-04-13 14:41:19 +0000 | [diff] [blame] | 229 | |
| 230 | static HRESULT WINAPI OleDocumentView_QueryInterface(IOleDocumentView *iface, REFIID riid, void **ppvObject) |
| 231 | { |
Jacek Caban | 04a8cff | 2005-07-14 10:14:33 +0000 | [diff] [blame] | 232 | HTMLDocument *This = DOCVIEW_THIS(iface); |
Jacek Caban | da56a9c | 2005-04-13 14:41:19 +0000 | [diff] [blame] | 233 | return IHTMLDocument2_QueryInterface(HTMLDOC(This), riid, ppvObject); |
| 234 | } |
| 235 | |
| 236 | static ULONG WINAPI OleDocumentView_AddRef(IOleDocumentView *iface) |
| 237 | { |
Jacek Caban | 04a8cff | 2005-07-14 10:14:33 +0000 | [diff] [blame] | 238 | HTMLDocument *This = DOCVIEW_THIS(iface); |
Jacek Caban | da56a9c | 2005-04-13 14:41:19 +0000 | [diff] [blame] | 239 | return IHTMLDocument2_AddRef(HTMLDOC(This)); |
| 240 | } |
| 241 | |
| 242 | static ULONG WINAPI OleDocumentView_Release(IOleDocumentView *iface) |
| 243 | { |
Jacek Caban | 04a8cff | 2005-07-14 10:14:33 +0000 | [diff] [blame] | 244 | HTMLDocument *This = DOCVIEW_THIS(iface); |
Jacek Caban | da56a9c | 2005-04-13 14:41:19 +0000 | [diff] [blame] | 245 | return IHTMLDocument2_Release(HTMLDOC(This)); |
| 246 | } |
| 247 | |
| 248 | static HRESULT WINAPI OleDocumentView_SetInPlaceSite(IOleDocumentView *iface, IOleInPlaceSite *pIPSite) |
| 249 | { |
Jacek Caban | 04a8cff | 2005-07-14 10:14:33 +0000 | [diff] [blame] | 250 | HTMLDocument *This = DOCVIEW_THIS(iface); |
Jacek Caban | da56a9c | 2005-04-13 14:41:19 +0000 | [diff] [blame] | 251 | TRACE("(%p)->(%p)\n", This, pIPSite); |
| 252 | |
Jacek Caban | da56a9c | 2005-04-13 14:41:19 +0000 | [diff] [blame] | 253 | if(pIPSite) |
| 254 | IOleInPlaceSite_AddRef(pIPSite); |
| 255 | |
| 256 | if(This->ipsite) |
| 257 | IOleInPlaceSite_Release(This->ipsite); |
| 258 | |
| 259 | This->ipsite = pIPSite; |
| 260 | return S_OK; |
| 261 | } |
| 262 | |
| 263 | static HRESULT WINAPI OleDocumentView_GetInPlaceSite(IOleDocumentView *iface, IOleInPlaceSite **ppIPSite) |
| 264 | { |
Jacek Caban | 04a8cff | 2005-07-14 10:14:33 +0000 | [diff] [blame] | 265 | HTMLDocument *This = DOCVIEW_THIS(iface); |
Jacek Caban | da56a9c | 2005-04-13 14:41:19 +0000 | [diff] [blame] | 266 | TRACE("(%p)->(%p)\n", This, ppIPSite); |
| 267 | |
| 268 | if(!ppIPSite) |
| 269 | return E_INVALIDARG; |
| 270 | |
| 271 | if(This->ipsite) |
| 272 | IOleInPlaceSite_AddRef(This->ipsite); |
| 273 | |
| 274 | *ppIPSite = This->ipsite; |
| 275 | return S_OK; |
| 276 | } |
| 277 | |
| 278 | static HRESULT WINAPI OleDocumentView_GetDocument(IOleDocumentView *iface, IUnknown **ppunk) |
| 279 | { |
Jacek Caban | 04a8cff | 2005-07-14 10:14:33 +0000 | [diff] [blame] | 280 | HTMLDocument *This = DOCVIEW_THIS(iface); |
Jacek Caban | da56a9c | 2005-04-13 14:41:19 +0000 | [diff] [blame] | 281 | TRACE("(%p)->(%p)\n", This, ppunk); |
| 282 | |
| 283 | if(!ppunk) |
| 284 | return E_INVALIDARG; |
| 285 | |
| 286 | IHTMLDocument2_AddRef(HTMLDOC(This)); |
| 287 | *ppunk = (IUnknown*)HTMLDOC(This); |
| 288 | return S_OK; |
| 289 | } |
| 290 | |
| 291 | static HRESULT WINAPI OleDocumentView_SetRect(IOleDocumentView *iface, LPRECT prcView) |
| 292 | { |
Jacek Caban | 04a8cff | 2005-07-14 10:14:33 +0000 | [diff] [blame] | 293 | HTMLDocument *This = DOCVIEW_THIS(iface); |
Jacek Caban | 44d2da9 | 2005-04-14 11:30:50 +0000 | [diff] [blame] | 294 | RECT rect; |
| 295 | |
| 296 | TRACE("(%p)->(%p)\n", This, prcView); |
| 297 | |
| 298 | if(!prcView) |
| 299 | return E_INVALIDARG; |
| 300 | |
| 301 | if(This->hwnd) { |
| 302 | GetClientRect(This->hwnd, &rect); |
| 303 | if(memcmp(prcView, &rect, sizeof(RECT))) { |
| 304 | InvalidateRect(This->hwnd,NULL,TRUE); |
| 305 | SetWindowPos(This->hwnd, NULL, prcView->left, prcView->top, prcView->right, |
| 306 | prcView->bottom, SWP_NOZORDER | SWP_NOACTIVATE); |
| 307 | } |
| 308 | } |
| 309 | |
| 310 | return S_OK; |
Jacek Caban | da56a9c | 2005-04-13 14:41:19 +0000 | [diff] [blame] | 311 | } |
| 312 | |
| 313 | static HRESULT WINAPI OleDocumentView_GetRect(IOleDocumentView *iface, LPRECT prcView) |
| 314 | { |
Jacek Caban | 04a8cff | 2005-07-14 10:14:33 +0000 | [diff] [blame] | 315 | HTMLDocument *This = DOCVIEW_THIS(iface); |
Jacek Caban | 44d2da9 | 2005-04-14 11:30:50 +0000 | [diff] [blame] | 316 | |
| 317 | TRACE("(%p)->(%p)\n", This, prcView); |
| 318 | |
| 319 | if(!prcView) |
| 320 | return E_INVALIDARG; |
| 321 | |
| 322 | GetClientRect(This->hwnd, prcView); |
| 323 | return S_OK; |
Jacek Caban | da56a9c | 2005-04-13 14:41:19 +0000 | [diff] [blame] | 324 | } |
| 325 | |
| 326 | static HRESULT WINAPI OleDocumentView_SetRectComplex(IOleDocumentView *iface, LPRECT prcView, |
| 327 | LPRECT prcHScroll, LPRECT prcVScroll, LPRECT prcSizeBox) |
| 328 | { |
Jacek Caban | 04a8cff | 2005-07-14 10:14:33 +0000 | [diff] [blame] | 329 | HTMLDocument *This = DOCVIEW_THIS(iface); |
Jacek Caban | da56a9c | 2005-04-13 14:41:19 +0000 | [diff] [blame] | 330 | FIXME("(%p)->(%p %p %p %p)\n", This, prcView, prcHScroll, prcVScroll, prcSizeBox); |
| 331 | return E_NOTIMPL; |
| 332 | } |
| 333 | |
| 334 | static HRESULT WINAPI OleDocumentView_Show(IOleDocumentView *iface, BOOL fShow) |
| 335 | { |
Jacek Caban | 04a8cff | 2005-07-14 10:14:33 +0000 | [diff] [blame] | 336 | HTMLDocument *This = DOCVIEW_THIS(iface); |
Jacek Caban | 76cc9f2 | 2005-08-15 09:41:30 +0000 | [diff] [blame] | 337 | HRESULT hres; |
| 338 | |
Jacek Caban | 6d54716 | 2005-04-15 16:12:45 +0000 | [diff] [blame] | 339 | TRACE("(%p)->(%x)\n", This, fShow); |
| 340 | |
Jacek Caban | 76cc9f2 | 2005-08-15 09:41:30 +0000 | [diff] [blame] | 341 | if(fShow) { |
| 342 | if(!This->ui_active) { |
| 343 | hres = activate_window(This); |
| 344 | if(FAILED(hres)) |
| 345 | return hres; |
| 346 | } |
| 347 | ShowWindow(This->hwnd, SW_SHOW); |
| 348 | }else { |
| 349 | ShowWindow(This->hwnd, SW_HIDE); |
| 350 | } |
Jacek Caban | 6d54716 | 2005-04-15 16:12:45 +0000 | [diff] [blame] | 351 | |
| 352 | return S_OK; |
Jacek Caban | da56a9c | 2005-04-13 14:41:19 +0000 | [diff] [blame] | 353 | } |
| 354 | |
| 355 | static HRESULT WINAPI OleDocumentView_UIActivate(IOleDocumentView *iface, BOOL fUIActivate) |
| 356 | { |
Jacek Caban | 04a8cff | 2005-07-14 10:14:33 +0000 | [diff] [blame] | 357 | HTMLDocument *This = DOCVIEW_THIS(iface); |
Jacek Caban | 44d2da9 | 2005-04-14 11:30:50 +0000 | [diff] [blame] | 358 | HRESULT hres; |
Jacek Caban | 44d2da9 | 2005-04-14 11:30:50 +0000 | [diff] [blame] | 359 | |
| 360 | TRACE("(%p)->(%x)\n", This, fUIActivate); |
| 361 | |
| 362 | if(!This->ipsite) { |
| 363 | FIXME("This->ipsite = NULL\n"); |
| 364 | return E_FAIL; |
| 365 | } |
| 366 | |
| 367 | if(fUIActivate) { |
Jacek Caban | 04a8cff | 2005-07-14 10:14:33 +0000 | [diff] [blame] | 368 | if(This->ui_active) |
Jacek Caban | 44d2da9 | 2005-04-14 11:30:50 +0000 | [diff] [blame] | 369 | return S_OK; |
Jacek Caban | 44d2da9 | 2005-04-14 11:30:50 +0000 | [diff] [blame] | 370 | |
Jacek Caban | 76cc9f2 | 2005-08-15 09:41:30 +0000 | [diff] [blame] | 371 | if(!This->window_active) { |
| 372 | hres = activate_window(This); |
| 373 | if(FAILED(hres)) |
| 374 | return hres; |
Jacek Caban | 44d2da9 | 2005-04-14 11:30:50 +0000 | [diff] [blame] | 375 | } |
| 376 | |
Jacek Caban | 44d2da9 | 2005-04-14 11:30:50 +0000 | [diff] [blame] | 377 | hres = IOleInPlaceSite_OnUIActivate(This->ipsite); |
| 378 | if(SUCCEEDED(hres)) { |
Jacek Caban | b5ec066 | 2005-08-29 10:15:17 +0000 | [diff] [blame^] | 379 | OLECHAR wszHTMLDocument[30]; |
| 380 | LoadStringW(hInst, IDS_HTMLDOCUMENT, wszHTMLDocument, |
| 381 | sizeof(wszHTMLDocument)/sizeof(WCHAR)); |
| 382 | IOleInPlaceFrame_SetActiveObject(This->frame, ACTOBJ(This), wszHTMLDocument); |
Jacek Caban | 44d2da9 | 2005-04-14 11:30:50 +0000 | [diff] [blame] | 383 | }else { |
| 384 | FIXME("OnUIActivate failed: %08lx\n", hres); |
Jacek Caban | 76cc9f2 | 2005-08-15 09:41:30 +0000 | [diff] [blame] | 385 | IOleInPlaceFrame_Release(This->frame); |
| 386 | This->frame = NULL; |
Jacek Caban | 04a8cff | 2005-07-14 10:14:33 +0000 | [diff] [blame] | 387 | This->ui_active = FALSE; |
Jacek Caban | 44d2da9 | 2005-04-14 11:30:50 +0000 | [diff] [blame] | 388 | return hres; |
| 389 | } |
Jacek Caban | 9caed94 | 2005-07-13 11:29:38 +0000 | [diff] [blame] | 390 | |
| 391 | hres = IDocHostUIHandler_ShowUI(This->hostui, 0, ACTOBJ(This), CMDTARGET(This), |
Jacek Caban | 76cc9f2 | 2005-08-15 09:41:30 +0000 | [diff] [blame] | 392 | This->frame, NULL); |
Jacek Caban | 9caed94 | 2005-07-13 11:29:38 +0000 | [diff] [blame] | 393 | if(FAILED(hres)) |
| 394 | IDocHostUIHandler_HideUI(This->hostui); |
Jacek Caban | 76cc9f2 | 2005-08-15 09:41:30 +0000 | [diff] [blame] | 395 | |
| 396 | This->ui_active = TRUE; |
Jacek Caban | 44d2da9 | 2005-04-14 11:30:50 +0000 | [diff] [blame] | 397 | }else { |
Jacek Caban | 76cc9f2 | 2005-08-15 09:41:30 +0000 | [diff] [blame] | 398 | This->window_active = FALSE; |
| 399 | if(This->ui_active) { |
| 400 | This->ui_active = FALSE; |
| 401 | if(This->frame) |
| 402 | IOleInPlaceFrame_SetActiveObject(This->frame, NULL, NULL); |
| 403 | if(This->hostui) |
| 404 | IDocHostUIHandler_HideUI(This->hostui); |
| 405 | if(This->ipsite) |
| 406 | IOleInPlaceSite_OnUIDeactivate(This->ipsite, FALSE); |
| 407 | } |
Jacek Caban | 44d2da9 | 2005-04-14 11:30:50 +0000 | [diff] [blame] | 408 | } |
| 409 | return S_OK; |
Jacek Caban | da56a9c | 2005-04-13 14:41:19 +0000 | [diff] [blame] | 410 | } |
| 411 | |
| 412 | static HRESULT WINAPI OleDocumentView_Open(IOleDocumentView *iface) |
| 413 | { |
Jacek Caban | 04a8cff | 2005-07-14 10:14:33 +0000 | [diff] [blame] | 414 | HTMLDocument *This = DOCVIEW_THIS(iface); |
Jacek Caban | da56a9c | 2005-04-13 14:41:19 +0000 | [diff] [blame] | 415 | FIXME("(%p)\n", This); |
| 416 | return E_NOTIMPL; |
| 417 | } |
| 418 | |
| 419 | static HRESULT WINAPI OleDocumentView_CloseView(IOleDocumentView *iface, DWORD dwReserved) |
| 420 | { |
Jacek Caban | 04a8cff | 2005-07-14 10:14:33 +0000 | [diff] [blame] | 421 | HTMLDocument *This = DOCVIEW_THIS(iface); |
Jacek Caban | 6d54716 | 2005-04-15 16:12:45 +0000 | [diff] [blame] | 422 | TRACE("(%p)->(%lx)\n", This, dwReserved); |
| 423 | |
| 424 | if(dwReserved) |
| 425 | WARN("dwReserved = %ld\n", dwReserved); |
| 426 | |
| 427 | /* NOTE: |
| 428 | * Windows implementation calls QueryInterface(IID_IOleCommandTarget), |
| 429 | * QueryInterface(IID_IOleControlSite) and KillTimer |
| 430 | */ |
| 431 | |
| 432 | IOleDocumentView_Show(iface, FALSE); |
| 433 | |
| 434 | return S_OK; |
Jacek Caban | da56a9c | 2005-04-13 14:41:19 +0000 | [diff] [blame] | 435 | } |
| 436 | |
| 437 | static HRESULT WINAPI OleDocumentView_SaveViewState(IOleDocumentView *iface, LPSTREAM pstm) |
| 438 | { |
Jacek Caban | 04a8cff | 2005-07-14 10:14:33 +0000 | [diff] [blame] | 439 | HTMLDocument *This = DOCVIEW_THIS(iface); |
Jacek Caban | da56a9c | 2005-04-13 14:41:19 +0000 | [diff] [blame] | 440 | FIXME("(%p)->(%p)\n", This, pstm); |
| 441 | return E_NOTIMPL; |
| 442 | } |
| 443 | |
| 444 | static HRESULT WINAPI OleDocumentView_ApplyViewState(IOleDocumentView *iface, LPSTREAM pstm) |
| 445 | { |
Jacek Caban | 04a8cff | 2005-07-14 10:14:33 +0000 | [diff] [blame] | 446 | HTMLDocument *This = DOCVIEW_THIS(iface); |
Jacek Caban | da56a9c | 2005-04-13 14:41:19 +0000 | [diff] [blame] | 447 | FIXME("(%p)->(%p)\n", This, pstm); |
| 448 | return E_NOTIMPL; |
| 449 | } |
| 450 | |
| 451 | static HRESULT WINAPI OleDocumentView_Clone(IOleDocumentView *iface, IOleInPlaceSite *pIPSiteNew, |
| 452 | IOleDocumentView **ppViewNew) |
| 453 | { |
Jacek Caban | 04a8cff | 2005-07-14 10:14:33 +0000 | [diff] [blame] | 454 | HTMLDocument *This = DOCVIEW_THIS(iface); |
Jacek Caban | da56a9c | 2005-04-13 14:41:19 +0000 | [diff] [blame] | 455 | FIXME("(%p)->(%p %p)\n", This, pIPSiteNew, ppViewNew); |
| 456 | return E_NOTIMPL; |
| 457 | } |
| 458 | |
Jacek Caban | 04a8cff | 2005-07-14 10:14:33 +0000 | [diff] [blame] | 459 | #undef DOCVIEW_THIS |
| 460 | |
Dmitry Timoshkov | b67da5b | 2005-06-01 19:57:42 +0000 | [diff] [blame] | 461 | static const IOleDocumentViewVtbl OleDocumentViewVtbl = { |
Jacek Caban | da56a9c | 2005-04-13 14:41:19 +0000 | [diff] [blame] | 462 | OleDocumentView_QueryInterface, |
| 463 | OleDocumentView_AddRef, |
| 464 | OleDocumentView_Release, |
| 465 | OleDocumentView_SetInPlaceSite, |
| 466 | OleDocumentView_GetInPlaceSite, |
| 467 | OleDocumentView_GetDocument, |
| 468 | OleDocumentView_SetRect, |
| 469 | OleDocumentView_GetRect, |
| 470 | OleDocumentView_SetRectComplex, |
| 471 | OleDocumentView_Show, |
| 472 | OleDocumentView_UIActivate, |
| 473 | OleDocumentView_Open, |
| 474 | OleDocumentView_CloseView, |
| 475 | OleDocumentView_SaveViewState, |
| 476 | OleDocumentView_ApplyViewState, |
| 477 | OleDocumentView_Clone |
| 478 | }; |
| 479 | |
Jacek Caban | 34d7124 | 2005-06-23 16:44:43 +0000 | [diff] [blame] | 480 | /********************************************************** |
| 481 | * IViewObject implementation |
| 482 | */ |
| 483 | |
Jacek Caban | 04a8cff | 2005-07-14 10:14:33 +0000 | [diff] [blame] | 484 | #define VIEWOBJ_THIS(iface) DEFINE_THIS(HTMLDocument, ViewObject2, iface) |
Jacek Caban | 34d7124 | 2005-06-23 16:44:43 +0000 | [diff] [blame] | 485 | |
| 486 | static HRESULT WINAPI ViewObject_QueryInterface(IViewObject2 *iface, REFIID riid, void **ppvObject) |
| 487 | { |
Jacek Caban | 04a8cff | 2005-07-14 10:14:33 +0000 | [diff] [blame] | 488 | HTMLDocument *This = VIEWOBJ_THIS(iface); |
Jacek Caban | 34d7124 | 2005-06-23 16:44:43 +0000 | [diff] [blame] | 489 | return IHTMLDocument2_QueryInterface(HTMLDOC(This), riid, ppvObject); |
| 490 | } |
| 491 | |
| 492 | static ULONG WINAPI ViewObject_AddRef(IViewObject2 *iface) |
| 493 | { |
Jacek Caban | 04a8cff | 2005-07-14 10:14:33 +0000 | [diff] [blame] | 494 | HTMLDocument *This = VIEWOBJ_THIS(iface); |
Jacek Caban | 34d7124 | 2005-06-23 16:44:43 +0000 | [diff] [blame] | 495 | return IHTMLDocument2_AddRef(HTMLDOC(This)); |
| 496 | } |
| 497 | |
| 498 | static ULONG WINAPI ViewObject_Release(IViewObject2 *iface) |
| 499 | { |
Jacek Caban | 04a8cff | 2005-07-14 10:14:33 +0000 | [diff] [blame] | 500 | HTMLDocument *This = VIEWOBJ_THIS(iface); |
Jacek Caban | 34d7124 | 2005-06-23 16:44:43 +0000 | [diff] [blame] | 501 | return IHTMLDocument2_Release(HTMLDOC(This)); |
| 502 | } |
| 503 | |
| 504 | static HRESULT WINAPI ViewObject_Draw(IViewObject2 *iface, DWORD dwDrawAspect, LONG lindex, void *pvAspect, |
| 505 | DVTARGETDEVICE *ptd, HDC hdcTargetDev, HDC hdcDraw, LPCRECTL lprcBounds, |
| 506 | LPCRECTL lprcWBounds, BOOL (CALLBACK *pfnContinue)(ULONG_PTR dwContinue), ULONG_PTR dwContinue) |
| 507 | { |
Jacek Caban | 04a8cff | 2005-07-14 10:14:33 +0000 | [diff] [blame] | 508 | HTMLDocument *This = VIEWOBJ_THIS(iface); |
Jacek Caban | 34d7124 | 2005-06-23 16:44:43 +0000 | [diff] [blame] | 509 | FIXME("(%p)->(%ld %ld %p %p %p %p %p %p %p %ld)\n", This, dwDrawAspect, lindex, pvAspect, |
| 510 | ptd, hdcTargetDev, hdcDraw, lprcBounds, lprcWBounds, pfnContinue, dwContinue); |
| 511 | return E_NOTIMPL; |
| 512 | } |
| 513 | |
| 514 | static HRESULT WINAPI ViewObject_GetColorSet(IViewObject2 *iface, DWORD dwDrawAspect, LONG lindex, void *pvAspect, |
| 515 | DVTARGETDEVICE *ptd, HDC hicTargetDev, LOGPALETTE **ppColorSet) |
| 516 | { |
Jacek Caban | 04a8cff | 2005-07-14 10:14:33 +0000 | [diff] [blame] | 517 | HTMLDocument *This = VIEWOBJ_THIS(iface); |
Jacek Caban | 34d7124 | 2005-06-23 16:44:43 +0000 | [diff] [blame] | 518 | FIXME("(%p)->(%ld %ld %p %p %p %p)\n", This, dwDrawAspect, lindex, pvAspect, ptd, hicTargetDev, ppColorSet); |
| 519 | return E_NOTIMPL; |
| 520 | } |
| 521 | |
| 522 | static HRESULT WINAPI ViewObject_Freeze(IViewObject2 *iface, DWORD dwDrawAspect, LONG lindex, |
| 523 | void *pvAspect, DWORD *pdwFreeze) |
| 524 | { |
Jacek Caban | 04a8cff | 2005-07-14 10:14:33 +0000 | [diff] [blame] | 525 | HTMLDocument *This = VIEWOBJ_THIS(iface); |
Jacek Caban | 34d7124 | 2005-06-23 16:44:43 +0000 | [diff] [blame] | 526 | FIXME("(%p)->(%ld %ld %p %p)\n", This, dwDrawAspect, lindex, pvAspect, pdwFreeze); |
| 527 | return E_NOTIMPL; |
| 528 | } |
| 529 | |
| 530 | static HRESULT WINAPI ViewObject_Unfreeze(IViewObject2 *iface, DWORD dwFreeze) |
| 531 | { |
Jacek Caban | 04a8cff | 2005-07-14 10:14:33 +0000 | [diff] [blame] | 532 | HTMLDocument *This = VIEWOBJ_THIS(iface); |
Jacek Caban | 34d7124 | 2005-06-23 16:44:43 +0000 | [diff] [blame] | 533 | FIXME("(%p)->(%ld)\n", This, dwFreeze); |
| 534 | return E_NOTIMPL; |
| 535 | } |
| 536 | |
| 537 | static HRESULT WINAPI ViewObject_SetAdvise(IViewObject2 *iface, DWORD aspects, DWORD advf, IAdviseSink *pAdvSink) |
| 538 | { |
Jacek Caban | 04a8cff | 2005-07-14 10:14:33 +0000 | [diff] [blame] | 539 | HTMLDocument *This = VIEWOBJ_THIS(iface); |
Jacek Caban | 34d7124 | 2005-06-23 16:44:43 +0000 | [diff] [blame] | 540 | FIXME("(%p)->(%ld %ld %p)\n", This, aspects, advf, pAdvSink); |
| 541 | return E_NOTIMPL; |
| 542 | } |
| 543 | |
| 544 | static HRESULT WINAPI ViewObject_GetAdvise(IViewObject2 *iface, DWORD *pAspects, DWORD *pAdvf, IAdviseSink **ppAdvSink) |
| 545 | { |
Jacek Caban | 04a8cff | 2005-07-14 10:14:33 +0000 | [diff] [blame] | 546 | HTMLDocument *This = VIEWOBJ_THIS(iface); |
Jacek Caban | 34d7124 | 2005-06-23 16:44:43 +0000 | [diff] [blame] | 547 | FIXME("(%p)->(%p %p %p)\n", This, pAspects, pAdvf, ppAdvSink); |
| 548 | return E_NOTIMPL; |
| 549 | } |
| 550 | |
| 551 | static HRESULT WINAPI ViewObject_GetExtent(IViewObject2 *iface, DWORD dwDrawAspect, LONG lindex, |
| 552 | DVTARGETDEVICE* ptd, LPSIZEL lpsizel) |
| 553 | { |
Jacek Caban | 04a8cff | 2005-07-14 10:14:33 +0000 | [diff] [blame] | 554 | HTMLDocument *This = VIEWOBJ_THIS(iface); |
Jacek Caban | 34d7124 | 2005-06-23 16:44:43 +0000 | [diff] [blame] | 555 | FIXME("(%p)->(%ld %ld %p %p)\n", This, dwDrawAspect, lindex, ptd, lpsizel); |
| 556 | return E_NOTIMPL; |
| 557 | } |
| 558 | |
Jacek Caban | 04a8cff | 2005-07-14 10:14:33 +0000 | [diff] [blame] | 559 | #undef VIEWOBJ_THIS |
| 560 | |
Jacek Caban | 34d7124 | 2005-06-23 16:44:43 +0000 | [diff] [blame] | 561 | static const IViewObject2Vtbl ViewObjectVtbl = { |
| 562 | ViewObject_QueryInterface, |
| 563 | ViewObject_AddRef, |
| 564 | ViewObject_Release, |
| 565 | ViewObject_Draw, |
| 566 | ViewObject_GetColorSet, |
| 567 | ViewObject_Freeze, |
| 568 | ViewObject_Unfreeze, |
| 569 | ViewObject_SetAdvise, |
| 570 | ViewObject_GetAdvise, |
| 571 | ViewObject_GetExtent |
| 572 | }; |
| 573 | |
Jacek Caban | da56a9c | 2005-04-13 14:41:19 +0000 | [diff] [blame] | 574 | void HTMLDocument_View_Init(HTMLDocument *This) |
| 575 | { |
| 576 | This->lpOleDocumentViewVtbl = &OleDocumentViewVtbl; |
Jacek Caban | 34d7124 | 2005-06-23 16:44:43 +0000 | [diff] [blame] | 577 | This->lpViewObject2Vtbl = &ViewObjectVtbl; |
Jacek Caban | da56a9c | 2005-04-13 14:41:19 +0000 | [diff] [blame] | 578 | |
| 579 | This->ipsite = NULL; |
Jacek Caban | 6d54716 | 2005-04-15 16:12:45 +0000 | [diff] [blame] | 580 | This->frame = NULL; |
Jacek Caban | 44d2da9 | 2005-04-14 11:30:50 +0000 | [diff] [blame] | 581 | This->hwnd = NULL; |
Jacek Caban | 04a8cff | 2005-07-14 10:14:33 +0000 | [diff] [blame] | 582 | |
| 583 | This->in_place_active = FALSE; |
| 584 | This->ui_active = FALSE; |
Jacek Caban | 76cc9f2 | 2005-08-15 09:41:30 +0000 | [diff] [blame] | 585 | This->window_active = FALSE; |
Jacek Caban | da56a9c | 2005-04-13 14:41:19 +0000 | [diff] [blame] | 586 | } |