merge the formfield patch from ooo-build
[ooovba.git] / sd / source / ui / toolpanel / ConstrainedIterator.cxx
blobddbe3b21d2058b09a4eb2ced25a1b681dd6f5857
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: ConstrainedIterator.cxx,v $
10 * $Revision: 1.5 $
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 // This is a definition file of a template class. It is therefore
35 // included by other files and thus has to be guarded against multiple
36 // inclusion.
38 #ifndef SD_TOOLPANEL_CONSTRAINED_ITERATOR_CXX
39 #define SD_TOOLPANEL_CONSTRAINED_ITERATOR_CXX
41 namespace sd { namespace toolpanel {
44 template <class Container>
45 ConstrainedIterator<Container>::value_type&
46 ConstrainedIterator<Container>::operator* (void)
48 return *maIterator;
54 template <class Container>
55 const ConstrainedIterator<Container>::value_type&
56 ConstrainedIterator<Container>::operator* (void)
57 const
59 return *maIterator;
65 template <class Container>
66 ConstrainedIterator<Container>::value_type&
67 ConstrainedIterator<Container>::operator-> (void)
69 return *maIterator;
75 template <class Container>
76 const ConstrainedIterator<Container>::value_type&
77 ConstrainedIterator<Container>::operator-> (void)
78 const
80 return *maIterator;
87 template <class Container>
88 ConstrainedIterator<Container>
89 ::ConstrainedIterator (void)
90 : mpContainer (NULL)
97 template <class Container>
98 ConstrainedIterator<Container>::ConstrainedIterator (
99 const Container& rContainer,
100 const Container::iterator& rIterator)
101 : mpContainer(&rContainer),
102 maIterator (rIterator),
103 mpConstraint (NULL)
105 AdvanceToNextValidElement();
111 template <class Container>
112 ConstrainedIterator<Container>::ConstrainedIterator (
113 const Container& rContainer,
114 const Container::iterator& rIterator,
115 const Constraint<Container>& rConstraint)
116 : mpContainer(&rContainer),
117 maIterator (rIterator),
118 mpConstraint (&rConstraint)
120 AdvanceToNextValidElement();
126 template <class Container>
127 ConstrainedIterator<Container>::ConstrainedIterator (
128 const ConstrainedIterator& rIterator)
129 : mpContainer (rIterator.mpContainer),
130 maIterator (rIterator.maIterator),
131 mpConstraint (rIterator.mpConstraint)
133 // Everything has been done in the initializer
139 template <class Container>
140 ConstrainedIterator<Container>&
141 ConstrainedIterator<Container>
142 ::operator= (const ConstrainedIterator& rIterator)
144 mpContainer = rIterator.mpContainer;
145 maIterator = rIterator.maIterator;
146 mpConstraint = rIterator.mpConstraint;
148 AdvanceToNextValidElement();
150 return *this;
156 template <class Container>
157 bool ConstrainedIterator<Container>::operator== (
158 const ConstrainedIterator& aIterator) const
160 return ! operator!=(aIterator);
166 template <class Container>
167 bool ConstrainedIterator<Container>::operator!= (
168 const ConstrainedIterator& aIterator) const
170 return maIterator != aIterator.maIterator;
176 template <class Container>
177 ConstrainedIterator<Container>&
178 ConstrainedIterator<Container>::operator++ (void)
180 maIterator++;
181 AdvanceToNextValidElement();
182 return *this;
188 template <class Container>
189 ConstrainedIterator<Container>
190 ConstrainedIterator<Container>::operator++ (int)
192 ConstrainedIterator aIterator (*this);
193 ++(*this);
194 return aIterator;
200 template <class Container>
201 ConstrainedIterator<Container>&
202 ConstrainedIterator<Container>::operator-- (void)
204 maIterator--;
205 AdvanceToPreviousValidElement();
206 return *this;
212 template <class Container>
213 ConstrainedIterator<Container>
214 ConstrainedIterator<Container>::operator-- (int)
216 ConstrainedIterator aIterator (*this);
217 --(*this);
218 return aIterator;
224 template <class Container>
225 ConstrainedIterator<Container>
226 ConstrainedIterator<Container>::operator+ (int nValue) const
228 return ConstrainedIterator (*mpContainer, maIterator+nValue);
233 template <class Container>
234 ConstrainedIterator<Container>
235 ConstrainedIterator<Container>::operator- (int nValue) const
237 return ConstrainedIterator (*mpContainer, maIterator-nValue);
242 template <class Container>
243 void ConstrainedIterator<Container>::AdvanceToNextValidElement (void)
245 if (mpContainer!=NULL && mpConstraint!=NULL)
247 while (maIterator != mpContainer->end()
248 && ! mpConstraint->operator()(*mpContainer, maIterator))
249 ++maIterator;
256 template <class Container>
257 void ConstrainedIterator<Container>::AdvanceToPreviousValidElement (void)
259 if (mpContainer!=NULL && mpConstraint!=NULL)
261 while (maIterator != mpContainer->begin()
262 && ! mpConstraint->operator()(*mpContainer, maIterator))
263 --maIterator;
268 } } // end of namespace ::sd::toolpanel
270 #endif