Version 5.2.6.1, tag libreoffice-5.2.6.1
[LibreOffice.git] / sc / source / ui / inc / csvsplits.hxx
blob7ab80e34a76f078e8d5985b0be3552e4ab1fa965
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
3 * This file is part of the LibreOffice project.
5 * This Source Code Form is subject to the terms of the Mozilla Public
6 * License, v. 2.0. If a copy of the MPL was not distributed with this
7 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
9 * This file incorporates work covered by the following license notice:
11 * Licensed to the Apache Software Foundation (ASF) under one or more
12 * contributor license agreements. See the NOTICE file distributed
13 * with this work for additional information regarding copyright
14 * ownership. The ASF licenses this file to you under the Apache
15 * License, Version 2.0 (the "License"); you may not use this file
16 * except in compliance with the License. You may obtain a copy of
17 * the License at http://www.apache.org/licenses/LICENSE-2.0 .
20 #ifndef INCLUDED_SC_SOURCE_UI_INC_CSVSPLITS_HXX
21 #define INCLUDED_SC_SOURCE_UI_INC_CSVSPLITS_HXX
23 #include <sal/types.h>
25 #include <vector>
27 /** Constant for an invalid vector index. */
28 const sal_uInt32 CSV_VEC_NOTFOUND = SAL_MAX_UINT32;
29 /** Constant for an invalid ruler position. */
30 const sal_Int32 CSV_POS_INVALID = -1;
32 /** A vector of column splits that supports inserting, removing and moving splits. */
33 class ScCsvSplits
35 private:
36 typedef ::std::vector< sal_Int32 > ScSplitVector;
37 typedef ScSplitVector::iterator iterator;
38 typedef ScSplitVector::const_iterator const_iterator;
40 ScSplitVector maVec; /// The split containter.
42 public:
43 // *** access by position *** ---------------------------------------------
45 /** Inserts a new split at position nPos into the vector.
46 @return true = split inserted (nPos was valid and empty). */
47 bool Insert( sal_Int32 nPos );
48 /** Removes a split by position.
49 @return true = split found and removed. */
50 bool Remove( sal_Int32 nPos );
51 /** Removes a range of splits in the given position range. */
52 void RemoveRange( sal_Int32 nPosStart, sal_Int32 nPosEnd );
53 /** Removes all elements from the vector. */
54 void Clear();
56 /** Returns true if at position nPos is a split. */
57 bool HasSplit( sal_Int32 nPos ) const;
59 // *** access by index *** ------------------------------------------------
61 /** Searches for a split at position nPos.
62 @return the vector index of the split. */
63 sal_uInt32 GetIndex( sal_Int32 nPos ) const;
64 /** Returns index of the first split greater than or equal to nPos. */
65 sal_uInt32 LowerBound( sal_Int32 nPos ) const;
66 /** Returns index of the last split less than or equal to nPos. */
67 sal_uInt32 UpperBound( sal_Int32 nPos ) const;
69 /** Returns the number of splits. */
70 sal_uInt32 Count() const
71 { return static_cast<sal_uInt32>(maVec.size()); }
72 /** Returns the position of the specified split. */
73 sal_Int32 GetPos( sal_uInt32 nIndex ) const;
74 /** Returns the position of the specified split. */
75 sal_Int32 operator[]( sal_uInt32 nIndex ) const
76 { return GetPos( nIndex ); }
78 private:
79 /** Returns the vector index of an iterator. */
80 sal_uInt32 GetIterIndex( const_iterator aIter ) const;
83 #endif
85 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */