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 : #ifndef SD_FRAME_VIEW
35 : #include "FrameView.hxx"
36 : #endif
37 : #include "sdresid.hxx"
38 : #include "drawdoc.hxx"
39 : #include "DrawDocShell.hxx"
40 : #include "Window.hxx"
41 : #include "GraphicViewShell.hxx"
42 : #include "drawview.hxx"
43 :
44 : #include "slideshow.hxx"
45 :
46 : namespace sd {
47 :
48 : #define TABCONTROL_INITIAL_SIZE 500
49 :
50 : /*************************************************************************
51 : |*
52 : |* Sprung zu Bookmark
53 : |*
54 : \************************************************************************/
55 :
56 0 : sal_Bool DrawViewShell::GotoBookmark(const String& rBookmark)
57 : {
58 0 : sal_Bool bRet = sal_False;
59 0 : ::sd::DrawDocShell* pDocSh = GetDocSh();
60 0 : if( pDocSh )
61 : {
62 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
63 0 : pDocSh->Connect(this);
64 0 : bRet = (pDocSh->GotoBookmark(rBookmark));
65 : }
66 0 : return bRet;
67 : }
68 :
69 : /*************************************************************************
70 : |*
71 : |* Bereich sichtbar machen (Bildausschnitt scrollen)
72 : |*
73 : \************************************************************************/
74 :
75 0 : void DrawViewShell::MakeVisible(const Rectangle& rRect, ::Window& rWin)
76 : {
77 : // In older versions, if in X or Y the size of the object was
78 : // smaller than the visible area, the user-defined zoom was
79 : // changed. This was decided to be a bug for 6.x, thus I developed a
80 : // version which instead handles X/Y bigger/smaller and visibility
81 : // questions seperately. The new behaviour is triggered with the
82 : // bZoomAllowed parameter which for old behaviour should be set to
83 : // sal_True. I looked at all uses of MakeVisible() in the application
84 : // and found no valid reason for really changing the zoom factor, thus I
85 : // decided to NOT expand (incompatible) this virtual method to get one
86 : // more parameter. If this is wanted in later versions, feel free to add
87 : // that bool to the parameter list.
88 0 : sal_Bool bZoomAllowed(sal_False);
89 0 : Size aLogicSize(rRect.GetSize());
90 :
91 : // Sichtbarer Bereich
92 0 : Size aVisSizePixel(rWin.GetOutputSizePixel());
93 0 : Rectangle aVisArea(rWin.PixelToLogic(Rectangle(Point(0,0), aVisSizePixel)));
94 0 : Size aVisAreaSize(aVisArea.GetSize());
95 :
96 0 : if(!aVisArea.IsInside(rRect) && !SlideShow::IsRunning( GetViewShellBase() ) )
97 : {
98 : // Objekt liegt nicht komplett im sichtbaren Bereich
99 0 : sal_Int32 nFreeSpaceX(aVisAreaSize.Width() - aLogicSize.Width());
100 0 : sal_Int32 nFreeSpaceY(aVisAreaSize.Height() - aLogicSize.Height());
101 :
102 0 : if(bZoomAllowed && (nFreeSpaceX < 0 || nFreeSpaceY < 0))
103 : {
104 : // Objekt passt nicht in sichtbaren Bereich -> auf Objektgroesse zoomen
105 0 : SetZoomRect(rRect);
106 : }
107 : else
108 : {
109 : // allow a mode for move-only visibility without zooming.
110 0 : const sal_Int32 nPercentBorder(30);
111 : const Rectangle aInnerRectangle(
112 0 : aVisArea.Left() + ((aVisAreaSize.Width() * nPercentBorder) / 200),
113 0 : aVisArea.Top() + ((aVisAreaSize.Height() * nPercentBorder) / 200),
114 0 : aVisArea.Right() - ((aVisAreaSize.Width() * nPercentBorder) / 200),
115 0 : aVisArea.Bottom() - ((aVisAreaSize.Height() * nPercentBorder) / 200)
116 0 : );
117 0 : Point aNewPos(aVisArea.TopLeft());
118 :
119 0 : if(nFreeSpaceX < 0)
120 : {
121 0 : if(aInnerRectangle.Left() > rRect.Right())
122 : {
123 : // object moves out to the left
124 0 : aNewPos.X() -= aVisAreaSize.Width() / 2;
125 : }
126 :
127 0 : if(aInnerRectangle.Right() < rRect.Left())
128 : {
129 : // object moves out to the right
130 0 : aNewPos.X() += aVisAreaSize.Width() / 2;
131 : }
132 : }
133 : else
134 : {
135 0 : if(nFreeSpaceX > rRect.GetWidth())
136 0 : nFreeSpaceX = rRect.GetWidth();
137 :
138 0 : while(rRect.Right() > aNewPos.X() + aVisAreaSize.Width())
139 0 : aNewPos.X() += nFreeSpaceX;
140 :
141 0 : while(rRect.Left() < aNewPos.X())
142 0 : aNewPos.X() -= nFreeSpaceX;
143 : }
144 :
145 0 : if(nFreeSpaceY < 0)
146 : {
147 0 : if(aInnerRectangle.Top() > rRect.Bottom())
148 : {
149 : // object moves out to the top
150 0 : aNewPos.Y() -= aVisAreaSize.Height() / 2;
151 : }
152 :
153 0 : if(aInnerRectangle.Bottom() < rRect.Top())
154 : {
155 : // object moves out to the right
156 0 : aNewPos.Y() += aVisAreaSize.Height() / 2;
157 : }
158 : }
159 : else
160 : {
161 0 : if(nFreeSpaceY > rRect.GetHeight())
162 0 : nFreeSpaceY = rRect.GetHeight();
163 :
164 0 : while(rRect.Bottom() > aNewPos.Y() + aVisAreaSize.Height())
165 0 : aNewPos.Y() += nFreeSpaceY;
166 :
167 0 : while(rRect.Top() < aNewPos.Y())
168 0 : aNewPos.Y() -= nFreeSpaceY;
169 : }
170 :
171 : // did position change? Does it need to be set?
172 0 : if(aNewPos != aVisArea.TopLeft())
173 : {
174 0 : aVisArea.SetPos(aNewPos);
175 0 : SetZoomRect(aVisArea);
176 : }
177 : }
178 : }
179 0 : }
180 :
181 : }
182 :
183 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|