1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: whiter.cxx,v $
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"
33 // INCLUDE ---------------------------------------------------------------
38 #include <svtools/itemset.hxx>
40 DBG_NAME(SfxWhichIter
)
42 // -----------------------------------------------------------------------
44 SfxWhichIter::SfxWhichIter( const SfxItemSet
& rSet
, USHORT nFromWh
, USHORT nToWh
):
45 pRanges(rSet
.GetRanges()),
46 pStart(rSet
.GetRanges()),
47 nOfst(0), nFrom(nFromWh
), nTo(nToWh
)
49 DBG_CTOR(SfxWhichIter
, 0);
54 // -----------------------------------------------------------------------
56 SfxWhichIter::~SfxWhichIter()
58 DBG_DTOR(SfxWhichIter
, 0);
61 // -----------------------------------------------------------------------
63 USHORT
SfxWhichIter::NextWhich()
65 DBG_CHKTHIS(SfxWhichIter
, 0);
66 while ( 0 != *pRanges
)
68 const USHORT nLastWhich
= *pRanges
+ nOfst
;
70 if (*(pRanges
+1) == nLastWhich
)
75 USHORT nWhich
= *pRanges
+ nOfst
;
76 if ( 0 == nWhich
|| ( nWhich
>= nFrom
&& nWhich
<= nTo
) )
82 // -----------------------------------------------------------------------
84 USHORT
SfxWhichIter::PrevWhich()
86 DBG_CHKTHIS(SfxWhichIter
, 0);
87 while ( pRanges
!= pStart
|| 0 != nOfst
)
93 nOfst
= *(pRanges
+1) - (*pRanges
);
95 USHORT nWhich
= *pRanges
+ nOfst
;
96 if ( nWhich
>= nFrom
&& nWhich
<= nTo
)
102 // -----------------------------------------------------------------------
104 USHORT
SfxWhichIter::FirstWhich()
106 DBG_CHKTHIS(SfxWhichIter
, 0);
109 if ( *pRanges
>= nFrom
&& *pRanges
<= nTo
)
114 // -----------------------------------------------------------------------
116 USHORT
SfxWhichIter::LastWhich()
118 DBG_CHKTHIS(SfxWhichIter
, 0);
122 USHORT nWhich
= *(pRanges
-1);
123 if ( nWhich
>= nFrom
&& nWhich
<= nTo
)