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 #include <com/sun/star/table/CellAddress.hpp>
29 #include <com/sun/star/table/CellRangeAddress.hpp>
30 #include <com/sun/star/uno/Sequence.hxx>
39 enum RutlNameScope
{ RUTL_NONE
=0, RUTL_NAMES
, RUTL_DBASE
};
41 class SC_DLLPUBLIC ScRangeUtil
47 bool MakeArea ( const OUString
& rAreaStr
,
51 ScAddress::Details
const & rDetails
= ScAddress::detailsOOOa1
) const;
53 void CutPosString ( const OUString
& theAreaStr
,
54 OUString
& thePosStr
) const;
56 bool IsAbsTabArea ( const OUString
& rAreaStr
,
58 ScArea
*** pppAreas
= 0,
59 sal_uInt16
* pAreaCount
= 0,
60 bool bAcceptCellRef
= false,
61 ScAddress::Details
const & rDetails
= ScAddress::detailsOOOa1
) const;
63 bool IsAbsArea ( const OUString
& rAreaStr
,
66 OUString
* pCompleteStr
= 0,
67 ScRefAddress
* pStartPos
= 0,
68 ScRefAddress
* pEndPos
= 0,
69 ScAddress::Details
const & rDetails
= ScAddress::detailsOOOa1
) const;
71 bool IsRefArea ( const OUString
&,
75 ScRefAddress
* = 0 ) const
78 bool IsAbsPos ( const OUString
& rPosStr
,
81 OUString
* pCompleteStr
= 0,
82 ScRefAddress
* pPosTripel
= 0,
83 ScAddress::Details
const & rDetails
= ScAddress::detailsOOOa1
) const;
85 bool MakeRangeFromName ( const OUString
& rName
,
89 RutlNameScope eScope
=RUTL_NAMES
,
90 ScAddress::Details
const & rDetails
= ScAddress::detailsOOOa1
) const;
93 class SC_DLLPUBLIC ScRangeStringConverter
98 static void AssignString(
100 const OUString
& rNewStr
,
102 sal_Unicode cSeparator
= ' ');
104 static sal_Int32
IndexOf(
105 const OUString
& rString
,
106 sal_Unicode cSearchChar
,
108 sal_Unicode cQuote
= '\'');
110 static sal_Int32
IndexOfDifferent(
111 const OUString
& rString
,
112 sal_Unicode cSearchChar
,
115 static sal_Int32
GetTokenCount(
116 const OUString
& rString
,
117 sal_Unicode cSeparator
= ' ',
118 sal_Unicode cQuote
= '\'');
120 static void GetTokenByOffset(
122 const OUString
& rString
,
124 sal_Unicode cSeparator
= ' ',
125 sal_Unicode cQuote
= '\'');
127 static void AppendTableName(
128 OUStringBuffer
& rBuf
,
129 const OUString
& rTabName
,
130 sal_Unicode cQuote
= '\'');
132 /// String to Range core
133 static bool GetAddressFromString(
135 const OUString
& rAddressStr
,
136 const ScDocument
* pDocument
,
137 formula::FormulaGrammar::AddressConvention eConv
,
139 sal_Unicode cSeparator
= ' ',
140 sal_Unicode cQuote
= '\'');
141 static bool GetRangeFromString(
143 const OUString
& rRangeStr
,
144 const ScDocument
* pDocument
,
145 formula::FormulaGrammar::AddressConvention eConv
,
147 sal_Unicode cSeparator
= ' ',
148 sal_Unicode cQuote
= '\'');
149 static bool GetRangeListFromString(
150 ScRangeList
& rRangeList
,
151 const OUString
& rRangeListStr
,
152 const ScDocument
* pDocument
,
153 formula::FormulaGrammar::AddressConvention eConv
,
154 sal_Unicode cSeparator
= ' ',
155 sal_Unicode cQuote
= '\'');
157 static bool GetAreaFromString(
159 const OUString
& rRangeStr
,
160 const ScDocument
* pDocument
,
161 formula::FormulaGrammar::AddressConvention eConv
,
163 sal_Unicode cSeparator
= ' ',
164 sal_Unicode cQuote
= '\'');
166 /// String to Range API
167 static bool GetAddressFromString(
168 ::com::sun::star::table::CellAddress
& rAddress
,
169 const OUString
& rAddressStr
,
170 const ScDocument
* pDocument
,
171 formula::FormulaGrammar::AddressConvention eConv
,
173 sal_Unicode cSeparator
= ' ',
174 sal_Unicode cQuote
= '\'');
175 static bool GetRangeFromString(
176 ::com::sun::star::table::CellRangeAddress
& rRange
,
177 const OUString
& rRangeStr
,
178 const ScDocument
* pDocument
,
179 formula::FormulaGrammar::AddressConvention eConv
,
181 sal_Unicode cSeparator
= ' ',
182 sal_Unicode cQuote
= '\'');
184 /// Range to String core
185 static void GetStringFromAddress(
187 const ScAddress
& rAddress
,
188 const ScDocument
* pDocument
,
189 formula::FormulaGrammar::AddressConvention eConv
,
190 sal_Unicode cSeparator
= ' ',
191 bool bAppendStr
= false,
192 sal_uInt16 nFormatFlags
= (SCA_VALID
| SCA_TAB_3D
) );
193 static void GetStringFromRange(
195 const ScRange
& rRange
,
196 const ScDocument
* pDocument
,
197 formula::FormulaGrammar::AddressConvention eConv
,
198 sal_Unicode cSeparator
= ' ',
199 bool bAppendStr
= false,
200 sal_uInt16 nFormatFlags
= (SCA_VALID
| SCA_TAB_3D
) );
201 static void GetStringFromRangeList(
203 const ScRangeList
* pRangeList
,
204 const ScDocument
* pDocument
,
205 formula::FormulaGrammar::AddressConvention eConv
,
206 sal_Unicode cSeparator
= ' ',
207 sal_uInt16 nFormatFlags
= (SCA_VALID
| SCA_TAB_3D
));
209 static void GetStringFromArea(
212 const ScDocument
* pDocument
,
213 formula::FormulaGrammar::AddressConvention eConv
,
214 sal_Unicode cSeparator
= ' ',
215 bool bAppendStr
= false,
216 sal_uInt16 nFormatFlags
= (SCA_VALID
| SCA_TAB_3D
) );
218 /// Range to String API
219 static void GetStringFromAddress(
221 const ::com::sun::star::table::CellAddress
& rAddress
,
222 const ScDocument
* pDocument
,
223 formula::FormulaGrammar::AddressConvention eConv
,
224 sal_Unicode cSeparator
= ' ',
225 bool bAppendStr
= false,
226 sal_uInt16 nFormatFlags
= (SCA_VALID
| SCA_TAB_3D
) );
227 static void GetStringFromRange(
229 const ::com::sun::star::table::CellRangeAddress
& rRange
,
230 const ScDocument
* pDocument
,
231 formula::FormulaGrammar::AddressConvention eConv
,
232 sal_Unicode cSeparator
= ' ',
233 bool bAppendStr
= false,
234 sal_uInt16 nFormatFlags
= (SCA_VALID
| SCA_TAB_3D
) );
235 static void GetStringFromRangeList(
237 const ::com::sun::star::uno::Sequence
< ::com::sun::star::table::CellRangeAddress
>& rRangeSeq
,
238 const ScDocument
* pDocument
,
239 formula::FormulaGrammar::AddressConvention eConv
,
240 sal_Unicode cSeparator
= ' ',
241 sal_uInt16 nFormatFlags
= (SCA_VALID
| SCA_TAB_3D
) );
243 /// XML Range to Calc Range
244 static void GetStringFromXMLRangeString(
246 const OUString
& rXMLRange
,
249 /// String to RangeData core
250 static ScRangeData
* GetRangeDataFromString(const OUString
& rString
, const SCTAB nTab
, const ScDocument
* pDoc
);
256 ScArea( SCTAB tab
= 0,
262 ScArea( const ScArea
& r
);
264 ScArea
& operator= ( const ScArea
& r
);
265 bool operator== ( const ScArea
& r
) const;
266 bool operator!= ( const ScArea
& r
) const { return !( operator==(r
) ); }
277 /// @return areas with reference and all db-areas
280 class SC_DLLPUBLIC ScAreaNameIterator
283 ScRangeName
* pRangeName
;
284 ScDBCollection
* pDBCollection
;
285 ScRangeName::const_iterator maRNPos
;
286 ScRangeName::const_iterator maRNEnd
;
287 ScDBCollection::NamedDBs::const_iterator maDBPos
;
288 ScDBCollection::NamedDBs::const_iterator maDBEnd
;
292 ScAreaNameIterator( ScDocument
* pDoc
);
293 ~ScAreaNameIterator() {}
295 bool Next( OUString
& rName
, ScRange
& rRange
);
296 bool WasDBName() const { return !bFirstPass
; }
299 #endif // INCLUDED_SC_INC_RANGEUTL_HXX
301 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */