LCOV - code coverage report
Current view: top level - sc/source/filter/inc - xladdress.hxx (source / functions) Hit Total Coverage
Test: commit e02a6cb2c3e2b23b203b422e4e0680877f232636 Lines: 0 36 0.0 %
Date: 2014-04-14 Functions: 0 23 0.0 %
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 SC_XLADDRESS_HXX
      21             : #define SC_XLADDRESS_HXX
      22             : 
      23             : #include <vector>
      24             : #include "address.hxx"
      25             : 
      26             : class XclImpStream;
      27             : class XclExpStream;
      28             : 
      29             : /** A 2D cell address struct with Excel column and row indexes. */
      30             : struct XclAddress
      31             : {
      32             :     sal_uInt16          mnCol;
      33             :     sal_uInt32          mnRow;
      34             : 
      35           0 :     inline explicit     XclAddress( ScAddress::Uninitialized ) {}
      36           0 :     inline explicit     XclAddress() : mnCol( 0 ), mnRow( 0 ) {}
      37           0 :     inline explicit     XclAddress( sal_uInt16 nCol, sal_uInt32 nRow ) : mnCol( nCol ), mnRow( nRow ) {}
      38             : 
      39           0 :     inline void         Set( sal_uInt16 nCol, sal_uInt32 nRow ) { mnCol = nCol; mnRow = nRow; }
      40             : 
      41             :     void                Read( XclImpStream& rStrm, bool bCol16Bit = true );
      42             :     void                Write( XclExpStream& rStrm, bool bCol16Bit = true ) const;
      43             : };
      44             : 
      45             : inline bool operator==( const XclAddress& rL, const XclAddress& rR )
      46             : {
      47             :     return (rL.mnCol == rR.mnCol) && (rL.mnRow == rR.mnRow);
      48             : }
      49             : 
      50             : inline bool operator<( const XclAddress& rL, const XclAddress& rR )
      51             : {
      52             :     return (rL.mnCol < rR.mnCol) || ((rL.mnCol == rR.mnCol) && (rL.mnRow < rR.mnRow));
      53             : }
      54             : 
      55           0 : inline XclImpStream& operator>>( XclImpStream& rStrm, XclAddress& rXclPos )
      56             : {
      57           0 :     rXclPos.Read( rStrm );
      58           0 :     return rStrm;
      59             : }
      60             : 
      61           0 : inline XclExpStream& operator<<( XclExpStream& rStrm, const XclAddress& rXclPos )
      62             : {
      63           0 :     rXclPos.Write( rStrm );
      64           0 :     return rStrm;
      65             : }
      66             : 
      67             : /** A 2D cell range address struct with Excel column and row indexes. */
      68             : struct XclRange
      69             : {
      70             :     XclAddress          maFirst;
      71             :     XclAddress          maLast;
      72             : 
      73           0 :     inline explicit     XclRange( ScAddress::Uninitialized e ) : maFirst( e ), maLast( e ) {}
      74           0 :     inline explicit     XclRange() {}
      75           0 :     inline explicit     XclRange( const XclAddress& rPos ) : maFirst( rPos ), maLast( rPos ) {}
      76             :     inline explicit     XclRange( const XclAddress& rFirst, const XclAddress& rLast ) : maFirst( rFirst ), maLast( rLast ) {}
      77           0 :     inline explicit     XclRange( sal_uInt16 nCol1, sal_uInt32 nRow1, sal_uInt16 nCol2, sal_uInt32 nRow2 ) :
      78           0 :                             maFirst( nCol1, nRow1 ), maLast( nCol2, nRow2 ) {}
      79             : 
      80             :     inline void         Set( const XclAddress& rFirst, const XclAddress& rLast )
      81             :                             { maFirst = rFirst; maLast = rLast; }
      82           0 :     inline void         Set( sal_uInt16 nCol1, sal_uInt32 nRow1, sal_uInt16 nCol2, sal_uInt32 nRow2 )
      83           0 :                             { maFirst.Set( nCol1, nRow1 ); maLast.Set( nCol2, nRow2 ); }
      84             : 
      85           0 :     inline sal_uInt16   GetColCount() const { return maLast.mnCol - maFirst.mnCol + 1; }
      86           0 :     inline sal_uInt32   GetRowCount() const { return maLast.mnRow - maFirst.mnRow + 1; }
      87             :     bool                Contains( const XclAddress& rPos ) const;
      88             : 
      89             :     void                Read( XclImpStream& rStrm, bool bCol16Bit = true );
      90             :     void                Write( XclExpStream& rStrm, bool bCol16Bit = true ) const;
      91             : };
      92             : 
      93             : inline bool operator==( const XclRange& rL, const XclRange& rR )
      94             : {
      95             :     return (rL.maFirst == rR.maFirst) && (rL.maLast == rR.maLast);
      96             : }
      97             : 
      98             : inline bool operator<( const XclRange& rL, const XclRange& rR )
      99             : {
     100             :     return (rL.maFirst < rR.maFirst) || ((rL.maFirst == rR.maFirst) && (rL.maLast < rR.maLast));
     101             : }
     102             : 
     103           0 : inline XclImpStream& operator>>( XclImpStream& rStrm, XclRange& rXclRange )
     104             : {
     105           0 :     rXclRange.Read( rStrm );
     106           0 :     return rStrm;
     107             : }
     108             : 
     109           0 : inline XclExpStream& operator<<( XclExpStream& rStrm, const XclRange& rXclRange )
     110             : {
     111           0 :     rXclRange.Write( rStrm );
     112           0 :     return rStrm;
     113             : }
     114             : 
     115             : /** A 2D cell range address list with Excel column and row indexes. */
     116           0 : class XclRangeList : public ::std::vector< XclRange >
     117             : {
     118             : public:
     119           0 :     inline explicit     XclRangeList() {}
     120             : 
     121             :     XclRange            GetEnclosingRange() const;
     122             : 
     123             :     void                Read( XclImpStream& rStrm, bool bCol16Bit = true, sal_uInt16 nCountInStream = 0 );
     124             :     void                Write( XclExpStream& rStrm, bool bCol16Bit = true, sal_uInt16 nCountInStream = 0 ) const;
     125             :     void                WriteSubList( XclExpStream& rStrm,
     126             :                             size_t nBegin, size_t nCount, bool bCol16Bit = true, sal_uInt16 nCountInStream = 0 ) const;
     127             : };
     128             : 
     129           0 : inline XclImpStream& operator>>( XclImpStream& rStrm, XclRangeList& rXclRanges )
     130             : {
     131           0 :     rXclRanges.Read( rStrm );
     132           0 :     return rStrm;
     133             : }
     134             : 
     135           0 : inline XclExpStream& operator<<( XclExpStream& rStrm, const XclRangeList& rXclRanges )
     136             : {
     137           0 :     rXclRanges.Write( rStrm );
     138           0 :     return rStrm;
     139             : }
     140             : 
     141             : class XclTracer;
     142             : 
     143             : /** Base class for import/export address converters. */
     144             : class XclAddressConverterBase
     145             : {
     146             : public:
     147             :     explicit            XclAddressConverterBase( XclTracer& rTracer, const ScAddress& rMaxPos );
     148             :     virtual             ~XclAddressConverterBase();
     149             : 
     150             :     /** Returns whether the "some columns have been cut" warning box should be shown. */
     151           0 :     inline bool         IsColTruncated() const { return mbColTrunc; }
     152             :     /** Returns whether the "some rows have been cut" warning box should be shown. */
     153           0 :     inline bool         IsRowTruncated() const { return mbRowTrunc; }
     154             :     /** Returns whether the "some sheets have been cut" warning box should be shown. */
     155           0 :     inline bool         IsTabTruncated() const { return mbTabTrunc; }
     156             : 
     157             :     /** Checks if the passed sheet index is valid.
     158             :         @param nScTab  The sheet index to check.
     159             :         @param bWarn  true = Sets the internal flag that produces a warning box
     160             :             after loading/saving the file, if the sheet index is not valid.
     161             :         @return  true = Sheet index in nScTab is valid. */
     162             :     bool                CheckScTab( SCTAB nScTab, bool bWarn );
     163             : 
     164             : 
     165             : protected:
     166             :     XclTracer&          mrTracer;       /// Tracer for invalid addresses.
     167             :     ScAddress           maMaxPos;       /// Default maximum position.
     168             :     sal_uInt16          mnMaxCol;       /// Maximum column index, as 16-bit value.
     169             :     sal_uInt32          mnMaxRow;       /// Maximum row index.
     170             :     bool                mbColTrunc;     /// Flag for "columns truncated" warning box.
     171             :     bool                mbRowTrunc;     /// Flag for "rows truncated" warning box.
     172             :     bool                mbTabTrunc;     /// Flag for "tables truncated" warning box.
     173             : };
     174             : 
     175             : #endif
     176             : 
     177             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10