1*5b190011SAndrew Rist /************************************************************** 2*5b190011SAndrew Rist * 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 12cdf0e10cSrcweir * 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 "DrawViewShell.hxx" 28cdf0e10cSrcweir #include <svl/aeitem.hxx> 29cdf0e10cSrcweir #include <svl/itemset.hxx> 30cdf0e10cSrcweir #include <sfx2/request.hxx> 31cdf0e10cSrcweir #ifndef _SVXIDS_HRC 32cdf0e10cSrcweir #include <svx/svxids.hrc> 33cdf0e10cSrcweir #endif 34cdf0e10cSrcweir 35cdf0e10cSrcweir 36cdf0e10cSrcweir #include <svx/fmshell.hxx> 37cdf0e10cSrcweir #include <sfx2/dispatch.hxx> 38cdf0e10cSrcweir 39cdf0e10cSrcweir #include "app.hrc" 40cdf0e10cSrcweir #include "strings.hrc" 41cdf0e10cSrcweir #include "sdpage.hxx" 42cdf0e10cSrcweir #ifndef SD_FRAME_VIEW 43cdf0e10cSrcweir #include "FrameView.hxx" 44cdf0e10cSrcweir #endif 45cdf0e10cSrcweir #include "sdresid.hxx" 46cdf0e10cSrcweir #include "drawdoc.hxx" 47cdf0e10cSrcweir #include "DrawDocShell.hxx" 48cdf0e10cSrcweir #include "Window.hxx" 49cdf0e10cSrcweir #include "GraphicViewShell.hxx" 50cdf0e10cSrcweir #include "drawview.hxx" 51cdf0e10cSrcweir 52cdf0e10cSrcweir #include "slideshow.hxx" 53cdf0e10cSrcweir 54cdf0e10cSrcweir namespace sd { 55cdf0e10cSrcweir 56cdf0e10cSrcweir #define TABCONTROL_INITIAL_SIZE 500 57cdf0e10cSrcweir 58cdf0e10cSrcweir /************************************************************************* 59cdf0e10cSrcweir |* 60cdf0e10cSrcweir |* Sprung zu Bookmark 61cdf0e10cSrcweir |* 62cdf0e10cSrcweir \************************************************************************/ 63cdf0e10cSrcweir 64cdf0e10cSrcweir sal_Bool DrawViewShell::GotoBookmark(const String& rBookmark) 65cdf0e10cSrcweir { 66cdf0e10cSrcweir sal_Bool bRet = sal_False; 67cdf0e10cSrcweir ::sd::DrawDocShell* pDocSh = GetDocSh(); 68cdf0e10cSrcweir if( pDocSh ) 69cdf0e10cSrcweir { 70cdf0e10cSrcweir 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 71cdf0e10cSrcweir pDocSh->Connect(this); 72cdf0e10cSrcweir bRet = (pDocSh->GotoBookmark(rBookmark)); 73cdf0e10cSrcweir } 74cdf0e10cSrcweir return bRet; 75cdf0e10cSrcweir } 76cdf0e10cSrcweir 77cdf0e10cSrcweir /************************************************************************* 78cdf0e10cSrcweir |* 79cdf0e10cSrcweir |* Bereich sichtbar machen (Bildausschnitt scrollen) 80cdf0e10cSrcweir |* 81cdf0e10cSrcweir \************************************************************************/ 82cdf0e10cSrcweir 83cdf0e10cSrcweir void DrawViewShell::MakeVisible(const Rectangle& rRect, ::Window& rWin) 84cdf0e10cSrcweir { 85cdf0e10cSrcweir // #98568# In older versions, if in X or Y the size of the object was 86cdf0e10cSrcweir // smaller than the visible area, the user-defined zoom was 87cdf0e10cSrcweir // changed. This was decided to be a bug for 6.x, thus I developed a 88cdf0e10cSrcweir // version which instead handles X/Y bigger/smaller and visibility 89cdf0e10cSrcweir // questions seperately. The new behaviour is triggered with the 90cdf0e10cSrcweir // bZoomAllowed parameter which for old behaviour should be set to 91cdf0e10cSrcweir // sal_True. I looked at all uses of MakeVisible() in the application 92cdf0e10cSrcweir // and found no valid reason for really changing the zoom factor, thus I 93cdf0e10cSrcweir // decided to NOT expand (incompatible) this virtual method to get one 94cdf0e10cSrcweir // more parameter. If this is wanted in later versions, feel free to add 95cdf0e10cSrcweir // that bool to the parameter list. 96cdf0e10cSrcweir sal_Bool bZoomAllowed(sal_False); 97cdf0e10cSrcweir Size aLogicSize(rRect.GetSize()); 98cdf0e10cSrcweir 99cdf0e10cSrcweir // Sichtbarer Bereich 100cdf0e10cSrcweir Size aVisSizePixel(rWin.GetOutputSizePixel()); 101cdf0e10cSrcweir Rectangle aVisArea(rWin.PixelToLogic(Rectangle(Point(0,0), aVisSizePixel))); 102cdf0e10cSrcweir Size aVisAreaSize(aVisArea.GetSize()); 103cdf0e10cSrcweir 104cdf0e10cSrcweir if(!aVisArea.IsInside(rRect) && !SlideShow::IsRunning( GetViewShellBase() ) ) 105cdf0e10cSrcweir { 106cdf0e10cSrcweir // Objekt liegt nicht komplett im sichtbaren Bereich 107cdf0e10cSrcweir sal_Int32 nFreeSpaceX(aVisAreaSize.Width() - aLogicSize.Width()); 108cdf0e10cSrcweir sal_Int32 nFreeSpaceY(aVisAreaSize.Height() - aLogicSize.Height()); 109cdf0e10cSrcweir 110cdf0e10cSrcweir if(bZoomAllowed && (nFreeSpaceX < 0 || nFreeSpaceY < 0)) 111cdf0e10cSrcweir { 112cdf0e10cSrcweir // Objekt passt nicht in sichtbaren Bereich -> auf Objektgroesse zoomen 113cdf0e10cSrcweir SetZoomRect(rRect); 114cdf0e10cSrcweir } 115cdf0e10cSrcweir else 116cdf0e10cSrcweir { 117cdf0e10cSrcweir // #98568# allow a mode for move-only visibility without zooming. 118cdf0e10cSrcweir const sal_Int32 nPercentBorder(30); 119cdf0e10cSrcweir const Rectangle aInnerRectangle( 120cdf0e10cSrcweir aVisArea.Left() + ((aVisAreaSize.Width() * nPercentBorder) / 200), 121cdf0e10cSrcweir aVisArea.Top() + ((aVisAreaSize.Height() * nPercentBorder) / 200), 122cdf0e10cSrcweir aVisArea.Right() - ((aVisAreaSize.Width() * nPercentBorder) / 200), 123cdf0e10cSrcweir aVisArea.Bottom() - ((aVisAreaSize.Height() * nPercentBorder) / 200) 124cdf0e10cSrcweir ); 125cdf0e10cSrcweir Point aNewPos(aVisArea.TopLeft()); 126cdf0e10cSrcweir 127cdf0e10cSrcweir if(nFreeSpaceX < 0) 128cdf0e10cSrcweir { 129cdf0e10cSrcweir if(aInnerRectangle.Left() > rRect.Right()) 130cdf0e10cSrcweir { 131cdf0e10cSrcweir // object moves out to the left 132cdf0e10cSrcweir aNewPos.X() -= aVisAreaSize.Width() / 2; 133cdf0e10cSrcweir } 134cdf0e10cSrcweir 135cdf0e10cSrcweir if(aInnerRectangle.Right() < rRect.Left()) 136cdf0e10cSrcweir { 137cdf0e10cSrcweir // object moves out to the right 138cdf0e10cSrcweir aNewPos.X() += aVisAreaSize.Width() / 2; 139cdf0e10cSrcweir } 140cdf0e10cSrcweir } 141cdf0e10cSrcweir else 142cdf0e10cSrcweir { 143cdf0e10cSrcweir if(nFreeSpaceX > rRect.GetWidth()) 144cdf0e10cSrcweir nFreeSpaceX = rRect.GetWidth(); 145cdf0e10cSrcweir 146cdf0e10cSrcweir while(rRect.Right() > aNewPos.X() + aVisAreaSize.Width()) 147cdf0e10cSrcweir aNewPos.X() += nFreeSpaceX; 148cdf0e10cSrcweir 149cdf0e10cSrcweir while(rRect.Left() < aNewPos.X()) 150cdf0e10cSrcweir aNewPos.X() -= nFreeSpaceX; 151cdf0e10cSrcweir } 152cdf0e10cSrcweir 153cdf0e10cSrcweir if(nFreeSpaceY < 0) 154cdf0e10cSrcweir { 155cdf0e10cSrcweir if(aInnerRectangle.Top() > rRect.Bottom()) 156cdf0e10cSrcweir { 157cdf0e10cSrcweir // object moves out to the top 158cdf0e10cSrcweir aNewPos.Y() -= aVisAreaSize.Height() / 2; 159cdf0e10cSrcweir } 160cdf0e10cSrcweir 161cdf0e10cSrcweir if(aInnerRectangle.Bottom() < rRect.Top()) 162cdf0e10cSrcweir { 163cdf0e10cSrcweir // object moves out to the right 164cdf0e10cSrcweir aNewPos.Y() += aVisAreaSize.Height() / 2; 165cdf0e10cSrcweir } 166cdf0e10cSrcweir } 167cdf0e10cSrcweir else 168cdf0e10cSrcweir { 169cdf0e10cSrcweir if(nFreeSpaceY > rRect.GetHeight()) 170cdf0e10cSrcweir nFreeSpaceY = rRect.GetHeight(); 171cdf0e10cSrcweir 172cdf0e10cSrcweir while(rRect.Bottom() > aNewPos.Y() + aVisAreaSize.Height()) 173cdf0e10cSrcweir aNewPos.Y() += nFreeSpaceY; 174cdf0e10cSrcweir 175cdf0e10cSrcweir while(rRect.Top() < aNewPos.Y()) 176cdf0e10cSrcweir aNewPos.Y() -= nFreeSpaceY; 177cdf0e10cSrcweir } 178cdf0e10cSrcweir 179cdf0e10cSrcweir // did position change? Does it need to be set? 180cdf0e10cSrcweir if(aNewPos != aVisArea.TopLeft()) 181cdf0e10cSrcweir { 182cdf0e10cSrcweir aVisArea.SetPos(aNewPos); 183cdf0e10cSrcweir SetZoomRect(aVisArea); 184cdf0e10cSrcweir } 185cdf0e10cSrcweir } 186cdf0e10cSrcweir } 187cdf0e10cSrcweir } 188cdf0e10cSrcweir 189cdf0e10cSrcweir } 190