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 SC_RANGEUTL_HXX
21 #define SC_RANGEUTL_HXX
23 #include <tools/string.hxx>
25 #include "address.hxx"
26 #include "rangenam.hxx"
30 #include <com/sun/star/table/CellAddress.hpp>
31 #include <com/sun/star/table/CellRangeAddress.hpp>
32 #include <com/sun/star/uno/Sequence.hxx>
34 //------------------------------------------------------------------------
43 enum RutlNameScope
{ RUTL_NONE
=0, RUTL_NAMES
, RUTL_DBASE
};
45 //------------------------------------------------------------------------
47 class SC_DLLPUBLIC ScRangeUtil
53 sal_Bool
MakeArea ( const String
& rAreaStr
,
57 ScAddress::Details
const & rDetails
= ScAddress::detailsOOOa1
) const;
59 void CutPosString ( const String
& theAreaStr
,
60 String
& thePosStr
) const;
62 sal_Bool
IsAbsTabArea ( const String
& rAreaStr
,
64 ScArea
*** pppAreas
= 0,
65 sal_uInt16
* pAreaCount
= 0,
66 sal_Bool bAcceptCellRef
= false,
67 ScAddress::Details
const & rDetails
= ScAddress::detailsOOOa1
) const;
69 sal_Bool
IsAbsArea ( const String
& rAreaStr
,
72 String
* pCompleteStr
= 0,
73 ScRefAddress
* pStartPos
= 0,
74 ScRefAddress
* pEndPos
= 0,
75 ScAddress::Details
const & rDetails
= ScAddress::detailsOOOa1
) const;
77 sal_Bool
IsRefArea ( const String
&,
81 ScRefAddress
* = 0 ) const
84 sal_Bool
IsAbsPos ( const String
& rPosStr
,
87 String
* pCompleteStr
= 0,
88 ScRefAddress
* pPosTripel
= 0,
89 ScAddress::Details
const & rDetails
= ScAddress::detailsOOOa1
) const;
91 sal_Bool
MakeRangeFromName ( const String
& rName
,
95 RutlNameScope eScope
=RUTL_NAMES
,
96 ScAddress::Details
const & rDetails
= ScAddress::detailsOOOa1
) const;
99 //------------------------------------------------------------------------
101 class SC_DLLPUBLIC ScRangeStringConverter
106 static void AssignString(
108 const OUString
& rNewStr
,
110 sal_Unicode cSeparator
= ' ');
112 static sal_Int32
IndexOf(
113 const OUString
& rString
,
114 sal_Unicode cSearchChar
,
116 sal_Unicode cQuote
= '\'');
118 static sal_Int32
IndexOfDifferent(
119 const OUString
& rString
,
120 sal_Unicode cSearchChar
,
123 static sal_Int32
GetTokenCount(
124 const OUString
& rString
,
125 sal_Unicode cSeparator
= ' ',
126 sal_Unicode cQuote
= '\'');
128 static void GetTokenByOffset(
130 const OUString
& rString
,
132 sal_Unicode cSeparator
= ' ',
133 sal_Unicode cQuote
= '\'');
135 static void AppendTableName(
136 OUStringBuffer
& rBuf
,
137 const OUString
& rTabName
,
138 sal_Unicode cQuote
= '\'');
140 // String to Range core
141 static sal_Bool
GetAddressFromString(
143 const OUString
& rAddressStr
,
144 const ScDocument
* pDocument
,
145 formula::FormulaGrammar::AddressConvention eConv
,
147 sal_Unicode cSeparator
= ' ',
148 sal_Unicode cQuote
= '\'');
149 static sal_Bool
GetRangeFromString(
151 const OUString
& rRangeStr
,
152 const ScDocument
* pDocument
,
153 formula::FormulaGrammar::AddressConvention eConv
,
155 sal_Unicode cSeparator
= ' ',
156 sal_Unicode cQuote
= '\'');
157 static sal_Bool
GetRangeListFromString(
158 ScRangeList
& rRangeList
,
159 const OUString
& rRangeListStr
,
160 const ScDocument
* pDocument
,
161 formula::FormulaGrammar::AddressConvention eConv
,
162 sal_Unicode cSeparator
= ' ',
163 sal_Unicode cQuote
= '\'');
165 static sal_Bool
GetAreaFromString(
167 const OUString
& rRangeStr
,
168 const ScDocument
* pDocument
,
169 formula::FormulaGrammar::AddressConvention eConv
,
171 sal_Unicode cSeparator
= ' ',
172 sal_Unicode cQuote
= '\'');
174 // String to Range API
175 static sal_Bool
GetAddressFromString(
176 ::com::sun::star::table::CellAddress
& rAddress
,
177 const OUString
& rAddressStr
,
178 const ScDocument
* pDocument
,
179 formula::FormulaGrammar::AddressConvention eConv
,
181 sal_Unicode cSeparator
= ' ',
182 sal_Unicode cQuote
= '\'');
183 static sal_Bool
GetRangeFromString(
184 ::com::sun::star::table::CellRangeAddress
& rRange
,
185 const OUString
& rRangeStr
,
186 const ScDocument
* pDocument
,
187 formula::FormulaGrammar::AddressConvention eConv
,
189 sal_Unicode cSeparator
= ' ',
190 sal_Unicode cQuote
= '\'');
191 static sal_Bool
GetRangeListFromString(
192 ::com::sun::star::uno::Sequence
< ::com::sun::star::table::CellRangeAddress
>& rRangeSeq
,
193 const OUString
& rRangeListStr
,
194 const ScDocument
* pDocument
,
195 formula::FormulaGrammar::AddressConvention eConv
,
196 sal_Unicode cSeparator
= ' ',
197 sal_Unicode cQuote
= '\'');
199 // Range to String core
200 static void GetStringFromAddress(
202 const ScAddress
& rAddress
,
203 const ScDocument
* pDocument
,
204 formula::FormulaGrammar::AddressConvention eConv
,
205 sal_Unicode cSeparator
= ' ',
206 sal_Bool bAppendStr
= false,
207 sal_uInt16 nFormatFlags
= (SCA_VALID
| SCA_TAB_3D
) );
208 static void GetStringFromRange(
210 const ScRange
& rRange
,
211 const ScDocument
* pDocument
,
212 formula::FormulaGrammar::AddressConvention eConv
,
213 sal_Unicode cSeparator
= ' ',
214 sal_Bool bAppendStr
= false,
215 sal_uInt16 nFormatFlags
= (SCA_VALID
| SCA_TAB_3D
) );
216 static void GetStringFromRangeList(
218 const ScRangeList
* pRangeList
,
219 const ScDocument
* pDocument
,
220 formula::FormulaGrammar::AddressConvention eConv
,
221 sal_Unicode cSeparator
= ' ',
222 sal_uInt16 nFormatFlags
= (SCA_VALID
| SCA_TAB_3D
));
224 static void GetStringFromArea(
227 const ScDocument
* pDocument
,
228 formula::FormulaGrammar::AddressConvention eConv
,
229 sal_Unicode cSeparator
= ' ',
230 sal_Bool bAppendStr
= false,
231 sal_uInt16 nFormatFlags
= (SCA_VALID
| SCA_TAB_3D
) );
233 // Range to String API
234 static void GetStringFromAddress(
236 const ::com::sun::star::table::CellAddress
& rAddress
,
237 const ScDocument
* pDocument
,
238 formula::FormulaGrammar::AddressConvention eConv
,
239 sal_Unicode cSeparator
= ' ',
240 sal_Bool bAppendStr
= false,
241 sal_uInt16 nFormatFlags
= (SCA_VALID
| SCA_TAB_3D
) );
242 static void GetStringFromRange(
244 const ::com::sun::star::table::CellRangeAddress
& rRange
,
245 const ScDocument
* pDocument
,
246 formula::FormulaGrammar::AddressConvention eConv
,
247 sal_Unicode cSeparator
= ' ',
248 sal_Bool bAppendStr
= false,
249 sal_uInt16 nFormatFlags
= (SCA_VALID
| SCA_TAB_3D
) );
250 static void GetStringFromRangeList(
252 const ::com::sun::star::uno::Sequence
< ::com::sun::star::table::CellRangeAddress
>& rRangeSeq
,
253 const ScDocument
* pDocument
,
254 formula::FormulaGrammar::AddressConvention eConv
,
255 sal_Unicode cSeparator
= ' ',
256 sal_uInt16 nFormatFlags
= (SCA_VALID
| SCA_TAB_3D
) );
258 // XML Range to Calc Range
259 static void GetStringFromXMLRangeString(
261 const OUString
& rXMLRange
,
264 // String to RangeData core
265 static ScRangeData
* GetRangeDataFromString(const OUString
& rString
, const SCTAB nTab
, const ScDocument
* pDoc
);
268 //------------------------------------------------------------------------
273 ScArea( SCTAB tab
= 0,
279 ScArea( const ScArea
& r
);
281 ScArea
& operator= ( const ScArea
& r
);
282 sal_Bool
operator== ( const ScArea
& r
) const;
283 sal_Bool
operator!= ( const ScArea
& r
) const { return !( operator==(r
) ); }
294 // returns areas with reference and all db-areas
297 class SC_DLLPUBLIC ScAreaNameIterator
300 ScRangeName
* pRangeName
;
301 ScDBCollection
* pDBCollection
;
302 ScRangeName::const_iterator maRNPos
;
303 ScRangeName::const_iterator maRNEnd
;
304 ScDBCollection::NamedDBs::const_iterator maDBPos
;
305 ScDBCollection::NamedDBs::const_iterator maDBEnd
;
309 ScAreaNameIterator( ScDocument
* pDoc
);
310 ~ScAreaNameIterator() {}
312 bool Next( OUString
& rName
, ScRange
& rRange
);
313 bool Next( String
& rName
, ScRange
& rRange
);
314 bool WasDBName() const { return !bFirstPass
; }
318 #endif // SC_RANGEUTL_HXX
320 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */