1 /************************************************************************* 2 * 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 4 * 5 * Copyright 2000, 2010 Oracle and/or its affiliates. 6 * 7 * OpenOffice.org - a multi-platform office productivity suite 8 * 9 * This file is part of OpenOffice.org. 10 * 11 * OpenOffice.org is free software: you can redistribute it and/or modify 12 * it under the terms of the GNU Lesser General Public License version 3 13 * only, as published by the Free Software Foundation. 14 * 15 * OpenOffice.org is distributed in the hope that it will be useful, 16 * but WITHOUT ANY WARRANTY; without even the implied warranty of 17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 18 * GNU Lesser General Public License version 3 for more details 19 * (a copy is included in the LICENSE file that accompanied this code). 20 * 21 * You should have received a copy of the GNU Lesser General Public License 22 * version 3 along with OpenOffice.org. If not, see 23 * <http://www.openoffice.org/license.html> 24 * for a copy of the LGPLv3 License. 25 * 26 ************************************************************************/ 27 28 // MARKER(update_precomp.py): autogen include statement, do not remove 29 #include "precompiled_svl.hxx" 30 31 #ifndef GCC 32 #endif 33 34 #include <svl/itemiter.hxx> 35 #include <svl/itempool.hxx> 36 #include <svl/itemset.hxx> 37 38 // STATIC DATA ----------------------------------------------------------- 39 40 DBG_NAME(SfxItemIter); 41 42 43 // -------------------------------------------------------------------------- 44 45 46 SfxItemIter::SfxItemIter( const SfxItemSet& rItemSet ) 47 : _rSet( rItemSet ) 48 { 49 DBG_CTOR(SfxItemIter, 0); 50 DBG_ASSERTWARNING( _rSet.Count(), "es gibt gar keine Attribute" ); 51 52 if ( !_rSet._nCount ) 53 { 54 _nStt = 1; 55 _nEnd = 0; 56 } 57 else 58 { 59 SfxItemArray ppFnd = _rSet._aItems; 60 61 // suche das 1. gesetzte Item 62 for ( _nStt = 0; !*(ppFnd + _nStt ); ++_nStt ) 63 ; // empty loop 64 if ( 1 < _rSet.Count() ) 65 for( _nEnd = _rSet.TotalCount(); !*( ppFnd + --_nEnd); ) 66 ; // empty loop 67 else 68 _nEnd = _nStt; 69 } 70 71 _nAkt = _nStt; 72 } 73 74 // -------------------------------------------------------------------------- 75 76 77 SfxItemIter::~SfxItemIter() 78 { 79 DBG_DTOR(SfxItemIter, 0); 80 } 81 82 // -------------------------------------------------------------------------- 83 84 85 const SfxPoolItem* SfxItemIter::NextItem() 86 { 87 DBG_CHKTHIS(SfxItemIter, 0); 88 SfxItemArray ppFnd = _rSet._aItems; 89 90 if( _nAkt < _nEnd ) 91 { 92 do { 93 _nAkt++; 94 } while( _nAkt < _nEnd && !*(ppFnd + _nAkt ) ); 95 return *(ppFnd+_nAkt); 96 } 97 return 0; 98 } 99 100 // -------------------------------------------------------------------------- 101 102 103 const SfxPoolItem* SfxItemIter::PrevItem() 104 { 105 DBG_CHKTHIS(SfxItemIter, 0); 106 SfxItemArray ppFnd = _rSet._aItems; 107 108 if ( _nAkt > _nStt ) 109 { 110 do { 111 --_nAkt; 112 } while( _nAkt && !*(ppFnd + _nAkt )); 113 return *(ppFnd+_nAkt); 114 } 115 return 0; 116 } 117 118 119 120