Line data Source code
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 <vector>
26 : #include <sal/types.h>
27 :
28 : class ScDocument;
29 :
30 : class SC_DLLPUBLIC ScRangeList : public SvRefBase
31 : {
32 : public:
33 : ScRangeList();
34 : ScRangeList( const ScRangeList& rList );
35 : ScRangeList( const ScRange& rRange );
36 : virtual ~ScRangeList();
37 :
38 : ScRangeList& operator=(const ScRangeList& rList);
39 : void Append( const ScRange& rRange );
40 :
41 : sal_uInt16 Parse( const OUString&, ScDocument* = NULL,
42 : sal_uInt16 nMask = SCA_VALID,
43 : formula::FormulaGrammar::AddressConvention eConv = formula::FormulaGrammar::CONV_OOO,
44 : SCTAB nDefaultTab = 0, sal_Unicode cDelimiter = 0 );
45 :
46 : void Format( OUString&, sal_uInt16 nFlags = 0, ScDocument* = NULL,
47 : formula::FormulaGrammar::AddressConvention eConv = formula::FormulaGrammar::CONV_OOO,
48 : sal_Unicode cDelimiter = 0 ) const;
49 :
50 : void Join( const ScRange&, bool bIsInList = false );
51 :
52 : bool UpdateReference( UpdateRefMode, ScDocument*,
53 : const ScRange& rWhere,
54 : SCsCOL nDx,
55 : SCsROW nDy,
56 : SCsTAB nDz
57 : );
58 :
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 );
61 :
62 : /** For now this method assumes that nTab1 == nTab2
63 : * The algorithm will be much more complicated if nTab1 != nTab2
64 : */
65 : void DeleteArea( SCCOL nCol1, SCROW nRow1, SCTAB nTab1, SCCOL nCol2,
66 : SCROW nRow2, SCTAB nTab2 );
67 :
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;
76 :
77 : ScRangeList GetIntersectedRange(const ScRange& rRange) const;
78 :
79 : ScRange* Remove(size_t nPos);
80 : void RemoveAll();
81 :
82 : ScRange Combine() const;
83 :
84 : bool empty() const;
85 : size_t size() const;
86 : ScRange* operator[](size_t idx);
87 : const ScRange* operator[](size_t idx) const;
88 : ScRange* front();
89 : const ScRange* front() const;
90 : ScRange* back();
91 : const ScRange* back() const;
92 : void push_back(ScRange* p);
93 :
94 : void swap( ScRangeList& r );
95 :
96 : private:
97 : ::std::vector<ScRange*> maRanges;
98 : SCROW mnMaxRowUsed;
99 : typedef std::vector<ScRange*>::iterator iterator;
100 : typedef std::vector<ScRange*>::const_iterator const_iterator;
101 : };
102 : typedef tools::SvRef<ScRangeList> ScRangeListRef;
103 :
104 : // RangePairList:
105 : // aRange[0]: actual range,
106 : // aRange[1]: data for that range, e.g. Rows belonging to a ColName
107 4647 : class SC_DLLPUBLIC ScRangePairList : public SvRefBase
108 : {
109 : public:
110 : virtual ~ScRangePairList();
111 : ScRangePairList* Clone() const;
112 11 : void Append( const ScRangePair& rRangePair )
113 : {
114 11 : ScRangePair* pR = new ScRangePair( rRangePair );
115 11 : maPairs.push_back( pR );
116 11 : }
117 : void Join( const ScRangePair&, bool bIsInList = false );
118 : bool UpdateReference( UpdateRefMode, ScDocument*,
119 : const ScRange& rWhere,
120 : SCsCOL nDx, SCsROW nDy, SCsTAB nDz );
121 : void DeleteOnTab( SCTAB nTab );
122 : ScRangePair* Find( const ScAddress& ) const;
123 : ScRangePair* Find( const ScRange& ) const;
124 : ScRangePair** CreateNameSortedArray( size_t& nCount, ScDocument* ) const;
125 : bool operator==( const ScRangePairList& ) const;
126 :
127 : ScRangePair* Remove(size_t nPos);
128 : ScRangePair* Remove(ScRangePair* pAdr);
129 :
130 : size_t size() const;
131 : ScRangePair* operator[](size_t idx);
132 : const ScRangePair* operator[](size_t idx) const;
133 :
134 : private:
135 : ::std::vector< ScRangePair* > maPairs;
136 : };
137 : typedef tools::SvRef<ScRangePairList> ScRangePairListRef;
138 :
139 : extern "C"
140 : int SAL_CALL ScRangePairList_QsortNameCompare( const void*, const void* );
141 :
142 : #endif
143 :
144 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|