Update ooo320-m1
[ooovba.git] / sd / source / ui / view / drviewsh.cxx
bloba1b87c98e21970f35fc66e6e6b4e278c2d207efc
1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: drviewsh.cxx,v $
10 * $Revision: 1.12 $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
31 // MARKER(update_precomp.py): autogen include statement, do not remove
32 #include "precompiled_sd.hxx"
34 #include "DrawViewShell.hxx"
35 #include <svtools/aeitem.hxx>
36 #include <svtools/itemset.hxx>
37 #include <sfx2/request.hxx>
38 #ifndef _SVXIDS_HRC
39 #include <svx/svxids.hrc>
40 #endif
43 #include <svx/fmshell.hxx>
44 #include <sfx2/dispatch.hxx>
46 #include "app.hrc"
47 #include "strings.hrc"
48 #include "sdpage.hxx"
49 #ifndef SD_FRAME_VIEW
50 #include "FrameView.hxx"
51 #endif
52 #include "sdresid.hxx"
53 #include "drawdoc.hxx"
54 #include "DrawDocShell.hxx"
55 #include "Window.hxx"
56 #include "GraphicViewShell.hxx"
57 #include "drawview.hxx"
59 #include "slideshow.hxx"
61 namespace sd {
63 #define TABCONTROL_INITIAL_SIZE 500
65 /*************************************************************************
67 |* Sprung zu Bookmark
69 \************************************************************************/
71 BOOL DrawViewShell::GotoBookmark(const String& rBookmark)
73 BOOL bRet = FALSE;
74 ::sd::DrawDocShell* pDocSh = GetDocSh();
75 if( pDocSh )
77 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
78 pDocSh->Connect(this);
79 bRet = (pDocSh->GotoBookmark(rBookmark));
81 return bRet;
84 /*************************************************************************
86 |* Bereich sichtbar machen (Bildausschnitt scrollen)
88 \************************************************************************/
90 void DrawViewShell::MakeVisible(const Rectangle& rRect, ::Window& rWin)
92 // #98568# In older versions, if in X or Y the size of the object was
93 // smaller than the visible area, the user-defined zoom was
94 // changed. This was decided to be a bug for 6.x, thus I developed a
95 // version which instead handles X/Y bigger/smaller and visibility
96 // questions seperately. The new behaviour is triggered with the
97 // bZoomAllowed parameter which for old behaviour should be set to
98 // sal_True. I looked at all uses of MakeVisible() in the application
99 // and found no valid reason for really changing the zoom factor, thus I
100 // decided to NOT expand (incompatible) this virtual method to get one
101 // more parameter. If this is wanted in later versions, feel free to add
102 // that bool to the parameter list.
103 sal_Bool bZoomAllowed(sal_False);
104 Size aLogicSize(rRect.GetSize());
106 // Sichtbarer Bereich
107 Size aVisSizePixel(rWin.GetOutputSizePixel());
108 Rectangle aVisArea(rWin.PixelToLogic(Rectangle(Point(0,0), aVisSizePixel)));
109 Size aVisAreaSize(aVisArea.GetSize());
111 if(!aVisArea.IsInside(rRect) && !SlideShow::IsRunning( GetViewShellBase() ) )
113 // Objekt liegt nicht komplett im sichtbaren Bereich
114 sal_Int32 nFreeSpaceX(aVisAreaSize.Width() - aLogicSize.Width());
115 sal_Int32 nFreeSpaceY(aVisAreaSize.Height() - aLogicSize.Height());
117 if(bZoomAllowed && (nFreeSpaceX < 0 || nFreeSpaceY < 0))
119 // Objekt passt nicht in sichtbaren Bereich -> auf Objektgroesse zoomen
120 SetZoomRect(rRect);
122 else
124 // #98568# allow a mode for move-only visibility without zooming.
125 const sal_Int32 nPercentBorder(30);
126 const Rectangle aInnerRectangle(
127 aVisArea.Left() + ((aVisAreaSize.Width() * nPercentBorder) / 200),
128 aVisArea.Top() + ((aVisAreaSize.Height() * nPercentBorder) / 200),
129 aVisArea.Right() - ((aVisAreaSize.Width() * nPercentBorder) / 200),
130 aVisArea.Bottom() - ((aVisAreaSize.Height() * nPercentBorder) / 200)
132 Point aNewPos(aVisArea.TopLeft());
134 if(nFreeSpaceX < 0)
136 if(aInnerRectangle.Left() > rRect.Right())
138 // object moves out to the left
139 aNewPos.X() -= aVisAreaSize.Width() / 2;
142 if(aInnerRectangle.Right() < rRect.Left())
144 // object moves out to the right
145 aNewPos.X() += aVisAreaSize.Width() / 2;
148 else
150 if(nFreeSpaceX > rRect.GetWidth())
151 nFreeSpaceX = rRect.GetWidth();
153 while(rRect.Right() > aNewPos.X() + aVisAreaSize.Width())
154 aNewPos.X() += nFreeSpaceX;
156 while(rRect.Left() < aNewPos.X())
157 aNewPos.X() -= nFreeSpaceX;
160 if(nFreeSpaceY < 0)
162 if(aInnerRectangle.Top() > rRect.Bottom())
164 // object moves out to the top
165 aNewPos.Y() -= aVisAreaSize.Height() / 2;
168 if(aInnerRectangle.Bottom() < rRect.Top())
170 // object moves out to the right
171 aNewPos.Y() += aVisAreaSize.Height() / 2;
174 else
176 if(nFreeSpaceY > rRect.GetHeight())
177 nFreeSpaceY = rRect.GetHeight();
179 while(rRect.Bottom() > aNewPos.Y() + aVisAreaSize.Height())
180 aNewPos.Y() += nFreeSpaceY;
182 while(rRect.Top() < aNewPos.Y())
183 aNewPos.Y() -= nFreeSpaceY;
186 // did position change? Does it need to be set?
187 if(aNewPos != aVisArea.TopLeft())
189 aVisArea.SetPos(aNewPos);
190 SetZoomRect(aVisArea);