xref: /AOO42X/main/sd/source/ui/view/zoomlist.cxx (revision 9ef95394755e89ea68a9e224c657b2e284e46ad0)
1 /**************************************************************
2  *
3  * Licensed to the Apache Software Foundation (ASF) under one
4  * or more contributor license agreements.  See the NOTICE file
5  * distributed with this work for additional information
6  * regarding copyright ownership.  The ASF licenses this file
7  * to you under the Apache License, Version 2.0 (the
8  * "License"); you may not use this file except in compliance
9  * with the License.  You may obtain a copy of the License at
10  *
11  *   http://www.apache.org/licenses/LICENSE-2.0
12  *
13  * Unless required by applicable law or agreed to in writing,
14  * software distributed under the License is distributed on an
15  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16  * KIND, either express or implied.  See the License for the
17  * specific language governing permissions and limitations
18  * under the License.
19  *
20  *************************************************************/
21 
22 // MARKER(update_precomp.py): autogen include statement, do not remove
23 #include "precompiled_sd.hxx"
24 
25 #include "zoomlist.hxx"
26 
27 #ifndef _SVXIDS_HRC
28 #include <svx/svxids.hrc>
29 #endif
30 #include <sfx2/bindings.hxx>
31 #include <sfx2/viewfrm.hxx>
32 #ifndef _SFXVIEWSHELL_HXX
33 #include <sfx2/viewsh.hxx>
34 #endif
35 
36 #include "ViewShell.hxx"
37 
38 namespace sd {
39 
40 #define MAX_ENTRYS  10
41 
42 /*************************************************************************
43 |* Konstruktor
44 \************************************************************************/
45 
ZoomList(ViewShell * pViewShell)46 ZoomList::ZoomList(ViewShell* pViewShell)
47 : List()
48 , mpViewShell (pViewShell)
49 , mnCurPos(0)
50 {
51 }
52 
53 /*************************************************************************
54 |* Destruktor
55 \************************************************************************/
56 
~ZoomList()57 ZoomList::~ZoomList()
58 {
59 #if ( defined GCC && defined C272 )
60     for (sal_uLong nObject=0; nObject<List::Count(); nObject++)
61 #else
62     for (sal_uLong nObject=0; nObject<Count(); nObject++)
63 #endif
64     {
65         // Ggf. ZoomRects löschen
66         delete ((Rectangle*) GetObject(nObject));
67     }
68 }
69 
70 /*************************************************************************
71 |* Neues ZoomRect aufnehmen
72 \************************************************************************/
73 
InsertZoomRect(const Rectangle & rRect)74 void ZoomList::InsertZoomRect(const Rectangle& rRect)
75 {
76     sal_uLong nRectCount = Count();
77 
78     if (nRectCount >= MAX_ENTRYS)
79     {
80         delete ((Rectangle*) GetObject(0));
81         Remove((sal_uLong) 0);
82     }
83     else if (nRectCount == 0)
84     {
85         mnCurPos = 0;
86     }
87     else
88     {
89         mnCurPos++;
90     }
91 
92     Rectangle* pRect = new Rectangle(rRect);
93     Insert(pRect, mnCurPos);
94 
95     SfxBindings& rBindings = mpViewShell->GetViewFrame()->GetBindings();
96     rBindings.Invalidate( SID_ZOOM_NEXT );
97     rBindings.Invalidate( SID_ZOOM_PREV );
98 }
99 
100 /*************************************************************************
101 |* Nächstes ZoomRect herausgeben
102 \************************************************************************/
103 
GetNextZoomRect()104 Rectangle ZoomList::GetNextZoomRect()
105 {
106     mnCurPos++;
107     sal_uLong nRectCount = Count();
108 
109     if (nRectCount > 0 && mnCurPos > nRectCount - 1)
110     {
111         mnCurPos = nRectCount - 1;
112     }
113 
114     SfxBindings& rBindings = mpViewShell->GetViewFrame()->GetBindings();
115     rBindings.Invalidate( SID_ZOOM_NEXT );
116     rBindings.Invalidate( SID_ZOOM_PREV );
117 
118     Rectangle aRect(*(Rectangle*) GetObject(mnCurPos));
119     return (aRect);
120 }
121 
122 /*************************************************************************
123 |* Letztes ZoomRect herausgeben
124 \************************************************************************/
125 
GetPreviousZoomRect()126 Rectangle ZoomList::GetPreviousZoomRect()
127 {
128     if (mnCurPos > 0)
129     {
130         mnCurPos--;
131     }
132 
133     SfxBindings& rBindings = mpViewShell->GetViewFrame()->GetBindings();
134     rBindings.Invalidate( SID_ZOOM_NEXT );
135     rBindings.Invalidate( SID_ZOOM_PREV );
136 
137     Rectangle aRect(*(Rectangle*) GetObject(mnCurPos));
138     return (aRect);
139 }
140 
141 /*************************************************************************
142 |* Gibt es ein nächstes ZoomRect?
143 \************************************************************************/
144 
IsNextPossible() const145 sal_Bool ZoomList::IsNextPossible() const
146 {
147     sal_Bool bPossible = sal_False;
148     sal_uLong nRectCount = Count();
149 
150     if (nRectCount > 0 && mnCurPos < nRectCount - 1)
151     {
152         bPossible = sal_True;
153     }
154 
155     return (bPossible);
156 }
157 
158 /*************************************************************************
159 |* Gibt es ein vorheriges ZoomRect?
160 \************************************************************************/
161 
IsPreviousPossible() const162 sal_Bool ZoomList::IsPreviousPossible() const
163 {
164     sal_Bool bPossible = sal_False;
165 
166     if (mnCurPos > 0)
167     {
168         bPossible = sal_True;
169     }
170 
171     return (bPossible);
172 }
173 
174 } // end of namespace sd
175 
176 /* vim: set noet sw=4 ts=4: */
177