LCOV - code coverage report
Current view: top level - sc/source/filter/inc - xladdress.hxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 23 36 63.9 %
Date: 2012-08-25 Functions: 16 23 69.6 %
Legend: Lines: hit not hit | Branches: + taken - not taken # not executed Branches: 0 0 -

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

Generated by: LCOV version 1.10