xref: /trunk/main/sd/source/ui/view/zoomlist.cxx (revision 79aad27f)
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 
23 
24 // MARKER(update_precomp.py): autogen include statement, do not remove
25 #include "precompiled_sd.hxx"
26 
27 #include "zoomlist.hxx"
28 
29 #ifndef _SVXIDS_HRC
30 #include <svx/svxids.hrc>
31 #endif
32 #include <sfx2/bindings.hxx>
33 #include <sfx2/viewfrm.hxx>
34 #ifndef _SFXVIEWSHELL_HXX
35 #include <sfx2/viewsh.hxx>
36 #endif
37 
38 
39 #include "ViewShell.hxx"
40 
41 namespace sd {
42 
43 #define MAX_ENTRYS	10
44 
45 /*************************************************************************
46 |*
47 |* Konstruktor
48 |*
49 \************************************************************************/
50 
ZoomList(ViewShell * pViewShell)51 ZoomList::ZoomList(ViewShell* pViewShell)
52 : List()
53 , mpViewShell (pViewShell)
54 , mnCurPos(0)
55 {
56 }
57 
58 
59 /*************************************************************************
60 |*
61 |* Destruktor
62 |*
63 \************************************************************************/
64 
~ZoomList()65 ZoomList::~ZoomList()
66 {
67 #if ( defined GCC && defined C272 )
68 	for (sal_uLong nObject=0; nObject<List::Count(); nObject++)
69 #else
70 	for (sal_uLong nObject=0; nObject<Count(); nObject++)
71 #endif
72 	{
73 		// Ggf. ZoomRects loeschen
74 		delete ((Rectangle*) GetObject(nObject));
75 	}
76 }
77 
78 
79 /*************************************************************************
80 |*
81 |* Neues ZoomRect aufnehmen
82 |*
83 \************************************************************************/
84 
InsertZoomRect(const Rectangle & rRect)85 void ZoomList::InsertZoomRect(const Rectangle& rRect)
86 {
87 	sal_uLong nRectCount = Count();
88 
89 	if (nRectCount >= MAX_ENTRYS)
90 	{
91 		delete ((Rectangle*) GetObject(0));
92 		Remove((sal_uLong) 0);
93 	}
94 	else if (nRectCount == 0)
95 	{
96 		mnCurPos = 0;
97 	}
98 	else
99 	{
100 		mnCurPos++;
101 	}
102 
103 	Rectangle* pRect = new Rectangle(rRect);
104 	Insert(pRect, mnCurPos);
105 
106 	SfxBindings& rBindings = mpViewShell->GetViewFrame()->GetBindings();
107 	rBindings.Invalidate( SID_ZOOM_NEXT );
108 	rBindings.Invalidate( SID_ZOOM_PREV );
109 }
110 
111 /*************************************************************************
112 |*
113 |* Naechstes ZoomRect herausgeben
114 |*
115 \************************************************************************/
116 
GetNextZoomRect()117 Rectangle ZoomList::GetNextZoomRect()
118 {
119 	mnCurPos++;
120 	sal_uLong nRectCount = Count();
121 
122 	if (nRectCount > 0 && mnCurPos > nRectCount - 1)
123 	{
124 		mnCurPos = nRectCount - 1;
125 	}
126 
127 	SfxBindings& rBindings = mpViewShell->GetViewFrame()->GetBindings();
128 	rBindings.Invalidate( SID_ZOOM_NEXT );
129 	rBindings.Invalidate( SID_ZOOM_PREV );
130 
131 	Rectangle aRect(*(Rectangle*) GetObject(mnCurPos));
132 	return (aRect);
133 }
134 
135 /*************************************************************************
136 |*
137 |* Letztes ZoomRect herausgeben
138 |*
139 \************************************************************************/
140 
GetPreviousZoomRect()141 Rectangle ZoomList::GetPreviousZoomRect()
142 {
143 	if (mnCurPos > 0)
144 	{
145 		mnCurPos--;
146 	}
147 
148 	SfxBindings& rBindings = mpViewShell->GetViewFrame()->GetBindings();
149 	rBindings.Invalidate( SID_ZOOM_NEXT );
150 	rBindings.Invalidate( SID_ZOOM_PREV );
151 
152 	Rectangle aRect(*(Rectangle*) GetObject(mnCurPos));
153 	return (aRect);
154 }
155 
156 /*************************************************************************
157 |*
158 |* Gibt es ein naechstes ZoomRect?
159 |*
160 \************************************************************************/
161 
IsNextPossible() const162 sal_Bool ZoomList::IsNextPossible() const
163 {
164 	sal_Bool bPossible = sal_False;
165 	sal_uLong nRectCount = Count();
166 
167 	if (nRectCount > 0 && mnCurPos < nRectCount - 1)
168 	{
169 		bPossible = sal_True;
170 	}
171 
172 	return (bPossible);
173 }
174 
175 /*************************************************************************
176 |*
177 |* Gibt es ein vorheriges ZoomRect?
178 |*
179 \************************************************************************/
180 
IsPreviousPossible() const181 sal_Bool ZoomList::IsPreviousPossible() const
182 {
183 	sal_Bool bPossible = sal_False;
184 
185 	if (mnCurPos > 0)
186 	{
187 		bPossible = sal_True;
188 	}
189 
190 	return (bPossible);
191 }
192 
193 } // end of namespace sd
194