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 static bool MakeArea ( const OUString
& rAreaStr
,
51 ScAddress::Details
const & rDetails
= ScAddress::detailsOOOa1
);
53 static void CutPosString ( const OUString
& theAreaStr
,
54 OUString
& thePosStr
);
56 static 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
);
63 static bool IsAbsArea ( const OUString
& rAreaStr
,
66 OUString
* pCompleteStr
= 0,
67 ScRefAddress
* pStartPos
= 0,
68 ScRefAddress
* pEndPos
= 0,
69 ScAddress::Details
const & rDetails
= ScAddress::detailsOOOa1
);
71 static bool IsAbsPos ( const OUString
& rPosStr
,
74 OUString
* pCompleteStr
= 0,
75 ScRefAddress
* pPosTripel
= 0,
76 ScAddress::Details
const & rDetails
= ScAddress::detailsOOOa1
);
78 static bool MakeRangeFromName( const OUString
& rName
,
82 RutlNameScope eScope
=RUTL_NAMES
,
83 ScAddress::Details
const & rDetails
= ScAddress::detailsOOOa1
);
86 class SC_DLLPUBLIC ScRangeStringConverter
91 static void AssignString(
93 const OUString
& rNewStr
,
95 sal_Unicode cSeparator
= ' ');
97 static sal_Int32
IndexOf(
98 const OUString
& rString
,
99 sal_Unicode cSearchChar
,
101 sal_Unicode cQuote
= '\'');
103 static sal_Int32
IndexOfDifferent(
104 const OUString
& rString
,
105 sal_Unicode cSearchChar
,
108 static sal_Int32
GetTokenCount(
109 const OUString
& rString
,
110 sal_Unicode cSeparator
= ' ',
111 sal_Unicode cQuote
= '\'');
113 static void GetTokenByOffset(
115 const OUString
& rString
,
117 sal_Unicode cSeparator
= ' ',
118 sal_Unicode cQuote
= '\'');
120 static void AppendTableName(
121 OUStringBuffer
& rBuf
,
122 const OUString
& rTabName
,
123 sal_Unicode cQuote
= '\'');
125 /// String to Range core
126 static bool GetAddressFromString(
128 const OUString
& rAddressStr
,
129 const ScDocument
* pDocument
,
130 formula::FormulaGrammar::AddressConvention eConv
,
132 sal_Unicode cSeparator
= ' ',
133 sal_Unicode cQuote
= '\'');
134 static bool GetRangeFromString(
136 const OUString
& rRangeStr
,
137 const ScDocument
* pDocument
,
138 formula::FormulaGrammar::AddressConvention eConv
,
140 sal_Unicode cSeparator
= ' ',
141 sal_Unicode cQuote
= '\'');
142 static bool GetRangeListFromString(
143 ScRangeList
& rRangeList
,
144 const OUString
& rRangeListStr
,
145 const ScDocument
* pDocument
,
146 formula::FormulaGrammar::AddressConvention eConv
,
147 sal_Unicode cSeparator
= ' ',
148 sal_Unicode cQuote
= '\'');
150 static bool GetAreaFromString(
152 const OUString
& rRangeStr
,
153 const ScDocument
* pDocument
,
154 formula::FormulaGrammar::AddressConvention eConv
,
156 sal_Unicode cSeparator
= ' ',
157 sal_Unicode cQuote
= '\'');
159 /// String to Range API
160 static bool GetAddressFromString(
161 ::com::sun::star::table::CellAddress
& rAddress
,
162 const OUString
& rAddressStr
,
163 const ScDocument
* pDocument
,
164 formula::FormulaGrammar::AddressConvention eConv
,
166 sal_Unicode cSeparator
= ' ',
167 sal_Unicode cQuote
= '\'');
168 static bool GetRangeFromString(
169 ::com::sun::star::table::CellRangeAddress
& rRange
,
170 const OUString
& rRangeStr
,
171 const ScDocument
* pDocument
,
172 formula::FormulaGrammar::AddressConvention eConv
,
174 sal_Unicode cSeparator
= ' ',
175 sal_Unicode cQuote
= '\'');
177 /// Range to String core
178 static void GetStringFromAddress(
180 const ScAddress
& rAddress
,
181 const ScDocument
* pDocument
,
182 formula::FormulaGrammar::AddressConvention eConv
,
183 sal_Unicode cSeparator
= ' ',
184 bool bAppendStr
= false,
185 sal_uInt16 nFormatFlags
= (SCA_VALID
| SCA_TAB_3D
) );
186 static void GetStringFromRange(
188 const ScRange
& rRange
,
189 const ScDocument
* pDocument
,
190 formula::FormulaGrammar::AddressConvention eConv
,
191 sal_Unicode cSeparator
= ' ',
192 bool bAppendStr
= false,
193 sal_uInt16 nFormatFlags
= (SCA_VALID
| SCA_TAB_3D
) );
194 static void GetStringFromRangeList(
196 const ScRangeList
* pRangeList
,
197 const ScDocument
* pDocument
,
198 formula::FormulaGrammar::AddressConvention eConv
,
199 sal_Unicode cSeparator
= ' ',
200 sal_uInt16 nFormatFlags
= (SCA_VALID
| SCA_TAB_3D
));
202 static void GetStringFromArea(
205 const ScDocument
* pDocument
,
206 formula::FormulaGrammar::AddressConvention eConv
,
207 sal_Unicode cSeparator
= ' ',
208 bool bAppendStr
= false,
209 sal_uInt16 nFormatFlags
= (SCA_VALID
| SCA_TAB_3D
) );
211 /// Range to String API
212 static void GetStringFromAddress(
214 const ::com::sun::star::table::CellAddress
& rAddress
,
215 const ScDocument
* pDocument
,
216 formula::FormulaGrammar::AddressConvention eConv
,
217 sal_Unicode cSeparator
= ' ',
218 bool bAppendStr
= false,
219 sal_uInt16 nFormatFlags
= (SCA_VALID
| SCA_TAB_3D
) );
220 static void GetStringFromRange(
222 const ::com::sun::star::table::CellRangeAddress
& rRange
,
223 const ScDocument
* pDocument
,
224 formula::FormulaGrammar::AddressConvention eConv
,
225 sal_Unicode cSeparator
= ' ',
226 bool bAppendStr
= false,
227 sal_uInt16 nFormatFlags
= (SCA_VALID
| SCA_TAB_3D
) );
228 static void GetStringFromRangeList(
230 const ::com::sun::star::uno::Sequence
< ::com::sun::star::table::CellRangeAddress
>& rRangeSeq
,
231 const ScDocument
* pDocument
,
232 formula::FormulaGrammar::AddressConvention eConv
,
233 sal_Unicode cSeparator
= ' ',
234 sal_uInt16 nFormatFlags
= (SCA_VALID
| SCA_TAB_3D
) );
236 /// XML Range to Calc Range
237 static void GetStringFromXMLRangeString(
239 const OUString
& rXMLRange
,
242 /// String to RangeData core
243 static ScRangeData
* GetRangeDataFromString(const OUString
& rString
, const SCTAB nTab
, const ScDocument
* pDoc
);
249 ScArea( SCTAB tab
= 0,
255 ScArea( const ScArea
& r
);
257 ScArea
& operator= ( const ScArea
& r
);
258 bool operator== ( const ScArea
& r
) const;
259 bool operator!= ( const ScArea
& r
) const { return !( operator==(r
) ); }
269 /// @return areas with reference and all db-areas
271 class SC_DLLPUBLIC ScAreaNameIterator
274 ScRangeName
* pRangeName
;
275 ScDBCollection
* pDBCollection
;
276 ScRangeName::const_iterator maRNPos
;
277 ScRangeName::const_iterator maRNEnd
;
278 ScDBCollection::NamedDBs::const_iterator maDBPos
;
279 ScDBCollection::NamedDBs::const_iterator maDBEnd
;
283 ScAreaNameIterator( ScDocument
* pDoc
);
284 ~ScAreaNameIterator() {}
286 bool Next( OUString
& rName
, ScRange
& rRange
);
287 bool WasDBName() const { return !bFirstPass
; }
290 #endif // INCLUDED_SC_INC_RANGEUTL_HXX
292 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */