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