xref: /aoo41x/main/sd/source/ui/view/zoomlist.cxx (revision cdf0e10c)
1 /*************************************************************************
2  *
3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4  *
5  * Copyright 2000, 2010 Oracle and/or its affiliates.
6  *
7  * OpenOffice.org - a multi-platform office productivity suite
8  *
9  * This file is part of OpenOffice.org.
10  *
11  * OpenOffice.org is free software: you can redistribute it and/or modify
12  * it under the terms of the GNU Lesser General Public License version 3
13  * only, as published by the Free Software Foundation.
14  *
15  * OpenOffice.org is distributed in the hope that it will be useful,
16  * but WITHOUT ANY WARRANTY; without even the implied warranty of
17  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
18  * GNU Lesser General Public License version 3 for more details
19  * (a copy is included in the LICENSE file that accompanied this code).
20  *
21  * You should have received a copy of the GNU Lesser General Public License
22  * version 3 along with OpenOffice.org.  If not, see
23  * <http://www.openoffice.org/license.html>
24  * for a copy of the LGPLv3 License.
25  *
26  ************************************************************************/
27 
28 // MARKER(update_precomp.py): autogen include statement, do not remove
29 #include "precompiled_sd.hxx"
30 
31 #include "zoomlist.hxx"
32 
33 #ifndef _SVXIDS_HRC
34 #include <svx/svxids.hrc>
35 #endif
36 #include <sfx2/bindings.hxx>
37 #include <sfx2/viewfrm.hxx>
38 #ifndef _SFXVIEWSHELL_HXX
39 #include <sfx2/viewsh.hxx>
40 #endif
41 
42 
43 #include "ViewShell.hxx"
44 
45 namespace sd {
46 
47 #define MAX_ENTRYS	10
48 
49 /*************************************************************************
50 |*
51 |* Konstruktor
52 |*
53 \************************************************************************/
54 
55 ZoomList::ZoomList(ViewShell* pViewShell)
56 : List()
57 , mpViewShell (pViewShell)
58 , mnCurPos(0)
59 {
60 }
61 
62 
63 /*************************************************************************
64 |*
65 |* Destruktor
66 |*
67 \************************************************************************/
68 
69 ZoomList::~ZoomList()
70 {
71 #if ( defined GCC && defined C272 )
72 	for (sal_uLong nObject=0; nObject<List::Count(); nObject++)
73 #else
74 	for (sal_uLong nObject=0; nObject<Count(); nObject++)
75 #endif
76 	{
77 		// Ggf. ZoomRects loeschen
78 		delete ((Rectangle*) GetObject(nObject));
79 	}
80 }
81 
82 
83 /*************************************************************************
84 |*
85 |* Neues ZoomRect aufnehmen
86 |*
87 \************************************************************************/
88 
89 void ZoomList::InsertZoomRect(const Rectangle& rRect)
90 {
91 	sal_uLong nRectCount = Count();
92 
93 	if (nRectCount >= MAX_ENTRYS)
94 	{
95 		delete ((Rectangle*) GetObject(0));
96 		Remove((sal_uLong) 0);
97 	}
98 	else if (nRectCount == 0)
99 	{
100 		mnCurPos = 0;
101 	}
102 	else
103 	{
104 		mnCurPos++;
105 	}
106 
107 	Rectangle* pRect = new Rectangle(rRect);
108 	Insert(pRect, mnCurPos);
109 
110 	SfxBindings& rBindings = mpViewShell->GetViewFrame()->GetBindings();
111 	rBindings.Invalidate( SID_ZOOM_NEXT );
112 	rBindings.Invalidate( SID_ZOOM_PREV );
113 }
114 
115 /*************************************************************************
116 |*
117 |* Naechstes ZoomRect herausgeben
118 |*
119 \************************************************************************/
120 
121 Rectangle ZoomList::GetNextZoomRect()
122 {
123 	mnCurPos++;
124 	sal_uLong nRectCount = Count();
125 
126 	if (nRectCount > 0 && mnCurPos > nRectCount - 1)
127 	{
128 		mnCurPos = nRectCount - 1;
129 	}
130 
131 	SfxBindings& rBindings = mpViewShell->GetViewFrame()->GetBindings();
132 	rBindings.Invalidate( SID_ZOOM_NEXT );
133 	rBindings.Invalidate( SID_ZOOM_PREV );
134 
135 	Rectangle aRect(*(Rectangle*) GetObject(mnCurPos));
136 	return (aRect);
137 }
138 
139 /*************************************************************************
140 |*
141 |* Letztes ZoomRect herausgeben
142 |*
143 \************************************************************************/
144 
145 Rectangle ZoomList::GetPreviousZoomRect()
146 {
147 	if (mnCurPos > 0)
148 	{
149 		mnCurPos--;
150 	}
151 
152 	SfxBindings& rBindings = mpViewShell->GetViewFrame()->GetBindings();
153 	rBindings.Invalidate( SID_ZOOM_NEXT );
154 	rBindings.Invalidate( SID_ZOOM_PREV );
155 
156 	Rectangle aRect(*(Rectangle*) GetObject(mnCurPos));
157 	return (aRect);
158 }
159 
160 /*************************************************************************
161 |*
162 |* Gibt es ein naechstes ZoomRect?
163 |*
164 \************************************************************************/
165 
166 sal_Bool ZoomList::IsNextPossible() const
167 {
168 	sal_Bool bPossible = sal_False;
169 	sal_uLong nRectCount = Count();
170 
171 	if (nRectCount > 0 && mnCurPos < nRectCount - 1)
172 	{
173 		bPossible = sal_True;
174 	}
175 
176 	return (bPossible);
177 }
178 
179 /*************************************************************************
180 |*
181 |* Gibt es ein vorheriges ZoomRect?
182 |*
183 \************************************************************************/
184 
185 sal_Bool ZoomList::IsPreviousPossible() const
186 {
187 	sal_Bool bPossible = sal_False;
188 
189 	if (mnCurPos > 0)
190 	{
191 		bPossible = sal_True;
192 	}
193 
194 	return (bPossible);
195 }
196 
197 } // end of namespace sd
198