1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 * Copyright 2000, 2010 Oracle and/or its affiliates.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * This file is part of OpenOffice.org.
11 * OpenOffice.org is free software: you can redistribute it and/or modify
12 * it under the terms of the GNU Lesser General Public License version 3
13 * only, as published by the Free Software Foundation.
15 * OpenOffice.org is distributed in the hope that it will be useful,
16 * but WITHOUT ANY WARRANTY; without even the implied warranty of
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 * GNU Lesser General Public License version 3 for more details
19 * (a copy is included in the LICENSE file that accompanied this code).
21 * You should have received a copy of the GNU Lesser General Public License
22 * version 3 along with OpenOffice.org. If not, see
23 * <http://www.openoffice.org/license.html>
24 * for a copy of the LGPLv3 License.
26 ************************************************************************/
28 #ifndef SC_RANGEUTL_HXX
29 #define SC_RANGEUTL_HXX
31 #include "address.hxx"
32 #include <tools/string.hxx>
34 #include <com/sun/star/table/CellAddress.hpp>
35 #include <com/sun/star/table/CellRangeAddress.hpp>
36 #include <com/sun/star/uno/Sequence.hxx>
38 //------------------------------------------------------------------------
49 enum RutlNameScope
{ RUTL_NONE
=0, RUTL_NAMES
, RUTL_DBASE
};
51 //------------------------------------------------------------------------
53 class SC_DLLPUBLIC ScRangeUtil
59 BOOL
MakeArea ( const String
& rAreaStr
,
63 ScAddress::Details
const & rDetails
= ScAddress::detailsOOOa1
) const;
65 void CutPosString ( const String
& theAreaStr
,
66 String
& thePosStr
) const;
68 BOOL
IsAbsTabArea ( const String
& rAreaStr
,
70 ScArea
*** pppAreas
= 0,
71 USHORT
* pAreaCount
= 0,
72 BOOL bAcceptCellRef
= FALSE
,
73 ScAddress::Details
const & rDetails
= ScAddress::detailsOOOa1
) const;
75 BOOL
IsAbsArea ( const String
& rAreaStr
,
78 String
* pCompleteStr
= 0,
79 ScRefAddress
* pStartPos
= 0,
80 ScRefAddress
* pEndPos
= 0,
81 ScAddress::Details
const & rDetails
= ScAddress::detailsOOOa1
) const;
83 BOOL
IsRefArea ( const String
&,
87 ScRefAddress
* = 0 ) const
90 BOOL
IsAbsPos ( const String
& rPosStr
,
93 String
* pCompleteStr
= 0,
94 ScRefAddress
* pPosTripel
= 0,
95 ScAddress::Details
const & rDetails
= ScAddress::detailsOOOa1
) const;
97 BOOL
MakeRangeFromName ( const String
& rName
,
101 RutlNameScope eScope
=RUTL_NAMES
,
102 ScAddress::Details
const & rDetails
= ScAddress::detailsOOOa1
) const;
105 //------------------------------------------------------------------------
107 class SC_DLLPUBLIC ScRangeStringConverter
112 static void AssignString(
113 ::rtl::OUString
& rString
,
114 const ::rtl::OUString
& rNewStr
,
116 sal_Unicode cSeperator
= ' ');
118 static sal_Int32
IndexOf(
119 const ::rtl::OUString
& rString
,
120 sal_Unicode cSearchChar
,
122 sal_Unicode cQuote
= '\'');
124 static sal_Int32
IndexOfDifferent(
125 const ::rtl::OUString
& rString
,
126 sal_Unicode cSearchChar
,
129 static sal_Int32
GetTokenCount(
130 const ::rtl::OUString
& rString
,
131 sal_Unicode cSeperator
= ' ',
132 sal_Unicode cQuote
= '\'');
134 static void GetTokenByOffset(
135 ::rtl::OUString
& rToken
,
136 const ::rtl::OUString
& rString
,
138 sal_Unicode cSeperator
= ' ',
139 sal_Unicode cQuote
= '\'');
141 static void AppendTableName(
142 ::rtl::OUStringBuffer
& rBuf
,
143 const ::rtl::OUString
& rTabName
,
144 sal_Unicode cQuote
= '\'');
146 // String to Range core
147 static sal_Bool
GetAddressFromString(
149 const ::rtl::OUString
& rAddressStr
,
150 const ScDocument
* pDocument
,
151 formula::FormulaGrammar::AddressConvention eConv
,
153 sal_Unicode cSeperator
= ' ',
154 sal_Unicode cQuote
= '\'');
155 static sal_Bool
GetRangeFromString(
157 const ::rtl::OUString
& rRangeStr
,
158 const ScDocument
* pDocument
,
159 formula::FormulaGrammar::AddressConvention eConv
,
161 sal_Unicode cSeperator
= ' ',
162 sal_Unicode cQuote
= '\'');
163 static sal_Bool
GetRangeListFromString(
164 ScRangeList
& rRangeList
,
165 const ::rtl::OUString
& rRangeListStr
,
166 const ScDocument
* pDocument
,
167 formula::FormulaGrammar::AddressConvention eConv
,
168 sal_Unicode cSeperator
= ' ',
169 sal_Unicode cQuote
= '\'');
171 static sal_Bool
GetAreaFromString(
173 const ::rtl::OUString
& rRangeStr
,
174 const ScDocument
* pDocument
,
175 formula::FormulaGrammar::AddressConvention eConv
,
177 sal_Unicode cSeperator
= ' ',
178 sal_Unicode cQuote
= '\'');
180 // String to Range API
181 static sal_Bool
GetAddressFromString(
182 ::com::sun::star::table::CellAddress
& rAddress
,
183 const ::rtl::OUString
& rAddressStr
,
184 const ScDocument
* pDocument
,
185 formula::FormulaGrammar::AddressConvention eConv
,
187 sal_Unicode cSeperator
= ' ',
188 sal_Unicode cQuote
= '\'');
189 static sal_Bool
GetRangeFromString(
190 ::com::sun::star::table::CellRangeAddress
& rRange
,
191 const ::rtl::OUString
& rRangeStr
,
192 const ScDocument
* pDocument
,
193 formula::FormulaGrammar::AddressConvention eConv
,
195 sal_Unicode cSeperator
= ' ',
196 sal_Unicode cQuote
= '\'');
197 static sal_Bool
GetRangeListFromString(
198 ::com::sun::star::uno::Sequence
< ::com::sun::star::table::CellRangeAddress
>& rRangeSeq
,
199 const ::rtl::OUString
& rRangeListStr
,
200 const ScDocument
* pDocument
,
201 formula::FormulaGrammar::AddressConvention eConv
,
202 sal_Unicode cSeperator
= ' ',
203 sal_Unicode cQuote
= '\'');
205 // Range to String core
206 static void GetStringFromAddress(
207 ::rtl::OUString
& rString
,
208 const ScAddress
& rAddress
,
209 const ScDocument
* pDocument
,
210 formula::FormulaGrammar::AddressConvention eConv
,
211 sal_Unicode cSeperator
= ' ',
212 sal_Bool bAppendStr
= sal_False
,
213 sal_uInt16 nFormatFlags
= (SCA_VALID
| SCA_TAB_3D
) );
214 static void GetStringFromRange(
215 ::rtl::OUString
& rString
,
216 const ScRange
& rRange
,
217 const ScDocument
* pDocument
,
218 formula::FormulaGrammar::AddressConvention eConv
,
219 sal_Unicode cSeperator
= ' ',
220 sal_Bool bAppendStr
= sal_False
,
221 sal_uInt16 nFormatFlags
= (SCA_VALID
| SCA_TAB_3D
) );
222 static void GetStringFromRangeList(
223 ::rtl::OUString
& rString
,
224 const ScRangeList
* pRangeList
,
225 const ScDocument
* pDocument
,
226 formula::FormulaGrammar::AddressConvention eConv
,
227 sal_Unicode cSeperator
= ' ',
228 sal_uInt16 nFormatFlags
= (SCA_VALID
| SCA_TAB_3D
));
230 static void GetStringFromArea(
231 ::rtl::OUString
& rString
,
233 const ScDocument
* pDocument
,
234 formula::FormulaGrammar::AddressConvention eConv
,
235 sal_Unicode cSeperator
= ' ',
236 sal_Bool bAppendStr
= sal_False
,
237 sal_uInt16 nFormatFlags
= (SCA_VALID
| SCA_TAB_3D
) );
239 // Range to String API
240 static void GetStringFromAddress(
241 ::rtl::OUString
& rString
,
242 const ::com::sun::star::table::CellAddress
& rAddress
,
243 const ScDocument
* pDocument
,
244 formula::FormulaGrammar::AddressConvention eConv
,
245 sal_Unicode cSeperator
= ' ',
246 sal_Bool bAppendStr
= sal_False
,
247 sal_uInt16 nFormatFlags
= (SCA_VALID
| SCA_TAB_3D
) );
248 static void GetStringFromRange(
249 ::rtl::OUString
& rString
,
250 const ::com::sun::star::table::CellRangeAddress
& rRange
,
251 const ScDocument
* pDocument
,
252 formula::FormulaGrammar::AddressConvention eConv
,
253 sal_Unicode cSeperator
= ' ',
254 sal_Bool bAppendStr
= sal_False
,
255 sal_uInt16 nFormatFlags
= (SCA_VALID
| SCA_TAB_3D
) );
256 static void GetStringFromRangeList(
257 ::rtl::OUString
& rString
,
258 const ::com::sun::star::uno::Sequence
< ::com::sun::star::table::CellRangeAddress
>& rRangeSeq
,
259 const ScDocument
* pDocument
,
260 formula::FormulaGrammar::AddressConvention eConv
,
261 sal_Unicode cSeperator
= ' ',
262 sal_uInt16 nFormatFlags
= (SCA_VALID
| SCA_TAB_3D
) );
264 // XML Range to Calc Range
265 static void GetStringFromXMLRangeString(
266 ::rtl::OUString
& rString
,
267 const ::rtl::OUString
& rXMLRange
,
271 //------------------------------------------------------------------------
276 ScArea( SCTAB tab
= 0,
282 ScArea( const ScArea
& r
);
284 ScArea
& operator= ( const ScArea
& r
);
285 BOOL
operator== ( const ScArea
& r
) const;
286 BOOL
operator!= ( const ScArea
& r
) const { return !( operator==(r
) ); }
296 //------------------------------------------------------------------------
299 // gibt Bereiche mit Referenz und alle DB-Bereiche zurueck
302 class SC_DLLPUBLIC ScAreaNameIterator
305 ScRangeName
* pRangeName
;
306 ScDBCollection
* pDBCollection
;
312 ScAreaNameIterator( ScDocument
* pDoc
);
313 ~ScAreaNameIterator() {}
315 BOOL
Next( String
& rName
, ScRange
& rRange
);
316 BOOL
WasDBName() const { return !bFirstPass
; }
320 #endif // SC_RANGEUTL_HXX