LibreOffice Module sc (master)  1
rangeutl.hxx
Go to the documentation of this file.
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
3  * This file is part of the LibreOffice project.
4  *
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/.
8  *
9  * This file incorporates work covered by the following license notice:
10  *
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 .
18  */
19 
20 #ifndef INCLUDED_SC_INC_RANGEUTL_HXX
21 #define INCLUDED_SC_INC_RANGEUTL_HXX
22 
23 #include "address.hxx"
24 #include "rangenam.hxx"
25 #include "dbdata.hxx"
26 #include "scdllapi.h"
27 
28 namespace com::sun::star::table { struct CellAddress; }
29 namespace com::sun::star::table { struct CellRangeAddress; }
30 namespace com::sun::star::uno { template <typename > class Sequence; }
31 
32 class ScArea;
33 class ScDocument;
34 class ScRangeList;
35 
37 
39 {
40 public:
41  ScRangeUtil() = delete;
42 
43  static bool MakeArea ( const OUString& rAreaStr,
44  ScArea& rArea,
45  const ScDocument* pDoc,
46  SCTAB nTab,
47  ScAddress::Details const & rDetails );
48 
49  static void CutPosString ( const OUString& theAreaStr,
50  OUString& thePosStr );
51 
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 );
58 
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 );
66 
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 );
73 
74  static bool MakeRangeFromName( const OUString& rName,
75  const ScDocument* pDoc,
76  SCTAB nCurTab,
77  ScRange& rRange,
79  ScAddress::Details const & rDetails = ScAddress::detailsOOOa1 );
80 };
81 
83 {
84 public:
85 
87  static void AssignString(
88  OUString& rString,
89  const OUString& rNewStr,
90  bool bAppendStr,
91  sal_Unicode cSeparator = ' ');
92 
93  static sal_Int32 IndexOf(
94  const OUString& rString,
95  sal_Unicode cSearchChar,
96  sal_Int32 nOffset,
97  sal_Unicode cQuote = '\'');
98 
99  static sal_Int32 IndexOfDifferent(
100  const OUString& rString,
101  sal_Unicode cSearchChar,
102  sal_Int32 nOffset );
103 
104  static sal_Int32 GetTokenCount(
105  const OUString& rString,
106  sal_Unicode cSeparator = ' ');
107 
108  static void GetTokenByOffset(
109  OUString& rToken,
110  const OUString& rString,
111  sal_Int32& nOffset,
112  sal_Unicode cSeparator = ' ',
113  sal_Unicode cQuote = '\'');
114 
115  static void AppendTableName(
116  OUStringBuffer& rBuf,
117  const OUString& rTabName);
118 
120  static bool GetAddressFromString(
121  ScAddress& rAddress,
122  const OUString& rAddressStr,
123  const ScDocument* pDocument,
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,
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,
141  sal_Unicode cSeparator = ' ',
142  sal_Unicode cQuote = '\'');
143 
144  static bool GetAreaFromString(
145  ScArea& rArea,
146  const OUString& rRangeStr,
147  const ScDocument* pDocument,
149  sal_Int32& nOffset,
150  sal_Unicode cSeparator = ' ');
151 
153  static bool GetRangeFromString(
154  css::table::CellRangeAddress& rRange,
155  const OUString& rRangeStr,
156  const ScDocument* pDocument,
158  sal_Int32& nOffset,
159  sal_Unicode cSeparator = ' ');
160 
162  static void GetStringFromAddress(
163  OUString& rString,
164  const ScAddress& rAddress,
165  const ScDocument* pDocument,
167  sal_Unicode cSeparator = ' ',
168  bool bAppendStr = false,
170  static void GetStringFromRange(
171  OUString& rString,
172  const ScRange& rRange,
173  const ScDocument* pDocument,
175  sal_Unicode cSeparator = ' ',
176  bool bAppendStr = false,
178  static void GetStringFromRangeList(
179  OUString& rString,
180  const ScRangeList* pRangeList,
181  const ScDocument* pDocument,
183  sal_Unicode cSeparator = ' ');
184 
185  static void GetStringFromArea(
186  OUString& rString,
187  const ScArea& rArea,
188  const ScDocument* pDocument,
190  sal_Unicode cSeparator,
191  bool bAppendStr = false,
193 
195  static void GetStringFromAddress(
196  OUString& rString,
197  const css::table::CellAddress& rAddress,
198  const ScDocument* pDocument,
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,
207  sal_Unicode cSeparator = ' ',
208  bool bAppendStr = false,
210  static void GetStringFromRangeList(
211  OUString& rString,
212  const css::uno::Sequence< css::table::CellRangeAddress >& rRangeSeq,
213  const ScDocument* pDocument,
215  sal_Unicode cSeparator = ' ' );
216 
218  static void GetStringFromXMLRangeString(
219  OUString& rString,
220  const OUString& rXMLRange,
221  const ScDocument* pDoc );
222 
224  static ScRangeData* GetRangeDataFromString(const OUString& rString, const SCTAB nTab, const ScDocument* pDoc);
225 };
226 
227 class ScArea
228 {
229 public:
230  ScArea( SCTAB tab = 0,
231  SCCOL colStart = 0,
232  SCROW rowStart = 0,
233  SCCOL colEnd = 0,
234  SCROW rowEnd = 0 );
235 
236  bool operator== ( const ScArea& r ) const;
237 
238 public:
244 };
245 
247 
249 {
250 private:
258 
259 public:
260  ScAreaNameIterator( const ScDocument* pDoc );
261 
262  bool Next( OUString& rName, ScRange& rRange );
263  bool WasDBName() const { return !bFirstPass; }
264 };
265 
267 {
268  ScRangeUpdater() = delete;
269 
270  static void UpdateInsertTab(ScAddress& rAddr, const sc::RefUpdateInsertTabContext& rCxt);
271  static void UpdateDeleteTab(ScAddress& rAddr, const sc::RefUpdateDeleteTabContext& rCxt);
272 };
273 
274 #endif // INCLUDED_SC_INC_RANGEUTL_HXX
275 
276 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
SCCOL nColEnd
Definition: rangeutl.hxx:242
SCCOL nColStart
Definition: rangeutl.hxx:240
SCROW nRowStart
Definition: rangeutl.hxx:241
RutlNameScope
Definition: rangeutl.hxx:36
ScRangeName * pRangeName
Definition: rangeutl.hxx:251
bool WasDBName() const
Definition: rangeutl.hxx:263
ScArea(SCTAB tab=0, SCCOL colStart=0, SCROW rowStart=0, SCCOL colEnd=0, SCROW rowEnd=0)
Definition: rangeutl.cxx:919
sal_uInt16 sal_Unicode
DataType::const_iterator const_iterator
Definition: rangenam.hxx:196
SCROW nRowEnd
Definition: rangeutl.hxx:243
bool operator==(const ScArea &r) const
Definition: rangeutl.cxx:928
static SC_DLLPUBLIC const Details detailsOOOa1
Definition: address.hxx:229
ScRangeName::const_iterator maRNPos
Definition: rangeutl.hxx:253
sal_Int16 SCCOL
Definition: types.hxx:22
exports com.sun.star.awt. tab
ScDBCollection * pDBCollection
Definition: rangeutl.hxx:252
ScRangeName::const_iterator maRNEnd
Definition: rangeutl.hxx:254
ScDBCollection::NamedDBs::const_iterator maDBPos
Definition: rangeutl.hxx:255
sal_Int32 SCROW
Definition: types.hxx:18
ScDBCollection::NamedDBs::const_iterator maDBEnd
Definition: rangeutl.hxx:256
DBsType::const_iterator const_iterator
Definition: dbdata.hxx:251
SCTAB nTab
Definition: rangeutl.hxx:239
ScRefFlags
Definition: address.hxx:145
#define SC_DLLPUBLIC
Definition: scdllapi.h:28
sal_Int16 SCTAB
Definition: types.hxx:23