1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
3 * This file is part of the LibreOffice project.
5 * This Source Code Form is subject to the terms of the Mozilla Public
6 * License, v. 2.0. If a copy of the MPL was not distributed with this
7 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
9 * This file incorporates work covered by the following license notice:
11 * Licensed to the Apache Software Foundation (ASF) under one or more
12 * contributor license agreements. See the NOTICE file distributed
13 * with this work for additional information regarding copyright
14 * ownership. The ASF licenses this file to you under the Apache
15 * License, Version 2.0 (the "License"); you may not use this file
16 * except in compliance with the License. You may obtain a copy of
17 * the License at http://www.apache.org/licenses/LICENSE-2.0 .
21 #include "DrawViewShell.hxx"
22 #include <svl/aeitem.hxx>
23 #include <svl/itemset.hxx>
24 #include <sfx2/request.hxx>
25 #include <svx/svxids.hrc>
28 #include <svx/fmshell.hxx>
29 #include <sfx2/dispatch.hxx>
32 #include "strings.hrc"
35 #include "FrameView.hxx"
37 #include "sdresid.hxx"
38 #include "drawdoc.hxx"
39 #include "DrawDocShell.hxx"
41 #include "GraphicViewShell.hxx"
42 #include "drawview.hxx"
44 #include "slideshow.hxx"
48 sal_Bool
DrawViewShell::GotoBookmark(const String
& rBookmark
)
50 sal_Bool bRet
= sal_False
;
51 ::sd::DrawDocShell
* pDocSh
= GetDocSh();
54 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
55 pDocSh
->Connect(this);
56 bRet
= (pDocSh
->GotoBookmark(rBookmark
));
62 * Make area visible (scroll part of picture)
64 \************************************************************************/
66 void DrawViewShell::MakeVisible(const Rectangle
& rRect
, ::Window
& rWin
)
68 // In older versions, if in X or Y the size of the object was
69 // smaller than the visible area, the user-defined zoom was
70 // changed. This was decided to be a bug for 6.x, thus I developed a
71 // version which instead handles X/Y bigger/smaller and visibility
72 // questions separately. The new behaviour is triggered with the
73 // bZoomAllowed parameter which for old behaviour should be set to
74 // sal_True. I looked at all uses of MakeVisible() in the application
75 // and found no valid reason for really changing the zoom factor, thus I
76 // decided to NOT expand (incompatible) this virtual method to get one
77 // more parameter. If this is wanted in later versions, feel free to add
78 // that bool to the parameter list.
79 sal_Bool
bZoomAllowed(sal_False
);
80 Size
aLogicSize(rRect
.GetSize());
83 Size
aVisSizePixel(rWin
.GetOutputSizePixel());
84 Rectangle
aVisArea(rWin
.PixelToLogic(Rectangle(Point(0,0), aVisSizePixel
)));
85 Size
aVisAreaSize(aVisArea
.GetSize());
87 if(!aVisArea
.IsInside(rRect
) && !SlideShow::IsRunning( GetViewShellBase() ) )
89 // object is not entirely in visible area
90 sal_Int32
nFreeSpaceX(aVisAreaSize
.Width() - aLogicSize
.Width());
91 sal_Int32
nFreeSpaceY(aVisAreaSize
.Height() - aLogicSize
.Height());
93 if(bZoomAllowed
&& (nFreeSpaceX
< 0 || nFreeSpaceY
< 0))
95 // object does not fit into visible area -> zoom to object size
100 // allow a mode for move-only visibility without zooming.
101 const sal_Int32
nPercentBorder(30);
102 const Rectangle
aInnerRectangle(
103 aVisArea
.Left() + ((aVisAreaSize
.Width() * nPercentBorder
) / 200),
104 aVisArea
.Top() + ((aVisAreaSize
.Height() * nPercentBorder
) / 200),
105 aVisArea
.Right() - ((aVisAreaSize
.Width() * nPercentBorder
) / 200),
106 aVisArea
.Bottom() - ((aVisAreaSize
.Height() * nPercentBorder
) / 200)
108 Point
aNewPos(aVisArea
.TopLeft());
112 if(aInnerRectangle
.Left() > rRect
.Right())
114 // object moves out to the left
115 aNewPos
.X() -= aVisAreaSize
.Width() / 2;
118 if(aInnerRectangle
.Right() < rRect
.Left())
120 // object moves out to the right
121 aNewPos
.X() += aVisAreaSize
.Width() / 2;
126 if(nFreeSpaceX
> rRect
.GetWidth())
127 nFreeSpaceX
= rRect
.GetWidth();
129 while(rRect
.Right() > aNewPos
.X() + aVisAreaSize
.Width())
130 aNewPos
.X() += nFreeSpaceX
;
132 while(rRect
.Left() < aNewPos
.X())
133 aNewPos
.X() -= nFreeSpaceX
;
138 if(aInnerRectangle
.Top() > rRect
.Bottom())
140 // object moves out to the top
141 aNewPos
.Y() -= aVisAreaSize
.Height() / 2;
144 if(aInnerRectangle
.Bottom() < rRect
.Top())
146 // object moves out to the right
147 aNewPos
.Y() += aVisAreaSize
.Height() / 2;
152 if(nFreeSpaceY
> rRect
.GetHeight())
153 nFreeSpaceY
= rRect
.GetHeight();
155 while(rRect
.Bottom() > aNewPos
.Y() + aVisAreaSize
.Height())
156 aNewPos
.Y() += nFreeSpaceY
;
158 while(rRect
.Top() < aNewPos
.Y())
159 aNewPos
.Y() -= nFreeSpaceY
;
162 // did position change? Does it need to be set?
163 if(aNewPos
!= aVisArea
.TopLeft())
165 aVisArea
.SetPos(aNewPos
);
166 SetZoomRect(aVisArea
);
174 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */