Branch data Line data Source code
1 : : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 : : /*************************************************************************
3 : : *
4 : : * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 : : *
6 : : * Copyright 2000, 2010 Oracle and/or its affiliates.
7 : : *
8 : : * OpenOffice.org - a multi-platform office productivity suite
9 : : *
10 : : * This file is part of OpenOffice.org.
11 : : *
12 : : * OpenOffice.org is free software: you can redistribute it and/or modify
13 : : * it under the terms of the GNU Lesser General Public License version 3
14 : : * only, as published by the Free Software Foundation.
15 : : *
16 : : * OpenOffice.org is distributed in the hope that it will be useful,
17 : : * but WITHOUT ANY WARRANTY; without even the implied warranty of
18 : : * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 : : * GNU Lesser General Public License version 3 for more details
20 : : * (a copy is included in the LICENSE file that accompanied this code).
21 : : *
22 : : * You should have received a copy of the GNU Lesser General Public License
23 : : * version 3 along with OpenOffice.org. If not, see
24 : : * <http://www.openoffice.org/license.html>
25 : : * for a copy of the LGPLv3 License.
26 : : *
27 : : ************************************************************************/
28 : :
29 : : #ifndef OOX_XLS_ADDRESSCONVERTER_HXX
30 : : #define OOX_XLS_ADDRESSCONVERTER_HXX
31 : :
32 : : #include <vector>
33 : : #include <com/sun/star/table/CellAddress.hpp>
34 : : #include <com/sun/star/table/CellRangeAddress.hpp>
35 : : #include "workbookhelper.hxx"
36 : :
37 : : namespace oox {
38 : : namespace xls {
39 : :
40 : : class BiffInputStream;
41 : :
42 : : // ============================================================================
43 : : // ============================================================================
44 : :
45 : : /** A vector of com.sun.star.table.CellRangeAddress elements and additional
46 : : functionality. */
47 : 1134 : class ApiCellRangeList : public ::std::vector< ::com::sun::star::table::CellRangeAddress >
48 : : {
49 : : public:
50 : 297 : inline explicit ApiCellRangeList() {}
51 : :
52 : : /** Returns the base address of this range list (top-left cell of first range). */
53 : : ::com::sun::star::table::CellAddress
54 : : getBaseAddress() const;
55 : : };
56 : :
57 : : // ============================================================================
58 : :
59 : : /** A 2D cell address struct for binary filters. */
60 : : struct BinAddress
61 : : {
62 : : sal_Int32 mnCol;
63 : : sal_Int32 mnRow;
64 : :
65 : 120 : inline explicit BinAddress() : mnCol( 0 ), mnRow( 0 ) {}
66 : 6 : inline explicit BinAddress( sal_Int32 nCol, sal_Int32 nRow ) : mnCol( nCol ), mnRow( nRow ) {}
67 : 0 : inline explicit BinAddress( const ::com::sun::star::table::CellAddress& rAddr ) : mnCol( rAddr.Column ), mnRow( rAddr.Row ) {}
68 : :
69 : : inline void set( sal_Int32 nCol, sal_Int32 nRow ) { mnCol = nCol; mnRow = nRow; }
70 : : inline void set( const ::com::sun::star::table::CellAddress& rAddr ) { mnCol = rAddr.Column; mnRow = rAddr.Row; }
71 : :
72 : : void read( SequenceInputStream& rStrm );
73 : : void read( BiffInputStream& rStrm, bool bCol16Bit = true, bool bRow32Bit = false );
74 : : };
75 : :
76 : : // ----------------------------------------------------------------------------
77 : :
78 : : inline bool operator==( const BinAddress& rL, const BinAddress& rR )
79 : : {
80 : : return (rL.mnCol == rR.mnCol) && (rL.mnRow == rR.mnRow);
81 : : }
82 : :
83 : 0 : inline bool operator<( const BinAddress& rL, const BinAddress& rR )
84 : : {
85 [ # # ][ # # ]: 0 : return (rL.mnCol < rR.mnCol) || ((rL.mnCol == rR.mnCol) && (rL.mnRow < rR.mnRow));
[ # # ]
86 : : }
87 : :
88 : 0 : inline SequenceInputStream& operator>>( SequenceInputStream& rStrm, BinAddress& orPos )
89 : : {
90 : 0 : orPos.read( rStrm );
91 : 0 : return rStrm;
92 : : }
93 : :
94 : 0 : inline BiffInputStream& operator>>( BiffInputStream& rStrm, BinAddress& orPos )
95 : : {
96 : 0 : orPos.read( rStrm );
97 : 0 : return rStrm;
98 : : }
99 : :
100 : : // ============================================================================
101 : :
102 : : /** A 2D cell range address struct for binary filters. */
103 : : struct BinRange
104 : : {
105 : : BinAddress maFirst;
106 : : BinAddress maLast;
107 : :
108 : 0 : inline explicit BinRange() {}
109 : : inline explicit BinRange( const BinAddress& rAddr ) : maFirst( rAddr ), maLast( rAddr ) {}
110 : : inline explicit BinRange( const BinAddress& rFirst, const BinAddress& rLast ) : maFirst( rFirst ), maLast( rLast ) {}
111 : : inline explicit BinRange( sal_Int32 nCol1, sal_Int32 nRow1, sal_Int32 nCol2, sal_Int32 nRow2 ) :
112 : : maFirst( nCol1, nRow1 ), maLast( nCol2, nRow2 ) {}
113 : : inline explicit BinRange( const ::com::sun::star::table::CellAddress& rAddr ) : maFirst( rAddr ), maLast( rAddr ) {}
114 : : inline explicit BinRange( const ::com::sun::star::table::CellAddress& rFirst, const ::com::sun::star::table::CellAddress& rLast ) : maFirst( rFirst ), maLast( rLast ) {}
115 : 0 : inline explicit BinRange( const ::com::sun::star::table::CellRangeAddress& rRange ) : maFirst( rRange.StartColumn, rRange.StartRow ), maLast( rRange.EndColumn, rRange.EndRow ) {}
116 : :
117 : : inline void set( const BinAddress& rFirst, const BinAddress& rLast )
118 : : { maFirst = rFirst; maLast = rLast; }
119 : : inline void set( sal_Int32 nCol1, sal_Int32 nRow1, sal_Int32 nCol2, sal_Int32 nRow2 )
120 : : { maFirst.set( nCol1, nRow1 ); maLast.set( nCol2, nRow2 ); }
121 : : inline void set( const ::com::sun::star::table::CellAddress& rFirst, const ::com::sun::star::table::CellAddress& rLast )
122 : : { maFirst.set( rFirst ); maLast.set( rLast ); }
123 : : inline void set( const ::com::sun::star::table::CellRangeAddress& rRange )
124 : : { maFirst.set( rRange.StartColumn, rRange.StartRow ); maLast.set( rRange.EndColumn, rRange.EndRow ); }
125 : :
126 : 0 : inline sal_Int32 getColCount() const { return maLast.mnCol - maFirst.mnCol + 1; }
127 : 0 : inline sal_Int32 getRowCount() const { return maLast.mnRow - maFirst.mnRow + 1; }
128 : :
129 : : void read( SequenceInputStream& rStrm );
130 : : void read( BiffInputStream& rStrm, bool bCol16Bit = true, bool bRow32Bit = false );
131 : : };
132 : :
133 : : // ----------------------------------------------------------------------------
134 : :
135 : : inline bool operator==( const BinRange& rL, const BinRange& rR )
136 : : {
137 : : return (rL.maFirst == rR.maFirst) && (rL.maLast == rR.maLast);
138 : : }
139 : :
140 : : inline bool operator<( const BinRange& rL, const BinRange& rR )
141 : : {
142 : : return (rL.maFirst < rR.maFirst) || ((rL.maFirst == rR.maFirst) && (rL.maLast < rR.maLast));
143 : : }
144 : :
145 : 0 : inline SequenceInputStream& operator>>( SequenceInputStream& rStrm, BinRange& orRange )
146 : : {
147 : 0 : orRange.read( rStrm );
148 : 0 : return rStrm;
149 : : }
150 : :
151 : 0 : inline BiffInputStream& operator>>( BiffInputStream& rStrm, BinRange& orRange )
152 : : {
153 : 0 : orRange.read( rStrm );
154 : 0 : return rStrm;
155 : : }
156 : :
157 : : // ============================================================================
158 : :
159 : : /** A 2D cell range address list for binary filters. */
160 : 0 : class BinRangeList : public ::std::vector< BinRange >
161 : : {
162 : : public:
163 : 0 : inline explicit BinRangeList() {}
164 : :
165 : : void read( SequenceInputStream& rStrm );
166 : : };
167 : :
168 : : // ----------------------------------------------------------------------------
169 : :
170 : 0 : inline SequenceInputStream& operator>>( SequenceInputStream& rStrm, BinRangeList& orRanges )
171 : : {
172 : 0 : orRanges.read( rStrm );
173 : 0 : return rStrm;
174 : : }
175 : :
176 : : // ============================================================================
177 : :
178 : : /** Different target types that can be encoded in a BIFF URL. */
179 : : enum BiffTargetType
180 : : {
181 : : BIFF_TARGETTYPE_URL, /// URL, URL with sheet name, or sheet name.
182 : : BIFF_TARGETTYPE_SAMESHEET, /// Target for special '!A1' syntax to refer to current sheet.
183 : : BIFF_TARGETTYPE_LIBRARY, /// Library directory in application installation.
184 : : BIFF_TARGETTYPE_DDE_OLE, /// DDE server/topic or OLE class/target.
185 : : BIFF_TARGETTYPE_UNKNOWN /// Unknown/unsupported target type.
186 : : };
187 : :
188 : : // ============================================================================
189 : : // ============================================================================
190 : :
191 : : /** Converter for cell addresses and cell ranges for OOXML and BIFF filters.
192 : : */
193 [ - + ]: 48 : class AddressConverter : public WorkbookHelper
194 : : {
195 : : public:
196 : : explicit AddressConverter( const WorkbookHelper& rHelper );
197 : :
198 : : // ------------------------------------------------------------------------
199 : :
200 : : /** Tries to parse the passed string for a 2d cell address in A1 notation.
201 : :
202 : : This function accepts all strings that match the regular expression
203 : : "[a-zA-Z]{1,6}0*[1-9][0-9]{0,8}" (without quotes), i.e. 1 to 6 letters
204 : : for the column index (translated to 0-based column indexes from 0 to
205 : : 321,272,405), and 1 to 9 digits for the 1-based row index (translated
206 : : to 0-based row indexes from 0 to 999,999,998). The row number part may
207 : : contain leading zeros, they will be ignored. It is up to the caller to
208 : : handle cell addresses outside of a specific valid range (e.g. the
209 : : entire spreadsheet).
210 : :
211 : : @param ornColumn (out-parameter) Returns the converted column index.
212 : : @param ornRow (out-parameter) returns the converted row index.
213 : : @param rString The string containing the cell address.
214 : : @param nStart Start index of string part in rString to be parsed.
215 : : @param nLength Length of string part in rString to be parsed.
216 : :
217 : : @return true = Parsed string was valid, returned values can be used.
218 : : */
219 : : static bool parseOoxAddress2d(
220 : : sal_Int32& ornColumn, sal_Int32& ornRow,
221 : : const ::rtl::OUString& rString,
222 : : sal_Int32 nStart = 0,
223 : : sal_Int32 nLength = SAL_MAX_INT32 );
224 : :
225 : : /** Tries to parse the passed string for a 2d cell range in A1 notation.
226 : :
227 : : This function accepts all strings that match the regular expression
228 : : "ADDR(:ADDR)?" (without quotes), where ADDR is a cell address accepted
229 : : by the parseOoxAddress2d() function of this class. It is up to the
230 : : caller to handle cell ranges outside of a specific valid range (e.g.
231 : : the entire spreadsheet).
232 : :
233 : : @param ornStartColumn (out-parameter) Returns the converted start column index.
234 : : @param ornStartRow (out-parameter) returns the converted start row index.
235 : : @param ornEndColumn (out-parameter) Returns the converted end column index.
236 : : @param ornEndRow (out-parameter) returns the converted end row index.
237 : : @param rString The string containing the cell address.
238 : : @param nStart Start index of string part in rString to be parsed.
239 : : @param nLength Length of string part in rString to be parsed.
240 : :
241 : : @return true = Parsed string was valid, returned values can be used.
242 : : */
243 : : static bool parseOoxRange2d(
244 : : sal_Int32& ornStartColumn, sal_Int32& ornStartRow,
245 : : sal_Int32& ornEndColumn, sal_Int32& ornEndRow,
246 : : const ::rtl::OUString& rString,
247 : : sal_Int32 nStart = 0,
248 : : sal_Int32 nLength = SAL_MAX_INT32 );
249 : :
250 : : // ------------------------------------------------------------------------
251 : :
252 : : /** Returns the biggest valid cell address in the own Calc document. */
253 : : inline const ::com::sun::star::table::CellAddress&
254 : 411 : getMaxApiAddress() const { return maMaxApiPos; }
255 : :
256 : : /** Returns the biggest valid cell address in the imported/exported
257 : : Excel document. */
258 : : inline const ::com::sun::star::table::CellAddress&
259 : 48 : getMaxXlsAddress() const { return maMaxXlsPos; }
260 : :
261 : : /** Returns the biggest valid cell address in both Calc and the
262 : : imported/exported Excel document. */
263 : : inline const ::com::sun::star::table::CellAddress&
264 : 0 : getMaxAddress() const { return maMaxPos; }
265 : :
266 : : /** Returns the column overflow status. */
267 : : inline bool isColOverflow() const { return mbColOverflow; }
268 : : /** Returns the row overflow status. */
269 : : inline bool isRowOverflow() const { return mbRowOverflow; }
270 : : /** Returns the sheet overflow status. */
271 : : inline bool isTabOverflow() const { return mbTabOverflow; }
272 : :
273 : : // ------------------------------------------------------------------------
274 : :
275 : : /** Checks if the passed column index is valid.
276 : :
277 : : @param nCol The column index to check.
278 : : @param bTrackOverflow true = Update the internal overflow flag, if the
279 : : column index is outside of the supported limits.
280 : : @return true = Passed column index is valid (no index overflow).
281 : : */
282 : : bool checkCol( sal_Int32 nCol, bool bTrackOverflow );
283 : :
284 : : /** Checks if the passed row index is valid.
285 : :
286 : : @param nRow The row index to check.
287 : : @param bTrackOverflow true = Update the internal overflow flag, if the
288 : : row index is outside of the supported limits.
289 : : @return true = Passed row index is valid (no index overflow).
290 : : */
291 : : bool checkRow( sal_Int32 nRow, bool bTrackOverflow );
292 : :
293 : : /** Checks if the passed sheet index is valid.
294 : :
295 : : @param nSheet The sheet index to check.
296 : : @param bTrackOverflow true = Update the internal overflow flag, if the
297 : : sheet index is outside of the supported limits.
298 : : @return true = Passed sheet index is valid (no index overflow).
299 : : */
300 : : bool checkTab( sal_Int16 nSheet, bool bTrackOverflow );
301 : :
302 : : // ------------------------------------------------------------------------
303 : :
304 : : /** Checks the passed cell address if it fits into the spreadsheet limits.
305 : :
306 : : @param rAddress The cell address to be checked.
307 : : @param bTrackOverflow true = Update the internal overflow flags, if
308 : : the address is outside of the supported sheet limits.
309 : : @return true = Passed address is valid (no index overflow).
310 : : */
311 : : bool checkCellAddress(
312 : : const ::com::sun::star::table::CellAddress& rAddress,
313 : : bool bTrackOverflow );
314 : :
315 : : /** Converts the passed string to a single cell address, without checking
316 : : any sheet limits.
317 : :
318 : : @param orAddress (out-parameter) Returns the converted cell address.
319 : : @param rString Cell address string in A1 notation.
320 : : @param nSheet Sheet index to be inserted into orAddress.
321 : : @return true = Cell address could be parsed from the passed string.
322 : : */
323 : : bool convertToCellAddressUnchecked(
324 : : ::com::sun::star::table::CellAddress& orAddress,
325 : : const ::rtl::OUString& rString,
326 : : sal_Int16 nSheet );
327 : :
328 : : /** Tries to convert the passed string to a single cell address.
329 : :
330 : : @param orAddress (out-parameter) Returns the converted cell address.
331 : : @param rString Cell address string in A1 notation.
332 : : @param nSheet Sheet index to be inserted into orAddress (will be checked).
333 : : @param bTrackOverflow true = Update the internal overflow flags, if
334 : : the address is outside of the supported sheet limits.
335 : : @return true = Converted address is valid (no index overflow).
336 : : */
337 : : bool convertToCellAddress(
338 : : ::com::sun::star::table::CellAddress& orAddress,
339 : : const ::rtl::OUString& rString,
340 : : sal_Int16 nSheet,
341 : : bool bTrackOverflow );
342 : :
343 : : /** Returns a valid cell address by moving it into allowed dimensions.
344 : :
345 : : @param rString Cell address string in A1 notation.
346 : : @param nSheet Sheet index for the returned address (will be checked).
347 : : @param bTrackOverflow true = Update the internal overflow flags, if
348 : : the address is outside of the supported sheet limits.
349 : : @return A valid API cell address struct. */
350 : : ::com::sun::star::table::CellAddress
351 : : createValidCellAddress(
352 : : const ::rtl::OUString& rString,
353 : : sal_Int16 nSheet,
354 : : bool bTrackOverflow );
355 : :
356 : : /** Converts the passed address to a single cell address, without checking
357 : : any sheet limits.
358 : :
359 : : @param orAddress (out-parameter) Returns the converted cell address.
360 : : @param rBinAddress Binary cell address struct.
361 : : @param nSheet Sheet index to be inserted into orAddress.
362 : : */
363 : : void convertToCellAddressUnchecked(
364 : : ::com::sun::star::table::CellAddress& orAddress,
365 : : const BinAddress& rBinAddress,
366 : : sal_Int16 nSheet );
367 : :
368 : : /** Tries to convert the passed address to a single cell address.
369 : :
370 : : @param orAddress (out-parameter) Returns the converted cell address.
371 : : @param rBinAddress Binary cell address struct.
372 : : @param nSheet Sheet index to be inserted into orAddress (will be checked).
373 : : @param bTrackOverflow true = Update the internal overflow flags, if
374 : : the address is outside of the supported sheet limits.
375 : : @return true = Converted address is valid (no index overflow).
376 : : */
377 : : bool convertToCellAddress(
378 : : ::com::sun::star::table::CellAddress& orAddress,
379 : : const BinAddress& rBinAddress,
380 : : sal_Int16 nSheet,
381 : : bool bTrackOverflow );
382 : :
383 : : /** Returns a valid cell address by moving it into allowed dimensions.
384 : :
385 : : @param rBinAddress Binary cell address struct.
386 : : @param nSheet Sheet index for the returned address (will be checked).
387 : : @param bTrackOverflow true = Update the internal overflow flags, if
388 : : the address is outside of the supported sheet limits.
389 : : @return A valid API cell address struct. */
390 : : ::com::sun::star::table::CellAddress
391 : : createValidCellAddress(
392 : : const BinAddress& rBinAddress,
393 : : sal_Int16 nSheet,
394 : : bool bTrackOverflow );
395 : :
396 : : // ------------------------------------------------------------------------
397 : :
398 : : /** Checks the passed cell range if it fits into the spreadsheet limits.
399 : :
400 : : @param rRange The cell range address to be checked.
401 : : @param bAllowOverflow true = Allow ranges that start inside the
402 : : supported sheet limits but may end outside of these limits.
403 : : false = Do not allow ranges that overflow the supported limits.
404 : : @param bTrackOverflow true = Update the internal overflow flags, if
405 : : the passed range contains cells outside of the supported sheet
406 : : limits.
407 : : @return true = Cell range is valid. This function returns also true,
408 : : if only parts of the range are outside the current sheet limits and
409 : : such an overflow is allowed via parameter bAllowOverflow. Returns
410 : : false, if the entire range is outside the sheet limits, or if
411 : : overflow is not allowed via parameter bAllowOverflow.
412 : : */
413 : : bool checkCellRange(
414 : : const ::com::sun::star::table::CellRangeAddress& rRange,
415 : : bool bAllowOverflow, bool bTrackOverflow );
416 : :
417 : : /** Checks the passed cell range, may try to fit it to current sheet limits.
418 : :
419 : : First, this function reorders the column and row indexes so that the
420 : : starting indexes are less than or equal to the end indexes. Then,
421 : : depending on the parameter bAllowOverflow, the range is just checked or
422 : : cropped to the current sheet limits.
423 : :
424 : : @param orRange (in-out-parameter) Converts the passed cell range
425 : : into a valid cell range address. If the passed range contains cells
426 : : outside the currently supported spreadsheet limits, it will be
427 : : cropped to these limits.
428 : : @param bAllowOverflow true = Allow ranges that start inside the
429 : : supported sheet limits but may end outside of these limits. The
430 : : cell range returned in orRange will be cropped to these limits.
431 : : false = Do not allow ranges that overflow the supported limits. The
432 : : function will return false when the range overflows the sheet limits.
433 : : @param bTrackOverflow true = Update the internal overflow flags, if
434 : : the original range contains cells outside of the supported sheet
435 : : limits.
436 : : @return true = Converted range address is valid. This function
437 : : returns also true, if overflowing ranges are allowed via parameter
438 : : bAllowOverflow and the range has been cropped, but still contains
439 : : cells inside the current sheet limits. Returns false, if the entire
440 : : range is outside the sheet limits or overflowing ranges are not
441 : : allowed via parameter bAllowOverflow.
442 : : */
443 : : bool validateCellRange(
444 : : ::com::sun::star::table::CellRangeAddress& orRange,
445 : : bool bAllowOverflow, bool bTrackOverflow );
446 : :
447 : : /** Converts the passed string to a cell range address, without checking
448 : : any sheet limits.
449 : :
450 : : @param orRange (out-parameter) Returns the converted range address.
451 : : @param rString Cell range string in A1 notation.
452 : : @param nSheet Sheet index to be inserted into orRange.
453 : : @return true = Range address could be parsed from the passed string.
454 : : */
455 : : bool convertToCellRangeUnchecked(
456 : : ::com::sun::star::table::CellRangeAddress& orRange,
457 : : const ::rtl::OUString& rString,
458 : : sal_Int16 nSheet );
459 : :
460 : : /** Tries to convert the passed string to a cell range address.
461 : :
462 : : @param orRange (out-parameter) Returns the converted cell range
463 : : address. If the original range in the passed string contains cells
464 : : outside the currently supported spreadsheet limits, and parameter
465 : : bAllowOverflow is set to true, the range will be cropped to these
466 : : limits. Example: the range string "A1:ZZ100000" may be converted to
467 : : the range A1:IV65536.
468 : : @param rString Cell range string in A1 notation.
469 : : @param nSheet Sheet index to be inserted into orRange (will be checked).
470 : : @param bAllowOverflow true = Allow ranges that start inside the
471 : : supported sheet limits but may end outside of these limits. The
472 : : cell range returned in orRange will be cropped to these limits.
473 : : false = Do not allow ranges that overflow the supported limits.
474 : : @param bTrackOverflow true = Update the internal overflow flags, if
475 : : the original range contains cells outside of the supported sheet
476 : : limits.
477 : : @return true = Converted and returned range is valid. This function
478 : : returns also true, if overflowing ranges are allowed via parameter
479 : : bAllowOverflow and the range has been cropped, but still contains
480 : : cells inside the current sheet limits. Returns false, if the entire
481 : : range is outside the sheet limits or overflowing ranges are not
482 : : allowed via parameter bAllowOverflow.
483 : : */
484 : : bool convertToCellRange(
485 : : ::com::sun::star::table::CellRangeAddress& orRange,
486 : : const ::rtl::OUString& rString,
487 : : sal_Int16 nSheet,
488 : : bool bAllowOverflow, bool bTrackOverflow );
489 : :
490 : : /** Converts the passed range to a cell range address, without checking any
491 : : sheet limits.
492 : :
493 : : @param orRange (out-parameter) Returns the converted range address.
494 : : @param rBinRange Binary cell range struct.
495 : : @param nSheet Sheet index to be inserted into orRange.
496 : : */
497 : : void convertToCellRangeUnchecked(
498 : : ::com::sun::star::table::CellRangeAddress& orRange,
499 : : const BinRange& rBinRange,
500 : : sal_Int16 nSheet );
501 : :
502 : : /** Tries to convert the passed range to a cell range address.
503 : :
504 : : @param orRange (out-parameter) Returns the converted cell range
505 : : address. If the passed original range contains cells outside the
506 : : currently supported spreadsheet limits, and parameter bAllowOverflow
507 : : is set to true, the range will be cropped to these limits.
508 : : @param rBinRange Binary cell range struct.
509 : : @param nSheet Sheet index to be inserted into orRange (will be checked).
510 : : @param bAllowOverflow true = Allow ranges that start inside the
511 : : supported sheet limits but may end outside of these limits. The
512 : : cell range returned in orRange will be cropped to these limits.
513 : : false = Do not allow ranges that overflow the supported limits.
514 : : @param bTrackOverflow true = Update the internal overflow flags, if
515 : : the original range contains cells outside of the supported sheet
516 : : limits.
517 : : @return true = Converted and returned range is valid. This function
518 : : returns also true, if overflowing ranges are allowed via parameter
519 : : bAllowOverflow and the range has been cropped, but still contains
520 : : cells inside the current sheet limits. Returns false, if the entire
521 : : range is outside the sheet limits or if overflowing ranges are not
522 : : allowed via parameter bAllowOverflow.
523 : : */
524 : : bool convertToCellRange(
525 : : ::com::sun::star::table::CellRangeAddress& orRange,
526 : : const BinRange& rBinRange,
527 : : sal_Int16 nSheet,
528 : : bool bAllowOverflow, bool bTrackOverflow );
529 : :
530 : : // ------------------------------------------------------------------------
531 : :
532 : : /** Tries to restrict the passed cell range list to current sheet limits.
533 : :
534 : : @param orRanges (in-out-parameter) Restricts the cell range addresses
535 : : in the passed list to the current sheet limits and removes invalid
536 : : ranges from the list.
537 : : @param bTrackOverflow true = Update the internal overflow flags, if
538 : : the original ranges contain cells outside of the supported sheet
539 : : limits.
540 : : */
541 : : void validateCellRangeList(
542 : : ApiCellRangeList& orRanges,
543 : : bool bTrackOverflow );
544 : :
545 : : /** Tries to convert the passed string to a cell range list.
546 : :
547 : : @param orRanges (out-parameter) Returns the converted cell range
548 : : addresses. If a range in the passed string contains cells outside
549 : : the currently supported spreadsheet limits, it will be cropped to
550 : : these limits. Example: the range string "A1:ZZ100000" may be
551 : : converted to the range A1:IV65536. If a range is completely outside
552 : : the limits, it will be omitted.
553 : : @param rString Cell range list string in A1 notation, space separated.
554 : : @param nSheet Sheet index to be inserted into orRanges (will be checked).
555 : : @param bTrackOverflow true = Update the internal overflow flags, if
556 : : the original ranges contain cells outside of the supported sheet
557 : : limits.
558 : : */
559 : : void convertToCellRangeList(
560 : : ApiCellRangeList& orRanges,
561 : : const ::rtl::OUString& rString,
562 : : sal_Int16 nSheet,
563 : : bool bTrackOverflow );
564 : :
565 : : /** Tries to convert the passed range list to a cell range list.
566 : :
567 : : @param orRanges (out-parameter) Returns the converted cell range
568 : : addresses. If a range in the passed string contains cells outside
569 : : the currently supported spreadsheet limits, it will be cropped to
570 : : these limits. Example: the range string "A1:ZZ100000" may be
571 : : converted to the range A1:IV65536. If a range is completely outside
572 : : the limits, it will be omitted.
573 : : @param rBinRanges List of binary cell range objects.
574 : : @param nSheet Sheet index to be inserted into orRanges (will be checked).
575 : : @param bTrackOverflow true = Update the internal overflow flags, if
576 : : the original ranges contain cells outside of the supported sheet
577 : : limits.
578 : : */
579 : : void convertToCellRangeList(
580 : : ApiCellRangeList& orRanges,
581 : : const BinRangeList& rBinRanges,
582 : : sal_Int16 nSheet,
583 : : bool bTrackOverflow );
584 : :
585 : : // ------------------------------------------------------------------------
586 : : private:
587 : : void initializeMaxPos(
588 : : sal_Int16 nMaxXlsTab, sal_Int32 nMaxXlsCol, sal_Int32 nMaxXlsRow );
589 : :
590 : : private:
591 : : struct ControlCharacters
592 : : {
593 : : sal_Unicode mcThisWorkbook; /// Control character: Link to current workbook.
594 : : sal_Unicode mcExternal; /// Control character: Link to external workbook/sheet.
595 : : sal_Unicode mcThisSheet; /// Control character: Link to current sheet.
596 : : sal_Unicode mcInternal; /// Control character: Link to internal sheet.
597 : : sal_Unicode mcSameSheet; /// Control character: Link to same sheet (special '!A1' syntax).
598 : :
599 : : void set(
600 : : sal_Unicode cThisWorkbook, sal_Unicode cExternal,
601 : : sal_Unicode cThisSheet, sal_Unicode cInternal,
602 : : sal_Unicode cSameSheet );
603 : : };
604 : :
605 : : ::com::sun::star::table::CellAddress maMaxApiPos; /// Maximum valid cell address in Calc.
606 : : ::com::sun::star::table::CellAddress maMaxXlsPos; /// Maximum valid cell address in Excel.
607 : : ::com::sun::star::table::CellAddress maMaxPos; /// Maximum valid cell address in Calc/Excel.
608 : : ControlCharacters maLinkChars; /// Control characters for external link import (BIFF).
609 : : ControlCharacters maDConChars; /// Control characters for DCON* record import (BIFF).
610 : : bool mbColOverflow; /// Flag for "columns overflow".
611 : : bool mbRowOverflow; /// Flag for "rows overflow".
612 : : bool mbTabOverflow; /// Flag for "tables overflow".
613 : : };
614 : :
615 : : // ============================================================================
616 : :
617 : : } // namespace xls
618 : : } // namespace oox
619 : :
620 : : #endif
621 : :
622 : : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|