LCOV - code coverage report
Current view: top level - libreoffice/sc/source/filter/inc - addressconverter.hxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 7 29 24.1 %
Date: 2012-12-27 Functions: 10 22 45.5 %
Legend: Lines: hit not hit

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

Generated by: LCOV version 1.10