LibreOffice Module sc (master)  1
rangelst.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_INC_RANGELST_HXX
21 #define INCLUDED_SC_INC_RANGELST_HXX
22 
23 #include "global.hxx"
24 #include "address.hxx"
25 #include <ostream>
26 #include <vector>
27 #include <sal/types.h>
28 
29 class ScDocument;
30 
31 
33 {
34 public:
35  ScRangeList();
36  ScRangeList( const ScRangeList& rList );
37  ScRangeList(ScRangeList&& rList) noexcept;
38  ScRangeList( const ScRange& rRange );
39  virtual ~ScRangeList() override;
40 
41  ScRangeList& operator=(const ScRangeList& rList);
42  ScRangeList& operator=(ScRangeList&& rList) noexcept;
43 
44  ScRefFlags Parse( const OUString&, const ScDocument*,
46  SCTAB nDefaultTab = 0, sal_Unicode cDelimiter = 0 );
47 
48  void Format( OUString&, ScRefFlags nFlags, const ScDocument&,
50  sal_Unicode cDelimiter = 0, bool bFullAddressNotation = false ) const;
51 
52  void Join( const ScRange&, bool bIsInList = false );
53 
54  bool UpdateReference( UpdateRefMode, const ScDocument*,
55  const ScRange& rWhere,
56  SCCOL nDx,
57  SCROW nDy,
58  SCTAB nDz
59  );
60 
61  void InsertRow( SCTAB nTab, SCCOL nColStart, SCCOL nColEnd, SCROW nRowPos, SCSIZE nSize );
62  void InsertCol( SCTAB nTab, SCROW nRowStart, SCROW nRowEnd, SCCOL nColPos, SCSIZE nSize );
63  void InsertCol( SCTAB nTab, SCCOL nColPos );
64 
68  bool DeleteArea( SCCOL nCol1, SCROW nRow1, SCTAB nTab1, SCCOL nCol2,
69  SCROW nRow2, SCTAB nTab2 );
70 
71  const ScRange* Find( const ScAddress& ) const;
72  ScRange* Find( const ScAddress& );
73  bool operator==( const ScRangeList& ) const;
74  bool operator!=( const ScRangeList& r ) const;
75  bool Intersects( const ScRange& ) const;
76  bool In( const ScRange& ) const;
77  size_t GetCellCount() const;
78  ScAddress GetTopLeftCorner() const;
79 
80  ScRangeList GetIntersectedRange(const ScRange& rRange) const;
81 
82  void Remove(size_t nPos);
83  void RemoveAll();
84 
85  ScRange Combine() const;
86  // Add new range, and do a partial combine up till one row back
87  void AddAndPartialCombine(const ScRange&);
88 
89  bool empty() const { return maRanges.empty(); }
90  size_t size() const { return maRanges.size(); }
91  ScRange& operator[](size_t idx) { return maRanges[idx]; }
92  const ScRange& operator[](size_t idx) const { return maRanges[idx]; }
93  ScRange& front() { return maRanges.front(); }
94  const ScRange& front() const { return maRanges.front(); }
95  ScRange& back() { return maRanges.back(); }
96  const ScRange& back() const { return maRanges.back(); }
97  void push_back(const ScRange & rRange);
98  ::std::vector<ScRange>::const_iterator begin() const { return maRanges.begin(); }
99  ::std::vector<ScRange>::const_iterator end() const { return maRanges.end(); }
100  ::std::vector<ScRange>::iterator begin() { return maRanges.begin(); }
101  ::std::vector<ScRange>::iterator end() { return maRanges.end(); }
102 
103  void swap( ScRangeList& r );
104 
105 private:
106  ::std::vector<ScRange> maRanges;
108 };
110 
111 // For use in SAL_DEBUG etc. Output format not guaranteed to be stable.
112 template<typename charT, typename traits>
113 inline std::basic_ostream<charT, traits> & operator <<(std::basic_ostream<charT, traits> & stream, const ScRangeList& rRangeList)
114 {
115  stream << "(";
116  for (size_t i = 0; i < rRangeList.size(); ++i)
117  {
118  if (i > 0)
119  stream << ",";
120  stream << rRangeList[i];
121  }
122  stream << ")";
123 
124  return stream;
125 }
126 
127 // RangePairList:
128 // aRange[0]: actual range,
129 // aRange[1]: data for that range, e.g. Rows belonging to a ColName
131 {
132 public:
133  virtual ~ScRangePairList() override;
134  ScRangePairList* Clone() const;
135  void Append( const ScRangePair& rRangePair )
136  {
137  maPairs.push_back( rRangePair );
138  }
139  void Join( const ScRangePair&, bool bIsInList = false );
140  void UpdateReference( UpdateRefMode, const ScDocument*,
141  const ScRange& rWhere,
142  SCCOL nDx, SCROW nDy, SCTAB nDz );
143  void DeleteOnTab( SCTAB nTab );
144  ScRangePair* Find( const ScAddress& );
145  ScRangePair* Find( const ScRange& );
146  std::vector<const ScRangePair*>
147  CreateNameSortedArray( ScDocument* ) const;
148 
149  void Remove(size_t nPos);
150  void Remove(const ScRangePair & rAdr);
151 
152  size_t size() const;
153  ScRangePair& operator[](size_t idx);
154  const ScRangePair& operator[](size_t idx) const;
155 
156 private:
157  ::std::vector< ScRangePair > maPairs;
158 };
160 
161 extern "C"
162 int ScRangePairList_QsortNameCompare( const void*, const void* );
163 
164 #endif
165 
166 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
bool operator==(const XclFontData &rLeft, const XclFontData &rRight)
Definition: xlstyle.cxx:517
bool operator!=(const XclExpString &rLeft, const XclExpString &rRight)
Definition: xestring.hxx:246
const ScRange & operator[](size_t idx) const
Definition: rangelst.hxx:92
const ScRange & front() const
Definition: rangelst.hxx:94
const sal_Unicode cDelimiter
Definition: tpusrlst.cxx:44
void Append(const ScRangePair &rRangePair)
Definition: rangelst.hxx:135
::std::vector< ScRange > maRanges
Definition: rangelst.hxx:106
sal_uInt16 sal_Unicode
size_t SCSIZE
size_t typedef to be able to find places where code was changed from USHORT to size_t and is used to ...
Definition: address.hxx:45
::std::vector< ScRange >::iterator begin()
Definition: rangelst.hxx:100
bool empty() const
Definition: rangelst.hxx:89
void swap(cow_wrapper< T, P > &a, cow_wrapper< T, P > &b)
int i
Reference< XAnimationNode > Clone(const Reference< XAnimationNode > &xSourceNode, const SdPage *pSource, const SdPage *pTarget)
sal_Int16 SCCOL
Definition: types.hxx:22
::std::vector< ScRange >::const_iterator end() const
Definition: rangelst.hxx:99
size_t size() const
Definition: rangelst.hxx:90
size
ScRange & back()
Definition: rangelst.hxx:95
Reference< XOutputStream > stream
#define SAL_WARN_UNUSED
UpdateRefMode
Definition: global.hxx:310
sal_Int32 SCROW
Definition: types.hxx:18
SvRefBase & operator=(const SvRefBase &)
tools::SvRef< ScRangePairList > ScRangePairListRef
Definition: rangelst.hxx:159
tools::SvRef< ScRangeList > ScRangeListRef
Definition: rangelst.hxx:109
ScRange & operator[](size_t idx)
Definition: rangelst.hxx:91
ScRange & front()
Definition: rangelst.hxx:93
::std::vector< ScRange >::const_iterator begin() const
Definition: rangelst.hxx:98
SCROW mnMaxRowUsed
Definition: rangelst.hxx:107
ScRefFlags
Definition: address.hxx:145
::std::vector< ScRangePair > maPairs
Definition: rangelst.hxx:157
int ScRangePairList_QsortNameCompare(const void *, const void *)
#define SC_DLLPUBLIC
Definition: scdllapi.h:28
sal_uInt16 nPos
sal_Int16 SCTAB
Definition: types.hxx:23
const ScRange & back() const
Definition: rangelst.hxx:96
::std::vector< ScRange >::iterator end()
Definition: rangelst.hxx:101