update emoji autocorrect entries from po-files
[LibreOffice.git] / sc / inc / rangeutl.hxx
blob90e5873820f9e8def7e818cbd5e68a90ea58744e
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
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"
25 #include "dbdata.hxx"
26 #include "scdllapi.h"
28 #include <com/sun/star/table/CellAddress.hpp>
29 #include <com/sun/star/table/CellRangeAddress.hpp>
30 #include <com/sun/star/uno/Sequence.hxx>
32 class ScArea;
33 class ScDocument;
34 class ScRange;
35 class ScRangeName;
36 class ScRangeList;
37 class ScDBCollection;
39 enum RutlNameScope { RUTL_NONE=0, RUTL_NAMES, RUTL_DBASE };
41 class SC_DLLPUBLIC ScRangeUtil
43 public:
44 ScRangeUtil() {}
45 ~ScRangeUtil() {}
47 static bool MakeArea ( const OUString& rAreaStr,
48 ScArea& rArea,
49 ScDocument* pDoc,
50 SCTAB nTab,
51 ScAddress::Details const & rDetails = ScAddress::detailsOOOa1 );
53 static void CutPosString ( const OUString& theAreaStr,
54 OUString& thePosStr );
56 static bool IsAbsTabArea ( const OUString& rAreaStr,
57 ScDocument* pDoc,
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,
64 ScDocument* pDoc,
65 SCTAB nTab,
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,
72 ScDocument* pDoc,
73 SCTAB nTab,
74 OUString* pCompleteStr = 0,
75 ScRefAddress* pPosTripel = 0,
76 ScAddress::Details const & rDetails = ScAddress::detailsOOOa1 );
78 static bool MakeRangeFromName( const OUString& rName,
79 ScDocument* pDoc,
80 SCTAB nCurTab,
81 ScRange& rRange,
82 RutlNameScope eScope=RUTL_NAMES,
83 ScAddress::Details const & rDetails = ScAddress::detailsOOOa1 );
86 class SC_DLLPUBLIC ScRangeStringConverter
88 public:
90 /// helper methods
91 static void AssignString(
92 OUString& rString,
93 const OUString& rNewStr,
94 bool bAppendStr,
95 sal_Unicode cSeparator = ' ');
97 static sal_Int32 IndexOf(
98 const OUString& rString,
99 sal_Unicode cSearchChar,
100 sal_Int32 nOffset,
101 sal_Unicode cQuote = '\'');
103 static sal_Int32 IndexOfDifferent(
104 const OUString& rString,
105 sal_Unicode cSearchChar,
106 sal_Int32 nOffset );
108 static sal_Int32 GetTokenCount(
109 const OUString& rString,
110 sal_Unicode cSeparator = ' ',
111 sal_Unicode cQuote = '\'');
113 static void GetTokenByOffset(
114 OUString& rToken,
115 const OUString& rString,
116 sal_Int32& nOffset,
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(
127 ScAddress& rAddress,
128 const OUString& rAddressStr,
129 const ScDocument* pDocument,
130 formula::FormulaGrammar::AddressConvention eConv,
131 sal_Int32& nOffset,
132 sal_Unicode cSeparator = ' ',
133 sal_Unicode cQuote = '\'');
134 static bool GetRangeFromString(
135 ScRange& rRange,
136 const OUString& rRangeStr,
137 const ScDocument* pDocument,
138 formula::FormulaGrammar::AddressConvention eConv,
139 sal_Int32& nOffset,
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(
151 ScArea& rArea,
152 const OUString& rRangeStr,
153 const ScDocument* pDocument,
154 formula::FormulaGrammar::AddressConvention eConv,
155 sal_Int32& nOffset,
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,
165 sal_Int32& nOffset,
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,
173 sal_Int32& nOffset,
174 sal_Unicode cSeparator = ' ',
175 sal_Unicode cQuote = '\'');
177 /// Range to String core
178 static void GetStringFromAddress(
179 OUString& rString,
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(
187 OUString& rString,
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(
195 OUString& rString,
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(
203 OUString& rString,
204 const ScArea& rArea,
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(
213 OUString& rString,
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(
221 OUString& rString,
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(
229 OUString& rString,
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(
238 OUString& rString,
239 const OUString& rXMLRange,
240 ScDocument* pDoc );
242 /// String to RangeData core
243 static ScRangeData* GetRangeDataFromString(const OUString& rString, const SCTAB nTab, const ScDocument* pDoc);
246 class ScArea
248 public:
249 ScArea( SCTAB tab = 0,
250 SCCOL colStart = 0,
251 SCROW rowStart = 0,
252 SCCOL colEnd = 0,
253 SCROW rowEnd = 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) ); }
261 public:
262 SCTAB nTab;
263 SCCOL nColStart;
264 SCROW nRowStart;
265 SCCOL nColEnd;
266 SCROW nRowEnd;
269 /// @return areas with reference and all db-areas
271 class SC_DLLPUBLIC ScAreaNameIterator
273 private:
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;
280 bool bFirstPass;
282 public:
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: */