xref: /AOO42X/main/svl/source/items/itemiter.cxx (revision b1c5455db1639c48e26c568e4fa7ee78ca5d60ee)
1*40df464eSAndrew Rist /**************************************************************
2cdf0e10cSrcweir  *
3*40df464eSAndrew Rist  * Licensed to the Apache Software Foundation (ASF) under one
4*40df464eSAndrew Rist  * or more contributor license agreements.  See the NOTICE file
5*40df464eSAndrew Rist  * distributed with this work for additional information
6*40df464eSAndrew Rist  * regarding copyright ownership.  The ASF licenses this file
7*40df464eSAndrew Rist  * to you under the Apache License, Version 2.0 (the
8*40df464eSAndrew Rist  * "License"); you may not use this file except in compliance
9*40df464eSAndrew Rist  * with the License.  You may obtain a copy of the License at
10cdf0e10cSrcweir  *
11*40df464eSAndrew Rist  *   http://www.apache.org/licenses/LICENSE-2.0
12cdf0e10cSrcweir  *
13*40df464eSAndrew Rist  * Unless required by applicable law or agreed to in writing,
14*40df464eSAndrew Rist  * software distributed under the License is distributed on an
15*40df464eSAndrew Rist  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16*40df464eSAndrew Rist  * KIND, either express or implied.  See the License for the
17*40df464eSAndrew Rist  * specific language governing permissions and limitations
18*40df464eSAndrew Rist  * under the License.
19cdf0e10cSrcweir  *
20*40df464eSAndrew Rist  *************************************************************/
21*40df464eSAndrew Rist 
22*40df464eSAndrew Rist 
23cdf0e10cSrcweir 
24cdf0e10cSrcweir // MARKER(update_precomp.py): autogen include statement, do not remove
25cdf0e10cSrcweir #include "precompiled_svl.hxx"
26cdf0e10cSrcweir 
27cdf0e10cSrcweir #ifndef GCC
28cdf0e10cSrcweir #endif
29cdf0e10cSrcweir 
30cdf0e10cSrcweir #include <svl/itemiter.hxx>
31cdf0e10cSrcweir #include <svl/itempool.hxx>
32cdf0e10cSrcweir #include <svl/itemset.hxx>
33cdf0e10cSrcweir 
34cdf0e10cSrcweir // STATIC DATA -----------------------------------------------------------
35cdf0e10cSrcweir 
36cdf0e10cSrcweir DBG_NAME(SfxItemIter);
37cdf0e10cSrcweir 
38cdf0e10cSrcweir 
39cdf0e10cSrcweir // --------------------------------------------------------------------------
40cdf0e10cSrcweir 
41cdf0e10cSrcweir 
SfxItemIter(const SfxItemSet & rItemSet)42cdf0e10cSrcweir SfxItemIter::SfxItemIter( const SfxItemSet& rItemSet )
43cdf0e10cSrcweir     : _rSet( rItemSet )
44cdf0e10cSrcweir {
45cdf0e10cSrcweir     DBG_CTOR(SfxItemIter, 0);
46cdf0e10cSrcweir     DBG_ASSERTWARNING( _rSet.Count(), "es gibt gar keine Attribute" );
47cdf0e10cSrcweir 
48cdf0e10cSrcweir     if ( !_rSet._nCount )
49cdf0e10cSrcweir     {
50cdf0e10cSrcweir         _nStt = 1;
51cdf0e10cSrcweir         _nEnd = 0;
52cdf0e10cSrcweir     }
53cdf0e10cSrcweir     else
54cdf0e10cSrcweir     {
55cdf0e10cSrcweir         SfxItemArray ppFnd = _rSet._aItems;
56cdf0e10cSrcweir 
57cdf0e10cSrcweir         // suche das 1. gesetzte Item
58cdf0e10cSrcweir         for ( _nStt = 0; !*(ppFnd + _nStt ); ++_nStt )
59cdf0e10cSrcweir             ; // empty loop
60cdf0e10cSrcweir         if ( 1 < _rSet.Count() )
61cdf0e10cSrcweir             for( _nEnd = _rSet.TotalCount(); !*( ppFnd + --_nEnd);  )
62cdf0e10cSrcweir                 ; // empty loop
63cdf0e10cSrcweir         else
64cdf0e10cSrcweir             _nEnd = _nStt;
65cdf0e10cSrcweir     }
66cdf0e10cSrcweir 
67cdf0e10cSrcweir     _nAkt = _nStt;
68cdf0e10cSrcweir }
69cdf0e10cSrcweir 
70cdf0e10cSrcweir // --------------------------------------------------------------------------
71cdf0e10cSrcweir 
72cdf0e10cSrcweir 
~SfxItemIter()73cdf0e10cSrcweir SfxItemIter::~SfxItemIter()
74cdf0e10cSrcweir {
75cdf0e10cSrcweir     DBG_DTOR(SfxItemIter, 0);
76cdf0e10cSrcweir }
77cdf0e10cSrcweir 
78cdf0e10cSrcweir // --------------------------------------------------------------------------
79cdf0e10cSrcweir 
80cdf0e10cSrcweir 
NextItem()81cdf0e10cSrcweir const SfxPoolItem* SfxItemIter::NextItem()
82cdf0e10cSrcweir {
83cdf0e10cSrcweir     DBG_CHKTHIS(SfxItemIter, 0);
84cdf0e10cSrcweir     SfxItemArray ppFnd = _rSet._aItems;
85cdf0e10cSrcweir 
86cdf0e10cSrcweir     if( _nAkt < _nEnd )
87cdf0e10cSrcweir     {
88cdf0e10cSrcweir         do {
89cdf0e10cSrcweir             _nAkt++;
90cdf0e10cSrcweir         } while( _nAkt < _nEnd && !*(ppFnd + _nAkt ) );
91cdf0e10cSrcweir         return *(ppFnd+_nAkt);
92cdf0e10cSrcweir     }
93cdf0e10cSrcweir     return 0;
94cdf0e10cSrcweir }
95cdf0e10cSrcweir 
96cdf0e10cSrcweir // --------------------------------------------------------------------------
97cdf0e10cSrcweir 
98cdf0e10cSrcweir 
PrevItem()99cdf0e10cSrcweir const SfxPoolItem* SfxItemIter::PrevItem()
100cdf0e10cSrcweir {
101cdf0e10cSrcweir     DBG_CHKTHIS(SfxItemIter, 0);
102cdf0e10cSrcweir     SfxItemArray ppFnd = _rSet._aItems;
103cdf0e10cSrcweir 
104cdf0e10cSrcweir     if ( _nAkt > _nStt )
105cdf0e10cSrcweir     {
106cdf0e10cSrcweir         do {
107cdf0e10cSrcweir             --_nAkt;
108cdf0e10cSrcweir         } while( _nAkt && !*(ppFnd + _nAkt ));
109cdf0e10cSrcweir         return *(ppFnd+_nAkt);
110cdf0e10cSrcweir     }
111cdf0e10cSrcweir     return 0;
112cdf0e10cSrcweir }
113