15b190011SAndrew Rist /************************************************************** 2cdf0e10cSrcweir * 35b190011SAndrew Rist * Licensed to the Apache Software Foundation (ASF) under one 45b190011SAndrew Rist * or more contributor license agreements. See the NOTICE file 55b190011SAndrew Rist * distributed with this work for additional information 65b190011SAndrew Rist * regarding copyright ownership. The ASF licenses this file 75b190011SAndrew Rist * to you under the Apache License, Version 2.0 (the 85b190011SAndrew Rist * "License"); you may not use this file except in compliance 95b190011SAndrew Rist * with the License. You may obtain a copy of the License at 10cdf0e10cSrcweir * 115b190011SAndrew Rist * http://www.apache.org/licenses/LICENSE-2.0 12cdf0e10cSrcweir * 135b190011SAndrew Rist * Unless required by applicable law or agreed to in writing, 145b190011SAndrew Rist * software distributed under the License is distributed on an 155b190011SAndrew Rist * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 165b190011SAndrew Rist * KIND, either express or implied. See the License for the 175b190011SAndrew Rist * specific language governing permissions and limitations 185b190011SAndrew Rist * under the License. 19cdf0e10cSrcweir * 205b190011SAndrew Rist *************************************************************/ 215b190011SAndrew Rist 225b190011SAndrew Rist 23cdf0e10cSrcweir 24cdf0e10cSrcweir // MARKER(update_precomp.py): autogen include statement, do not remove 25cdf0e10cSrcweir #include "precompiled_sd.hxx" 26cdf0e10cSrcweir 27cdf0e10cSrcweir #include "Window.hxx" 28cdf0e10cSrcweir #include <sfx2/dispatch.hxx> 29cdf0e10cSrcweir #include <sfx2/request.hxx> 30cdf0e10cSrcweir 31cdf0e10cSrcweir #include <sfx2/viewfrm.hxx> 32cdf0e10cSrcweir #include <svx/svxids.hrc> 33cdf0e10cSrcweir 34cdf0e10cSrcweir #include <editeng/outliner.hxx> 35cdf0e10cSrcweir #include <editeng/editview.hxx> 36cdf0e10cSrcweir 37cdf0e10cSrcweir #include "app.hrc" 38cdf0e10cSrcweir #include "helpids.h" 39cdf0e10cSrcweir #include "ViewShell.hxx" 40cdf0e10cSrcweir #include "DrawViewShell.hxx" 41cdf0e10cSrcweir #include "View.hxx" 42cdf0e10cSrcweir #include "FrameView.hxx" 43cdf0e10cSrcweir #include "OutlineViewShell.hxx" 44cdf0e10cSrcweir #include "drawdoc.hxx" 45cdf0e10cSrcweir #include "AccessibleDrawDocumentView.hxx" 46cdf0e10cSrcweir #include "WindowUpdater.hxx" 47cdf0e10cSrcweir 48*0deba7fbSSteve Yin //IAccessibility2 Implementation 2009----- 49*0deba7fbSSteve Yin #include <vcl/svapp.hxx> 50*0deba7fbSSteve Yin //-----IAccessibility2 Implementation 2009 51*0deba7fbSSteve Yin 52cdf0e10cSrcweir namespace sd { 53cdf0e10cSrcweir 54cdf0e10cSrcweir #define SCROLL_LINE_FACT 0.05 // Faktor fuer Zeilenscrolling 55cdf0e10cSrcweir #define SCROLL_PAGE_FACT 0.5 // Faktor fuer Seitenscrolling 56cdf0e10cSrcweir #define SCROLL_SENSITIVE 20 // Sensitiver Bereich (Pixel) 57cdf0e10cSrcweir #define ZOOM_MULTIPLICATOR 10000 // Multiplikator um Rundungsfehler zu vermeiden 58cdf0e10cSrcweir #define MIN_ZOOM 5 // Minimaler Zoomfaktor 59cdf0e10cSrcweir #define MAX_ZOOM 3000 // Maximaler Zoomfaktor 60cdf0e10cSrcweir 61cdf0e10cSrcweir 62cdf0e10cSrcweir /************************************************************************* 63cdf0e10cSrcweir |* 64cdf0e10cSrcweir |* Konstruktor 65cdf0e10cSrcweir |* 66cdf0e10cSrcweir \************************************************************************/ 67cdf0e10cSrcweir 68cdf0e10cSrcweir Window::Window(::Window* pParent) 69cdf0e10cSrcweir : ::Window(pParent, WinBits(WB_CLIPCHILDREN | WB_DIALOGCONTROL)), 70cdf0e10cSrcweir DropTargetHelper( this ), 71cdf0e10cSrcweir mpShareWin(NULL), 72cdf0e10cSrcweir maWinPos(0, 0), // vorsichtshalber; die Werte sollten aber 73cdf0e10cSrcweir maViewOrigin(0, 0), // vom Besitzer des Fensters neu gesetzt 74cdf0e10cSrcweir maViewSize(1000, 1000), // werden 75cdf0e10cSrcweir mnMinZoom(MIN_ZOOM), 76cdf0e10cSrcweir mnMaxZoom(MAX_ZOOM), 77cdf0e10cSrcweir mbMinZoomAutoCalc(false), 78cdf0e10cSrcweir mbCalcMinZoomByMinSide(true), 79cdf0e10cSrcweir mbCenterAllowed(true), 80cdf0e10cSrcweir mnTicks (0), 81cdf0e10cSrcweir mbDraggedFrom(false), 82cdf0e10cSrcweir mpViewShell(NULL), 83cdf0e10cSrcweir mbUseDropScroll (true) 84cdf0e10cSrcweir { 85cdf0e10cSrcweir SetDialogControlFlags( WINDOW_DLGCTRL_RETURN | WINDOW_DLGCTRL_WANTFOCUS ); 86cdf0e10cSrcweir 87cdf0e10cSrcweir MapMode aMap(GetMapMode()); 88cdf0e10cSrcweir aMap.SetMapUnit(MAP_100TH_MM); 89cdf0e10cSrcweir SetMapMode(aMap); 90cdf0e10cSrcweir 91cdf0e10cSrcweir // Damit im Diamodus die ::WindowColor genommen wird 92cdf0e10cSrcweir SetBackground( Wallpaper( GetSettings().GetStyleSettings().GetWindowColor() ) ); 93cdf0e10cSrcweir 94cdf0e10cSrcweir // adjust contrast mode initially 95cdf0e10cSrcweir bool bUseContrast = GetSettings().GetStyleSettings().GetHighContrastMode(); 96cdf0e10cSrcweir SetDrawMode( bUseContrast 97cdf0e10cSrcweir ? ViewShell::OUTPUT_DRAWMODE_CONTRAST 98cdf0e10cSrcweir : ViewShell::OUTPUT_DRAWMODE_COLOR ); 99cdf0e10cSrcweir 100cdf0e10cSrcweir // Hilfe-ID setzen 101cdf0e10cSrcweir // SetHelpId(HID_SD_WIN_DOCUMENT); 102cdf0e10cSrcweir SetUniqueId(HID_SD_WIN_DOCUMENT); 103cdf0e10cSrcweir 104cdf0e10cSrcweir // #i78183# Added after discussed with AF 105cdf0e10cSrcweir EnableRTL(sal_False); 106cdf0e10cSrcweir } 107cdf0e10cSrcweir 108cdf0e10cSrcweir /************************************************************************* 109cdf0e10cSrcweir |* 110cdf0e10cSrcweir |* Destruktor 111cdf0e10cSrcweir |* 112cdf0e10cSrcweir \************************************************************************/ 113cdf0e10cSrcweir 114cdf0e10cSrcweir Window::~Window (void) 115cdf0e10cSrcweir { 116cdf0e10cSrcweir if (mpViewShell != NULL) 117cdf0e10cSrcweir { 118cdf0e10cSrcweir WindowUpdater* pWindowUpdater = mpViewShell->GetWindowUpdater(); 119cdf0e10cSrcweir if (pWindowUpdater != NULL) 120cdf0e10cSrcweir pWindowUpdater->UnregisterWindow (this); 121cdf0e10cSrcweir } 122cdf0e10cSrcweir } 123cdf0e10cSrcweir 124cdf0e10cSrcweir 125cdf0e10cSrcweir 126cdf0e10cSrcweir 127cdf0e10cSrcweir void Window::SetViewShell (ViewShell* pViewSh) 128cdf0e10cSrcweir { 129cdf0e10cSrcweir WindowUpdater* pWindowUpdater = NULL; 130cdf0e10cSrcweir // Unregister at device updater of old view shell. 131cdf0e10cSrcweir if (mpViewShell != NULL) 132cdf0e10cSrcweir { 133cdf0e10cSrcweir pWindowUpdater = mpViewShell->GetWindowUpdater(); 134cdf0e10cSrcweir if (pWindowUpdater != NULL) 135cdf0e10cSrcweir pWindowUpdater->UnregisterWindow (this); 136cdf0e10cSrcweir } 137cdf0e10cSrcweir 138cdf0e10cSrcweir mpViewShell = pViewSh; 139cdf0e10cSrcweir 140cdf0e10cSrcweir // Register at device updater of new view shell 141cdf0e10cSrcweir if (mpViewShell != NULL) 142cdf0e10cSrcweir { 143cdf0e10cSrcweir pWindowUpdater = mpViewShell->GetWindowUpdater(); 144cdf0e10cSrcweir if (pWindowUpdater != NULL) 145cdf0e10cSrcweir pWindowUpdater->RegisterWindow (this); 146cdf0e10cSrcweir } 147cdf0e10cSrcweir } 148cdf0e10cSrcweir 149cdf0e10cSrcweir void Window::CalcMinZoom() 150cdf0e10cSrcweir { 151cdf0e10cSrcweir // Are we entitled to change the minimal zoom factor? 152cdf0e10cSrcweir if ( mbMinZoomAutoCalc ) 153cdf0e10cSrcweir { 154cdf0e10cSrcweir // Get current zoom factor. 155cdf0e10cSrcweir long nZoom = GetZoom(); 156cdf0e10cSrcweir 157cdf0e10cSrcweir if ( mpShareWin ) 158cdf0e10cSrcweir { 159cdf0e10cSrcweir mpShareWin->CalcMinZoom(); 160cdf0e10cSrcweir mnMinZoom = mpShareWin->mnMinZoom; 161cdf0e10cSrcweir } 162cdf0e10cSrcweir else 163cdf0e10cSrcweir { 164cdf0e10cSrcweir // Get the rectangle of the output area in logical coordinates 165cdf0e10cSrcweir // and calculate the scaling factors that would lead to the view 166cdf0e10cSrcweir // area (also called application area) to completely fill the 167cdf0e10cSrcweir // window. 168cdf0e10cSrcweir Size aWinSize = PixelToLogic(GetOutputSizePixel()); 169cdf0e10cSrcweir sal_uLong nX = (sal_uLong) ((double) aWinSize.Width() 170cdf0e10cSrcweir * (double) ZOOM_MULTIPLICATOR / (double) maViewSize.Width()); 171cdf0e10cSrcweir sal_uLong nY = (sal_uLong) ((double) aWinSize.Height() 172cdf0e10cSrcweir * (double) ZOOM_MULTIPLICATOR / (double) maViewSize.Height()); 173cdf0e10cSrcweir 174cdf0e10cSrcweir // Decide whether to take the larger or the smaller factor. 175cdf0e10cSrcweir sal_uLong nFact; 176cdf0e10cSrcweir if (mbCalcMinZoomByMinSide) 177cdf0e10cSrcweir nFact = Min(nX, nY); 178cdf0e10cSrcweir else 179cdf0e10cSrcweir nFact = Max(nX, nY); 180cdf0e10cSrcweir 181cdf0e10cSrcweir // The factor is tansfomed according to the current zoom factor. 182cdf0e10cSrcweir nFact = nFact * nZoom / ZOOM_MULTIPLICATOR; 183cdf0e10cSrcweir mnMinZoom = Max((sal_uInt16) MIN_ZOOM, (sal_uInt16) nFact); 184cdf0e10cSrcweir } 185cdf0e10cSrcweir // If the current zoom factor is smaller than the calculated minimal 186cdf0e10cSrcweir // zoom factor then set the new minimal factor as the current zoom 187cdf0e10cSrcweir // factor. 188cdf0e10cSrcweir if ( nZoom < (long) mnMinZoom ) 189cdf0e10cSrcweir SetZoomFactor(mnMinZoom); 190cdf0e10cSrcweir } 191cdf0e10cSrcweir } 192cdf0e10cSrcweir 193cdf0e10cSrcweir 194cdf0e10cSrcweir 195cdf0e10cSrcweir 196cdf0e10cSrcweir void Window::SetMinZoom (long int nMin) 197cdf0e10cSrcweir { 198cdf0e10cSrcweir mnMinZoom = (sal_uInt16) nMin; 199cdf0e10cSrcweir } 200cdf0e10cSrcweir 201cdf0e10cSrcweir 202cdf0e10cSrcweir 203cdf0e10cSrcweir 204cdf0e10cSrcweir long Window::GetMinZoom (void) const 205cdf0e10cSrcweir { 206cdf0e10cSrcweir return mnMinZoom; 207cdf0e10cSrcweir } 208cdf0e10cSrcweir 209cdf0e10cSrcweir 210cdf0e10cSrcweir 211cdf0e10cSrcweir 212cdf0e10cSrcweir void Window::SetMaxZoom (long int nMax) 213cdf0e10cSrcweir { 214cdf0e10cSrcweir mnMaxZoom = (sal_uInt16) nMax; 215cdf0e10cSrcweir } 216cdf0e10cSrcweir 217cdf0e10cSrcweir 218cdf0e10cSrcweir 219cdf0e10cSrcweir 220cdf0e10cSrcweir long Window::GetMaxZoom (void) const 221cdf0e10cSrcweir { 222cdf0e10cSrcweir return mnMaxZoom; 223cdf0e10cSrcweir } 224cdf0e10cSrcweir 225cdf0e10cSrcweir 226cdf0e10cSrcweir 227cdf0e10cSrcweir 228cdf0e10cSrcweir long Window::GetZoom (void) const 229cdf0e10cSrcweir { 230cdf0e10cSrcweir if( GetMapMode().GetScaleX().GetDenominator() ) 231cdf0e10cSrcweir { 232cdf0e10cSrcweir return GetMapMode().GetScaleX().GetNumerator() * 100L 233cdf0e10cSrcweir / GetMapMode().GetScaleX().GetDenominator(); 234cdf0e10cSrcweir } 235cdf0e10cSrcweir else 236cdf0e10cSrcweir { 237cdf0e10cSrcweir return 0; 238cdf0e10cSrcweir } 239cdf0e10cSrcweir } 240cdf0e10cSrcweir 241cdf0e10cSrcweir 242cdf0e10cSrcweir 243cdf0e10cSrcweir 244cdf0e10cSrcweir /************************************************************************* 245cdf0e10cSrcweir |* 246cdf0e10cSrcweir |* Resize event 247cdf0e10cSrcweir |* 248cdf0e10cSrcweir \************************************************************************/ 249cdf0e10cSrcweir 250cdf0e10cSrcweir void Window::Resize() 251cdf0e10cSrcweir { 252cdf0e10cSrcweir ::Window::Resize(); 253cdf0e10cSrcweir CalcMinZoom(); 254cdf0e10cSrcweir 255cdf0e10cSrcweir if( mpViewShell && mpViewShell->GetViewFrame() ) 256cdf0e10cSrcweir mpViewShell->GetViewFrame()->GetBindings().Invalidate( SID_ATTR_ZOOMSLIDER ); 257cdf0e10cSrcweir } 258cdf0e10cSrcweir 259cdf0e10cSrcweir /************************************************************************* 260cdf0e10cSrcweir |* 261cdf0e10cSrcweir |* PrePaint event 262cdf0e10cSrcweir |* 263cdf0e10cSrcweir \************************************************************************/ 264cdf0e10cSrcweir 265cdf0e10cSrcweir void Window::PrePaint() 266cdf0e10cSrcweir { 267cdf0e10cSrcweir if ( mpViewShell ) 268cdf0e10cSrcweir mpViewShell->PrePaint(); 269cdf0e10cSrcweir } 270cdf0e10cSrcweir 271cdf0e10cSrcweir /************************************************************************* 272cdf0e10cSrcweir |* 273cdf0e10cSrcweir |* Paint event 274cdf0e10cSrcweir |* 275cdf0e10cSrcweir \************************************************************************/ 276cdf0e10cSrcweir 277cdf0e10cSrcweir void Window::Paint(const Rectangle& rRect) 278cdf0e10cSrcweir { 279cdf0e10cSrcweir if ( mpViewShell ) 280cdf0e10cSrcweir mpViewShell->Paint(rRect, this); 281cdf0e10cSrcweir } 282cdf0e10cSrcweir 283cdf0e10cSrcweir /************************************************************************* 284cdf0e10cSrcweir |* 285cdf0e10cSrcweir |* Keyboard event 286cdf0e10cSrcweir |* 287cdf0e10cSrcweir \************************************************************************/ 288cdf0e10cSrcweir 289cdf0e10cSrcweir void Window::KeyInput(const KeyEvent& rKEvt) 290cdf0e10cSrcweir { 291cdf0e10cSrcweir if (!(mpViewShell && mpViewShell->KeyInput(rKEvt, this))) 292cdf0e10cSrcweir { 293cdf0e10cSrcweir if (mpViewShell && rKEvt.GetKeyCode().GetCode() == KEY_ESCAPE) 294cdf0e10cSrcweir { 295cdf0e10cSrcweir mpViewShell->GetViewShell()->Escape(); 296cdf0e10cSrcweir } 297cdf0e10cSrcweir else 298cdf0e10cSrcweir { 299cdf0e10cSrcweir ::Window::KeyInput(rKEvt); 300cdf0e10cSrcweir } 301cdf0e10cSrcweir } 302cdf0e10cSrcweir } 303cdf0e10cSrcweir 304cdf0e10cSrcweir /************************************************************************* 305cdf0e10cSrcweir |* 306cdf0e10cSrcweir |* MouseButtonDown event 307cdf0e10cSrcweir |* 308cdf0e10cSrcweir \************************************************************************/ 309cdf0e10cSrcweir 310cdf0e10cSrcweir void Window::MouseButtonDown(const MouseEvent& rMEvt) 311cdf0e10cSrcweir { 312cdf0e10cSrcweir if ( mpViewShell ) 313cdf0e10cSrcweir mpViewShell->MouseButtonDown(rMEvt, this); 314cdf0e10cSrcweir } 315cdf0e10cSrcweir 316cdf0e10cSrcweir /************************************************************************* 317cdf0e10cSrcweir |* 318cdf0e10cSrcweir |* MouseMove event 319cdf0e10cSrcweir |* 320cdf0e10cSrcweir \************************************************************************/ 321cdf0e10cSrcweir 322cdf0e10cSrcweir void Window::MouseMove(const MouseEvent& rMEvt) 323cdf0e10cSrcweir { 324cdf0e10cSrcweir if ( mpViewShell ) 325cdf0e10cSrcweir mpViewShell->MouseMove(rMEvt, this); 326cdf0e10cSrcweir } 327cdf0e10cSrcweir 328cdf0e10cSrcweir /************************************************************************* 329cdf0e10cSrcweir |* 330cdf0e10cSrcweir |* MouseButtonUp event 331cdf0e10cSrcweir |* 332cdf0e10cSrcweir \************************************************************************/ 333cdf0e10cSrcweir 334cdf0e10cSrcweir void Window::MouseButtonUp(const MouseEvent& rMEvt) 335cdf0e10cSrcweir { 336cdf0e10cSrcweir mnTicks = 0; 337cdf0e10cSrcweir 338cdf0e10cSrcweir if ( mpViewShell ) 339cdf0e10cSrcweir mpViewShell->MouseButtonUp(rMEvt, this); 340cdf0e10cSrcweir } 341cdf0e10cSrcweir 342cdf0e10cSrcweir /************************************************************************* 343cdf0e10cSrcweir |* 344cdf0e10cSrcweir |* Command event 345cdf0e10cSrcweir |* 346cdf0e10cSrcweir \************************************************************************/ 347cdf0e10cSrcweir 348cdf0e10cSrcweir void Window::Command(const CommandEvent& rCEvt) 349cdf0e10cSrcweir { 350cdf0e10cSrcweir if ( mpViewShell ) 351cdf0e10cSrcweir mpViewShell->Command(rCEvt, this); 352cdf0e10cSrcweir } 353cdf0e10cSrcweir 354cdf0e10cSrcweir long Window::Notify( NotifyEvent& rNEvt ) 355cdf0e10cSrcweir { 356cdf0e10cSrcweir long nResult = sal_False; 357cdf0e10cSrcweir if ( mpViewShell ) 358cdf0e10cSrcweir { 359cdf0e10cSrcweir nResult = mpViewShell->Notify(rNEvt, this); 360cdf0e10cSrcweir } 361cdf0e10cSrcweir if( !nResult ) 362cdf0e10cSrcweir nResult = ::Window::Notify( rNEvt ); 363cdf0e10cSrcweir 364cdf0e10cSrcweir return nResult; 365cdf0e10cSrcweir } 366cdf0e10cSrcweir 367cdf0e10cSrcweir 368cdf0e10cSrcweir /************************************************************************* 369cdf0e10cSrcweir |* 370cdf0e10cSrcweir |* RequestHelp event 371cdf0e10cSrcweir |* 372cdf0e10cSrcweir \************************************************************************/ 373cdf0e10cSrcweir 374cdf0e10cSrcweir void Window::RequestHelp(const HelpEvent& rEvt) 375cdf0e10cSrcweir { 376cdf0e10cSrcweir if ( mpViewShell ) 377cdf0e10cSrcweir { 378cdf0e10cSrcweir if( !mpViewShell->RequestHelp( rEvt, this) ) 379cdf0e10cSrcweir ::Window::RequestHelp( rEvt ); 380cdf0e10cSrcweir } 381cdf0e10cSrcweir else 382cdf0e10cSrcweir ::Window::RequestHelp( rEvt ); 383cdf0e10cSrcweir } 384cdf0e10cSrcweir 385cdf0e10cSrcweir 386cdf0e10cSrcweir 387cdf0e10cSrcweir 388cdf0e10cSrcweir Point Window::GetWinViewPos (void) const 389cdf0e10cSrcweir { 390cdf0e10cSrcweir return maWinPos; 391cdf0e10cSrcweir } 392cdf0e10cSrcweir 393cdf0e10cSrcweir 394cdf0e10cSrcweir 395cdf0e10cSrcweir 396cdf0e10cSrcweir Point Window::GetViewOrigin (void) const 397cdf0e10cSrcweir { 398cdf0e10cSrcweir return maViewOrigin; 399cdf0e10cSrcweir } 400cdf0e10cSrcweir 401cdf0e10cSrcweir 402cdf0e10cSrcweir 403cdf0e10cSrcweir 404cdf0e10cSrcweir Size Window::GetViewSize (void) const 405cdf0e10cSrcweir { 406cdf0e10cSrcweir return maViewSize; 407cdf0e10cSrcweir } 408cdf0e10cSrcweir 409cdf0e10cSrcweir 410cdf0e10cSrcweir 411cdf0e10cSrcweir 412cdf0e10cSrcweir /************************************************************************* 413cdf0e10cSrcweir |* 414cdf0e10cSrcweir |* Position der linken oberen Ecke des im Fenster sichtbaren Bereichs 415cdf0e10cSrcweir |* setzen 416cdf0e10cSrcweir |* 417cdf0e10cSrcweir \************************************************************************/ 418cdf0e10cSrcweir 419cdf0e10cSrcweir void Window::SetWinViewPos(const Point& rPnt) 420cdf0e10cSrcweir { 421cdf0e10cSrcweir maWinPos = rPnt; 422cdf0e10cSrcweir } 423cdf0e10cSrcweir 424cdf0e10cSrcweir /************************************************************************* 425cdf0e10cSrcweir |* 426cdf0e10cSrcweir |* Ursprung der Darstellung in Bezug zur gesamten Arbeitsflaeche setzen 427cdf0e10cSrcweir |* 428cdf0e10cSrcweir \************************************************************************/ 429cdf0e10cSrcweir 430cdf0e10cSrcweir void Window::SetViewOrigin(const Point& rPnt) 431cdf0e10cSrcweir { 432cdf0e10cSrcweir maViewOrigin = rPnt; 433cdf0e10cSrcweir } 434cdf0e10cSrcweir 435cdf0e10cSrcweir /************************************************************************* 436cdf0e10cSrcweir |* 437cdf0e10cSrcweir |* Groesse der gesamten Arbeitsflaeche, die mit dem Fenster betrachtet 438cdf0e10cSrcweir |* werden kann, setzen 439cdf0e10cSrcweir |* 440cdf0e10cSrcweir \************************************************************************/ 441cdf0e10cSrcweir 442cdf0e10cSrcweir void Window::SetViewSize(const Size& rSize) 443cdf0e10cSrcweir { 444cdf0e10cSrcweir maViewSize = rSize; 445cdf0e10cSrcweir CalcMinZoom(); 446cdf0e10cSrcweir } 447cdf0e10cSrcweir 448cdf0e10cSrcweir 449cdf0e10cSrcweir 450cdf0e10cSrcweir 451cdf0e10cSrcweir void Window::SetCenterAllowed (bool bIsAllowed) 452cdf0e10cSrcweir { 453cdf0e10cSrcweir mbCenterAllowed = bIsAllowed; 454cdf0e10cSrcweir } 455cdf0e10cSrcweir 456cdf0e10cSrcweir 457cdf0e10cSrcweir 458cdf0e10cSrcweir 459cdf0e10cSrcweir long Window::SetZoomFactor(long nZoom) 460cdf0e10cSrcweir { 461cdf0e10cSrcweir // Clip the zoom factor to the valid range marked by nMinZoom as 462cdf0e10cSrcweir // calculated by CalcMinZoom() and the constant MAX_ZOOM. 463cdf0e10cSrcweir if ( nZoom > MAX_ZOOM ) 464cdf0e10cSrcweir nZoom = MAX_ZOOM; 465cdf0e10cSrcweir if ( nZoom < (long) mnMinZoom ) 466cdf0e10cSrcweir nZoom = mnMinZoom; 467cdf0e10cSrcweir 468cdf0e10cSrcweir // Set the zoom factor at the window's map mode. 469cdf0e10cSrcweir MapMode aMap(GetMapMode()); 470cdf0e10cSrcweir aMap.SetScaleX(Fraction(nZoom, 100)); 471cdf0e10cSrcweir aMap.SetScaleY(Fraction(nZoom, 100)); 472cdf0e10cSrcweir SetMapMode(aMap); 473cdf0e10cSrcweir 474cdf0e10cSrcweir // Update the map mode's origin (to what effect?). 475cdf0e10cSrcweir UpdateMapOrigin(); 476cdf0e10cSrcweir 477cdf0e10cSrcweir // Update the view's snapping to the the new zoom factor. 478cdf0e10cSrcweir if ( mpViewShell && mpViewShell->ISA(DrawViewShell) ) 479cdf0e10cSrcweir ((DrawViewShell*) mpViewShell)->GetView()-> 480cdf0e10cSrcweir RecalcLogicSnapMagnetic(*this); 481cdf0e10cSrcweir 482cdf0e10cSrcweir // Return the zoom factor just in case it has been changed above to lie 483cdf0e10cSrcweir // inside the valid range. 484cdf0e10cSrcweir return nZoom; 485cdf0e10cSrcweir } 486cdf0e10cSrcweir 487cdf0e10cSrcweir void Window::SetZoomIntegral(long nZoom) 488cdf0e10cSrcweir { 489cdf0e10cSrcweir // Clip the zoom factor to the valid range marked by nMinZoom as 490cdf0e10cSrcweir // previously calculated by <member>CalcMinZoom()</member> and the 491cdf0e10cSrcweir // MAX_ZOOM constant. 492cdf0e10cSrcweir if ( nZoom > MAX_ZOOM ) 493cdf0e10cSrcweir nZoom = MAX_ZOOM; 494cdf0e10cSrcweir if ( nZoom < (long) mnMinZoom ) 495cdf0e10cSrcweir nZoom = mnMinZoom; 496cdf0e10cSrcweir 497cdf0e10cSrcweir // Calculate the window's new origin. 498cdf0e10cSrcweir Size aSize = PixelToLogic(GetOutputSizePixel()); 499cdf0e10cSrcweir long nW = aSize.Width() * GetZoom() / nZoom; 500cdf0e10cSrcweir long nH = aSize.Height() * GetZoom() / nZoom; 501cdf0e10cSrcweir maWinPos.X() += (aSize.Width() - nW) / 2; 502cdf0e10cSrcweir maWinPos.Y() += (aSize.Height() - nH) / 2; 503cdf0e10cSrcweir if ( maWinPos.X() < 0 ) maWinPos.X() = 0; 504cdf0e10cSrcweir if ( maWinPos.Y() < 0 ) maWinPos.Y() = 0; 505cdf0e10cSrcweir 506cdf0e10cSrcweir // Finally update this window's map mode to the given zoom factor that 507cdf0e10cSrcweir // has been clipped to the valid range. 508cdf0e10cSrcweir SetZoomFactor(nZoom); 509cdf0e10cSrcweir } 510cdf0e10cSrcweir 511cdf0e10cSrcweir long Window::GetZoomForRect( const Rectangle& rZoomRect ) 512cdf0e10cSrcweir { 513cdf0e10cSrcweir long nRetZoom = 100; 514cdf0e10cSrcweir 515cdf0e10cSrcweir if( (rZoomRect.GetWidth() != 0) && (rZoomRect.GetHeight() != 0)) 516cdf0e10cSrcweir { 517cdf0e10cSrcweir // Calculate the scale factors which will lead to the given 518cdf0e10cSrcweir // rectangle being fully visible (when translated accordingly) as 519cdf0e10cSrcweir // large as possible in the output area independently in both 520cdf0e10cSrcweir // coordinate directions . 521cdf0e10cSrcweir sal_uLong nX(0L); 522cdf0e10cSrcweir sal_uLong nY(0L); 523cdf0e10cSrcweir 524cdf0e10cSrcweir const Size aWinSize( PixelToLogic(GetOutputSizePixel()) ); 525cdf0e10cSrcweir if(rZoomRect.GetHeight()) 526cdf0e10cSrcweir { 527cdf0e10cSrcweir nX = (sal_uLong) ((double) aWinSize.Height() 528cdf0e10cSrcweir * (double) ZOOM_MULTIPLICATOR / (double) rZoomRect.GetHeight()); 529cdf0e10cSrcweir } 530cdf0e10cSrcweir 531cdf0e10cSrcweir if(rZoomRect.GetWidth()) 532cdf0e10cSrcweir { 533cdf0e10cSrcweir nY = (sal_uLong) ((double) aWinSize.Width() 534cdf0e10cSrcweir * (double) ZOOM_MULTIPLICATOR / (double) rZoomRect.GetWidth()); 535cdf0e10cSrcweir } 536cdf0e10cSrcweir 537cdf0e10cSrcweir // Use the smaller one of both so that the zoom rectangle will be 538cdf0e10cSrcweir // fully visible with respect to both coordinate directions. 539cdf0e10cSrcweir sal_uLong nFact = Min(nX, nY); 540cdf0e10cSrcweir 541cdf0e10cSrcweir // Transform the current zoom factor so that it leads to the desired 542cdf0e10cSrcweir // scaling. 543cdf0e10cSrcweir nRetZoom = nFact * GetZoom() / ZOOM_MULTIPLICATOR; 544cdf0e10cSrcweir 545cdf0e10cSrcweir // Calculate the new origin. 546cdf0e10cSrcweir if ( nFact == 0 ) 547cdf0e10cSrcweir { 548cdf0e10cSrcweir // Don't change anything if the scale factor is degenrate. 549cdf0e10cSrcweir nRetZoom = GetZoom(); 550cdf0e10cSrcweir } 551cdf0e10cSrcweir else 552cdf0e10cSrcweir { 553cdf0e10cSrcweir // Clip the zoom factor to the valid range marked by nMinZoom as 554cdf0e10cSrcweir // previously calculated by <member>CalcMinZoom()</member> and the 555cdf0e10cSrcweir // MAX_ZOOM constant. 556cdf0e10cSrcweir if ( nRetZoom > MAX_ZOOM ) 557cdf0e10cSrcweir nRetZoom = MAX_ZOOM; 558cdf0e10cSrcweir if ( nRetZoom < (long) mnMinZoom ) 559cdf0e10cSrcweir nRetZoom = mnMinZoom; 560cdf0e10cSrcweir } 561cdf0e10cSrcweir } 562cdf0e10cSrcweir 563cdf0e10cSrcweir return nRetZoom; 564cdf0e10cSrcweir } 565cdf0e10cSrcweir 566cdf0e10cSrcweir /** Recalculate the zoom factor and translation so that the given rectangle 567cdf0e10cSrcweir is displayed centered and as large as possible while still being fully 568cdf0e10cSrcweir visible in the window. 569cdf0e10cSrcweir */ 570cdf0e10cSrcweir long Window::SetZoomRect (const Rectangle& rZoomRect) 571cdf0e10cSrcweir { 572cdf0e10cSrcweir long nNewZoom = 100; 573cdf0e10cSrcweir 574cdf0e10cSrcweir if (rZoomRect.GetWidth() == 0 || rZoomRect.GetHeight() == 0) 575cdf0e10cSrcweir { 576cdf0e10cSrcweir // The given rectangle is degenerate. Use the default zoom factor 577cdf0e10cSrcweir // (above) of 100%. 578cdf0e10cSrcweir SetZoomIntegral(nNewZoom); 579cdf0e10cSrcweir } 580cdf0e10cSrcweir else 581cdf0e10cSrcweir { 582cdf0e10cSrcweir Point aPos = rZoomRect.TopLeft(); 583cdf0e10cSrcweir // Transform the output area from pixel coordinates into logical 584cdf0e10cSrcweir // coordinates. 585cdf0e10cSrcweir Size aWinSize = PixelToLogic(GetOutputSizePixel()); 586cdf0e10cSrcweir // Paranoia! The degenerate case of zero width or height has been 587cdf0e10cSrcweir // taken care of above. 588cdf0e10cSrcweir DBG_ASSERT(rZoomRect.GetWidth(), "ZoomRect-Breite = 0!"); 589cdf0e10cSrcweir DBG_ASSERT(rZoomRect.GetHeight(), "ZoomRect-Hoehe = 0!"); 590cdf0e10cSrcweir 591cdf0e10cSrcweir // Calculate the scale factors which will lead to the given 592cdf0e10cSrcweir // rectangle being fully visible (when translated accordingly) as 593cdf0e10cSrcweir // large as possible in the output area independently in both 594cdf0e10cSrcweir // coordinate directions . 595cdf0e10cSrcweir sal_uLong nX(0L); 596cdf0e10cSrcweir sal_uLong nY(0L); 597cdf0e10cSrcweir 598cdf0e10cSrcweir if(rZoomRect.GetHeight()) 599cdf0e10cSrcweir { 600cdf0e10cSrcweir nX = (sal_uLong) ((double) aWinSize.Height() 601cdf0e10cSrcweir * (double) ZOOM_MULTIPLICATOR / (double) rZoomRect.GetHeight()); 602cdf0e10cSrcweir } 603cdf0e10cSrcweir 604cdf0e10cSrcweir if(rZoomRect.GetWidth()) 605cdf0e10cSrcweir { 606cdf0e10cSrcweir nY = (sal_uLong) ((double) aWinSize.Width() 607cdf0e10cSrcweir * (double) ZOOM_MULTIPLICATOR / (double) rZoomRect.GetWidth()); 608cdf0e10cSrcweir } 609cdf0e10cSrcweir 610cdf0e10cSrcweir // Use the smaller one of both so that the zoom rectangle will be 611cdf0e10cSrcweir // fully visible with respect to both coordinate directions. 612cdf0e10cSrcweir sal_uLong nFact = Min(nX, nY); 613cdf0e10cSrcweir 614cdf0e10cSrcweir // Transform the current zoom factor so that it leads to the desired 615cdf0e10cSrcweir // scaling. 616cdf0e10cSrcweir long nZoom = nFact * GetZoom() / ZOOM_MULTIPLICATOR; 617cdf0e10cSrcweir 618cdf0e10cSrcweir // Calculate the new origin. 619cdf0e10cSrcweir if ( nFact == 0 ) 620cdf0e10cSrcweir { 621cdf0e10cSrcweir // Don't change anything if the scale factor is degenrate. 622cdf0e10cSrcweir nNewZoom = GetZoom(); 623cdf0e10cSrcweir } 624cdf0e10cSrcweir else 625cdf0e10cSrcweir { 626cdf0e10cSrcweir // Calculate the new window position that centers the given 627cdf0e10cSrcweir // rectangle on the screen. 628cdf0e10cSrcweir if ( nZoom > MAX_ZOOM ) 629cdf0e10cSrcweir nFact = nFact * MAX_ZOOM / nZoom; 630cdf0e10cSrcweir 631cdf0e10cSrcweir maWinPos = maViewOrigin + aPos; 632cdf0e10cSrcweir 633cdf0e10cSrcweir aWinSize.Width() = (long) ((double) aWinSize.Width() * (double) ZOOM_MULTIPLICATOR / (double) nFact); 634cdf0e10cSrcweir maWinPos.X() += (rZoomRect.GetWidth() - aWinSize.Width()) / 2; 635cdf0e10cSrcweir aWinSize.Height() = (long) ((double) aWinSize.Height() * (double) ZOOM_MULTIPLICATOR / (double) nFact); 636cdf0e10cSrcweir maWinPos.Y() += (rZoomRect.GetHeight() - aWinSize.Height()) / 2; 637cdf0e10cSrcweir 638cdf0e10cSrcweir if ( maWinPos.X() < 0 ) maWinPos.X() = 0; 639cdf0e10cSrcweir if ( maWinPos.Y() < 0 ) maWinPos.Y() = 0; 640cdf0e10cSrcweir 641cdf0e10cSrcweir // Adapt the window's map mode to the new zoom factor. 642cdf0e10cSrcweir nNewZoom = SetZoomFactor(nZoom); 643cdf0e10cSrcweir } 644cdf0e10cSrcweir } 645cdf0e10cSrcweir 646cdf0e10cSrcweir return(nNewZoom); 647cdf0e10cSrcweir } 648cdf0e10cSrcweir 649cdf0e10cSrcweir 650cdf0e10cSrcweir 651cdf0e10cSrcweir 652cdf0e10cSrcweir void Window::SetMinZoomAutoCalc (bool bAuto) 653cdf0e10cSrcweir { 654cdf0e10cSrcweir mbMinZoomAutoCalc = bAuto; 655cdf0e10cSrcweir } 656cdf0e10cSrcweir 657cdf0e10cSrcweir 658cdf0e10cSrcweir 659cdf0e10cSrcweir 660cdf0e10cSrcweir /************************************************************************* 661cdf0e10cSrcweir |* 662cdf0e10cSrcweir |* Neuen MapMode-Origin berechnen und setzen; wenn aWinPos.X()/Y() 663cdf0e10cSrcweir |* gleich -1 ist, wird die entsprechende Position zentriert 664cdf0e10cSrcweir |* (z.B. fuer Initialisierung) 665cdf0e10cSrcweir |* 666cdf0e10cSrcweir \************************************************************************/ 667cdf0e10cSrcweir 668cdf0e10cSrcweir void Window::UpdateMapOrigin(sal_Bool bInvalidate) 669cdf0e10cSrcweir { 670cdf0e10cSrcweir sal_Bool bChanged = sal_False; 671cdf0e10cSrcweir Size aWinSize = PixelToLogic(GetOutputSizePixel()); 672cdf0e10cSrcweir 673cdf0e10cSrcweir if ( mbCenterAllowed ) 674cdf0e10cSrcweir { 675cdf0e10cSrcweir if ( maWinPos.X() > maViewSize.Width() - aWinSize.Width() ) 676cdf0e10cSrcweir { 677cdf0e10cSrcweir maWinPos.X() = maViewSize.Width() - aWinSize.Width(); 678cdf0e10cSrcweir bChanged = sal_True; 679cdf0e10cSrcweir } 680cdf0e10cSrcweir if ( maWinPos.Y() > maViewSize.Height() - aWinSize.Height() ) 681cdf0e10cSrcweir { 682cdf0e10cSrcweir maWinPos.Y() = maViewSize.Height() - aWinSize.Height(); 683cdf0e10cSrcweir bChanged = sal_True; 684cdf0e10cSrcweir } 685cdf0e10cSrcweir if ( aWinSize.Width() > maViewSize.Width() || maWinPos.X() < 0 ) 686cdf0e10cSrcweir { 687cdf0e10cSrcweir maWinPos.X() = maViewSize.Width() / 2 - aWinSize.Width() / 2; 688cdf0e10cSrcweir bChanged = sal_True; 689cdf0e10cSrcweir } 690cdf0e10cSrcweir if ( aWinSize.Height() > maViewSize.Height() || maWinPos.Y() < 0 ) 691cdf0e10cSrcweir { 692cdf0e10cSrcweir maWinPos.Y() = maViewSize.Height() / 2 - aWinSize.Height() / 2; 693cdf0e10cSrcweir bChanged = sal_True; 694cdf0e10cSrcweir } 695cdf0e10cSrcweir } 696cdf0e10cSrcweir 697cdf0e10cSrcweir UpdateMapMode (); 698cdf0e10cSrcweir 699cdf0e10cSrcweir if (bChanged && bInvalidate) 700cdf0e10cSrcweir Invalidate(); 701cdf0e10cSrcweir } 702cdf0e10cSrcweir 703cdf0e10cSrcweir 704cdf0e10cSrcweir 705cdf0e10cSrcweir 706cdf0e10cSrcweir void Window::UpdateMapMode (void) 707cdf0e10cSrcweir { 708cdf0e10cSrcweir Size aWinSize = PixelToLogic(GetOutputSizePixel()); 709cdf0e10cSrcweir maWinPos -= maViewOrigin; 710cdf0e10cSrcweir Size aPix(maWinPos.X(), maWinPos.Y()); 711cdf0e10cSrcweir aPix = LogicToPixel(aPix); 712cdf0e10cSrcweir // Groesse muss vielfaches von BRUSH_SIZE sein, damit Muster 713cdf0e10cSrcweir // richtig dargestellt werden 714cdf0e10cSrcweir // #i2237# 715cdf0e10cSrcweir // removed old stuff here which still forced zoom to be 716cdf0e10cSrcweir // %BRUSH_SIZE which is outdated now 717cdf0e10cSrcweir 718cdf0e10cSrcweir if (mpViewShell && mpViewShell->ISA(DrawViewShell)) 719cdf0e10cSrcweir { 720cdf0e10cSrcweir Size aViewSizePixel = LogicToPixel(maViewSize); 721cdf0e10cSrcweir Size aWinSizePixel = LogicToPixel(aWinSize); 722cdf0e10cSrcweir 723cdf0e10cSrcweir // Seite soll nicht am Fensterrand "kleben" 724cdf0e10cSrcweir if (aPix.Width() == 0) 725cdf0e10cSrcweir { 726cdf0e10cSrcweir // #i2237# 727cdf0e10cSrcweir // Since BRUSH_SIZE alignment is outdated now, i use the 728cdf0e10cSrcweir // former constant here directly 729cdf0e10cSrcweir aPix.Width() -= 8; 730cdf0e10cSrcweir } 731cdf0e10cSrcweir if (aPix.Height() == 0) 732cdf0e10cSrcweir { 733cdf0e10cSrcweir // #i2237# 734cdf0e10cSrcweir // Since BRUSH_SIZE alignment is outdated now, i use the 735cdf0e10cSrcweir // former constant here directly 736cdf0e10cSrcweir aPix.Height() -= 8; 737cdf0e10cSrcweir } 738cdf0e10cSrcweir } 739cdf0e10cSrcweir 740cdf0e10cSrcweir aPix = PixelToLogic(aPix); 741cdf0e10cSrcweir maWinPos.X() = aPix.Width(); 742cdf0e10cSrcweir maWinPos.Y() = aPix.Height(); 743cdf0e10cSrcweir Point aNewOrigin (-maWinPos.X(), -maWinPos.Y()); 744cdf0e10cSrcweir maWinPos += maViewOrigin; 745cdf0e10cSrcweir 746cdf0e10cSrcweir MapMode aMap(GetMapMode()); 747cdf0e10cSrcweir aMap.SetOrigin(aNewOrigin); 748cdf0e10cSrcweir SetMapMode(aMap); 749cdf0e10cSrcweir } 750cdf0e10cSrcweir 751cdf0e10cSrcweir 752cdf0e10cSrcweir 753cdf0e10cSrcweir 754cdf0e10cSrcweir /************************************************************************* 755cdf0e10cSrcweir |* 756cdf0e10cSrcweir |* X-Position des sichtbaren Bereichs als Bruchteil (< 1) 757cdf0e10cSrcweir |* der gesamten Arbeitsbereichbreite zuruegeben 758cdf0e10cSrcweir |* 759cdf0e10cSrcweir \************************************************************************/ 760cdf0e10cSrcweir 761cdf0e10cSrcweir double Window::GetVisibleX() 762cdf0e10cSrcweir { 763cdf0e10cSrcweir return ((double) maWinPos.X() / maViewSize.Width()); 764cdf0e10cSrcweir } 765cdf0e10cSrcweir 766cdf0e10cSrcweir /************************************************************************* 767cdf0e10cSrcweir |* 768cdf0e10cSrcweir |* Y-Position des sichtbaren Bereichs als Bruchteil (< 1) 769cdf0e10cSrcweir |* der gesamten Arbeitsbereichhoehe zuruegeben 770cdf0e10cSrcweir |* 771cdf0e10cSrcweir \************************************************************************/ 772cdf0e10cSrcweir 773cdf0e10cSrcweir double Window::GetVisibleY() 774cdf0e10cSrcweir { 775cdf0e10cSrcweir return ((double) maWinPos.Y() / maViewSize.Height()); 776cdf0e10cSrcweir } 777cdf0e10cSrcweir 778cdf0e10cSrcweir /************************************************************************* 779cdf0e10cSrcweir |* 780cdf0e10cSrcweir |* X- und Y-Position des sichtbaren Bereichs als Bruchteile (< 1) 781cdf0e10cSrcweir |* der gesamten Arbeitsbereichgroesse setzen 782cdf0e10cSrcweir |* negative Werte werden ignoriert 783cdf0e10cSrcweir |* 784cdf0e10cSrcweir \************************************************************************/ 785cdf0e10cSrcweir 786cdf0e10cSrcweir void Window::SetVisibleXY(double fX, double fY) 787cdf0e10cSrcweir { 788cdf0e10cSrcweir long nOldX = maWinPos.X(); 789cdf0e10cSrcweir long nOldY = maWinPos.Y(); 790cdf0e10cSrcweir 791cdf0e10cSrcweir if ( fX >= 0 ) 792cdf0e10cSrcweir maWinPos.X() = (long) (fX * maViewSize.Width()); 793cdf0e10cSrcweir if ( fY >= 0 ) 794cdf0e10cSrcweir maWinPos.Y() = (long) (fY * maViewSize.Height()); 795cdf0e10cSrcweir UpdateMapOrigin(sal_False); 796cdf0e10cSrcweir // Size sz(nOldX - aWinPos.X(), nOldY - aWinPos.Y()); 797cdf0e10cSrcweir // sz = LogicToPixel(sz); 798cdf0e10cSrcweir Scroll(nOldX - maWinPos.X(), nOldY - maWinPos.Y(), SCROLL_CHILDREN); 799cdf0e10cSrcweir Update(); 800cdf0e10cSrcweir } 801cdf0e10cSrcweir 802cdf0e10cSrcweir /************************************************************************* 803cdf0e10cSrcweir |* 804cdf0e10cSrcweir |* Breite des sichtbaren Bereichs im Verhaeltnis zur 805cdf0e10cSrcweir |* gesamten Arbeitsbereichbreite zuruegeben 806cdf0e10cSrcweir |* 807cdf0e10cSrcweir \************************************************************************/ 808cdf0e10cSrcweir 809cdf0e10cSrcweir double Window::GetVisibleWidth() 810cdf0e10cSrcweir { 811cdf0e10cSrcweir Size aWinSize = PixelToLogic(GetOutputSizePixel()); 812cdf0e10cSrcweir if ( aWinSize.Width() > maViewSize.Width() ) 813cdf0e10cSrcweir aWinSize.Width() = maViewSize.Width(); 814cdf0e10cSrcweir return ((double) aWinSize.Width() / maViewSize.Width()); 815cdf0e10cSrcweir } 816cdf0e10cSrcweir 817cdf0e10cSrcweir /************************************************************************* 818cdf0e10cSrcweir |* 819cdf0e10cSrcweir |* Hoehe des sichtbaren Bereichs im Verhaeltnis zur 820cdf0e10cSrcweir |* gesamten Arbeitsbereichhoehe zuruegeben 821cdf0e10cSrcweir |* 822cdf0e10cSrcweir \************************************************************************/ 823cdf0e10cSrcweir 824cdf0e10cSrcweir double Window::GetVisibleHeight() 825cdf0e10cSrcweir { 826cdf0e10cSrcweir Size aWinSize = PixelToLogic(GetOutputSizePixel()); 827cdf0e10cSrcweir if ( aWinSize.Height() > maViewSize.Height() ) 828cdf0e10cSrcweir aWinSize.Height() = maViewSize.Height(); 829cdf0e10cSrcweir return ((double) aWinSize.Height() / maViewSize.Height()); 830cdf0e10cSrcweir } 831cdf0e10cSrcweir 832cdf0e10cSrcweir /************************************************************************* 833cdf0e10cSrcweir |* 834cdf0e10cSrcweir |* Breite einer Scrollspalte im Verhaeltnis zur gesamten 835cdf0e10cSrcweir |* Arbeitsbereichbreite zuruegeben 836cdf0e10cSrcweir |* 837cdf0e10cSrcweir \************************************************************************/ 838cdf0e10cSrcweir 839cdf0e10cSrcweir double Window::GetScrlLineWidth() 840cdf0e10cSrcweir { 841cdf0e10cSrcweir return (GetVisibleWidth() * SCROLL_LINE_FACT); 842cdf0e10cSrcweir } 843cdf0e10cSrcweir 844cdf0e10cSrcweir /************************************************************************* 845cdf0e10cSrcweir |* 846cdf0e10cSrcweir |* Breite einer Scrollspalte im Verhaeltnis zur gesamten 847cdf0e10cSrcweir |* Arbeitsbereichhoehe zuruegeben 848cdf0e10cSrcweir |* 849cdf0e10cSrcweir \************************************************************************/ 850cdf0e10cSrcweir 851cdf0e10cSrcweir double Window::GetScrlLineHeight() 852cdf0e10cSrcweir { 853cdf0e10cSrcweir return (GetVisibleHeight() * SCROLL_LINE_FACT); 854cdf0e10cSrcweir } 855cdf0e10cSrcweir 856cdf0e10cSrcweir /************************************************************************* 857cdf0e10cSrcweir |* 858cdf0e10cSrcweir |* Breite einer Scrollpage im Verhaeltnis zur gesamten 859cdf0e10cSrcweir |* Arbeitsbereichbreite zuruegeben 860cdf0e10cSrcweir |* 861cdf0e10cSrcweir \************************************************************************/ 862cdf0e10cSrcweir 863cdf0e10cSrcweir double Window::GetScrlPageWidth() 864cdf0e10cSrcweir { 865cdf0e10cSrcweir return (GetVisibleWidth() * SCROLL_PAGE_FACT); 866cdf0e10cSrcweir } 867cdf0e10cSrcweir 868cdf0e10cSrcweir /************************************************************************* 869cdf0e10cSrcweir |* 870cdf0e10cSrcweir |* Breite einer Scrollpage im Verhaeltnis zur gesamten 871cdf0e10cSrcweir |* Arbeitsbereichhoehe zuruegeben 872cdf0e10cSrcweir |* 873cdf0e10cSrcweir \************************************************************************/ 874cdf0e10cSrcweir 875cdf0e10cSrcweir double Window::GetScrlPageHeight() 876cdf0e10cSrcweir { 877cdf0e10cSrcweir return (GetVisibleHeight() * SCROLL_PAGE_FACT); 878cdf0e10cSrcweir } 879cdf0e10cSrcweir 880cdf0e10cSrcweir /************************************************************************* 881cdf0e10cSrcweir |* 882cdf0e10cSrcweir |* Fenster deaktivieren 883cdf0e10cSrcweir |* 884cdf0e10cSrcweir \************************************************************************/ 885cdf0e10cSrcweir 886cdf0e10cSrcweir void Window::LoseFocus() 887cdf0e10cSrcweir { 888cdf0e10cSrcweir mnTicks = 0; 889cdf0e10cSrcweir ::Window::LoseFocus (); 890cdf0e10cSrcweir } 891cdf0e10cSrcweir 892cdf0e10cSrcweir /************************************************************************* 893cdf0e10cSrcweir |* 894cdf0e10cSrcweir |* Fenster aktivieren 895cdf0e10cSrcweir |* 896cdf0e10cSrcweir \************************************************************************/ 897cdf0e10cSrcweir 898cdf0e10cSrcweir void Window::GrabFocus() 899cdf0e10cSrcweir { 900cdf0e10cSrcweir mnTicks = 0; 901cdf0e10cSrcweir ::Window::GrabFocus (); 902cdf0e10cSrcweir } 903cdf0e10cSrcweir 904cdf0e10cSrcweir 905cdf0e10cSrcweir /************************************************************************* 906cdf0e10cSrcweir |* 907cdf0e10cSrcweir |* DataChanged 908cdf0e10cSrcweir |* 909cdf0e10cSrcweir \************************************************************************/ 910cdf0e10cSrcweir 911cdf0e10cSrcweir void Window::DataChanged( const DataChangedEvent& rDCEvt ) 912cdf0e10cSrcweir { 913cdf0e10cSrcweir ::Window::DataChanged( rDCEvt ); 914cdf0e10cSrcweir 915cdf0e10cSrcweir // PRINTER bei allen Dokumenten weglassen, die keinen Printer benutzen. 916cdf0e10cSrcweir // FONTS und FONTSUBSTITUTION weglassen, wenn keine Textausgaben 917cdf0e10cSrcweir // vorhanden sind, bzw. wenn das Dokument keinen Text zulaesst. 918cdf0e10cSrcweir 919cdf0e10cSrcweir if ( (rDCEvt.GetType() == DATACHANGED_PRINTER) || 920cdf0e10cSrcweir (rDCEvt.GetType() == DATACHANGED_DISPLAY) || 921cdf0e10cSrcweir (rDCEvt.GetType() == DATACHANGED_FONTS) || 922cdf0e10cSrcweir (rDCEvt.GetType() == DATACHANGED_FONTSUBSTITUTION) || 923cdf0e10cSrcweir ((rDCEvt.GetType() == DATACHANGED_SETTINGS) && 924cdf0e10cSrcweir (rDCEvt.GetFlags() & SETTINGS_STYLE)) ) 925cdf0e10cSrcweir { 926cdf0e10cSrcweir if ( (rDCEvt.GetType() == DATACHANGED_SETTINGS) && 927cdf0e10cSrcweir (rDCEvt.GetFlags() & SETTINGS_STYLE) ) 928cdf0e10cSrcweir { 929cdf0e10cSrcweir // When the screen zoom factor has changed then reset the zoom 930cdf0e10cSrcweir // factor of the frame to allways display the whole page. 931cdf0e10cSrcweir const AllSettings* pOldSettings = rDCEvt.GetOldSettings (); 932cdf0e10cSrcweir const AllSettings& rNewSettings = GetSettings (); 933cdf0e10cSrcweir if (pOldSettings) 934cdf0e10cSrcweir if (pOldSettings->GetStyleSettings().GetScreenZoom() 935cdf0e10cSrcweir != rNewSettings.GetStyleSettings().GetScreenZoom()) 936cdf0e10cSrcweir mpViewShell->GetViewFrame()->GetDispatcher()-> 937cdf0e10cSrcweir Execute(SID_SIZE_PAGE, SFX_CALLMODE_ASYNCHRON | SFX_CALLMODE_RECORD); 938cdf0e10cSrcweir 939cdf0e10cSrcweir // ScrollBars neu anordnen bzw. Resize ausloesen, da sich 940cdf0e10cSrcweir // ScrollBar-Groesse geaendert haben kann. Dazu muss dann im 941cdf0e10cSrcweir // Resize-Handler aber auch die Groesse der ScrollBars aus 942cdf0e10cSrcweir // den Settings abgefragt werden. 943cdf0e10cSrcweir Resize(); 944cdf0e10cSrcweir 945cdf0e10cSrcweir // Daten neu Setzen, die aus den Systemeinstellungen bzw. aus 946cdf0e10cSrcweir // den Settings uebernommen werden. Evtl. weitere Daten neu 947cdf0e10cSrcweir // berechnen, da sich auch die Aufloesung hierdurch geaendert 948cdf0e10cSrcweir // haben kann. 949cdf0e10cSrcweir if( mpViewShell ) 950cdf0e10cSrcweir { 951cdf0e10cSrcweir const StyleSettings& rStyleSettings = GetSettings().GetStyleSettings(); 952cdf0e10cSrcweir SvtAccessibilityOptions aAccOptions; 953cdf0e10cSrcweir sal_uLong nOutputMode; 954cdf0e10cSrcweir sal_uInt16 nPreviewSlot; 955cdf0e10cSrcweir 956cdf0e10cSrcweir if( rStyleSettings.GetHighContrastMode() ) 957cdf0e10cSrcweir nOutputMode = ViewShell::OUTPUT_DRAWMODE_CONTRAST; 958cdf0e10cSrcweir else 959cdf0e10cSrcweir nOutputMode = ViewShell::OUTPUT_DRAWMODE_COLOR; 960cdf0e10cSrcweir 961cdf0e10cSrcweir if( rStyleSettings.GetHighContrastMode() && aAccOptions.GetIsForPagePreviews() ) 962cdf0e10cSrcweir nPreviewSlot = SID_PREVIEW_QUALITY_CONTRAST; 963cdf0e10cSrcweir else 964cdf0e10cSrcweir nPreviewSlot = SID_PREVIEW_QUALITY_COLOR; 965cdf0e10cSrcweir 966cdf0e10cSrcweir if( mpViewShell->ISA( DrawViewShell ) ) 967cdf0e10cSrcweir { 968cdf0e10cSrcweir SetDrawMode( nOutputMode ); 969cdf0e10cSrcweir mpViewShell->GetFrameView()->SetDrawMode( nOutputMode ); 970cdf0e10cSrcweir // #110094#-7 971cdf0e10cSrcweir // mpViewShell->GetView()->ReleaseMasterPagePaintCache(); 972cdf0e10cSrcweir Invalidate(); 973cdf0e10cSrcweir } 974cdf0e10cSrcweir 975cdf0e10cSrcweir // #103100# Overwrite window color for OutlineView 976cdf0e10cSrcweir if( mpViewShell->ISA(OutlineViewShell ) ) 977cdf0e10cSrcweir { 978cdf0e10cSrcweir svtools::ColorConfig aColorConfig; 979cdf0e10cSrcweir const Color aDocColor( aColorConfig.GetColorValue( svtools::DOCCOLOR ).nColor ); 980cdf0e10cSrcweir SetBackground( Wallpaper( aDocColor ) ); 981cdf0e10cSrcweir } 982cdf0e10cSrcweir 983cdf0e10cSrcweir SfxRequest aReq( nPreviewSlot, 0, mpViewShell->GetDocSh()->GetDoc()->GetItemPool() ); 984cdf0e10cSrcweir mpViewShell->ExecReq( aReq ); 985cdf0e10cSrcweir mpViewShell->Invalidate(); 986cdf0e10cSrcweir mpViewShell->ArrangeGUIElements(); 987cdf0e10cSrcweir 988cdf0e10cSrcweir // #101928# re-create handles to show new outfit 989cdf0e10cSrcweir if(mpViewShell->ISA(DrawViewShell)) 990cdf0e10cSrcweir { 991cdf0e10cSrcweir mpViewShell->GetView()->AdjustMarkHdl(); 992cdf0e10cSrcweir } 993cdf0e10cSrcweir } 994cdf0e10cSrcweir } 995cdf0e10cSrcweir 996cdf0e10cSrcweir if ( (rDCEvt.GetType() == DATACHANGED_DISPLAY) || 997cdf0e10cSrcweir ((rDCEvt.GetType() == DATACHANGED_SETTINGS) && 998cdf0e10cSrcweir (rDCEvt.GetFlags() & SETTINGS_STYLE)) ) 999cdf0e10cSrcweir { 1000cdf0e10cSrcweir // Virtuelle Device die auch von der Aufloesung oder von 1001cdf0e10cSrcweir // Systemeinstellungen abhaengen, sollten geupdatet werden. 1002cdf0e10cSrcweir // Ansonsten sollte zumindest bei DATACHANGED_DISPLAY 1003cdf0e10cSrcweir // die virtuellen Devices geupdatet werden, da es einige 1004cdf0e10cSrcweir // Systeme erlauben die Aufloesung und Farbtiefe waehrend 1005cdf0e10cSrcweir // der Laufzeit zu aendern oder eben bei Palettenaenderungen 1006cdf0e10cSrcweir // die virtuellen Device geupdatet werden muessen, da bei 1007cdf0e10cSrcweir // Ausgaben ein anderes Farbmatching stattfinden kann. 1008cdf0e10cSrcweir } 1009cdf0e10cSrcweir 1010cdf0e10cSrcweir if ( rDCEvt.GetType() == DATACHANGED_FONTS ) 1011cdf0e10cSrcweir { 1012cdf0e10cSrcweir // Wenn das Dokument Font-AuswahlBoxen anbietet, muessen 1013cdf0e10cSrcweir // diese geupdatet werden. Wie dies genau aussehen muss, 1014cdf0e10cSrcweir // weiss ich leider auch nicht. Aber evtl. kann man das 1015cdf0e10cSrcweir // ja global handeln. Dies muessten wir evtl. mal 1016cdf0e10cSrcweir // mit PB absprechen, aber der ist derzeit leider Krank. 1017cdf0e10cSrcweir // Also bevor dies hier gehandelt wird, vorher mit 1018cdf0e10cSrcweir // PB und mir absprechen. 1019cdf0e10cSrcweir } 1020cdf0e10cSrcweir 1021cdf0e10cSrcweir if ( (rDCEvt.GetType() == DATACHANGED_FONTS) || 1022cdf0e10cSrcweir (rDCEvt.GetType() == DATACHANGED_FONTSUBSTITUTION) ) 1023cdf0e10cSrcweir { 1024cdf0e10cSrcweir // Formatierung neu durchfuehren, da Fonts die im Dokument 1025cdf0e10cSrcweir // vorkommen, nicht mehr vorhanden sein muessen oder 1026cdf0e10cSrcweir // jetzt vorhanden sind oder durch andere ersetzt wurden 1027cdf0e10cSrcweir // sind. 1028cdf0e10cSrcweir if( mpViewShell ) 1029cdf0e10cSrcweir { 1030cdf0e10cSrcweir DrawDocShell* pDocSh = mpViewShell->GetDocSh(); 1031cdf0e10cSrcweir if( pDocSh ) 1032cdf0e10cSrcweir pDocSh->SetPrinter( pDocSh->GetPrinter( sal_True ) ); 1033cdf0e10cSrcweir } 1034cdf0e10cSrcweir } 1035cdf0e10cSrcweir 1036cdf0e10cSrcweir if ( rDCEvt.GetType() == DATACHANGED_PRINTER ) 1037cdf0e10cSrcweir { 1038cdf0e10cSrcweir // Wie hier die Behandlung aussehen soll, weiss ich leider 1039cdf0e10cSrcweir // selbst noch nicht. Evtl. mal einen Printer loeschen und 1040cdf0e10cSrcweir // schauen was gemacht werden muss. Evtl. muesste ich in 1041cdf0e10cSrcweir // VCL dafuer noch etwas einbauen, wenn der benutze Printer 1042cdf0e10cSrcweir // geloescht wird. Ansonsten wuerde ich hier evtl. die 1043cdf0e10cSrcweir // Formatierung neu berechnen, wenn der aktuelle Drucker 1044cdf0e10cSrcweir // zerstoert wurde. 1045cdf0e10cSrcweir if( mpViewShell ) 1046cdf0e10cSrcweir { 1047cdf0e10cSrcweir DrawDocShell* pDocSh = mpViewShell->GetDocSh(); 1048cdf0e10cSrcweir if( pDocSh ) 1049cdf0e10cSrcweir pDocSh->SetPrinter( pDocSh->GetPrinter( sal_True ) ); 1050cdf0e10cSrcweir } 1051cdf0e10cSrcweir } 1052cdf0e10cSrcweir 1053cdf0e10cSrcweir // Alles neu ausgeben 1054cdf0e10cSrcweir Invalidate(); 1055cdf0e10cSrcweir } 1056cdf0e10cSrcweir } 1057cdf0e10cSrcweir 1058cdf0e10cSrcweir 1059cdf0e10cSrcweir 1060cdf0e10cSrcweir 1061cdf0e10cSrcweir /************************************************************************* 1062cdf0e10cSrcweir |* 1063cdf0e10cSrcweir |* DropTargetHelper::AcceptDrop 1064cdf0e10cSrcweir |* 1065cdf0e10cSrcweir \************************************************************************/ 1066cdf0e10cSrcweir 1067cdf0e10cSrcweir sal_Int8 Window::AcceptDrop( const AcceptDropEvent& rEvt ) 1068cdf0e10cSrcweir { 1069cdf0e10cSrcweir sal_Int8 nRet = DND_ACTION_NONE; 1070cdf0e10cSrcweir 1071cdf0e10cSrcweir if( mpViewShell && !mpViewShell->GetDocSh()->IsReadOnly() ) 1072cdf0e10cSrcweir { 1073cdf0e10cSrcweir if( mpViewShell ) 1074cdf0e10cSrcweir nRet = mpViewShell->AcceptDrop( rEvt, *this, this, SDRPAGE_NOTFOUND, SDRLAYER_NOTFOUND ); 1075cdf0e10cSrcweir 1076cdf0e10cSrcweir if (mbUseDropScroll && ! mpViewShell->ISA(OutlineViewShell)) 1077cdf0e10cSrcweir DropScroll( rEvt.maPosPixel ); 1078cdf0e10cSrcweir } 1079cdf0e10cSrcweir 1080cdf0e10cSrcweir return nRet; 1081cdf0e10cSrcweir } 1082cdf0e10cSrcweir 1083cdf0e10cSrcweir /************************************************************************* 1084cdf0e10cSrcweir |* 1085cdf0e10cSrcweir |* DropTargetHelper::ExecuteDrop 1086cdf0e10cSrcweir |* 1087cdf0e10cSrcweir \************************************************************************/ 1088cdf0e10cSrcweir 1089cdf0e10cSrcweir sal_Int8 Window::ExecuteDrop( const ExecuteDropEvent& rEvt ) 1090cdf0e10cSrcweir { 1091cdf0e10cSrcweir sal_Int8 nRet = DND_ACTION_NONE; 1092cdf0e10cSrcweir 1093cdf0e10cSrcweir if( mpViewShell ) 1094cdf0e10cSrcweir { 1095cdf0e10cSrcweir nRet = mpViewShell->ExecuteDrop( rEvt, *this, this, SDRPAGE_NOTFOUND, SDRLAYER_NOTFOUND ); 1096cdf0e10cSrcweir } 1097cdf0e10cSrcweir 1098cdf0e10cSrcweir return nRet; 1099cdf0e10cSrcweir } 1100cdf0e10cSrcweir 1101cdf0e10cSrcweir 1102cdf0e10cSrcweir 1103cdf0e10cSrcweir 1104cdf0e10cSrcweir void Window::SetUseDropScroll (bool bUseDropScroll) 1105cdf0e10cSrcweir { 1106cdf0e10cSrcweir mbUseDropScroll = bUseDropScroll; 1107cdf0e10cSrcweir } 1108cdf0e10cSrcweir 1109cdf0e10cSrcweir 1110cdf0e10cSrcweir 1111cdf0e10cSrcweir 1112cdf0e10cSrcweir /************************************************************************* 1113cdf0e10cSrcweir |* 1114cdf0e10cSrcweir |* Scrolling bei AcceptDrop-Events 1115cdf0e10cSrcweir |* 1116cdf0e10cSrcweir \************************************************************************/ 1117cdf0e10cSrcweir 1118cdf0e10cSrcweir void Window::DropScroll(const Point& rMousePos) 1119cdf0e10cSrcweir { 1120cdf0e10cSrcweir short nDx = 0; 1121cdf0e10cSrcweir short nDy = 0; 1122cdf0e10cSrcweir 1123cdf0e10cSrcweir Size aSize = GetOutputSizePixel(); 1124cdf0e10cSrcweir 1125cdf0e10cSrcweir if (aSize.Width() > SCROLL_SENSITIVE * 3) 1126cdf0e10cSrcweir { 1127cdf0e10cSrcweir if ( rMousePos.X() < SCROLL_SENSITIVE ) 1128cdf0e10cSrcweir { 1129cdf0e10cSrcweir nDx = -1; 1130cdf0e10cSrcweir } 1131cdf0e10cSrcweir 1132cdf0e10cSrcweir if ( rMousePos.X() >= aSize.Width() - SCROLL_SENSITIVE ) 1133cdf0e10cSrcweir { 1134cdf0e10cSrcweir nDx = 1; 1135cdf0e10cSrcweir } 1136cdf0e10cSrcweir } 1137cdf0e10cSrcweir 1138cdf0e10cSrcweir if (aSize.Height() > SCROLL_SENSITIVE * 3) 1139cdf0e10cSrcweir { 1140cdf0e10cSrcweir if ( rMousePos.Y() < SCROLL_SENSITIVE ) 1141cdf0e10cSrcweir { 1142cdf0e10cSrcweir nDy = -1; 1143cdf0e10cSrcweir } 1144cdf0e10cSrcweir 1145cdf0e10cSrcweir if ( rMousePos.Y() >= aSize.Height() - SCROLL_SENSITIVE ) 1146cdf0e10cSrcweir { 1147cdf0e10cSrcweir nDy = 1; 1148cdf0e10cSrcweir } 1149cdf0e10cSrcweir } 1150cdf0e10cSrcweir 1151cdf0e10cSrcweir if ( (nDx || nDy) && (rMousePos.X()!=0 || rMousePos.Y()!=0 ) ) 1152cdf0e10cSrcweir { 1153cdf0e10cSrcweir if (mnTicks > 20) 1154cdf0e10cSrcweir mpViewShell->ScrollLines(nDx, nDy); 1155cdf0e10cSrcweir else 1156cdf0e10cSrcweir mnTicks ++; 1157cdf0e10cSrcweir } 1158cdf0e10cSrcweir } 1159cdf0e10cSrcweir 1160cdf0e10cSrcweir 1161cdf0e10cSrcweir 1162cdf0e10cSrcweir 1163cdf0e10cSrcweir ::com::sun::star::uno::Reference< 1164cdf0e10cSrcweir ::com::sun::star::accessibility::XAccessible> 1165cdf0e10cSrcweir Window::CreateAccessible (void) 1166cdf0e10cSrcweir { 1167*0deba7fbSSteve Yin //IAccessibility2 Implementation 2009----- 1168*0deba7fbSSteve Yin // If current viewshell is PresentationViewShell, just return empty because the correct ShowWin will be created later. 1169*0deba7fbSSteve Yin if (mpViewShell && mpViewShell->ISA(PresentationViewShell)) 1170*0deba7fbSSteve Yin { 1171*0deba7fbSSteve Yin return ::Window::CreateAccessible (); 1172*0deba7fbSSteve Yin } 1173*0deba7fbSSteve Yin ::com::sun::star::uno::Reference< ::com::sun::star::accessibility::XAccessible > xAcc = GetAccessible(sal_False); 1174*0deba7fbSSteve Yin if (xAcc.get()) 1175*0deba7fbSSteve Yin { 1176*0deba7fbSSteve Yin return xAcc; 1177*0deba7fbSSteve Yin } 1178cdf0e10cSrcweir if (mpViewShell != NULL) 1179*0deba7fbSSteve Yin //return mpViewShell->CreateAccessibleDocumentView (this); 1180*0deba7fbSSteve Yin { 1181*0deba7fbSSteve Yin xAcc = mpViewShell->CreateAccessibleDocumentView (this); 1182*0deba7fbSSteve Yin SetAccessible(xAcc); 1183*0deba7fbSSteve Yin return xAcc; 1184*0deba7fbSSteve Yin } 1185*0deba7fbSSteve Yin //-----IAccessibility2 Implementation 2009 1186cdf0e10cSrcweir else 1187cdf0e10cSrcweir { 1188cdf0e10cSrcweir OSL_TRACE ("::sd::Window::CreateAccessible: no view shell"); 1189cdf0e10cSrcweir return ::Window::CreateAccessible (); 1190cdf0e10cSrcweir } 1191cdf0e10cSrcweir } 1192cdf0e10cSrcweir 1193*0deba7fbSSteve Yin //IAccessibility2 Implementation 2009----- 1194*0deba7fbSSteve Yin // MT: Removed Windows::SwitchView() introduced with IA2 CWS. 1195*0deba7fbSSteve Yin // There are other notifications for this when the active view has chnaged, so please update the code to use that event mechanism 1196*0deba7fbSSteve Yin void Window::SwitchView() 1197*0deba7fbSSteve Yin { 1198*0deba7fbSSteve Yin if (!Application::IsAccessibilityEnabled()) 1199*0deba7fbSSteve Yin { 1200*0deba7fbSSteve Yin return ; 1201*0deba7fbSSteve Yin } 1202*0deba7fbSSteve Yin if (mpViewShell) 1203*0deba7fbSSteve Yin { 1204*0deba7fbSSteve Yin mpViewShell->SwitchViewFireFocus(GetAccessible(sal_False)); 1205*0deba7fbSSteve Yin } 1206*0deba7fbSSteve Yin } 1207*0deba7fbSSteve Yin //-----IAccessibility2 Implementation 2009 1208*0deba7fbSSteve Yin 1209cdf0e10cSrcweir XubString Window::GetSurroundingText() const 1210cdf0e10cSrcweir { 1211cdf0e10cSrcweir if ( mpViewShell->GetShellType() == ViewShell::ST_OUTLINE ) 1212cdf0e10cSrcweir { 1213cdf0e10cSrcweir return XubString(); 1214cdf0e10cSrcweir } 1215cdf0e10cSrcweir else if ( mpViewShell->GetView()->IsTextEdit() ) 1216cdf0e10cSrcweir { 1217cdf0e10cSrcweir OutlinerView *pOLV = mpViewShell->GetView()->GetTextEditOutlinerView(); 1218cdf0e10cSrcweir return pOLV->GetEditView().GetSurroundingText(); 1219cdf0e10cSrcweir } 1220cdf0e10cSrcweir else 1221cdf0e10cSrcweir { 1222cdf0e10cSrcweir return XubString(); 1223cdf0e10cSrcweir } 1224cdf0e10cSrcweir } 1225cdf0e10cSrcweir 1226cdf0e10cSrcweir Selection Window::GetSurroundingTextSelection() const 1227cdf0e10cSrcweir { 1228cdf0e10cSrcweir if ( mpViewShell->GetShellType() == ViewShell::ST_OUTLINE ) 1229cdf0e10cSrcweir { 1230cdf0e10cSrcweir return Selection( 0, 0 ); 1231cdf0e10cSrcweir } 1232cdf0e10cSrcweir else if ( mpViewShell->GetView()->IsTextEdit() ) 1233cdf0e10cSrcweir { 1234cdf0e10cSrcweir OutlinerView *pOLV = mpViewShell->GetView()->GetTextEditOutlinerView(); 1235cdf0e10cSrcweir return pOLV->GetEditView().GetSurroundingTextSelection(); 1236cdf0e10cSrcweir } 1237cdf0e10cSrcweir else 1238cdf0e10cSrcweir { 1239cdf0e10cSrcweir return Selection( 0, 0 ); 1240cdf0e10cSrcweir } 1241cdf0e10cSrcweir } 1242cdf0e10cSrcweir 1243cdf0e10cSrcweir } // end of namespace sd 1244