Update ooo320-m1
[ooovba.git] / sd / source / ui / toolpanel / ControlDescriptorIterator.cxx
blobc44be2f70b9f8afe5495ed466d13e8dad084a144
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: ControlDescriptorIterator.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"
35 #include "ControlDescriptorIterator.hxx"
37 #include "ControlContainer.hxx"
38 #include "ControlContainerDescriptor.hxx"
40 namespace sd { namespace toolpanel {
43 ControlDescriptorIterator::ControlDescriptorIterator (void)
44 : mpContainer (NULL),
45 mbSkipInvisibleControls(true)
52 ControlDescriptorIterator::ControlDescriptorIterator (
53 ControlDescriptorList& rContainer,
54 const ControlDescriptorList::iterator& aIterator,
55 bool bSkipInvisibleControls)
56 : mpContainer(&rContainer),
57 maIterator (aIterator),
58 mbSkipInvisibleControls(bSkipInvisibleControls)
60 AdvanceToNextVisibleControl();
66 ControlDescriptorIterator::ControlDescriptorIterator (
67 const ControlDescriptorIterator& aIterator)
68 : mpContainer (aIterator.mpContainer),
69 maIterator (aIterator.maIterator),
70 mbSkipInvisibleControls (aIterator.mbSkipInvisibleControls)
77 ControlDescriptorIterator& ControlDescriptorIterator::operator= (
78 const ControlDescriptorIterator& aIterator)
80 mpContainer = aIterator.mpContainer;
81 maIterator = aIterator.maIterator;
82 mbSkipInvisibleControls = aIterator.mbSkipInvisibleControls;
84 AdvanceToNextVisibleControl();
86 return *this;
92 ControlDescriptorIterator::value_type&
93 ControlDescriptorIterator::operator* (void)
95 return *maIterator;
101 const ControlDescriptorIterator::value_type&
102 ControlDescriptorIterator::operator* (void)
103 const
105 return *maIterator;
111 ControlDescriptorIterator::value_type&
112 ControlDescriptorIterator::operator-> (void)
114 return *maIterator;
120 const ControlDescriptorIterator::value_type&
121 ControlDescriptorIterator::operator-> (void)
122 const
124 return *maIterator;
130 bool ControlDescriptorIterator::operator== (
131 const ControlDescriptorIterator& aIterator) const
133 return ! operator!=(aIterator);
139 bool ControlDescriptorIterator::operator!= (
140 const ControlDescriptorIterator& aIterator) const
142 return maIterator != aIterator.maIterator;
148 ControlDescriptorIterator& ControlDescriptorIterator::operator++ (void)
150 maIterator++;
151 AdvanceToNextVisibleControl();
152 return *this;
157 ControlDescriptorIterator ControlDescriptorIterator::operator++ (int)
159 ControlDescriptorIterator aIterator (*this);
160 ++(*this);
161 return aIterator;
167 ControlDescriptorIterator& ControlDescriptorIterator::operator-- (void)
169 maIterator--;
170 AdvanceToPreviousVisibleControl();
171 return *this;
176 ControlDescriptorIterator ControlDescriptorIterator::operator-- (int)
178 ControlDescriptorIterator aIterator (*this);
179 --(*this);
180 return aIterator;
186 ControlDescriptorIterator ControlDescriptorIterator::operator+ (
187 int nValue) const
189 return ControlDescriptorIterator (*mpContainer, maIterator+nValue);
194 ControlDescriptorIterator ControlDescriptorIterator::operator- (
195 int nValue) const
197 return ControlDescriptorIterator (*mpContainer, maIterator-nValue);
202 void ControlDescriptorIterator::AdvanceToNextVisibleControl (void)
204 if (mbSkipInvisibleControls && mpContainer!=NULL)
206 while (maIterator != mpContainer->end()
207 && ! (**maIterator).IsVisible())
208 ++maIterator;
215 void ControlDescriptorIterator::AdvanceToPreviousVisibleControl (void)
217 if (mbSkipInvisibleControls && mpContainer!=NULL)
219 while (maIterator != mpContainer->begin()
220 && ! (**maIterator).IsVisible())
221 --maIterator;
225 } } // end of namespace ::sd::toolpanel