1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
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 .
23 #include "address.hxx"
26 #include <sal/types.h>
31 class SAL_WARN_UNUSED SC_DLLPUBLIC ScRangeList final
: public SvRefBase
35 ScRangeList( const ScRangeList
& rList
);
36 ScRangeList(ScRangeList
&& rList
) noexcept
;
37 ScRangeList( const ScRange
& rRange
);
38 virtual ~ScRangeList() override
;
40 ScRangeList
& operator=(const ScRangeList
& rList
);
41 ScRangeList
& operator=(ScRangeList
&& rList
) noexcept
;
43 ScRefFlags
Parse( const OUString
&, const ScDocument
&,
44 formula::FormulaGrammar::AddressConvention eConv
= formula::FormulaGrammar::CONV_OOO
,
45 SCTAB nDefaultTab
= 0, sal_Unicode cDelimiter
= 0 );
47 void Format( OUString
&, ScRefFlags nFlags
, const ScDocument
&,
48 formula::FormulaGrammar::AddressConvention eConv
= formula::FormulaGrammar::CONV_OOO
,
49 sal_Unicode cDelimiter
= 0, bool bFullAddressNotation
= false ) const;
51 void Join( const ScRange
&, bool bIsInList
= false );
53 bool UpdateReference( UpdateRefMode
, const ScDocument
*,
54 const ScRange
& rWhere
,
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
);
64 /** For now this method assumes that nTab1 == nTab2
65 * The algorithm will be much more complicated if nTab1 != nTab2
67 bool DeleteArea( SCCOL nCol1
, SCROW nRow1
, SCTAB nTab1
, SCCOL nCol2
,
68 SCROW nRow2
, SCTAB nTab2
);
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 In( const ScRange
& ) const;
76 sal_uInt64
GetCellCount() const;
77 ScAddress
GetTopLeftCorner() const;
79 ScRangeList
GetIntersectedRange(const ScRange
& rRange
) const;
81 void Remove(size_t nPos
);
84 ScRange
Combine() const;
85 // Add new range, and do a partial combine up till one row back
86 void AddAndPartialCombine(const ScRange
&);
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
); }
104 void swap( ScRangeList
& r
);
107 ::std::vector
<ScRange
> maRanges
;
110 typedef tools::SvRef
<ScRangeList
> ScRangeListRef
;
112 // For use in SAL_DEBUG etc. Output format not guaranteed to be stable.
113 template<typename charT
, typename traits
>
114 inline std::basic_ostream
<charT
, traits
> & operator <<(std::basic_ostream
<charT
, traits
> & stream
, const ScRangeList
& rRangeList
)
117 for (size_t i
= 0; i
< rRangeList
.size(); ++i
)
121 stream
<< rRangeList
[i
];
129 // aRange[0]: actual range,
130 // aRange[1]: data for that range, e.g. Rows belonging to a ColName
131 class SC_DLLPUBLIC ScRangePairList final
: public SvRefBase
134 virtual ~ScRangePairList() override
;
135 ScRangePairList
* Clone() const;
136 void Append( const ScRangePair
& rRangePair
)
138 maPairs
.push_back( rRangePair
);
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;
150 void Remove(size_t nPos
);
151 void Remove(const ScRangePair
& rAdr
);
154 ScRangePair
& operator[](size_t idx
);
155 const ScRangePair
& operator[](size_t idx
) const;
158 ::std::vector
< ScRangePair
> maPairs
;
160 typedef tools::SvRef
<ScRangePairList
> ScRangePairListRef
;
163 int ScRangePairList_QsortNameCompare( const void*, const void* );
165 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */