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