1*cdf0e10cSrcweir /************************************************************************* 2*cdf0e10cSrcweir * 3*cdf0e10cSrcweir * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 4*cdf0e10cSrcweir * 5*cdf0e10cSrcweir * Copyright 2000, 2010 Oracle and/or its affiliates. 6*cdf0e10cSrcweir * 7*cdf0e10cSrcweir * OpenOffice.org - a multi-platform office productivity suite 8*cdf0e10cSrcweir * 9*cdf0e10cSrcweir * This file is part of OpenOffice.org. 10*cdf0e10cSrcweir * 11*cdf0e10cSrcweir * OpenOffice.org is free software: you can redistribute it and/or modify 12*cdf0e10cSrcweir * it under the terms of the GNU Lesser General Public License version 3 13*cdf0e10cSrcweir * only, as published by the Free Software Foundation. 14*cdf0e10cSrcweir * 15*cdf0e10cSrcweir * OpenOffice.org is distributed in the hope that it will be useful, 16*cdf0e10cSrcweir * but WITHOUT ANY WARRANTY; without even the implied warranty of 17*cdf0e10cSrcweir * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 18*cdf0e10cSrcweir * GNU Lesser General Public License version 3 for more details 19*cdf0e10cSrcweir * (a copy is included in the LICENSE file that accompanied this code). 20*cdf0e10cSrcweir * 21*cdf0e10cSrcweir * You should have received a copy of the GNU Lesser General Public License 22*cdf0e10cSrcweir * version 3 along with OpenOffice.org. If not, see 23*cdf0e10cSrcweir * <http://www.openoffice.org/license.html> 24*cdf0e10cSrcweir * for a copy of the LGPLv3 License. 25*cdf0e10cSrcweir * 26*cdf0e10cSrcweir ************************************************************************/ 27*cdf0e10cSrcweir 28*cdf0e10cSrcweir // MARKER(update_precomp.py): autogen include statement, do not remove 29*cdf0e10cSrcweir #include "precompiled_sd.hxx" 30*cdf0e10cSrcweir 31*cdf0e10cSrcweir #include "DrawViewShell.hxx" 32*cdf0e10cSrcweir #include <svl/aeitem.hxx> 33*cdf0e10cSrcweir #include <svl/itemset.hxx> 34*cdf0e10cSrcweir #include <sfx2/request.hxx> 35*cdf0e10cSrcweir #ifndef _SVXIDS_HRC 36*cdf0e10cSrcweir #include <svx/svxids.hrc> 37*cdf0e10cSrcweir #endif 38*cdf0e10cSrcweir 39*cdf0e10cSrcweir 40*cdf0e10cSrcweir #include <svx/fmshell.hxx> 41*cdf0e10cSrcweir #include <sfx2/dispatch.hxx> 42*cdf0e10cSrcweir 43*cdf0e10cSrcweir #include "app.hrc" 44*cdf0e10cSrcweir #include "strings.hrc" 45*cdf0e10cSrcweir #include "sdpage.hxx" 46*cdf0e10cSrcweir #ifndef SD_FRAME_VIEW 47*cdf0e10cSrcweir #include "FrameView.hxx" 48*cdf0e10cSrcweir #endif 49*cdf0e10cSrcweir #include "sdresid.hxx" 50*cdf0e10cSrcweir #include "drawdoc.hxx" 51*cdf0e10cSrcweir #include "DrawDocShell.hxx" 52*cdf0e10cSrcweir #include "Window.hxx" 53*cdf0e10cSrcweir #include "GraphicViewShell.hxx" 54*cdf0e10cSrcweir #include "drawview.hxx" 55*cdf0e10cSrcweir 56*cdf0e10cSrcweir #include "slideshow.hxx" 57*cdf0e10cSrcweir 58*cdf0e10cSrcweir namespace sd { 59*cdf0e10cSrcweir 60*cdf0e10cSrcweir #define TABCONTROL_INITIAL_SIZE 500 61*cdf0e10cSrcweir 62*cdf0e10cSrcweir /************************************************************************* 63*cdf0e10cSrcweir |* 64*cdf0e10cSrcweir |* Sprung zu Bookmark 65*cdf0e10cSrcweir |* 66*cdf0e10cSrcweir \************************************************************************/ 67*cdf0e10cSrcweir 68*cdf0e10cSrcweir sal_Bool DrawViewShell::GotoBookmark(const String& rBookmark) 69*cdf0e10cSrcweir { 70*cdf0e10cSrcweir sal_Bool bRet = sal_False; 71*cdf0e10cSrcweir ::sd::DrawDocShell* pDocSh = GetDocSh(); 72*cdf0e10cSrcweir if( pDocSh ) 73*cdf0e10cSrcweir { 74*cdf0e10cSrcweir if( !pDocSh->GetViewShell() ) //#i26016# this case occurs if the jump-target-document was opened already with file open dialog before triggering the jump via hyperlink 75*cdf0e10cSrcweir pDocSh->Connect(this); 76*cdf0e10cSrcweir bRet = (pDocSh->GotoBookmark(rBookmark)); 77*cdf0e10cSrcweir } 78*cdf0e10cSrcweir return bRet; 79*cdf0e10cSrcweir } 80*cdf0e10cSrcweir 81*cdf0e10cSrcweir /************************************************************************* 82*cdf0e10cSrcweir |* 83*cdf0e10cSrcweir |* Bereich sichtbar machen (Bildausschnitt scrollen) 84*cdf0e10cSrcweir |* 85*cdf0e10cSrcweir \************************************************************************/ 86*cdf0e10cSrcweir 87*cdf0e10cSrcweir void DrawViewShell::MakeVisible(const Rectangle& rRect, ::Window& rWin) 88*cdf0e10cSrcweir { 89*cdf0e10cSrcweir // #98568# In older versions, if in X or Y the size of the object was 90*cdf0e10cSrcweir // smaller than the visible area, the user-defined zoom was 91*cdf0e10cSrcweir // changed. This was decided to be a bug for 6.x, thus I developed a 92*cdf0e10cSrcweir // version which instead handles X/Y bigger/smaller and visibility 93*cdf0e10cSrcweir // questions seperately. The new behaviour is triggered with the 94*cdf0e10cSrcweir // bZoomAllowed parameter which for old behaviour should be set to 95*cdf0e10cSrcweir // sal_True. I looked at all uses of MakeVisible() in the application 96*cdf0e10cSrcweir // and found no valid reason for really changing the zoom factor, thus I 97*cdf0e10cSrcweir // decided to NOT expand (incompatible) this virtual method to get one 98*cdf0e10cSrcweir // more parameter. If this is wanted in later versions, feel free to add 99*cdf0e10cSrcweir // that bool to the parameter list. 100*cdf0e10cSrcweir sal_Bool bZoomAllowed(sal_False); 101*cdf0e10cSrcweir Size aLogicSize(rRect.GetSize()); 102*cdf0e10cSrcweir 103*cdf0e10cSrcweir // Sichtbarer Bereich 104*cdf0e10cSrcweir Size aVisSizePixel(rWin.GetOutputSizePixel()); 105*cdf0e10cSrcweir Rectangle aVisArea(rWin.PixelToLogic(Rectangle(Point(0,0), aVisSizePixel))); 106*cdf0e10cSrcweir Size aVisAreaSize(aVisArea.GetSize()); 107*cdf0e10cSrcweir 108*cdf0e10cSrcweir if(!aVisArea.IsInside(rRect) && !SlideShow::IsRunning( GetViewShellBase() ) ) 109*cdf0e10cSrcweir { 110*cdf0e10cSrcweir // Objekt liegt nicht komplett im sichtbaren Bereich 111*cdf0e10cSrcweir sal_Int32 nFreeSpaceX(aVisAreaSize.Width() - aLogicSize.Width()); 112*cdf0e10cSrcweir sal_Int32 nFreeSpaceY(aVisAreaSize.Height() - aLogicSize.Height()); 113*cdf0e10cSrcweir 114*cdf0e10cSrcweir if(bZoomAllowed && (nFreeSpaceX < 0 || nFreeSpaceY < 0)) 115*cdf0e10cSrcweir { 116*cdf0e10cSrcweir // Objekt passt nicht in sichtbaren Bereich -> auf Objektgroesse zoomen 117*cdf0e10cSrcweir SetZoomRect(rRect); 118*cdf0e10cSrcweir } 119*cdf0e10cSrcweir else 120*cdf0e10cSrcweir { 121*cdf0e10cSrcweir // #98568# allow a mode for move-only visibility without zooming. 122*cdf0e10cSrcweir const sal_Int32 nPercentBorder(30); 123*cdf0e10cSrcweir const Rectangle aInnerRectangle( 124*cdf0e10cSrcweir aVisArea.Left() + ((aVisAreaSize.Width() * nPercentBorder) / 200), 125*cdf0e10cSrcweir aVisArea.Top() + ((aVisAreaSize.Height() * nPercentBorder) / 200), 126*cdf0e10cSrcweir aVisArea.Right() - ((aVisAreaSize.Width() * nPercentBorder) / 200), 127*cdf0e10cSrcweir aVisArea.Bottom() - ((aVisAreaSize.Height() * nPercentBorder) / 200) 128*cdf0e10cSrcweir ); 129*cdf0e10cSrcweir Point aNewPos(aVisArea.TopLeft()); 130*cdf0e10cSrcweir 131*cdf0e10cSrcweir if(nFreeSpaceX < 0) 132*cdf0e10cSrcweir { 133*cdf0e10cSrcweir if(aInnerRectangle.Left() > rRect.Right()) 134*cdf0e10cSrcweir { 135*cdf0e10cSrcweir // object moves out to the left 136*cdf0e10cSrcweir aNewPos.X() -= aVisAreaSize.Width() / 2; 137*cdf0e10cSrcweir } 138*cdf0e10cSrcweir 139*cdf0e10cSrcweir if(aInnerRectangle.Right() < rRect.Left()) 140*cdf0e10cSrcweir { 141*cdf0e10cSrcweir // object moves out to the right 142*cdf0e10cSrcweir aNewPos.X() += aVisAreaSize.Width() / 2; 143*cdf0e10cSrcweir } 144*cdf0e10cSrcweir } 145*cdf0e10cSrcweir else 146*cdf0e10cSrcweir { 147*cdf0e10cSrcweir if(nFreeSpaceX > rRect.GetWidth()) 148*cdf0e10cSrcweir nFreeSpaceX = rRect.GetWidth(); 149*cdf0e10cSrcweir 150*cdf0e10cSrcweir while(rRect.Right() > aNewPos.X() + aVisAreaSize.Width()) 151*cdf0e10cSrcweir aNewPos.X() += nFreeSpaceX; 152*cdf0e10cSrcweir 153*cdf0e10cSrcweir while(rRect.Left() < aNewPos.X()) 154*cdf0e10cSrcweir aNewPos.X() -= nFreeSpaceX; 155*cdf0e10cSrcweir } 156*cdf0e10cSrcweir 157*cdf0e10cSrcweir if(nFreeSpaceY < 0) 158*cdf0e10cSrcweir { 159*cdf0e10cSrcweir if(aInnerRectangle.Top() > rRect.Bottom()) 160*cdf0e10cSrcweir { 161*cdf0e10cSrcweir // object moves out to the top 162*cdf0e10cSrcweir aNewPos.Y() -= aVisAreaSize.Height() / 2; 163*cdf0e10cSrcweir } 164*cdf0e10cSrcweir 165*cdf0e10cSrcweir if(aInnerRectangle.Bottom() < rRect.Top()) 166*cdf0e10cSrcweir { 167*cdf0e10cSrcweir // object moves out to the right 168*cdf0e10cSrcweir aNewPos.Y() += aVisAreaSize.Height() / 2; 169*cdf0e10cSrcweir } 170*cdf0e10cSrcweir } 171*cdf0e10cSrcweir else 172*cdf0e10cSrcweir { 173*cdf0e10cSrcweir if(nFreeSpaceY > rRect.GetHeight()) 174*cdf0e10cSrcweir nFreeSpaceY = rRect.GetHeight(); 175*cdf0e10cSrcweir 176*cdf0e10cSrcweir while(rRect.Bottom() > aNewPos.Y() + aVisAreaSize.Height()) 177*cdf0e10cSrcweir aNewPos.Y() += nFreeSpaceY; 178*cdf0e10cSrcweir 179*cdf0e10cSrcweir while(rRect.Top() < aNewPos.Y()) 180*cdf0e10cSrcweir aNewPos.Y() -= nFreeSpaceY; 181*cdf0e10cSrcweir } 182*cdf0e10cSrcweir 183*cdf0e10cSrcweir // did position change? Does it need to be set? 184*cdf0e10cSrcweir if(aNewPos != aVisArea.TopLeft()) 185*cdf0e10cSrcweir { 186*cdf0e10cSrcweir aVisArea.SetPos(aNewPos); 187*cdf0e10cSrcweir SetZoomRect(aVisArea); 188*cdf0e10cSrcweir } 189*cdf0e10cSrcweir } 190*cdf0e10cSrcweir } 191*cdf0e10cSrcweir } 192*cdf0e10cSrcweir 193*cdf0e10cSrcweir } 194