tdf#125181 maxY is 50000 in prstGeom for star24 and star32
[LibreOffice.git] / sc / inc / rangeutl.hxx
blob54aba7bf817c567f3159e82452e7f39ab9624af6
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 namespace com { namespace sun { namespace star { namespace table { struct CellAddress; } } } }
29 namespace com { namespace sun { namespace star { namespace table { struct CellRangeAddress; } } } }
30 namespace com { namespace sun { namespace star { namespace uno { template <typename > class Sequence; } } } }
32 class ScArea;
33 class ScDocument;
34 class ScRangeList;
36 enum RutlNameScope { RUTL_NONE=0, RUTL_NAMES, RUTL_DBASE };
38 class SC_DLLPUBLIC ScRangeUtil
40 public:
41 ScRangeUtil() {}
43 static bool MakeArea ( const OUString& rAreaStr,
44 ScArea& rArea,
45 const ScDocument* pDoc,
46 SCTAB nTab,
47 ScAddress::Details const & rDetails );
49 static void CutPosString ( const OUString& theAreaStr,
50 OUString& thePosStr );
52 static bool IsAbsTabArea ( const OUString& rAreaStr,
53 const ScDocument* pDoc,
54 std::unique_ptr<ScArea[]>* ppAreas,
55 sal_uInt16* pAreaCount,
56 bool bAcceptCellRef = false,
57 ScAddress::Details const & rDetails = ScAddress::detailsOOOa1 );
59 static bool IsAbsArea ( const OUString& rAreaStr,
60 const ScDocument* pDoc,
61 SCTAB nTab,
62 OUString* pCompleteStr,
63 ScRefAddress* pStartPos = nullptr,
64 ScRefAddress* pEndPos = nullptr,
65 ScAddress::Details const & rDetails = ScAddress::detailsOOOa1 );
67 static bool IsAbsPos ( const OUString& rPosStr,
68 const ScDocument* pDoc,
69 SCTAB nTab,
70 OUString* pCompleteStr,
71 ScRefAddress* pPosTripel = nullptr,
72 ScAddress::Details const & rDetails = ScAddress::detailsOOOa1 );
74 static bool MakeRangeFromName( const OUString& rName,
75 const ScDocument* pDoc,
76 SCTAB nCurTab,
77 ScRange& rRange,
78 RutlNameScope eScope=RUTL_NAMES,
79 ScAddress::Details const & rDetails = ScAddress::detailsOOOa1 );
82 class SC_DLLPUBLIC ScRangeStringConverter
84 public:
86 /// helper methods
87 static void AssignString(
88 OUString& rString,
89 const OUString& rNewStr,
90 bool bAppendStr,
91 sal_Unicode cSeparator = ' ');
93 static sal_Int32 IndexOf(
94 const OUString& rString,
95 sal_Unicode cSearchChar,
96 sal_Int32 nOffset,
97 sal_Unicode cQuote = '\'');
99 static sal_Int32 IndexOfDifferent(
100 const OUString& rString,
101 sal_Unicode cSearchChar,
102 sal_Int32 nOffset );
104 static sal_Int32 GetTokenCount(
105 const OUString& rString,
106 sal_Unicode cSeparator = ' ');
108 static void GetTokenByOffset(
109 OUString& rToken,
110 const OUString& rString,
111 sal_Int32& nOffset,
112 sal_Unicode cSeparator = ' ',
113 sal_Unicode cQuote = '\'');
115 static void AppendTableName(
116 OUStringBuffer& rBuf,
117 const OUString& rTabName);
119 /// String to Range core
120 static bool GetAddressFromString(
121 ScAddress& rAddress,
122 const OUString& rAddressStr,
123 const ScDocument* pDocument,
124 formula::FormulaGrammar::AddressConvention eConv,
125 sal_Int32& nOffset,
126 sal_Unicode cSeparator = ' ',
127 sal_Unicode cQuote = '\'');
128 static bool GetRangeFromString(
129 ScRange& rRange,
130 const OUString& rRangeStr,
131 const ScDocument* pDocument,
132 formula::FormulaGrammar::AddressConvention eConv,
133 sal_Int32& nOffset,
134 sal_Unicode cSeparator = ' ',
135 sal_Unicode cQuote = '\'');
136 static bool GetRangeListFromString(
137 ScRangeList& rRangeList,
138 const OUString& rRangeListStr,
139 const ScDocument* pDocument,
140 formula::FormulaGrammar::AddressConvention eConv,
141 sal_Unicode cSeparator = ' ',
142 sal_Unicode cQuote = '\'');
144 static bool GetAreaFromString(
145 ScArea& rArea,
146 const OUString& rRangeStr,
147 const ScDocument* pDocument,
148 formula::FormulaGrammar::AddressConvention eConv,
149 sal_Int32& nOffset,
150 sal_Unicode cSeparator = ' ');
152 /// String to Range API
153 static bool GetRangeFromString(
154 css::table::CellRangeAddress& rRange,
155 const OUString& rRangeStr,
156 const ScDocument* pDocument,
157 formula::FormulaGrammar::AddressConvention eConv,
158 sal_Int32& nOffset,
159 sal_Unicode cSeparator = ' ');
161 /// Range to String core
162 static void GetStringFromAddress(
163 OUString& rString,
164 const ScAddress& rAddress,
165 const ScDocument* pDocument,
166 formula::FormulaGrammar::AddressConvention eConv,
167 sal_Unicode cSeparator = ' ',
168 bool bAppendStr = false,
169 ScRefFlags nFormatFlags = ScRefFlags::VALID | ScRefFlags::TAB_3D );
170 static void GetStringFromRange(
171 OUString& rString,
172 const ScRange& rRange,
173 const ScDocument* pDocument,
174 formula::FormulaGrammar::AddressConvention eConv,
175 sal_Unicode cSeparator = ' ',
176 bool bAppendStr = false,
177 ScRefFlags nFormatFlags = ScRefFlags::VALID | ScRefFlags::TAB_3D );
178 static void GetStringFromRangeList(
179 OUString& rString,
180 const ScRangeList* pRangeList,
181 const ScDocument* pDocument,
182 formula::FormulaGrammar::AddressConvention eConv,
183 sal_Unicode cSeparator = ' ');
185 static void GetStringFromArea(
186 OUString& rString,
187 const ScArea& rArea,
188 const ScDocument* pDocument,
189 formula::FormulaGrammar::AddressConvention eConv,
190 sal_Unicode cSeparator,
191 bool bAppendStr = false,
192 ScRefFlags nFormatFlags = ScRefFlags::VALID | ScRefFlags::TAB_3D );
194 /// Range to String API
195 static void GetStringFromAddress(
196 OUString& rString,
197 const css::table::CellAddress& rAddress,
198 const ScDocument* pDocument,
199 formula::FormulaGrammar::AddressConvention eConv,
200 sal_Unicode cSeparator = ' ',
201 bool bAppendStr = false );
202 static void GetStringFromRange(
203 OUString& rString,
204 const css::table::CellRangeAddress& rRange,
205 const ScDocument* pDocument,
206 formula::FormulaGrammar::AddressConvention eConv,
207 sal_Unicode cSeparator = ' ',
208 bool bAppendStr = false,
209 ScRefFlags nFormatFlags = ScRefFlags::VALID | ScRefFlags::TAB_3D );
210 static void GetStringFromRangeList(
211 OUString& rString,
212 const css::uno::Sequence< css::table::CellRangeAddress >& rRangeSeq,
213 const ScDocument* pDocument,
214 formula::FormulaGrammar::AddressConvention eConv,
215 sal_Unicode cSeparator = ' ' );
217 /// XML Range to Calc Range
218 static void GetStringFromXMLRangeString(
219 OUString& rString,
220 const OUString& rXMLRange,
221 const ScDocument* pDoc );
223 /// String to RangeData core
224 static ScRangeData* GetRangeDataFromString(const OUString& rString, const SCTAB nTab, const ScDocument* pDoc);
227 class ScArea
229 public:
230 ScArea( SCTAB tab = 0,
231 SCCOL colStart = 0,
232 SCROW rowStart = 0,
233 SCCOL colEnd = 0,
234 SCROW rowEnd = 0 );
236 bool operator== ( const ScArea& r ) const;
238 public:
239 SCTAB nTab;
240 SCCOL nColStart;
241 SCROW nRowStart;
242 SCCOL nColEnd;
243 SCROW nRowEnd;
246 /// @return areas with reference and all db-areas
248 class SC_DLLPUBLIC ScAreaNameIterator
250 private:
251 ScRangeName* pRangeName;
252 ScDBCollection* pDBCollection;
253 ScRangeName::const_iterator maRNPos;
254 ScRangeName::const_iterator maRNEnd;
255 ScDBCollection::NamedDBs::const_iterator maDBPos;
256 ScDBCollection::NamedDBs::const_iterator maDBEnd;
257 bool bFirstPass;
259 public:
260 ScAreaNameIterator( const ScDocument* pDoc );
262 bool Next( OUString& rName, ScRange& rRange );
263 bool WasDBName() const { return !bFirstPass; }
266 struct SC_DLLPUBLIC ScRangeUpdater
268 ScRangeUpdater() = delete;
270 static void UpdateInsertTab(ScAddress& rAddr, const sc::RefUpdateInsertTabContext& rCxt);
271 static void UpdateDeleteTab(ScAddress& rAddr, const sc::RefUpdateDeleteTabContext& rCxt);
274 #endif // INCLUDED_SC_INC_RANGEUTL_HXX
276 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */