Home | Info | Community | Development | myReactOS | Contact Us
ReactOS Development > Doxygenview.c
Go to the documentation of this file.
00001 /* 00002 * Copyright 2005-2006 Jacek Caban for CodeWeavers 00003 * 00004 * This library is free software; you can redistribute it and/or 00005 * modify it under the terms of the GNU Lesser General Public 00006 * License as published by the Free Software Foundation; either 00007 * version 2.1 of the License, or (at your option) any later version. 00008 * 00009 * This library is distributed in the hope that it will be useful, 00010 * but WITHOUT ANY WARRANTY; without even the implied warranty of 00011 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 00012 * Lesser General Public License for more details. 00013 * 00014 * You should have received a copy of the GNU Lesser General Public 00015 * License along with this library; if not, write to the Free Software 00016 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA 00017 */ 00018 00019 #include "config.h" 00020 00021 #include <stdarg.h> 00022 #include <stdio.h> 00023 00024 #define COBJMACROS 00025 00026 #include "windef.h" 00027 #include "winbase.h" 00028 #include "winuser.h" 00029 #include "commctrl.h" 00030 #include "ole2.h" 00031 #include "resource.h" 00032 00033 #include "wine/debug.h" 00034 00035 #include "mshtml_private.h" 00036 00037 WINE_DEFAULT_DEBUG_CHANNEL(mshtml); 00038 00039 #define TIMER_ID 0x1000 00040 00041 static const WCHAR wszInternetExplorer_Server[] = 00042 {'I','n','t','e','r','n','e','t',' ','E','x','p','l','o','r','e','r','_','S','e','r','v','e','r',0}; 00043 00044 static const WCHAR wszTooltipData[] = {'t','o','o','l','t','i','p','_','d','a','t','a',0}; 00045 00046 static ATOM serverwnd_class = 0; 00047 00048 typedef struct { 00049 HTMLDocumentObj *doc; 00050 WNDPROC proc; 00051 } tooltip_data; 00052 00053 static void paint_document(HTMLDocumentObj *This) 00054 { 00055 PAINTSTRUCT ps; 00056 RECT rect; 00057 HDC hdc; 00058 00059 GetClientRect(This->hwnd, &rect); 00060 00061 hdc = BeginPaint(This->hwnd, &ps); 00062 00063 if(!(This->hostinfo.dwFlags & (DOCHOSTUIFLAG_NO3DOUTERBORDER|DOCHOSTUIFLAG_NO3DBORDER))) 00064 DrawEdge(hdc, &rect, EDGE_SUNKEN, BF_RECT|BF_ADJUST); 00065 00066 if(!This->nscontainer) { 00067 WCHAR wszHTMLDisabled[100]; 00068 HFONT font; 00069 00070 LoadStringW(hInst, IDS_HTMLDISABLED, wszHTMLDisabled, sizeof(wszHTMLDisabled)/sizeof(WCHAR)); 00071 00072 font = CreateFontA(25,0,0,0,400,0,0,0,ANSI_CHARSET,0,0,DEFAULT_QUALITY,DEFAULT_PITCH,NULL); 00073 00074 SelectObject(hdc, font); 00075 SelectObject(hdc, GetSysColorBrush(COLOR_WINDOW)); 00076 00077 Rectangle(hdc, rect.left, rect.top, rect.right, rect.bottom); 00078 DrawTextW(hdc, wszHTMLDisabled,-1, &rect, DT_CENTER | DT_SINGLELINE | DT_VCENTER); 00079 00080 DeleteObject(font); 00081 } 00082 00083 EndPaint(This->hwnd, &ps); 00084 } 00085 00086 static void activate_gecko(NSContainer *This) 00087 { 00088 TRACE("(%p) %p\n", This, This->window); 00089 00090 SetParent(This->hwnd, This->doc->hwnd); 00091 ShowWindow(This->hwnd, SW_SHOW); 00092 00093 nsIBaseWindow_SetVisibility(This->window, TRUE); 00094 nsIBaseWindow_SetEnabled(This->window, TRUE); 00095 } 00096 00097 void update_doc(HTMLDocument *This, DWORD flags) 00098 { 00099 if(!This->doc_obj->update && This->doc_obj->hwnd) 00100 SetTimer(This->doc_obj->hwnd, TIMER_ID, 100, NULL); 00101 00102 This->doc_obj->update |= flags; 00103 } 00104 00105 void update_title(HTMLDocumentObj *This) 00106 { 00107 IOleCommandTarget *olecmd; 00108 HRESULT hres; 00109 00110 if(!(This->update & UPDATE_TITLE)) 00111 return; 00112 00113 This->update &= ~UPDATE_TITLE; 00114 00115 if(!This->client) 00116 return; 00117 00118 hres = IOleClientSite_QueryInterface(This->client, &IID_IOleCommandTarget, (void**)&olecmd); 00119 if(SUCCEEDED(hres)) { 00120 VARIANT title; 00121 WCHAR empty[] = {0}; 00122 00123 V_VT(&title) = VT_BSTR; 00124 V_BSTR(&title) = SysAllocString(empty); 00125 IOleCommandTarget_Exec(olecmd, NULL, OLECMDID_SETTITLE, OLECMDEXECOPT_DONTPROMPTUSER, 00126 &title, NULL); 00127 SysFreeString(V_BSTR(&title)); 00128 00129 IOleCommandTarget_Release(olecmd); 00130 } 00131 } 00132 00133 static LRESULT on_timer(HTMLDocumentObj *This) 00134 { 00135 TRACE("(%p) %x\n", This, This->update); 00136 00137 KillTimer(This->hwnd, TIMER_ID); 00138 00139 if(!This->update) 00140 return 0; 00141 00142 if(This->update & UPDATE_UI) { 00143 if(This->hostui) 00144 IDocHostUIHandler_UpdateUI(This->hostui); 00145 00146 if(This->client) { 00147 IOleCommandTarget *cmdtrg; 00148 HRESULT hres; 00149 00150 hres = IOleClientSite_QueryInterface(This->client, &IID_IOleCommandTarget, 00151 (void**)&cmdtrg); 00152 if(SUCCEEDED(hres)) { 00153 IOleCommandTarget_Exec(cmdtrg, NULL, OLECMDID_UPDATECOMMANDS, 00154 OLECMDEXECOPT_DONTPROMPTUSER, NULL, NULL); 00155 IOleCommandTarget_Release(cmdtrg); 00156 } 00157 } 00158 } 00159 00160 update_title(This); 00161 This->update = 0; 00162 return 0; 00163 } 00164 00165 void notif_focus(HTMLDocumentObj *This) 00166 { 00167 IOleControlSite *site; 00168 HRESULT hres; 00169 00170 if(!This->client) 00171 return; 00172 00173 hres = IOleClientSite_QueryInterface(This->client, &IID_IOleControlSite, (void**)&site); 00174 if(FAILED(hres)) 00175 return; 00176 00177 IOleControlSite_OnFocus(site, This->focus); 00178 IOleControlSite_Release(site); 00179 } 00180 00181 static LRESULT WINAPI serverwnd_proc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam) 00182 { 00183 HTMLDocumentObj *This; 00184 00185 static const WCHAR wszTHIS[] = {'T','H','I','S',0}; 00186 00187 if(msg == WM_CREATE) { 00188 This = *(HTMLDocumentObj**)lParam; 00189 SetPropW(hwnd, wszTHIS, This); 00190 }else { 00191 This = GetPropW(hwnd, wszTHIS); 00192 } 00193 00194 switch(msg) { 00195 case WM_CREATE: 00196 This->hwnd = hwnd; 00197 break; 00198 case WM_PAINT: 00199 paint_document(This); 00200 break; 00201 case WM_SIZE: 00202 TRACE("(%p)->(WM_SIZE)\n", This); 00203 if(This->nscontainer) { 00204 INT ew=0, eh=0; 00205 00206 if(!(This->hostinfo.dwFlags & (DOCHOSTUIFLAG_NO3DOUTERBORDER|DOCHOSTUIFLAG_NO3DBORDER))) { 00207 ew = GetSystemMetrics(SM_CXEDGE); 00208 eh = GetSystemMetrics(SM_CYEDGE); 00209 } 00210 00211 SetWindowPos(This->nscontainer->hwnd, NULL, ew, eh, 00212 LOWORD(lParam) - 2*ew, HIWORD(lParam) - 2*eh, 00213 SWP_NOZORDER | SWP_NOACTIVATE); 00214 } 00215 break; 00216 case WM_TIMER: 00217 return on_timer(This); 00218 case WM_SETFOCUS: 00219 TRACE("(%p) WM_SETFOCUS\n", This); 00220 nsIWebBrowserFocus_Activate(This->nscontainer->focus); 00221 break; 00222 case WM_MOUSEACTIVATE: 00223 return MA_ACTIVATE; 00224 } 00225 00226 return DefWindowProcW(hwnd, msg, wParam, lParam); 00227 } 00228 00229 static void register_serverwnd_class(void) 00230 { 00231 static WNDCLASSEXW wndclass = { 00232 sizeof(WNDCLASSEXW), 00233 CS_DBLCLKS, 00234 serverwnd_proc, 00235 0, 0, NULL, NULL, NULL, NULL, NULL, 00236 wszInternetExplorer_Server, 00237 NULL, 00238 }; 00239 wndclass.hInstance = hInst; 00240 serverwnd_class = RegisterClassExW(&wndclass); 00241 } 00242 00243 static HRESULT activate_window(HTMLDocumentObj *This) 00244 { 00245 IOleInPlaceFrame *pIPFrame; 00246 IOleCommandTarget *cmdtrg; 00247 IOleInPlaceSiteEx *ipsiteex; 00248 RECT posrect, cliprect; 00249 OLEINPLACEFRAMEINFO frameinfo; 00250 HWND parent_hwnd; 00251 HRESULT hres; 00252 00253 if(!serverwnd_class) 00254 register_serverwnd_class(); 00255 00256 hres = IOleInPlaceSite_CanInPlaceActivate(This->ipsite); 00257 if(hres != S_OK) { 00258 WARN("CanInPlaceActivate returned: %08x\n", hres); 00259 return FAILED(hres) ? hres : E_FAIL; 00260 } 00261 00262 frameinfo.cb = sizeof(OLEINPLACEFRAMEINFO); 00263 hres = IOleInPlaceSite_GetWindowContext(This->ipsite, &pIPFrame, &This->ip_window, 00264 &posrect, &cliprect, &frameinfo); 00265 if(FAILED(hres)) { 00266 WARN("GetWindowContext failed: %08x\n", hres); 00267 return hres; 00268 } 00269 00270 TRACE("got window context: %p %p {%d %d %d %d} {%d %d %d %d} {%d %x %p %p %d}\n", 00271 pIPFrame, This->ip_window, posrect.left, posrect.top, posrect.right, posrect.bottom, 00272 cliprect.left, cliprect.top, cliprect.right, cliprect.bottom, 00273 frameinfo.cb, frameinfo.fMDIApp, frameinfo.hwndFrame, frameinfo.haccel, frameinfo.cAccelEntries); 00274 00275 hres = IOleInPlaceSite_GetWindow(This->ipsite, &parent_hwnd); 00276 if(FAILED(hres)) { 00277 WARN("GetWindow failed: %08x\n", hres); 00278 return hres; 00279 } 00280 00281 TRACE("got parent window %p\n", parent_hwnd); 00282 00283 if(This->hwnd) { 00284 if(GetParent(This->hwnd) != parent_hwnd) 00285 SetParent(This->hwnd, parent_hwnd); 00286 SetWindowPos(This->hwnd, HWND_TOP, 00287 posrect.left, posrect.top, posrect.right-posrect.left, posrect.bottom-posrect.top, 00288 SWP_NOACTIVATE | SWP_SHOWWINDOW); 00289 }else { 00290 CreateWindowExW(0, wszInternetExplorer_Server, NULL, 00291 WS_CHILD | WS_CLIPSIBLINGS | WS_CLIPCHILDREN, 00292 posrect.left, posrect.top, posrect.right-posrect.left, posrect.bottom-posrect.top, 00293 parent_hwnd, NULL, hInst, This); 00294 00295 TRACE("Created window %p\n", This->hwnd); 00296 00297 SetWindowPos(This->hwnd, NULL, 0, 0, 0, 0, 00298 SWP_NOSIZE | SWP_NOMOVE | SWP_NOZORDER | SWP_NOREDRAW | SWP_NOACTIVATE | SWP_SHOWWINDOW); 00299 RedrawWindow(This->hwnd, NULL, NULL, RDW_INVALIDATE | RDW_NOERASE | RDW_ALLCHILDREN); 00300 00301 /* NOTE: 00302 * Windows implementation calls: 00303 * RegisterWindowMessage("MSWHEEL_ROLLMSG"); 00304 */ 00305 SetTimer(This->hwnd, TIMER_ID, 100, NULL); 00306 } 00307 00308 if(This->nscontainer) 00309 activate_gecko(This->nscontainer); 00310 00311 This->in_place_active = TRUE; 00312 hres = IOleInPlaceSite_QueryInterface(This->ipsite, &IID_IOleInPlaceSiteEx, (void**)&ipsiteex); 00313 if(SUCCEEDED(hres)) { 00314 BOOL redraw = FALSE; 00315 00316 hres = IOleInPlaceSiteEx_OnInPlaceActivateEx(ipsiteex, &redraw, 0); 00317 IOleInPlaceSiteEx_Release(ipsiteex); 00318 if(redraw) 00319 FIXME("unsupported redraw\n"); 00320 }else{ 00321 hres = IOleInPlaceSite_OnInPlaceActivate(This->ipsite); 00322 } 00323 if(FAILED(hres)) { 00324 WARN("OnInPlaceActivate failed: %08x\n", hres); 00325 This->in_place_active = FALSE; 00326 return hres; 00327 } 00328 00329 hres = IOleClientSite_QueryInterface(This->client, &IID_IOleCommandTarget, (void**)&cmdtrg); 00330 if(SUCCEEDED(hres)) { 00331 VARIANT var; 00332 00333 IOleInPlaceFrame_SetStatusText(pIPFrame, NULL); 00334 00335 V_VT(&var) = VT_I4; 00336 V_I4(&var) = 0; 00337 IOleCommandTarget_Exec(cmdtrg, NULL, OLECMDID_SETPROGRESSMAX, 00338 OLECMDEXECOPT_DONTPROMPTUSER, &var, NULL); 00339 IOleCommandTarget_Exec(cmdtrg, NULL, OLECMDID_SETPROGRESSPOS, 00340 OLECMDEXECOPT_DONTPROMPTUSER, &var, NULL); 00341 00342 IOleCommandTarget_Release(cmdtrg); 00343 } 00344 00345 if(This->frame) 00346 IOleInPlaceFrame_Release(This->frame); 00347 This->frame = pIPFrame; 00348 00349 if(!This->request_uiactivate) { 00350 hres = IOleInPlaceSite_QueryInterface(This->ipsite, &IID_IOleInPlaceSiteEx, (void**)&ipsiteex); 00351 if(SUCCEEDED(hres)) { 00352 IOleInPlaceSiteEx_RequestUIActivate(ipsiteex); 00353 IOleInPlaceSiteEx_Release(ipsiteex); 00354 } 00355 } 00356 00357 This->window_active = TRUE; 00358 00359 return S_OK; 00360 } 00361 00362 static LRESULT WINAPI tooltips_proc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam) 00363 { 00364 tooltip_data *data = GetPropW(hwnd, wszTooltipData); 00365 00366 TRACE("%d %p\n", msg, data); 00367 00368 if(msg == TTM_WINDOWFROMPOINT) { 00369 RECT rect; 00370 POINT *pt = (POINT*)lParam; 00371 00372 TRACE("TTM_WINDOWFROMPOINT (%d,%d)\n", pt->x, pt->y); 00373 00374 GetWindowRect(data->doc->hwnd, &rect); 00375 00376 if(rect.left <= pt->x && pt->x <= rect.right 00377 && rect.top <= pt->y && pt->y <= rect.bottom) 00378 return (LPARAM)data->doc->hwnd; 00379 } 00380 00381 return CallWindowProcW(data->proc, hwnd, msg, wParam, lParam); 00382 } 00383 00384 static void create_tooltips_window(HTMLDocumentObj *This) 00385 { 00386 tooltip_data *data = heap_alloc(sizeof(*data)); 00387 00388 This->tooltips_hwnd = CreateWindowExW(0, TOOLTIPS_CLASSW, NULL, TTS_NOPREFIX | WS_POPUP, 00389 CW_USEDEFAULT, CW_USEDEFAULT, 10, 10, This->hwnd, NULL, hInst, NULL); 00390 00391 data->doc = This; 00392 data->proc = (WNDPROC)GetWindowLongPtrW(This->tooltips_hwnd, GWLP_WNDPROC); 00393 00394 SetPropW(This->tooltips_hwnd, wszTooltipData, data); 00395 00396 SetWindowLongPtrW(This->tooltips_hwnd, GWLP_WNDPROC, (LONG_PTR)tooltips_proc); 00397 00398 SetWindowPos(This->tooltips_hwnd, HWND_TOPMOST,0, 0, 0, 0, 00399 SWP_NOMOVE | SWP_NOSIZE | SWP_NOACTIVATE); 00400 00401 } 00402 00403 void show_tooltip(HTMLDocumentObj *This, DWORD x, DWORD y, LPCWSTR text) 00404 { 00405 TTTOOLINFOW toolinfo = { 00406 sizeof(TTTOOLINFOW), 0, This->hwnd, 0xdeadbeef, 00407 {x>2 ? x-2 : 0, y>0 ? y-2 : 0, x+2, y+2}, /* FIXME */ 00408 NULL, (LPWSTR)text, 0}; 00409 MSG msg = {This->hwnd, WM_MOUSEMOVE, 0, MAKELPARAM(x,y), 0, {x,y}}; 00410 00411 TRACE("(%p)->(%d %d %s)\n", This, x, y, debugstr_w(text)); 00412 00413 if(!This->tooltips_hwnd) 00414 create_tooltips_window(This); 00415 00416 SendMessageW(This->tooltips_hwnd, TTM_ADDTOOLW, 0, (LPARAM)&toolinfo); 00417 SendMessageW(This->tooltips_hwnd, TTM_ACTIVATE, TRUE, 0); 00418 SendMessageW(This->tooltips_hwnd, TTM_RELAYEVENT, 0, (LPARAM)&msg); 00419 } 00420 00421 void hide_tooltip(HTMLDocumentObj *This) 00422 { 00423 TTTOOLINFOW toolinfo = { 00424 sizeof(TTTOOLINFOW), 0, This->hwnd, 0xdeadbeef, 00425 {0,0,0,0}, NULL, NULL, 0}; 00426 00427 TRACE("(%p)\n", This); 00428 00429 SendMessageW(This->tooltips_hwnd, TTM_DELTOOLW, 0, (LPARAM)&toolinfo); 00430 SendMessageW(This->tooltips_hwnd, TTM_ACTIVATE, FALSE, 0); 00431 } 00432 00433 HRESULT call_set_active_object(IOleInPlaceUIWindow *window, IOleInPlaceActiveObject *act_obj) 00434 { 00435 static WCHAR html_documentW[30]; 00436 00437 if(act_obj && !html_documentW[0]) { 00438 LoadStringW(hInst, IDS_HTMLDOCUMENT, html_documentW, 00439 sizeof(html_documentW)/sizeof(WCHAR)); 00440 } 00441 00442 return IOleInPlaceFrame_SetActiveObject(window, act_obj, act_obj ? html_documentW : NULL); 00443 } 00444 00445 /********************************************************** 00446 * IOleDocumentView implementation 00447 */ 00448 00449 #define DOCVIEW_THIS(iface) DEFINE_THIS(HTMLDocument, OleDocumentView, iface) 00450 00451 static HRESULT WINAPI OleDocumentView_QueryInterface(IOleDocumentView *iface, REFIID riid, void **ppvObject) 00452 { 00453 HTMLDocument *This = DOCVIEW_THIS(iface); 00454 return IHTMLDocument2_QueryInterface(HTMLDOC(This), riid, ppvObject); 00455 } 00456 00457 static ULONG WINAPI OleDocumentView_AddRef(IOleDocumentView *iface) 00458 { 00459 HTMLDocument *This = DOCVIEW_THIS(iface); 00460 return IHTMLDocument2_AddRef(HTMLDOC(This)); 00461 } 00462 00463 static ULONG WINAPI OleDocumentView_Release(IOleDocumentView *iface) 00464 { 00465 HTMLDocument *This = DOCVIEW_THIS(iface); 00466 return IHTMLDocument2_Release(HTMLDOC(This)); 00467 } 00468 00469 static HRESULT WINAPI OleDocumentView_SetInPlaceSite(IOleDocumentView *iface, IOleInPlaceSite *pIPSite) 00470 { 00471 HTMLDocument *This = DOCVIEW_THIS(iface); 00472 TRACE("(%p)->(%p)\n", This, pIPSite); 00473 00474 if(pIPSite) 00475 IOleInPlaceSite_AddRef(pIPSite); 00476 00477 if(This->doc_obj->ipsite) 00478 IOleInPlaceSite_Release(This->doc_obj->ipsite); 00479 00480 This->doc_obj->ipsite = pIPSite; 00481 This->doc_obj->request_uiactivate = TRUE; 00482 return S_OK; 00483 } 00484 00485 static HRESULT WINAPI OleDocumentView_GetInPlaceSite(IOleDocumentView *iface, IOleInPlaceSite **ppIPSite) 00486 { 00487 HTMLDocument *This = DOCVIEW_THIS(iface); 00488 TRACE("(%p)->(%p)\n", This, ppIPSite); 00489 00490 if(!ppIPSite) 00491 return E_INVALIDARG; 00492 00493 if(This->doc_obj->ipsite) 00494 IOleInPlaceSite_AddRef(This->doc_obj->ipsite); 00495 00496 *ppIPSite = This->doc_obj->ipsite; 00497 return S_OK; 00498 } 00499 00500 static HRESULT WINAPI OleDocumentView_GetDocument(IOleDocumentView *iface, IUnknown **ppunk) 00501 { 00502 HTMLDocument *This = DOCVIEW_THIS(iface); 00503 TRACE("(%p)->(%p)\n", This, ppunk); 00504 00505 if(!ppunk) 00506 return E_INVALIDARG; 00507 00508 IHTMLDocument2_AddRef(HTMLDOC(This)); 00509 *ppunk = (IUnknown*)HTMLDOC(This); 00510 return S_OK; 00511 } 00512 00513 static HRESULT WINAPI OleDocumentView_SetRect(IOleDocumentView *iface, LPRECT prcView) 00514 { 00515 HTMLDocument *This = DOCVIEW_THIS(iface); 00516 RECT rect; 00517 00518 TRACE("(%p)->(%p)\n", This, prcView); 00519 00520 if(!prcView) 00521 return E_INVALIDARG; 00522 00523 if(This->doc_obj->hwnd) { 00524 GetClientRect(This->doc_obj->hwnd, &rect); 00525 if(memcmp(prcView, &rect, sizeof(RECT))) { 00526 InvalidateRect(This->doc_obj->hwnd, NULL, TRUE); 00527 SetWindowPos(This->doc_obj->hwnd, NULL, prcView->left, prcView->top, prcView->right, 00528 prcView->bottom, SWP_NOZORDER | SWP_NOACTIVATE); 00529 } 00530 } 00531 00532 return S_OK; 00533 } 00534 00535 static HRESULT WINAPI OleDocumentView_GetRect(IOleDocumentView *iface, LPRECT prcView) 00536 { 00537 HTMLDocument *This = DOCVIEW_THIS(iface); 00538 00539 TRACE("(%p)->(%p)\n", This, prcView); 00540 00541 if(!prcView) 00542 return E_INVALIDARG; 00543 00544 GetClientRect(This->doc_obj->hwnd, prcView); 00545 return S_OK; 00546 } 00547 00548 static HRESULT WINAPI OleDocumentView_SetRectComplex(IOleDocumentView *iface, LPRECT prcView, 00549 LPRECT prcHScroll, LPRECT prcVScroll, LPRECT prcSizeBox) 00550 { 00551 HTMLDocument *This = DOCVIEW_THIS(iface); 00552 FIXME("(%p)->(%p %p %p %p)\n", This, prcView, prcHScroll, prcVScroll, prcSizeBox); 00553 return E_NOTIMPL; 00554 } 00555 00556 static HRESULT WINAPI OleDocumentView_Show(IOleDocumentView *iface, BOOL fShow) 00557 { 00558 HTMLDocument *This = DOCVIEW_THIS(iface); 00559 HRESULT hres; 00560 00561 TRACE("(%p)->(%x)\n", This, fShow); 00562 00563 if(fShow) { 00564 if(!This->doc_obj->ui_active) { 00565 hres = activate_window(This->doc_obj); 00566 if(FAILED(hres)) 00567 return hres; 00568 } 00569 update_doc(This, UPDATE_UI); 00570 ShowWindow(This->doc_obj->hwnd, SW_SHOW); 00571 }else { 00572 ShowWindow(This->doc_obj->hwnd, SW_HIDE); 00573 00574 if(This->doc_obj->in_place_active) 00575 IOleInPlaceObjectWindowless_InPlaceDeactivate(INPLACEWIN(This)); 00576 00577 if(This->doc_obj->ip_window) { 00578 IOleInPlaceUIWindow_Release(This->doc_obj->ip_window); 00579 This->doc_obj->ip_window = NULL; 00580 } 00581 } 00582 00583 return S_OK; 00584 } 00585 00586 static HRESULT WINAPI OleDocumentView_UIActivate(IOleDocumentView *iface, BOOL fUIActivate) 00587 { 00588 HTMLDocument *This = DOCVIEW_THIS(iface); 00589 HRESULT hres; 00590 00591 TRACE("(%p)->(%x)\n", This, fUIActivate); 00592 00593 if(!This->doc_obj->ipsite) { 00594 IOleClientSite *cs = This->doc_obj->client; 00595 IOleInPlaceSite *ips; 00596 00597 if(!cs) { 00598 WARN("this->ipsite = NULL\n"); 00599 return E_UNEXPECTED; 00600 } 00601 00602 hres = IOleClientSite_QueryInterface(cs, &IID_IOleInPlaceSiteWindowless, (void**)&ips); 00603 if(SUCCEEDED(hres)) 00604 This->doc_obj->ipsite = ips; 00605 else { 00606 hres = IOleClientSite_QueryInterface(cs, &IID_IOleInPlaceSiteEx, (void**)&ips); 00607 if(SUCCEEDED(hres)) 00608 This->doc_obj->ipsite = ips; 00609 else { 00610 hres = IOleClientSite_QueryInterface(cs, &IID_IOleInPlaceSite, (void**)&ips); 00611 if(SUCCEEDED(hres)) 00612 This->doc_obj->ipsite = ips; 00613 else { 00614 WARN("this->ipsite = NULL\n"); 00615 return E_NOINTERFACE; 00616 } 00617 } 00618 } 00619 00620 IOleClientSite_AddRef(This->doc_obj->ipsite); 00621 This->doc_obj->request_uiactivate = FALSE; 00622 HTMLDocument_LockContainer(This->doc_obj, TRUE); 00623 } 00624 00625 if(fUIActivate) { 00626 RECT rcBorderWidths; 00627 00628 if(This->doc_obj->ui_active) 00629 return S_OK; 00630 00631 if(!This->doc_obj->window_active) { 00632 hres = activate_window(This->doc_obj); 00633 if(FAILED(hres)) 00634 return hres; 00635 } 00636 00637 This->doc_obj->focus = TRUE; 00638 if(This->doc_obj->nscontainer) 00639 nsIWebBrowserFocus_Activate(This->doc_obj->nscontainer->focus); 00640 notif_focus(This->doc_obj); 00641 00642 update_doc(This, UPDATE_UI); 00643 00644 hres = IOleInPlaceSite_OnUIActivate(This->doc_obj->ipsite); 00645 if(SUCCEEDED(hres)) { 00646 call_set_active_object((IOleInPlaceUIWindow*)This->doc_obj->frame, ACTOBJ(This)); 00647 }else { 00648 FIXME("OnUIActivate failed: %08x\n", hres); 00649 IOleInPlaceFrame_Release(This->doc_obj->frame); 00650 This->doc_obj->frame = NULL; 00651 This->doc_obj->ui_active = FALSE; 00652 return hres; 00653 } 00654 00655 if(This->doc_obj->hostui) { 00656 hres = IDocHostUIHandler_ShowUI(This->doc_obj->hostui, 00657 This->doc_obj->usermode == EDITMODE ? DOCHOSTUITYPE_AUTHOR : DOCHOSTUITYPE_BROWSE, 00658 ACTOBJ(This), CMDTARGET(This), This->doc_obj->frame, This->doc_obj->ip_window); 00659 if(FAILED(hres)) 00660 IDocHostUIHandler_HideUI(This->doc_obj->hostui); 00661 } 00662 00663 if(This->doc_obj->ip_window) 00664 call_set_active_object(This->doc_obj->ip_window, ACTOBJ(This)); 00665 00666 memset(&rcBorderWidths, 0, sizeof(rcBorderWidths)); 00667 IOleInPlaceFrame_SetBorderSpace(This->doc_obj->frame, &rcBorderWidths); 00668 00669 This->doc_obj->ui_active = TRUE; 00670 }else { 00671 This->doc_obj->focus = FALSE; 00672 nsIWebBrowserFocus_Deactivate(This->doc_obj->nscontainer->focus); 00673 if(This->doc_obj->ui_active) { 00674 This->doc_obj->ui_active = FALSE; 00675 if(This->doc_obj->ip_window) 00676 call_set_active_object(This->doc_obj->ip_window, NULL); 00677 if(This->doc_obj->frame) 00678 call_set_active_object((IOleInPlaceUIWindow*)This->doc_obj->frame, NULL); 00679 if(This->doc_obj->hostui) 00680 IDocHostUIHandler_HideUI(This->doc_obj->hostui); 00681 if(This->doc_obj->ipsite) 00682 IOleInPlaceSite_OnUIDeactivate(This->doc_obj->ipsite, FALSE); 00683 } 00684 } 00685 return S_OK; 00686 } 00687 00688 static HRESULT WINAPI OleDocumentView_Open(IOleDocumentView *iface) 00689 { 00690 HTMLDocument *This = DOCVIEW_THIS(iface); 00691 FIXME("(%p)\n", This); 00692 return E_NOTIMPL; 00693 } 00694 00695 static HRESULT WINAPI OleDocumentView_CloseView(IOleDocumentView *iface, DWORD dwReserved) 00696 { 00697 HTMLDocument *This = DOCVIEW_THIS(iface); 00698 TRACE("(%p)->(%x)\n", This, dwReserved); 00699 00700 if(dwReserved) 00701 WARN("dwReserved = %d\n", dwReserved); 00702 00703 /* NOTE: 00704 * Windows implementation calls QueryInterface(IID_IOleCommandTarget), 00705 * QueryInterface(IID_IOleControlSite) and KillTimer 00706 */ 00707 00708 IOleDocumentView_Show(iface, FALSE); 00709 00710 return S_OK; 00711 } 00712 00713 static HRESULT WINAPI OleDocumentView_SaveViewState(IOleDocumentView *iface, LPSTREAM pstm) 00714 { 00715 HTMLDocument *This = DOCVIEW_THIS(iface); 00716 FIXME("(%p)->(%p)\n", This, pstm); 00717 return E_NOTIMPL; 00718 } 00719 00720 static HRESULT WINAPI OleDocumentView_ApplyViewState(IOleDocumentView *iface, LPSTREAM pstm) 00721 { 00722 HTMLDocument *This = DOCVIEW_THIS(iface); 00723 FIXME("(%p)->(%p)\n", This, pstm); 00724 return E_NOTIMPL; 00725 } 00726 00727 static HRESULT WINAPI OleDocumentView_Clone(IOleDocumentView *iface, IOleInPlaceSite *pIPSiteNew, 00728 IOleDocumentView **ppViewNew) 00729 { 00730 HTMLDocument *This = DOCVIEW_THIS(iface); 00731 FIXME("(%p)->(%p %p)\n", This, pIPSiteNew, ppViewNew); 00732 return E_NOTIMPL; 00733 } 00734 00735 #undef DOCVIEW_THIS 00736 00737 static const IOleDocumentViewVtbl OleDocumentViewVtbl = { 00738 OleDocumentView_QueryInterface, 00739 OleDocumentView_AddRef, 00740 OleDocumentView_Release, 00741 OleDocumentView_SetInPlaceSite, 00742 OleDocumentView_GetInPlaceSite, 00743 OleDocumentView_GetDocument, 00744 OleDocumentView_SetRect, 00745 OleDocumentView_GetRect, 00746 OleDocumentView_SetRectComplex, 00747 OleDocumentView_Show, 00748 OleDocumentView_UIActivate, 00749 OleDocumentView_Open, 00750 OleDocumentView_CloseView, 00751 OleDocumentView_SaveViewState, 00752 OleDocumentView_ApplyViewState, 00753 OleDocumentView_Clone 00754 }; 00755 00756 /********************************************************** 00757 * IViewObject implementation 00758 */ 00759 00760 #define VIEWOBJ_THIS(iface) DEFINE_THIS(HTMLDocument, ViewObjectEx, iface) 00761 00762 static HRESULT WINAPI ViewObject_QueryInterface(IViewObjectEx *iface, REFIID riid, void **ppvObject) 00763 { 00764 HTMLDocument *This = VIEWOBJ_THIS(iface); 00765 return IHTMLDocument2_QueryInterface(HTMLDOC(This), riid, ppvObject); 00766 } 00767 00768 static ULONG WINAPI ViewObject_AddRef(IViewObjectEx *iface) 00769 { 00770 HTMLDocument *This = VIEWOBJ_THIS(iface); 00771 return IHTMLDocument2_AddRef(HTMLDOC(This)); 00772 } 00773 00774 static ULONG WINAPI ViewObject_Release(IViewObjectEx *iface) 00775 { 00776 HTMLDocument *This = VIEWOBJ_THIS(iface); 00777 return IHTMLDocument2_Release(HTMLDOC(This)); 00778 } 00779 00780 static HRESULT WINAPI ViewObject_Draw(IViewObjectEx *iface, DWORD dwDrawAspect, LONG lindex, void *pvAspect, 00781 DVTARGETDEVICE *ptd, HDC hdcTargetDev, HDC hdcDraw, LPCRECTL lprcBounds, 00782 LPCRECTL lprcWBounds, BOOL (CALLBACK *pfnContinue)(ULONG_PTR dwContinue), ULONG_PTR dwContinue) 00783 { 00784 HTMLDocument *This = VIEWOBJ_THIS(iface); 00785 FIXME("(%p)->(%d %d %p %p %p %p %p %p %p %ld)\n", This, dwDrawAspect, lindex, pvAspect, 00786 ptd, hdcTargetDev, hdcDraw, lprcBounds, lprcWBounds, pfnContinue, dwContinue); 00787 return E_NOTIMPL; 00788 } 00789 00790 static HRESULT WINAPI ViewObject_GetColorSet(IViewObjectEx *iface, DWORD dwDrawAspect, LONG lindex, void *pvAspect, 00791 DVTARGETDEVICE *ptd, HDC hicTargetDev, LOGPALETTE **ppColorSet) 00792 { 00793 HTMLDocument *This = VIEWOBJ_THIS(iface); 00794 FIXME("(%p)->(%d %d %p %p %p %p)\n", This, dwDrawAspect, lindex, pvAspect, ptd, hicTargetDev, ppColorSet); 00795 return E_NOTIMPL; 00796 } 00797 00798 static HRESULT WINAPI ViewObject_Freeze(IViewObjectEx *iface, DWORD dwDrawAspect, LONG lindex, 00799 void *pvAspect, DWORD *pdwFreeze) 00800 { 00801 HTMLDocument *This = VIEWOBJ_THIS(iface); 00802 FIXME("(%p)->(%d %d %p %p)\n", This, dwDrawAspect, lindex, pvAspect, pdwFreeze); 00803 return E_NOTIMPL; 00804 } 00805 00806 static HRESULT WINAPI ViewObject_Unfreeze(IViewObjectEx *iface, DWORD dwFreeze) 00807 { 00808 HTMLDocument *This = VIEWOBJ_THIS(iface); 00809 FIXME("(%p)->(%d)\n", This, dwFreeze); 00810 return E_NOTIMPL; 00811 } 00812 00813 static HRESULT WINAPI ViewObject_SetAdvise(IViewObjectEx *iface, DWORD aspects, DWORD advf, IAdviseSink *pAdvSink) 00814 { 00815 HTMLDocument *This = VIEWOBJ_THIS(iface); 00816 00817 TRACE("(%p)->(%d %d %p)\n", This, aspects, advf, pAdvSink); 00818 00819 if(aspects != DVASPECT_CONTENT || advf != ADVF_PRIMEFIRST) 00820 FIXME("unsupported arguments\n"); 00821 00822 if(This->doc_obj->view_sink) 00823 IAdviseSink_Release(This->doc_obj->view_sink); 00824 if(pAdvSink) 00825 IAdviseSink_AddRef(pAdvSink); 00826 00827 This->doc_obj->view_sink = pAdvSink; 00828 return S_OK; 00829 } 00830 00831 static HRESULT WINAPI ViewObject_GetAdvise(IViewObjectEx *iface, DWORD *pAspects, DWORD *pAdvf, IAdviseSink **ppAdvSink) 00832 { 00833 HTMLDocument *This = VIEWOBJ_THIS(iface); 00834 FIXME("(%p)->(%p %p %p)\n", This, pAspects, pAdvf, ppAdvSink); 00835 return E_NOTIMPL; 00836 } 00837 00838 static HRESULT WINAPI ViewObject_GetExtent(IViewObjectEx *iface, DWORD dwDrawAspect, LONG lindex, 00839 DVTARGETDEVICE* ptd, LPSIZEL lpsizel) 00840 { 00841 HTMLDocument *This = VIEWOBJ_THIS(iface); 00842 FIXME("(%p)->(%d %d %p %p)\n", This, dwDrawAspect, lindex, ptd, lpsizel); 00843 return E_NOTIMPL; 00844 } 00845 00846 static HRESULT WINAPI ViewObject_GetRect(IViewObjectEx *iface, DWORD dwAspect, LPRECTL pRect) 00847 { 00848 HTMLDocument *This = VIEWOBJ_THIS(iface); 00849 FIXME("(%p)->(%d %p)\n", This, dwAspect, pRect); 00850 return E_NOTIMPL; 00851 } 00852 00853 static HRESULT WINAPI ViewObject_GetViewStatus(IViewObjectEx *iface, DWORD *pdwStatus) 00854 { 00855 HTMLDocument *This = VIEWOBJ_THIS(iface); 00856 FIXME("(%p)->(%p)\n", This, pdwStatus); 00857 return E_NOTIMPL; 00858 } 00859 00860 static HRESULT WINAPI ViewObject_QueryHitPoint(IViewObjectEx* iface, DWORD dwAspect, 00861 LPCRECT pRectBounds, POINT ptlLoc, LONG lCloseHint, DWORD *pHitResult) 00862 { 00863 HTMLDocument *This = VIEWOBJ_THIS(iface); 00864 FIXME("(%p)->(%d %p (%d %d) %d %p)\n", This, dwAspect, pRectBounds, ptlLoc.x, 00865 ptlLoc.y, lCloseHint, pHitResult); 00866 return E_NOTIMPL; 00867 } 00868 00869 static HRESULT WINAPI ViewObject_QueryHitRect(IViewObjectEx *iface, DWORD dwAspect, 00870 LPCRECT pRectBounds, LPCRECT pRectLoc, LONG lCloseHint, DWORD *pHitResult) 00871 { 00872 HTMLDocument *This = VIEWOBJ_THIS(iface); 00873 FIXME("(%p)->(%d %p %p %d %p)\n", This, dwAspect, pRectBounds, pRectLoc, lCloseHint, pHitResult); 00874 return E_NOTIMPL; 00875 } 00876 00877 static HRESULT WINAPI ViewObject_GetNaturalExtent(IViewObjectEx *iface, DWORD dwAspect, LONG lindex, 00878 DVTARGETDEVICE *ptd, HDC hicTargetDev, DVEXTENTINFO *pExtentInfo, LPSIZEL pSizel) 00879 { 00880 HTMLDocument *This = VIEWOBJ_THIS(iface); 00881 FIXME("(%p)->(%d %d %p %p %p %p\n", This, dwAspect,lindex, ptd, 00882 hicTargetDev, pExtentInfo, pSizel); 00883 return E_NOTIMPL; 00884 } 00885 00886 #undef VIEWOBJ_THIS 00887 00888 static const IViewObjectExVtbl ViewObjectVtbl = { 00889 ViewObject_QueryInterface, 00890 ViewObject_AddRef, 00891 ViewObject_Release, 00892 ViewObject_Draw, 00893 ViewObject_GetColorSet, 00894 ViewObject_Freeze, 00895 ViewObject_Unfreeze, 00896 ViewObject_SetAdvise, 00897 ViewObject_GetAdvise, 00898 ViewObject_GetExtent, 00899 ViewObject_GetRect, 00900 ViewObject_GetViewStatus, 00901 ViewObject_QueryHitPoint, 00902 ViewObject_QueryHitRect, 00903 ViewObject_GetNaturalExtent 00904 }; 00905 00906 void HTMLDocument_View_Init(HTMLDocument *This) 00907 { 00908 This->lpOleDocumentViewVtbl = &OleDocumentViewVtbl; 00909 This->lpViewObjectExVtbl = &ViewObjectVtbl; 00910 } Generated on Sun May 27 2012 04:22:20 for ReactOS by
1.7.6.1
|