merge the formfield patch from ooo-build
[ooovba.git] / sd / source / ui / view / zoomlist.cxx
blob034d92eb03c5f67ce3a714b9c260b89ed8f0c443
1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: zoomlist.cxx,v $
10 * $Revision: 1.8 $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
31 // MARKER(update_precomp.py): autogen include statement, do not remove
32 #include "precompiled_sd.hxx"
34 #include "zoomlist.hxx"
36 #ifndef _SVXIDS_HRC
37 #include <svx/svxids.hrc>
38 #endif
39 #include <sfx2/bindings.hxx>
40 #include <sfx2/viewfrm.hxx>
41 #ifndef _SFXVIEWSHELL_HXX
42 #include <sfx2/viewsh.hxx>
43 #endif
46 #include "ViewShell.hxx"
48 namespace sd {
50 #define MAX_ENTRYS 10
52 /*************************************************************************
54 |* Konstruktor
56 \************************************************************************/
58 ZoomList::ZoomList(ViewShell* pViewShell)
59 : List()
60 , mpViewShell (pViewShell)
61 , mnCurPos(0)
66 /*************************************************************************
68 |* Destruktor
70 \************************************************************************/
72 ZoomList::~ZoomList()
74 #if ( defined GCC && defined C272 )
75 for (ULONG nObject=0; nObject<List::Count(); nObject++)
76 #else
77 for (ULONG nObject=0; nObject<Count(); nObject++)
78 #endif
80 // Ggf. ZoomRects loeschen
81 delete ((Rectangle*) GetObject(nObject));
86 /*************************************************************************
88 |* Neues ZoomRect aufnehmen
90 \************************************************************************/
92 void ZoomList::InsertZoomRect(const Rectangle& rRect)
94 ULONG nRectCount = Count();
96 if (nRectCount >= MAX_ENTRYS)
98 delete ((Rectangle*) GetObject(0));
99 Remove((ULONG) 0);
101 else if (nRectCount == 0)
103 mnCurPos = 0;
105 else
107 mnCurPos++;
110 Rectangle* pRect = new Rectangle(rRect);
111 Insert(pRect, mnCurPos);
113 SfxBindings& rBindings = mpViewShell->GetViewFrame()->GetBindings();
114 rBindings.Invalidate( SID_ZOOM_NEXT );
115 rBindings.Invalidate( SID_ZOOM_PREV );
119 /*************************************************************************
121 |* Aktuelles ZoomRect herausgeben
123 \************************************************************************/
125 Rectangle ZoomList::GetCurrentZoomRect() const
127 Rectangle aRect(*(Rectangle*) GetObject(mnCurPos));
128 return (aRect);
131 /*************************************************************************
133 |* Naechstes ZoomRect herausgeben
135 \************************************************************************/
137 Rectangle ZoomList::GetNextZoomRect()
139 mnCurPos++;
140 ULONG nRectCount = Count();
142 if (nRectCount > 0 && mnCurPos > nRectCount - 1)
144 mnCurPos = nRectCount - 1;
147 SfxBindings& rBindings = mpViewShell->GetViewFrame()->GetBindings();
148 rBindings.Invalidate( SID_ZOOM_NEXT );
149 rBindings.Invalidate( SID_ZOOM_PREV );
151 Rectangle aRect(*(Rectangle*) GetObject(mnCurPos));
152 return (aRect);
155 /*************************************************************************
157 |* Letztes ZoomRect herausgeben
159 \************************************************************************/
161 Rectangle ZoomList::GetPreviousZoomRect()
163 if (mnCurPos > 0)
165 mnCurPos--;
168 SfxBindings& rBindings = mpViewShell->GetViewFrame()->GetBindings();
169 rBindings.Invalidate( SID_ZOOM_NEXT );
170 rBindings.Invalidate( SID_ZOOM_PREV );
172 Rectangle aRect(*(Rectangle*) GetObject(mnCurPos));
173 return (aRect);
176 /*************************************************************************
178 |* Gibt es ein naechstes ZoomRect?
180 \************************************************************************/
182 BOOL ZoomList::IsNextPossible() const
184 BOOL bPossible = FALSE;
185 ULONG nRectCount = Count();
187 if (nRectCount > 0 && mnCurPos < nRectCount - 1)
189 bPossible = TRUE;
192 return (bPossible);
195 /*************************************************************************
197 |* Gibt es ein vorheriges ZoomRect?
199 \************************************************************************/
201 BOOL ZoomList::IsPreviousPossible() const
203 BOOL bPossible = FALSE;
205 if (mnCurPos > 0)
207 bPossible = TRUE;
210 return (bPossible);
213 } // end of namespace sd