LibreOffice Module sc (master)  1
csvsplits.hxx
Go to the documentation of this file.
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
3  * This file is part of the LibreOffice project.
4  *
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/.
8  *
9  * This file incorporates work covered by the following license notice:
10  *
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 .
18  */
19 
20 #ifndef INCLUDED_SC_SOURCE_UI_INC_CSVSPLITS_HXX
21 #define INCLUDED_SC_SOURCE_UI_INC_CSVSPLITS_HXX
22 
23 #include <sal/types.h>
24 
25 #include <vector>
26 
28 const sal_uInt32 CSV_VEC_NOTFOUND = SAL_MAX_UINT32;
30 const sal_Int32 CSV_POS_INVALID = -1;
31 
34 {
35 private:
36  typedef ::std::vector< sal_Int32 > ScSplitVector;
37  typedef ScSplitVector::const_iterator const_iterator;
38 
39  ScSplitVector maVec;
40 
41 public:
42  // *** access by position *** ---------------------------------------------
43 
46  bool Insert( sal_Int32 nPos );
49  bool Remove( sal_Int32 nPos );
51  void RemoveRange( sal_Int32 nPosStart, sal_Int32 nPosEnd );
53  void Clear();
54 
56  bool HasSplit( sal_Int32 nPos ) const;
57 
58  // *** access by index *** ------------------------------------------------
59 
62  sal_uInt32 GetIndex( sal_Int32 nPos ) const;
64  sal_uInt32 LowerBound( sal_Int32 nPos ) const;
66  sal_uInt32 UpperBound( sal_Int32 nPos ) const;
67 
69  sal_uInt32 Count() const
70  { return static_cast<sal_uInt32>(maVec.size()); }
72  sal_Int32 GetPos( sal_uInt32 nIndex ) const;
74  sal_Int32 operator[]( sal_uInt32 nIndex ) const
75  { return GetPos( nIndex ); }
76 
77 private:
79  sal_uInt32 GetIterIndex( const_iterator const & aIter ) const;
80 };
81 
82 #endif
83 
84 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
sal_uInt32 UpperBound(sal_Int32 nPos) const
Returns index of the last split less than or equal to nPos.
Definition: csvsplits.cxx:82
const sal_Int32 CSV_POS_INVALID
Constant for an invalid ruler position.
Definition: csvsplits.hxx:30
sal_Int32 GetPos(sal_uInt32 nIndex) const
Returns the position of the specified split.
Definition: csvsplits.cxx:92
::std::vector< sal_Int32 > ScSplitVector
Definition: csvsplits.hxx:36
sal_uInt32 LowerBound(sal_Int32 nPos) const
Returns index of the first split greater than or equal to nPos.
Definition: csvsplits.cxx:77
#define SAL_MAX_UINT32
bool Remove(sal_Int32 nPos)
Removes a split by position.
Definition: csvsplits.cxx:43
const sal_uInt32 CSV_VEC_NOTFOUND
Constant for an invalid vector index.
Definition: csvsplits.hxx:28
ScSplitVector::const_iterator const_iterator
Definition: csvsplits.hxx:37
sal_uInt32 GetIndex(sal_Int32 nPos) const
Searches for a split at position nPos.
Definition: csvsplits.cxx:71
ScSplitVector maVec
Definition: csvsplits.hxx:39
bool HasSplit(sal_Int32 nPos) const
Returns true if at position nPos is a split.
Definition: csvsplits.cxx:66
sal_uInt32 GetIterIndex(const_iterator const &aIter) const
Returns the vector index of an iterator.
Definition: csvsplits.cxx:97
void Clear()
Removes all elements from the vector.
Definition: csvsplits.cxx:61
A vector of column splits that supports inserting, removing and moving splits.
Definition: csvsplits.hxx:33
void RemoveRange(sal_Int32 nPosStart, sal_Int32 nPosEnd)
Removes a range of splits in the given position range.
Definition: csvsplits.cxx:53
sal_Int32 operator[](sal_uInt32 nIndex) const
Returns the position of the specified split.
Definition: csvsplits.hxx:74
bool Insert(sal_Int32 nPos)
The split container.
Definition: csvsplits.cxx:26
sal_uInt32 Count() const
Returns the number of splits.
Definition: csvsplits.hxx:69