sw lok: assign a parent window to property dialog
[LibreOffice.git] / sc / inc / rangeutl.hxx
blobdb54bc70cab6a8cc90891e3ec99ee94e0e5c45d0
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() {}
46 static bool MakeArea ( const OUString& rAreaStr,
47 ScArea& rArea,
48 const ScDocument* pDoc,
49 SCTAB nTab,
50 ScAddress::Details const & rDetails );
52 static void CutPosString ( const OUString& theAreaStr,
53 OUString& thePosStr );
55 static bool IsAbsTabArea ( const OUString& rAreaStr,
56 const ScDocument* pDoc,
57 ScArea*** pppAreas,
58 sal_uInt16* pAreaCount = nullptr,
59 bool bAcceptCellRef = false,
60 ScAddress::Details const & rDetails = ScAddress::detailsOOOa1 );
62 static bool IsAbsArea ( const OUString& rAreaStr,
63 const ScDocument* pDoc,
64 SCTAB nTab,
65 OUString* pCompleteStr,
66 ScRefAddress* pStartPos = nullptr,
67 ScRefAddress* pEndPos = nullptr,
68 ScAddress::Details const & rDetails = ScAddress::detailsOOOa1 );
70 static bool IsAbsPos ( const OUString& rPosStr,
71 const ScDocument* pDoc,
72 SCTAB nTab,
73 OUString* pCompleteStr,
74 ScRefAddress* pPosTripel = nullptr,
75 ScAddress::Details const & rDetails = ScAddress::detailsOOOa1 );
77 static bool MakeRangeFromName( const OUString& rName,
78 const ScDocument* pDoc,
79 SCTAB nCurTab,
80 ScRange& rRange,
81 RutlNameScope eScope=RUTL_NAMES,
82 ScAddress::Details const & rDetails = ScAddress::detailsOOOa1 );
85 class SC_DLLPUBLIC ScRangeStringConverter
87 public:
89 /// helper methods
90 static void AssignString(
91 OUString& rString,
92 const OUString& rNewStr,
93 bool bAppendStr,
94 sal_Unicode cSeparator = ' ');
96 static sal_Int32 IndexOf(
97 const OUString& rString,
98 sal_Unicode cSearchChar,
99 sal_Int32 nOffset,
100 sal_Unicode cQuote = '\'');
102 static sal_Int32 IndexOfDifferent(
103 const OUString& rString,
104 sal_Unicode cSearchChar,
105 sal_Int32 nOffset );
107 static sal_Int32 GetTokenCount(
108 const OUString& rString,
109 sal_Unicode cSeparator = ' ');
111 static void GetTokenByOffset(
112 OUString& rToken,
113 const OUString& rString,
114 sal_Int32& nOffset,
115 sal_Unicode cSeparator = ' ',
116 sal_Unicode cQuote = '\'');
118 static void AppendTableName(
119 OUStringBuffer& rBuf,
120 const OUString& rTabName);
122 /// String to Range core
123 static bool GetAddressFromString(
124 ScAddress& rAddress,
125 const OUString& rAddressStr,
126 const ScDocument* pDocument,
127 formula::FormulaGrammar::AddressConvention eConv,
128 sal_Int32& nOffset,
129 sal_Unicode cSeparator = ' ',
130 sal_Unicode cQuote = '\'');
131 static bool GetRangeFromString(
132 ScRange& rRange,
133 const OUString& rRangeStr,
134 const ScDocument* pDocument,
135 formula::FormulaGrammar::AddressConvention eConv,
136 sal_Int32& nOffset,
137 sal_Unicode cSeparator = ' ',
138 sal_Unicode cQuote = '\'');
139 static bool GetRangeListFromString(
140 ScRangeList& rRangeList,
141 const OUString& rRangeListStr,
142 const ScDocument* pDocument,
143 formula::FormulaGrammar::AddressConvention eConv,
144 sal_Unicode cSeparator = ' ',
145 sal_Unicode cQuote = '\'');
147 static bool GetAreaFromString(
148 ScArea& rArea,
149 const OUString& rRangeStr,
150 const ScDocument* pDocument,
151 formula::FormulaGrammar::AddressConvention eConv,
152 sal_Int32& nOffset,
153 sal_Unicode cSeparator = ' ');
155 /// String to Range API
156 static bool GetRangeFromString(
157 css::table::CellRangeAddress& rRange,
158 const OUString& rRangeStr,
159 const ScDocument* pDocument,
160 formula::FormulaGrammar::AddressConvention eConv,
161 sal_Int32& nOffset,
162 sal_Unicode cSeparator = ' ');
164 /// Range to String core
165 static void GetStringFromAddress(
166 OUString& rString,
167 const ScAddress& rAddress,
168 const ScDocument* pDocument,
169 formula::FormulaGrammar::AddressConvention eConv,
170 sal_Unicode cSeparator = ' ',
171 bool bAppendStr = false,
172 ScRefFlags nFormatFlags = (ScRefFlags::VALID | ScRefFlags::TAB_3D) );
173 static void GetStringFromRange(
174 OUString& rString,
175 const ScRange& rRange,
176 const ScDocument* pDocument,
177 formula::FormulaGrammar::AddressConvention eConv,
178 sal_Unicode cSeparator = ' ',
179 bool bAppendStr = false,
180 ScRefFlags nFormatFlags = (ScRefFlags::VALID | ScRefFlags::TAB_3D) );
181 static void GetStringFromRangeList(
182 OUString& rString,
183 const ScRangeList* pRangeList,
184 const ScDocument* pDocument,
185 formula::FormulaGrammar::AddressConvention eConv,
186 sal_Unicode cSeparator = ' ');
188 static void GetStringFromArea(
189 OUString& rString,
190 const ScArea& rArea,
191 const ScDocument* pDocument,
192 formula::FormulaGrammar::AddressConvention eConv,
193 sal_Unicode cSeparator,
194 bool bAppendStr = false,
195 ScRefFlags nFormatFlags = (ScRefFlags::VALID | ScRefFlags::TAB_3D) );
197 /// Range to String API
198 static void GetStringFromAddress(
199 OUString& rString,
200 const css::table::CellAddress& rAddress,
201 const ScDocument* pDocument,
202 formula::FormulaGrammar::AddressConvention eConv,
203 sal_Unicode cSeparator = ' ',
204 bool bAppendStr = false );
205 static void GetStringFromRange(
206 OUString& rString,
207 const css::table::CellRangeAddress& rRange,
208 const ScDocument* pDocument,
209 formula::FormulaGrammar::AddressConvention eConv,
210 sal_Unicode cSeparator = ' ',
211 bool bAppendStr = false,
212 ScRefFlags nFormatFlags = (ScRefFlags::VALID | ScRefFlags::TAB_3D) );
213 static void GetStringFromRangeList(
214 OUString& rString,
215 const css::uno::Sequence< css::table::CellRangeAddress >& rRangeSeq,
216 const ScDocument* pDocument,
217 formula::FormulaGrammar::AddressConvention eConv,
218 sal_Unicode cSeparator = ' ' );
220 /// XML Range to Calc Range
221 static void GetStringFromXMLRangeString(
222 OUString& rString,
223 const OUString& rXMLRange,
224 const ScDocument* pDoc );
226 /// String to RangeData core
227 static ScRangeData* GetRangeDataFromString(const OUString& rString, const SCTAB nTab, const ScDocument* pDoc);
230 class ScArea
232 public:
233 ScArea( SCTAB tab = 0,
234 SCCOL colStart = 0,
235 SCROW rowStart = 0,
236 SCCOL colEnd = 0,
237 SCROW rowEnd = 0 );
239 bool operator== ( const ScArea& r ) const;
241 public:
242 SCTAB nTab;
243 SCCOL nColStart;
244 SCROW nRowStart;
245 SCCOL nColEnd;
246 SCROW nRowEnd;
249 /// @return areas with reference and all db-areas
251 class SC_DLLPUBLIC ScAreaNameIterator
253 private:
254 ScRangeName* pRangeName;
255 ScDBCollection* pDBCollection;
256 ScRangeName::const_iterator maRNPos;
257 ScRangeName::const_iterator maRNEnd;
258 ScDBCollection::NamedDBs::const_iterator maDBPos;
259 ScDBCollection::NamedDBs::const_iterator maDBEnd;
260 bool bFirstPass;
262 public:
263 ScAreaNameIterator( const ScDocument* pDoc );
265 bool Next( OUString& rName, ScRange& rRange );
266 bool WasDBName() const { return !bFirstPass; }
269 struct SC_DLLPUBLIC ScRangeUpdater
271 ScRangeUpdater() = delete;
273 static void UpdateInsertTab(ScAddress& rAddr, const sc::RefUpdateInsertTabContext& rCxt);
274 static void UpdateDeleteTab(ScAddress& rAddr, const sc::RefUpdateDeleteTabContext& rCxt);
277 #endif // INCLUDED_SC_INC_RANGEUTL_HXX
279 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */