LCOV - code coverage report
Current view: top level - sc/source/filter/excel - xladdress.cxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 28 71 39.4 %
Date: 2012-08-25 Functions: 7 15 46.7 %
Legend: Lines: hit not hit | Branches: + taken - not taken # not executed Branches: 15 72 20.8 %

           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                 :            : #include "xladdress.hxx"
      30                 :            : #include "xestream.hxx"
      31                 :            : #include "xltracer.hxx"
      32                 :            : #include "xistream.hxx"
      33                 :            : 
      34                 :            : // ============================================================================
      35                 :            : 
      36                 :       7413 : void XclAddress::Read( XclImpStream& rStrm, bool bCol16Bit )
      37                 :            : {
      38                 :       7413 :     mnRow = rStrm.ReaduInt16();
      39         [ +  - ]:       7413 :     if( bCol16Bit )
      40                 :       7413 :         rStrm >> mnCol;
      41                 :            :     else
      42                 :          0 :         mnCol = rStrm.ReaduInt8();
      43                 :       7413 : }
      44                 :            : 
      45                 :          0 : void XclAddress::Write( XclExpStream& rStrm, bool bCol16Bit ) const
      46                 :            : {
      47                 :          0 :     rStrm << static_cast<sal_uInt16> (mnRow);
      48         [ #  # ]:          0 :     if( bCol16Bit )
      49                 :          0 :         rStrm << mnCol;
      50                 :            :     else
      51                 :          0 :         rStrm << static_cast< sal_uInt8 >( mnCol );
      52                 :          0 : }
      53                 :            : 
      54                 :            : // ----------------------------------------------------------------------------
      55                 :            : 
      56                 :          0 : bool XclRange::Contains( const XclAddress& rPos ) const
      57                 :            : {
      58                 :            :     return  (maFirst.mnCol <= rPos.mnCol) && (rPos.mnCol <= maLast.mnCol) &&
      59 [ #  # ][ #  # ]:          0 :             (maFirst.mnRow <= rPos.mnRow) && (rPos.mnRow <= maLast.mnRow);
         [ #  # ][ #  # ]
      60                 :            : }
      61                 :            : 
      62                 :        243 : void XclRange::Read( XclImpStream& rStrm, bool bCol16Bit )
      63                 :            : {
      64                 :        243 :     maFirst.mnRow = rStrm.ReaduInt16();
      65                 :        243 :     maLast.mnRow = rStrm.ReaduInt16();
      66                 :            : 
      67         [ +  + ]:        243 :     if( bCol16Bit )
      68                 :         75 :         rStrm >> maFirst.mnCol >> maLast.mnCol;
      69                 :            :     else
      70                 :            :     {
      71                 :        168 :         maFirst.mnCol = rStrm.ReaduInt8();
      72                 :        168 :         maLast.mnCol = rStrm.ReaduInt8();
      73                 :            :     }
      74                 :        243 : }
      75                 :            : 
      76                 :          0 : void XclRange::Write( XclExpStream& rStrm, bool bCol16Bit ) const
      77                 :            : {
      78                 :          0 :     rStrm << static_cast<sal_uInt16>(maFirst.mnRow) << static_cast<sal_uInt16>(maLast.mnRow);
      79         [ #  # ]:          0 :     if( bCol16Bit )
      80                 :          0 :         rStrm << maFirst.mnCol << maLast.mnCol;
      81                 :            :     else
      82                 :          0 :         rStrm << static_cast< sal_uInt8 >( maFirst.mnCol ) << static_cast< sal_uInt8 >( maLast.mnCol );
      83                 :          0 : }
      84                 :            : 
      85                 :            : // ----------------------------------------------------------------------------
      86                 :            : 
      87                 :          0 : XclRange XclRangeList::GetEnclosingRange() const
      88                 :            : {
      89                 :          0 :     XclRange aXclRange;
      90         [ #  # ]:          0 :     if( !empty() )
      91                 :            :     {
      92                 :          0 :         const_iterator aIt = begin(), aEnd = end();
      93                 :          0 :         aXclRange = *aIt;
      94 [ #  # ][ #  # ]:          0 :         for( ++aIt; aIt != aEnd; ++aIt )
      95                 :            :         {
      96         [ #  # ]:          0 :             aXclRange.maFirst.mnCol = ::std::min( aXclRange.maFirst.mnCol, aIt->maFirst.mnCol );
      97         [ #  # ]:          0 :             aXclRange.maFirst.mnRow = ::std::min( aXclRange.maFirst.mnRow, aIt->maFirst.mnRow );
      98         [ #  # ]:          0 :             aXclRange.maLast.mnCol = ::std::max( aXclRange.maLast.mnCol, aIt->maLast.mnCol );
      99         [ #  # ]:          0 :             aXclRange.maLast.mnRow = ::std::max( aXclRange.maLast.mnRow, aIt->maLast.mnRow );
     100                 :            :         }
     101                 :            :     }
     102                 :          0 :     return aXclRange;
     103                 :            : }
     104                 :            : 
     105                 :        168 : void XclRangeList::Read( XclImpStream& rStrm, bool bCol16Bit )
     106                 :            : {
     107                 :            :     sal_uInt16 nCount;
     108         [ +  - ]:        168 :     rStrm >> nCount;
     109                 :        168 :     size_t nOldSize = size();
     110         [ +  - ]:        168 :     resize( nOldSize + nCount );
     111 [ +  - ][ +  - ]:        336 :     for( iterator aIt = begin() + nOldSize; rStrm.IsValid() && (nCount > 0); --nCount, ++aIt )
         [ +  + ][ +  + ]
     112         [ +  - ]:        168 :         aIt->Read( rStrm, bCol16Bit );
     113                 :        168 : }
     114                 :            : 
     115                 :          0 : void XclRangeList::Write( XclExpStream& rStrm, bool bCol16Bit ) const
     116                 :            : {
     117                 :          0 :     WriteSubList( rStrm, 0, size(), bCol16Bit );
     118                 :          0 : }
     119                 :            : 
     120                 :          0 : void XclRangeList::WriteSubList( XclExpStream& rStrm, size_t nBegin, size_t nCount, bool bCol16Bit ) const
     121                 :            : {
     122                 :            :     OSL_ENSURE( nBegin <= size(), "XclRangeList::WriteSubList - invalid start position" );
     123         [ #  # ]:          0 :     size_t nEnd = ::std::min< size_t >( nBegin + nCount, size() );
     124                 :          0 :     sal_uInt16 nXclCount = ulimit_cast< sal_uInt16 >( nEnd - nBegin );
     125                 :          0 :     rStrm << nXclCount;
     126         [ #  # ]:          0 :     rStrm.SetSliceSize( bCol16Bit ? 8 : 6 );
     127 [ #  # ][ #  # ]:          0 :     for( const_iterator aIt = begin() + nBegin, aEnd = begin() + nEnd; aIt != aEnd; ++aIt )
         [ #  # ][ #  # ]
     128         [ #  # ]:          0 :         aIt->Write( rStrm, bCol16Bit );
     129                 :          0 : }
     130                 :            : 
     131                 :            : // ============================================================================
     132                 :            : 
     133                 :         55 : XclAddressConverterBase::XclAddressConverterBase( XclTracer& rTracer, const ScAddress& rMaxPos ) :
     134                 :            :     mrTracer( rTracer ),
     135                 :            :     maMaxPos( rMaxPos ),
     136                 :         55 :     mnMaxCol( static_cast< sal_uInt16 >( rMaxPos.Col() ) ),
     137                 :         55 :     mnMaxRow( static_cast< sal_uInt16 >( rMaxPos.Row() ) ),
     138                 :            :     mbColTrunc( false ),
     139                 :            :     mbRowTrunc( false ),
     140                 :         55 :     mbTabTrunc( false )
     141                 :            : {
     142                 :            :     OSL_ENSURE( static_cast< size_t >( rMaxPos.Col() ) <= SAL_MAX_UINT16, "XclAddressConverterBase::XclAddressConverterBase - invalid max column" );
     143                 :            :     OSL_ENSURE( static_cast< size_t >( rMaxPos.Row() ) <= SAL_MAX_UINT32, "XclAddressConverterBase::XclAddressConverterBase - invalid max row" );
     144                 :         55 : }
     145                 :            : 
     146                 :         55 : XclAddressConverterBase::~XclAddressConverterBase()
     147                 :            : {
     148         [ -  + ]:         55 : }
     149                 :            : 
     150                 :          0 : bool XclAddressConverterBase::CheckScTab( SCTAB nScTab, bool bWarn )
     151                 :            : {
     152 [ #  # ][ #  # ]:          0 :     bool bValid = (0 <= nScTab) && (nScTab <= maMaxPos.Tab());
     153 [ #  # ][ #  # ]:          0 :     if( !bValid && bWarn )
     154                 :            :     {
     155                 :          0 :         mbTabTrunc |= (nScTab > maMaxPos.Tab());  // do not warn for deleted refs
     156                 :          0 :         mrTracer.TraceInvalidTab( nScTab, maMaxPos.Tab() );
     157                 :            :     }
     158                 :          0 :     return bValid;
     159 [ +  - ][ +  - ]:         24 : }
     160                 :            : 
     161                 :            : // ============================================================================
     162                 :            : 
     163                 :            : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10