merge the formfield patch from ooo-build
[ooovba.git] / svtools / source / items1 / itemiter.cxx
blob96dc19c3acde8aa520103e72111dafdd85213180
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: itemiter.cxx,v $
10 * $Revision: 1.6 $
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_svtools.hxx"
34 #ifndef GCC
35 #endif
37 #include <svtools/itemiter.hxx>
38 #include <svtools/itempool.hxx>
39 #include <svtools/itemset.hxx>
41 // STATIC DATA -----------------------------------------------------------
43 DBG_NAME(SfxItemIter);
46 // --------------------------------------------------------------------------
49 SfxItemIter::SfxItemIter( const SfxItemSet& rItemSet )
50 : _rSet( rItemSet )
52 DBG_CTOR(SfxItemIter, 0);
53 DBG_ASSERTWARNING( _rSet.Count(), "es gibt gar keine Attribute" );
55 if ( !_rSet._nCount )
57 _nStt = 1;
58 _nEnd = 0;
60 else
62 SfxItemArray ppFnd = _rSet._aItems;
64 // suche das 1. gesetzte Item
65 for ( _nStt = 0; !*(ppFnd + _nStt ); ++_nStt )
66 ; // empty loop
67 if ( 1 < _rSet.Count() )
68 for( _nEnd = _rSet.TotalCount(); !*( ppFnd + --_nEnd); )
69 ; // empty loop
70 else
71 _nEnd = _nStt;
74 _nAkt = _nStt;
77 // --------------------------------------------------------------------------
80 SfxItemIter::~SfxItemIter()
82 DBG_DTOR(SfxItemIter, 0);
85 // --------------------------------------------------------------------------
88 const SfxPoolItem* SfxItemIter::NextItem()
90 DBG_CHKTHIS(SfxItemIter, 0);
91 SfxItemArray ppFnd = _rSet._aItems;
93 if( _nAkt < _nEnd )
95 do {
96 _nAkt++;
97 } while( _nAkt < _nEnd && !*(ppFnd + _nAkt ) );
98 return *(ppFnd+_nAkt);
100 return 0;
103 // --------------------------------------------------------------------------
106 const SfxPoolItem* SfxItemIter::PrevItem()
108 DBG_CHKTHIS(SfxItemIter, 0);
109 SfxItemArray ppFnd = _rSet._aItems;
111 if ( _nAkt > _nStt )
113 do {
114 --_nAkt;
115 } while( _nAkt && !*(ppFnd + _nAkt ));
116 return *(ppFnd+_nAkt);
118 return 0;