Line data Source code
1 : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 : /*
3 : * This file is part of the LibreOffice project.
4 : *
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/.
8 : *
9 : * This file incorporates work covered by the following license notice:
10 : *
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 .
18 : */
19 :
20 :
21 : #include "DrawViewShell.hxx"
22 : #include <svl/aeitem.hxx>
23 : #include <svl/itemset.hxx>
24 : #include <sfx2/request.hxx>
25 : #include <svx/svxids.hrc>
26 :
27 :
28 : #include <svx/fmshell.hxx>
29 : #include <sfx2/dispatch.hxx>
30 :
31 : #include "app.hrc"
32 : #include "strings.hrc"
33 : #include "sdpage.hxx"
34 : #include "FrameView.hxx"
35 : #include "sdresid.hxx"
36 : #include "drawdoc.hxx"
37 : #include "DrawDocShell.hxx"
38 : #include "Window.hxx"
39 : #include "GraphicViewShell.hxx"
40 : #include "drawview.hxx"
41 :
42 : #include "slideshow.hxx"
43 :
44 : namespace sd {
45 :
46 0 : sal_Bool DrawViewShell::GotoBookmark(const OUString& rBookmark)
47 : {
48 0 : sal_Bool bRet = sal_False;
49 0 : ::sd::DrawDocShell* pDocSh = GetDocSh();
50 0 : if( pDocSh )
51 : {
52 0 : 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
53 0 : pDocSh->Connect(this);
54 0 : bRet = (pDocSh->GotoBookmark(rBookmark));
55 : }
56 0 : return bRet;
57 : }
58 :
59 : /**
60 : * Make area visible (scroll part of picture)
61 : |*
62 : \************************************************************************/
63 :
64 0 : void DrawViewShell::MakeVisible(const Rectangle& rRect, ::Window& rWin)
65 : {
66 : // In older versions, if in X or Y the size of the object was
67 : // smaller than the visible area, the user-defined zoom was
68 : // changed. This was decided to be a bug for 6.x, thus I developed a
69 : // version which instead handles X/Y bigger/smaller and visibility
70 : // questions separately
71 0 : Size aLogicSize(rRect.GetSize());
72 :
73 : // visible area
74 0 : Size aVisSizePixel(rWin.GetOutputSizePixel());
75 0 : Rectangle aVisArea(rWin.PixelToLogic(Rectangle(Point(0,0), aVisSizePixel)));
76 0 : Size aVisAreaSize(aVisArea.GetSize());
77 :
78 0 : if (!aVisArea.IsInside(rRect) && !SlideShow::IsRunning( GetViewShellBase() ) )
79 : {
80 : // object is not entirely in visible area
81 0 : sal_Int32 nFreeSpaceX(aVisAreaSize.Width() - aLogicSize.Width());
82 0 : sal_Int32 nFreeSpaceY(aVisAreaSize.Height() - aLogicSize.Height());
83 :
84 : // allow a mode for move-only visibility without zooming.
85 0 : const sal_Int32 nPercentBorder(30);
86 : const Rectangle aInnerRectangle(
87 0 : aVisArea.Left() + ((aVisAreaSize.Width() * nPercentBorder) / 200),
88 0 : aVisArea.Top() + ((aVisAreaSize.Height() * nPercentBorder) / 200),
89 0 : aVisArea.Right() - ((aVisAreaSize.Width() * nPercentBorder) / 200),
90 0 : aVisArea.Bottom() - ((aVisAreaSize.Height() * nPercentBorder) / 200)
91 0 : );
92 0 : Point aNewPos(aVisArea.TopLeft());
93 :
94 0 : if(nFreeSpaceX < 0)
95 : {
96 0 : if(aInnerRectangle.Left() > rRect.Right())
97 : {
98 : // object moves out to the left
99 0 : aNewPos.X() -= aVisAreaSize.Width() / 2;
100 : }
101 :
102 0 : if(aInnerRectangle.Right() < rRect.Left())
103 : {
104 : // object moves out to the right
105 0 : aNewPos.X() += aVisAreaSize.Width() / 2;
106 : }
107 : }
108 : else
109 : {
110 0 : if(nFreeSpaceX > rRect.GetWidth())
111 0 : nFreeSpaceX = rRect.GetWidth();
112 :
113 0 : while(rRect.Right() > aNewPos.X() + aVisAreaSize.Width())
114 0 : aNewPos.X() += nFreeSpaceX;
115 :
116 0 : while(rRect.Left() < aNewPos.X())
117 0 : aNewPos.X() -= nFreeSpaceX;
118 : }
119 :
120 0 : if(nFreeSpaceY < 0)
121 : {
122 0 : if(aInnerRectangle.Top() > rRect.Bottom())
123 : {
124 : // object moves out to the top
125 0 : aNewPos.Y() -= aVisAreaSize.Height() / 2;
126 : }
127 :
128 0 : if(aInnerRectangle.Bottom() < rRect.Top())
129 : {
130 : // object moves out to the right
131 0 : aNewPos.Y() += aVisAreaSize.Height() / 2;
132 : }
133 : }
134 : else
135 : {
136 0 : if(nFreeSpaceY > rRect.GetHeight())
137 0 : nFreeSpaceY = rRect.GetHeight();
138 :
139 0 : while(rRect.Bottom() > aNewPos.Y() + aVisAreaSize.Height())
140 0 : aNewPos.Y() += nFreeSpaceY;
141 :
142 0 : while(rRect.Top() < aNewPos.Y())
143 0 : aNewPos.Y() -= nFreeSpaceY;
144 : }
145 :
146 : // did position change? Does it need to be set?
147 0 : if(aNewPos != aVisArea.TopLeft())
148 : {
149 0 : aVisArea.SetPos(aNewPos);
150 0 : SetZoomRect(aVisArea);
151 : }
152 : }
153 0 : }
154 :
155 : }
156 :
157 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|