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 .
20 #ifndef INCLUDED_SC_INC_RANGELST_HXX
21 #define INCLUDED_SC_INC_RANGELST_HXX
24 #include "address.hxx"
27 #include <sal/types.h>
31 class SC_DLLPUBLIC ScRangeList
: public SvRefBase
35 ScRangeList( const ScRangeList
& rList
);
36 ScRangeList( const ScRange
& rRange
);
37 virtual ~ScRangeList() override
;
39 ScRangeList
& operator=(const ScRangeList
& rList
);
40 void Append( const ScRange
& rRange
);
42 ScRefFlags
Parse( const OUString
&, const ScDocument
*,
43 formula::FormulaGrammar::AddressConvention eConv
= formula::FormulaGrammar::CONV_OOO
,
44 SCTAB nDefaultTab
= 0, sal_Unicode cDelimiter
= 0 );
46 void Format( OUString
&, ScRefFlags nFlags
, ScDocument
*,
47 formula::FormulaGrammar::AddressConvention eConv
= formula::FormulaGrammar::CONV_OOO
,
48 sal_Unicode cDelimiter
= 0, bool bFullAddressNotation
= false ) const;
50 void Join( const ScRange
&, bool bIsInList
= false );
52 bool UpdateReference( UpdateRefMode
, const ScDocument
*,
53 const ScRange
& rWhere
,
59 void InsertRow( SCTAB nTab
, SCCOL nColStart
, SCCOL nColEnd
, SCROW nRowPos
, SCSIZE nSize
);
60 void InsertCol( SCTAB nTab
, SCROW nRowStart
, SCROW nRowEnd
, SCCOL nColPos
, SCSIZE nSize
);
62 /** For now this method assumes that nTab1 == nTab2
63 * The algorithm will be much more complicated if nTab1 != nTab2
65 bool DeleteArea( SCCOL nCol1
, SCROW nRow1
, SCTAB nTab1
, SCCOL nCol2
,
66 SCROW nRow2
, SCTAB nTab2
);
68 const ScRange
* Find( const ScAddress
& ) const;
69 ScRange
* Find( const ScAddress
& );
70 bool operator==( const ScRangeList
& ) const;
71 bool operator!=( const ScRangeList
& r
) const;
72 bool Intersects( const ScRange
& ) const;
73 bool In( const ScRange
& ) const;
74 size_t GetCellCount() const;
75 ScAddress
GetTopLeftCorner() const;
77 ScRangeList
GetIntersectedRange(const ScRange
& rRange
) const;
79 void Remove(size_t nPos
);
82 ScRange
Combine() const;
86 ScRange
* operator[](size_t idx
);
87 const ScRange
* operator[](size_t idx
) const;
89 const ScRange
* front() const;
91 const ScRange
* back() const;
92 void push_back(ScRange
* p
);
94 void swap( ScRangeList
& r
);
97 ::std::vector
<ScRange
*> maRanges
;
99 typedef std::vector
<ScRange
*>::iterator iterator
;
100 typedef std::vector
<ScRange
*>::const_iterator const_iterator
;
102 typedef tools::SvRef
<ScRangeList
> ScRangeListRef
;
104 // For use in SAL_DEBUG etc. Output format not guaranteed to be stable.
105 template<typename charT
, typename traits
>
106 inline std::basic_ostream
<charT
, traits
> & operator <<(std::basic_ostream
<charT
, traits
> & stream
, const ScRangeList
& rRangeList
)
109 for (size_t i
= 0; i
< rRangeList
.size(); ++i
)
113 stream
<< *(rRangeList
[i
]);
121 // aRange[0]: actual range,
122 // aRange[1]: data for that range, e.g. Rows belonging to a ColName
123 class SC_DLLPUBLIC ScRangePairList
: public SvRefBase
126 virtual ~ScRangePairList() override
;
127 ScRangePairList
* Clone() const;
128 void Append( const ScRangePair
& rRangePair
)
130 ScRangePair
* pR
= new ScRangePair( rRangePair
);
131 maPairs
.push_back( pR
);
133 void Join( const ScRangePair
&, bool bIsInList
= false );
134 void UpdateReference( UpdateRefMode
, const ScDocument
*,
135 const ScRange
& rWhere
,
136 SCCOL nDx
, SCROW nDy
, SCTAB nDz
);
137 void DeleteOnTab( SCTAB nTab
);
138 ScRangePair
* Find( const ScAddress
& ) const;
139 ScRangePair
* Find( const ScRange
& ) const;
140 ScRangePair
** CreateNameSortedArray( size_t& nCount
, ScDocument
* ) const;
142 void Remove(size_t nPos
);
143 void Remove(const ScRangePair
* pAdr
);
146 ScRangePair
* operator[](size_t idx
);
147 const ScRangePair
* operator[](size_t idx
) const;
150 ::std::vector
< ScRangePair
* > maPairs
;
152 typedef tools::SvRef
<ScRangePairList
> ScRangePairListRef
;
155 int ScRangePairList_QsortNameCompare( const void*, const void* );
159 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */