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 .
20 #include "DrawViewShell.hxx"
21 #include <svl/aeitem.hxx>
22 #include <svl/itemset.hxx>
23 #include <sfx2/request.hxx>
24 #include <svx/svxids.hrc>
26 #include <svx/fmshell.hxx>
27 #include <sfx2/dispatch.hxx>
30 #include "strings.hrc"
32 #include "FrameView.hxx"
33 #include "sdresid.hxx"
34 #include "drawdoc.hxx"
35 #include "DrawDocShell.hxx"
37 #include "GraphicViewShell.hxx"
38 #include "drawview.hxx"
40 #include "slideshow.hxx"
44 bool DrawViewShell::GotoBookmark(const OUString
& rBookmark
)
47 ::sd::DrawDocShell
* pDocSh
= GetDocSh();
50 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
51 pDocSh
->Connect(this);
52 bRet
= (pDocSh
->GotoBookmark(rBookmark
));
58 * Make area visible (scroll part of picture)
60 \************************************************************************/
62 void DrawViewShell::MakeVisible(const Rectangle
& rRect
, vcl::Window
& rWin
)
64 // In older versions, if in X or Y the size of the object was
65 // smaller than the visible area, the user-defined zoom was
66 // changed. This was decided to be a bug for 6.x, thus I developed a
67 // version which instead handles X/Y bigger/smaller and visibility
68 // questions separately
69 Size
aLogicSize(rRect
.GetSize());
72 Size
aVisSizePixel(rWin
.GetOutputSizePixel());
73 Rectangle
aVisArea(rWin
.PixelToLogic(Rectangle(Point(0,0), aVisSizePixel
)));
74 Size
aVisAreaSize(aVisArea
.GetSize());
76 if (!aVisArea
.IsInside(rRect
) && !SlideShow::IsRunning( GetViewShellBase() ) )
78 // object is not entirely in visible area
79 sal_Int32
nFreeSpaceX(aVisAreaSize
.Width() - aLogicSize
.Width());
80 sal_Int32
nFreeSpaceY(aVisAreaSize
.Height() - aLogicSize
.Height());
82 // allow a mode for move-only visibility without zooming.
83 const sal_Int32
nPercentBorder(30);
84 const Rectangle
aInnerRectangle(
85 aVisArea
.Left() + ((aVisAreaSize
.Width() * nPercentBorder
) / 200),
86 aVisArea
.Top() + ((aVisAreaSize
.Height() * nPercentBorder
) / 200),
87 aVisArea
.Right() - ((aVisAreaSize
.Width() * nPercentBorder
) / 200),
88 aVisArea
.Bottom() - ((aVisAreaSize
.Height() * nPercentBorder
) / 200)
90 Point
aNewPos(aVisArea
.TopLeft());
94 if(aInnerRectangle
.Left() > rRect
.Right())
96 // object moves out to the left
97 aNewPos
.X() -= aVisAreaSize
.Width() / 2;
100 if(aInnerRectangle
.Right() < rRect
.Left())
102 // object moves out to the right
103 aNewPos
.X() += aVisAreaSize
.Width() / 2;
108 if(nFreeSpaceX
> rRect
.GetWidth())
109 nFreeSpaceX
= rRect
.GetWidth();
111 while(rRect
.Right() > aNewPos
.X() + aVisAreaSize
.Width())
112 aNewPos
.X() += nFreeSpaceX
;
114 while(rRect
.Left() < aNewPos
.X())
115 aNewPos
.X() -= nFreeSpaceX
;
120 if(aInnerRectangle
.Top() > rRect
.Bottom())
122 // object moves out to the top
123 aNewPos
.Y() -= aVisAreaSize
.Height() / 2;
126 if(aInnerRectangle
.Bottom() < rRect
.Top())
128 // object moves out to the right
129 aNewPos
.Y() += aVisAreaSize
.Height() / 2;
134 if(nFreeSpaceY
> rRect
.GetHeight())
135 nFreeSpaceY
= rRect
.GetHeight();
137 while(rRect
.Bottom() > aNewPos
.Y() + aVisAreaSize
.Height())
138 aNewPos
.Y() += nFreeSpaceY
;
140 while(rRect
.Top() < aNewPos
.Y())
141 aNewPos
.Y() -= nFreeSpaceY
;
144 // did position change? Does it need to be set?
145 if(aNewPos
!= aVisArea
.TopLeft())
147 aVisArea
.SetPos(aNewPos
);
148 SetZoomRect(aVisArea
);
155 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */