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 : #include "DrawViewShell.hxx"
21 : #include <svl/aeitem.hxx>
22 : #include <svl/itemset.hxx>
23 : #include <sfx2/request.hxx>
24 : #include <svx/svxids.hrc>
25 :
26 : #include <svx/fmshell.hxx>
27 : #include <sfx2/dispatch.hxx>
28 :
29 : #include "app.hrc"
30 : #include "strings.hrc"
31 : #include "sdpage.hxx"
32 : #include "FrameView.hxx"
33 : #include "sdresid.hxx"
34 : #include "drawdoc.hxx"
35 : #include "DrawDocShell.hxx"
36 : #include "Window.hxx"
37 : #include "GraphicViewShell.hxx"
38 : #include "drawview.hxx"
39 :
40 : #include "slideshow.hxx"
41 :
42 : namespace sd {
43 :
44 0 : bool DrawViewShell::GotoBookmark(const OUString& rBookmark)
45 : {
46 0 : bool bRet = false;
47 0 : ::sd::DrawDocShell* pDocSh = GetDocSh();
48 0 : if( pDocSh )
49 : {
50 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
51 0 : pDocSh->Connect(this);
52 0 : bRet = (pDocSh->GotoBookmark(rBookmark));
53 : }
54 0 : return bRet;
55 : }
56 :
57 : /**
58 : * Make area visible (scroll part of picture)
59 : |*
60 : \************************************************************************/
61 :
62 0 : void DrawViewShell::MakeVisible(const Rectangle& rRect, vcl::Window& rWin)
63 : {
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 0 : Size aLogicSize(rRect.GetSize());
70 :
71 : // visible area
72 0 : Size aVisSizePixel(rWin.GetOutputSizePixel());
73 0 : Rectangle aVisArea(rWin.PixelToLogic(Rectangle(Point(0,0), aVisSizePixel)));
74 0 : Size aVisAreaSize(aVisArea.GetSize());
75 :
76 0 : if (!aVisArea.IsInside(rRect) && !SlideShow::IsRunning( GetViewShellBase() ) )
77 : {
78 : // object is not entirely in visible area
79 0 : sal_Int32 nFreeSpaceX(aVisAreaSize.Width() - aLogicSize.Width());
80 0 : sal_Int32 nFreeSpaceY(aVisAreaSize.Height() - aLogicSize.Height());
81 :
82 : // allow a mode for move-only visibility without zooming.
83 0 : const sal_Int32 nPercentBorder(30);
84 : const Rectangle aInnerRectangle(
85 0 : aVisArea.Left() + ((aVisAreaSize.Width() * nPercentBorder) / 200),
86 0 : aVisArea.Top() + ((aVisAreaSize.Height() * nPercentBorder) / 200),
87 0 : aVisArea.Right() - ((aVisAreaSize.Width() * nPercentBorder) / 200),
88 0 : aVisArea.Bottom() - ((aVisAreaSize.Height() * nPercentBorder) / 200)
89 0 : );
90 0 : Point aNewPos(aVisArea.TopLeft());
91 :
92 0 : if(nFreeSpaceX < 0)
93 : {
94 0 : if(aInnerRectangle.Left() > rRect.Right())
95 : {
96 : // object moves out to the left
97 0 : aNewPos.X() -= aVisAreaSize.Width() / 2;
98 : }
99 :
100 0 : if(aInnerRectangle.Right() < rRect.Left())
101 : {
102 : // object moves out to the right
103 0 : aNewPos.X() += aVisAreaSize.Width() / 2;
104 : }
105 : }
106 : else
107 : {
108 0 : if(nFreeSpaceX > rRect.GetWidth())
109 0 : nFreeSpaceX = rRect.GetWidth();
110 :
111 0 : while(rRect.Right() > aNewPos.X() + aVisAreaSize.Width())
112 0 : aNewPos.X() += nFreeSpaceX;
113 :
114 0 : while(rRect.Left() < aNewPos.X())
115 0 : aNewPos.X() -= nFreeSpaceX;
116 : }
117 :
118 0 : if(nFreeSpaceY < 0)
119 : {
120 0 : if(aInnerRectangle.Top() > rRect.Bottom())
121 : {
122 : // object moves out to the top
123 0 : aNewPos.Y() -= aVisAreaSize.Height() / 2;
124 : }
125 :
126 0 : if(aInnerRectangle.Bottom() < rRect.Top())
127 : {
128 : // object moves out to the right
129 0 : aNewPos.Y() += aVisAreaSize.Height() / 2;
130 : }
131 : }
132 : else
133 : {
134 0 : if(nFreeSpaceY > rRect.GetHeight())
135 0 : nFreeSpaceY = rRect.GetHeight();
136 :
137 0 : while(rRect.Bottom() > aNewPos.Y() + aVisAreaSize.Height())
138 0 : aNewPos.Y() += nFreeSpaceY;
139 :
140 0 : while(rRect.Top() < aNewPos.Y())
141 0 : aNewPos.Y() -= nFreeSpaceY;
142 : }
143 :
144 : // did position change? Does it need to be set?
145 0 : if(aNewPos != aVisArea.TopLeft())
146 : {
147 0 : aVisArea.SetPos(aNewPos);
148 0 : SetZoomRect(aVisArea);
149 : }
150 : }
151 0 : }
152 :
153 114 : }
154 :
155 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|