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_RANGEUTL_HXX
21 #define INCLUDED_SC_INC_RANGEUTL_HXX
23 #include "address.hxx"
24 #include "rangenam.hxx"
28 namespace com
{ namespace sun
{ namespace star
{ namespace table
{ struct CellAddress
; } } } }
29 namespace com
{ namespace sun
{ namespace star
{ namespace table
{ struct CellRangeAddress
; } } } }
30 namespace com
{ namespace sun
{ namespace star
{ namespace uno
{ template <typename
> class Sequence
; } } } }
36 enum RutlNameScope
{ RUTL_NONE
=0, RUTL_NAMES
, RUTL_DBASE
};
38 class SC_DLLPUBLIC ScRangeUtil
41 ScRangeUtil() = delete;
43 static bool MakeArea ( const OUString
& rAreaStr
,
45 const ScDocument
* pDoc
,
47 ScAddress::Details
const & rDetails
);
49 static void CutPosString ( const OUString
& theAreaStr
,
50 OUString
& thePosStr
);
52 static bool IsAbsTabArea ( const OUString
& rAreaStr
,
53 const ScDocument
* pDoc
,
54 std::unique_ptr
<ScArea
[]>* ppAreas
,
55 sal_uInt16
* pAreaCount
,
56 bool bAcceptCellRef
= false,
57 ScAddress::Details
const & rDetails
= ScAddress::detailsOOOa1
);
59 static bool IsAbsArea ( const OUString
& rAreaStr
,
60 const ScDocument
* pDoc
,
62 OUString
* pCompleteStr
,
63 ScRefAddress
* pStartPos
= nullptr,
64 ScRefAddress
* pEndPos
= nullptr,
65 ScAddress::Details
const & rDetails
= ScAddress::detailsOOOa1
);
67 static bool IsAbsPos ( const OUString
& rPosStr
,
68 const ScDocument
* pDoc
,
70 OUString
* pCompleteStr
,
71 ScRefAddress
* pPosTripel
= nullptr,
72 ScAddress::Details
const & rDetails
= ScAddress::detailsOOOa1
);
74 static bool MakeRangeFromName( const OUString
& rName
,
75 const ScDocument
* pDoc
,
78 RutlNameScope eScope
=RUTL_NAMES
,
79 ScAddress::Details
const & rDetails
= ScAddress::detailsOOOa1
);
82 class SC_DLLPUBLIC ScRangeStringConverter
87 static void AssignString(
89 const OUString
& rNewStr
,
91 sal_Unicode cSeparator
= ' ');
93 static sal_Int32
IndexOf(
94 const OUString
& rString
,
95 sal_Unicode cSearchChar
,
97 sal_Unicode cQuote
= '\'');
99 static sal_Int32
IndexOfDifferent(
100 const OUString
& rString
,
101 sal_Unicode cSearchChar
,
104 static sal_Int32
GetTokenCount(
105 const OUString
& rString
,
106 sal_Unicode cSeparator
= ' ');
108 static void GetTokenByOffset(
110 const OUString
& rString
,
112 sal_Unicode cSeparator
= ' ',
113 sal_Unicode cQuote
= '\'');
115 static void AppendTableName(
116 OUStringBuffer
& rBuf
,
117 const OUString
& rTabName
);
119 /// String to Range core
120 static bool GetAddressFromString(
122 const OUString
& rAddressStr
,
123 const ScDocument
* pDocument
,
124 formula::FormulaGrammar::AddressConvention eConv
,
126 sal_Unicode cSeparator
= ' ',
127 sal_Unicode cQuote
= '\'');
128 static bool GetRangeFromString(
130 const OUString
& rRangeStr
,
131 const ScDocument
* pDocument
,
132 formula::FormulaGrammar::AddressConvention eConv
,
134 sal_Unicode cSeparator
= ' ',
135 sal_Unicode cQuote
= '\'');
136 static bool GetRangeListFromString(
137 ScRangeList
& rRangeList
,
138 const OUString
& rRangeListStr
,
139 const ScDocument
* pDocument
,
140 formula::FormulaGrammar::AddressConvention eConv
,
141 sal_Unicode cSeparator
= ' ',
142 sal_Unicode cQuote
= '\'');
144 static bool GetAreaFromString(
146 const OUString
& rRangeStr
,
147 const ScDocument
* pDocument
,
148 formula::FormulaGrammar::AddressConvention eConv
,
150 sal_Unicode cSeparator
= ' ');
152 /// String to Range API
153 static bool GetRangeFromString(
154 css::table::CellRangeAddress
& rRange
,
155 const OUString
& rRangeStr
,
156 const ScDocument
* pDocument
,
157 formula::FormulaGrammar::AddressConvention eConv
,
159 sal_Unicode cSeparator
= ' ');
161 /// Range to String core
162 static void GetStringFromAddress(
164 const ScAddress
& rAddress
,
165 const ScDocument
* pDocument
,
166 formula::FormulaGrammar::AddressConvention eConv
,
167 sal_Unicode cSeparator
= ' ',
168 bool bAppendStr
= false,
169 ScRefFlags nFormatFlags
= ScRefFlags::VALID
| ScRefFlags::TAB_3D
);
170 static void GetStringFromRange(
172 const ScRange
& rRange
,
173 const ScDocument
* pDocument
,
174 formula::FormulaGrammar::AddressConvention eConv
,
175 sal_Unicode cSeparator
= ' ',
176 bool bAppendStr
= false,
177 ScRefFlags nFormatFlags
= ScRefFlags::VALID
| ScRefFlags::TAB_3D
);
178 static void GetStringFromRangeList(
180 const ScRangeList
* pRangeList
,
181 const ScDocument
* pDocument
,
182 formula::FormulaGrammar::AddressConvention eConv
,
183 sal_Unicode cSeparator
= ' ');
185 static void GetStringFromArea(
188 const ScDocument
* pDocument
,
189 formula::FormulaGrammar::AddressConvention eConv
,
190 sal_Unicode cSeparator
,
191 bool bAppendStr
= false,
192 ScRefFlags nFormatFlags
= ScRefFlags::VALID
| ScRefFlags::TAB_3D
);
194 /// Range to String API
195 static void GetStringFromAddress(
197 const css::table::CellAddress
& rAddress
,
198 const ScDocument
* pDocument
,
199 formula::FormulaGrammar::AddressConvention eConv
,
200 sal_Unicode cSeparator
= ' ',
201 bool bAppendStr
= false );
202 static void GetStringFromRange(
204 const css::table::CellRangeAddress
& rRange
,
205 const ScDocument
* pDocument
,
206 formula::FormulaGrammar::AddressConvention eConv
,
207 sal_Unicode cSeparator
= ' ',
208 bool bAppendStr
= false,
209 ScRefFlags nFormatFlags
= ScRefFlags::VALID
| ScRefFlags::TAB_3D
);
210 static void GetStringFromRangeList(
212 const css::uno::Sequence
< css::table::CellRangeAddress
>& rRangeSeq
,
213 const ScDocument
* pDocument
,
214 formula::FormulaGrammar::AddressConvention eConv
,
215 sal_Unicode cSeparator
= ' ' );
217 /// XML Range to Calc Range
218 static void GetStringFromXMLRangeString(
220 const OUString
& rXMLRange
,
221 const ScDocument
* pDoc
);
223 /// String to RangeData core
224 static ScRangeData
* GetRangeDataFromString(const OUString
& rString
, const SCTAB nTab
, const ScDocument
* pDoc
);
230 ScArea( SCTAB tab
= 0,
236 bool operator== ( const ScArea
& r
) const;
246 /// @return areas with reference and all db-areas
248 class SC_DLLPUBLIC ScAreaNameIterator
251 ScRangeName
* pRangeName
;
252 ScDBCollection
* pDBCollection
;
253 ScRangeName::const_iterator maRNPos
;
254 ScRangeName::const_iterator maRNEnd
;
255 ScDBCollection::NamedDBs::const_iterator maDBPos
;
256 ScDBCollection::NamedDBs::const_iterator maDBEnd
;
260 ScAreaNameIterator( const ScDocument
* pDoc
);
262 bool Next( OUString
& rName
, ScRange
& rRange
);
263 bool WasDBName() const { return !bFirstPass
; }
266 struct SC_DLLPUBLIC ScRangeUpdater
268 ScRangeUpdater() = delete;
270 static void UpdateInsertTab(ScAddress
& rAddr
, const sc::RefUpdateInsertTabContext
& rCxt
);
271 static void UpdateDeleteTab(ScAddress
& rAddr
, const sc::RefUpdateDeleteTabContext
& rCxt
);
274 #endif // INCLUDED_SC_INC_RANGEUTL_HXX
276 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */