Update ooo320-m1
[ooovba.git] / sc / source / ui / inc / csvsplits.hxx
blob83973401218db0e7188d31a17c309d0cada43bdc
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: csvsplits.hxx,v $
10 * $Revision: 1.5 $
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 // ============================================================================
33 #ifndef _SC_CSVSPLITS_HXX
34 #define _SC_CSVSPLITS_HXX
36 #include <sal/types.h>
38 #include <vector>
41 // ============================================================================
43 /** Constant for an invalid vector index. */
44 const sal_uInt32 CSV_VEC_NOTFOUND = SAL_MAX_UINT32;
45 /** Constant for an invalid ruler position. */
46 const sal_Int32 CSV_POS_INVALID = -1;
49 // ----------------------------------------------------------------------------
51 /** A vector of column splits that supports inserting, removing and moving splits. */
52 class ScCsvSplits
54 private:
55 typedef ::std::vector< sal_Int32 > ScSplitVector;
56 typedef ScSplitVector::iterator iterator;
57 typedef ScSplitVector::const_iterator const_iterator;
59 ScSplitVector maVec; /// The split containter.
61 public:
62 // *** access by position *** ---------------------------------------------
64 /** Inserts a new split at position nPos into the vector.
65 @return true = split inserted (nPos was valid and empty). */
66 bool Insert( sal_Int32 nPos );
67 /** Removes a split by position.
68 @return true = split found and removed. */
69 bool Remove( sal_Int32 nPos );
70 /** Removes a range of splits in the given position range. */
71 void RemoveRange( sal_Int32 nPosStart, sal_Int32 nPosEnd );
72 /** Removes all elements from the vector. */
73 void Clear();
75 /** Returns true if at position nPos is a split. */
76 bool HasSplit( sal_Int32 nPos ) const;
78 // *** access by index *** ------------------------------------------------
80 /** Searches for a split at position nPos.
81 @return the vector index of the split. */
82 sal_uInt32 GetIndex( sal_Int32 nPos ) const;
83 /** Returns index of the first split greater than or equal to nPos. */
84 sal_uInt32 LowerBound( sal_Int32 nPos ) const;
85 /** Returns index of the last split less than or equal to nPos. */
86 sal_uInt32 UpperBound( sal_Int32 nPos ) const;
88 /** Returns the number of splits. */
89 inline sal_uInt32 Count() const
90 { return maVec.size(); }
91 /** Returns the position of the specified split. */
92 sal_Int32 GetPos( sal_uInt32 nIndex ) const;
93 /** Returns the position of the specified split. */
94 inline sal_Int32 operator[]( sal_uInt32 nIndex ) const
95 { return GetPos( nIndex ); }
97 private:
98 /** Returns the vector index of an iterator. */
99 sal_uInt32 GetIterIndex( const_iterator aIter ) const;
103 // ============================================================================
105 #endif