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