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 "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 sal_Bool
MakeArea ( const OUString
& rAreaStr
,
51 ScAddress::Details
const & rDetails
= ScAddress::detailsOOOa1
) const;
53 void CutPosString ( const OUString
& theAreaStr
,
54 OUString
& thePosStr
) const;
56 sal_Bool
IsAbsTabArea ( const OUString
& rAreaStr
,
58 ScArea
*** pppAreas
= 0,
59 sal_uInt16
* pAreaCount
= 0,
60 sal_Bool bAcceptCellRef
= false,
61 ScAddress::Details
const & rDetails
= ScAddress::detailsOOOa1
) const;
63 sal_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 sal_Bool
IsRefArea ( const OUString
&,
75 ScRefAddress
* = 0 ) const
78 sal_Bool
IsAbsPos ( const OUString
& rPosStr
,
81 OUString
* pCompleteStr
= 0,
82 ScRefAddress
* pPosTripel
= 0,
83 ScAddress::Details
const & rDetails
= ScAddress::detailsOOOa1
) const;
85 sal_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 sal_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 sal_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 sal_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 sal_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 sal_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 sal_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
= '\'');
183 static sal_Bool
GetRangeListFromString(
184 ::com::sun::star::uno::Sequence
< ::com::sun::star::table::CellRangeAddress
>& rRangeSeq
,
185 const OUString
& rRangeListStr
,
186 const ScDocument
* pDocument
,
187 formula::FormulaGrammar::AddressConvention eConv
,
188 sal_Unicode cSeparator
= ' ',
189 sal_Unicode cQuote
= '\'');
191 /// Range to String core
192 static void GetStringFromAddress(
194 const ScAddress
& rAddress
,
195 const ScDocument
* pDocument
,
196 formula::FormulaGrammar::AddressConvention eConv
,
197 sal_Unicode cSeparator
= ' ',
198 sal_Bool bAppendStr
= false,
199 sal_uInt16 nFormatFlags
= (SCA_VALID
| SCA_TAB_3D
) );
200 static void GetStringFromRange(
202 const ScRange
& rRange
,
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 GetStringFromRangeList(
210 const ScRangeList
* pRangeList
,
211 const ScDocument
* pDocument
,
212 formula::FormulaGrammar::AddressConvention eConv
,
213 sal_Unicode cSeparator
= ' ',
214 sal_uInt16 nFormatFlags
= (SCA_VALID
| SCA_TAB_3D
));
216 static void GetStringFromArea(
219 const ScDocument
* pDocument
,
220 formula::FormulaGrammar::AddressConvention eConv
,
221 sal_Unicode cSeparator
= ' ',
222 sal_Bool bAppendStr
= false,
223 sal_uInt16 nFormatFlags
= (SCA_VALID
| SCA_TAB_3D
) );
225 /// Range to String API
226 static void GetStringFromAddress(
228 const ::com::sun::star::table::CellAddress
& rAddress
,
229 const ScDocument
* pDocument
,
230 formula::FormulaGrammar::AddressConvention eConv
,
231 sal_Unicode cSeparator
= ' ',
232 sal_Bool bAppendStr
= false,
233 sal_uInt16 nFormatFlags
= (SCA_VALID
| SCA_TAB_3D
) );
234 static void GetStringFromRange(
236 const ::com::sun::star::table::CellRangeAddress
& rRange
,
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 GetStringFromRangeList(
244 const ::com::sun::star::uno::Sequence
< ::com::sun::star::table::CellRangeAddress
>& rRangeSeq
,
245 const ScDocument
* pDocument
,
246 formula::FormulaGrammar::AddressConvention eConv
,
247 sal_Unicode cSeparator
= ' ',
248 sal_uInt16 nFormatFlags
= (SCA_VALID
| SCA_TAB_3D
) );
250 /// XML Range to Calc Range
251 static void GetStringFromXMLRangeString(
253 const OUString
& rXMLRange
,
256 /// String to RangeData core
257 static ScRangeData
* GetRangeDataFromString(const OUString
& rString
, const SCTAB nTab
, const ScDocument
* pDoc
);
263 ScArea( SCTAB tab
= 0,
269 ScArea( const ScArea
& r
);
271 ScArea
& operator= ( const ScArea
& r
);
272 sal_Bool
operator== ( const ScArea
& r
) const;
273 sal_Bool
operator!= ( const ScArea
& r
) const { return !( operator==(r
) ); }
284 /// @return areas with reference and all db-areas
287 class SC_DLLPUBLIC ScAreaNameIterator
290 ScRangeName
* pRangeName
;
291 ScDBCollection
* pDBCollection
;
292 ScRangeName::const_iterator maRNPos
;
293 ScRangeName::const_iterator maRNEnd
;
294 ScDBCollection::NamedDBs::const_iterator maDBPos
;
295 ScDBCollection::NamedDBs::const_iterator maDBEnd
;
299 ScAreaNameIterator( ScDocument
* pDoc
);
300 ~ScAreaNameIterator() {}
302 bool Next( OUString
& rName
, ScRange
& rRange
);
303 bool WasDBName() const { return !bFirstPass
; }
306 #endif // SC_RANGEUTL_HXX
308 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */