LCOV - code coverage report
Current view: top level - sc/source/filter/inc - xladdress.hxx (source / functions) Hit Total Coverage
Test: commit c8344322a7af75b84dd3ca8f78b05543a976dfd5 Lines: 36 42 85.7 %
Date: 2015-06-13 12:38:46 Functions: 27 29 93.1 %
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 INCLUDED_SC_SOURCE_FILTER_INC_XLADDRESS_HXX
      21             : #define INCLUDED_SC_SOURCE_FILTER_INC_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        2992 :     inline explicit     XclAddress( ScAddress::Uninitialized ) {}
      36      289771 :     inline explicit     XclAddress() : mnCol( 0 ), mnRow( 0 ) {}
      37        5408 :     inline explicit     XclAddress( sal_uInt16 nCol, sal_uInt32 nRow ) : mnCol( nCol ), mnRow( nRow ) {}
      38             : 
      39        1175 :     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      287232 : inline XclImpStream& operator>>( XclImpStream& rStrm, XclAddress& rXclPos )
      56             : {
      57      287232 :     rXclPos.Read( rStrm );
      58      287232 :     return rStrm;
      59             : }
      60             : 
      61          58 : inline XclExpStream& operator<<( XclExpStream& rStrm, const XclAddress& rXclPos )
      62             : {
      63          58 :     rXclPos.Write( rStrm );
      64          58 :     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         720 :     inline explicit     XclRange( ScAddress::Uninitialized e ) : maFirst( e ), maLast( e ) {}
      74        1304 :     inline explicit     XclRange() {}
      75         115 :     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           2 :     inline explicit     XclRange( sal_uInt16 nCol1, sal_uInt32 nRow1, sal_uInt16 nCol2, sal_uInt32 nRow2 ) :
      78           2 :                             maFirst( nCol1, nRow1 ), maLast( nCol2, nRow2 ) {}
      79             : 
      80             :     inline void         Set( const XclAddress& rFirst, const XclAddress& rLast )
      81             :                             { maFirst = rFirst; maLast = rLast; }
      82           3 :     inline void         Set( sal_uInt16 nCol1, sal_uInt32 nRow1, sal_uInt16 nCol2, sal_uInt32 nRow2 )
      83           3 :                             { maFirst.Set( nCol1, nRow1 ); maLast.Set( nCol2, nRow2 ); }
      84             : 
      85         142 :     inline sal_uInt16   GetColCount() const { return maLast.mnCol - maFirst.mnCol + 1; }
      86           6 :     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         731 : inline XclImpStream& operator>>( XclImpStream& rStrm, XclRange& rXclRange )
     104             : {
     105         731 :     rXclRange.Read( rStrm );
     106         731 :     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             : typedef ::std::vector< XclRange > XclRangeVector;
     116             : 
     117             : /** A 2D cell range address list with Excel column and row indexes. */
     118         575 : class XclRangeList
     119             : {
     120             : private:
     121             :     XclRangeVector mRanges;
     122             : 
     123             : public:
     124         529 :     inline explicit     XclRangeList() : mRanges() {}
     125             : 
     126         144 :     size_t size() const { return mRanges.size(); }
     127         126 :     bool empty() const { return mRanges.empty(); }
     128         473 :     XclRangeVector::const_iterator begin() const { return mRanges.begin(); }
     129         459 :     XclRangeVector::const_iterator end() const { return mRanges.end(); }
     130         154 :     void clear() { mRanges.clear(); }
     131         153 :     void push_back(const XclRange &rRange) { mRanges.push_back(rRange); }
     132             : 
     133             :     XclRange            GetEnclosingRange() const;
     134             : 
     135             :     void                Read( XclImpStream& rStrm, bool bCol16Bit = true, sal_uInt16 nCountInStream = 0 );
     136             :     void                Write( XclExpStream& rStrm, bool bCol16Bit = true, sal_uInt16 nCountInStream = 0 ) const;
     137             :     void                WriteSubList( XclExpStream& rStrm,
     138             :                             size_t nBegin, size_t nCount, bool bCol16Bit = true, sal_uInt16 nCountInStream = 0 ) const;
     139             : };
     140             : 
     141           5 : inline XclImpStream& operator>>( XclImpStream& rStrm, XclRangeList& rXclRanges )
     142             : {
     143           5 :     rXclRanges.Read( rStrm );
     144           5 :     return rStrm;
     145             : }
     146             : 
     147           0 : inline XclExpStream& operator<<( XclExpStream& rStrm, const XclRangeList& rXclRanges )
     148             : {
     149           0 :     rXclRanges.Write( rStrm );
     150           0 :     return rStrm;
     151             : }
     152             : 
     153             : class XclTracer;
     154             : 
     155             : /** Base class for import/export address converters. */
     156             : class XclAddressConverterBase
     157             : {
     158             : public:
     159             :     explicit            XclAddressConverterBase( XclTracer& rTracer, const ScAddress& rMaxPos );
     160             :     virtual             ~XclAddressConverterBase();
     161             : 
     162             :     /** Returns whether the "some columns have been cut" warning box should be shown. */
     163         101 :     inline bool         IsColTruncated() const { return mbColTrunc; }
     164             :     /** Returns whether the "some rows have been cut" warning box should be shown. */
     165         101 :     inline bool         IsRowTruncated() const { return mbRowTrunc; }
     166             :     /** Returns whether the "some sheets have been cut" warning box should be shown. */
     167         101 :     inline bool         IsTabTruncated() const { return mbTabTrunc; }
     168             : 
     169             :     /** Checks if the passed sheet index is valid.
     170             :         @param nScTab  The sheet index to check.
     171             :         @param bWarn  true = Sets the internal flag that produces a warning box
     172             :             after loading/saving the file, if the sheet index is not valid.
     173             :         @return  true = Sheet index in nScTab is valid. */
     174             :     bool                CheckScTab( SCTAB nScTab, bool bWarn );
     175             : 
     176             : protected:
     177             :     XclTracer&          mrTracer;       /// Tracer for invalid addresses.
     178             :     ScAddress           maMaxPos;       /// Default maximum position.
     179             :     sal_uInt16          mnMaxCol;       /// Maximum column index, as 16-bit value.
     180             :     sal_uInt32          mnMaxRow;       /// Maximum row index.
     181             :     bool                mbColTrunc;     /// Flag for "columns truncated" warning box.
     182             :     bool                mbRowTrunc;     /// Flag for "rows truncated" warning box.
     183             :     bool                mbTabTrunc;     /// Flag for "tables truncated" warning box.
     184             : };
     185             : 
     186             : #endif
     187             : 
     188             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.11