LCOV - code coverage report
Current view: top level - sc/source/filter/excel - xladdress.cxx (source / functions) Hit Total Coverage
Test: commit c8344322a7af75b84dd3ca8f78b05543a976dfd5 Lines: 57 76 75.0 %
Date: 2015-06-13 12:38:46 Functions: 12 15 80.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             : #include "xladdress.hxx"
      21             : #include "xestream.hxx"
      22             : #include "xltracer.hxx"
      23             : #include "xistream.hxx"
      24             : 
      25             : #include <osl/diagnose.h>
      26             : 
      27      287232 : void XclAddress::Read( XclImpStream& rStrm, bool bCol16Bit )
      28             : {
      29      287232 :     mnRow = rStrm.ReaduInt16();
      30      287232 :     if( bCol16Bit )
      31      287232 :         mnCol = rStrm.ReaduInt16();
      32             :     else
      33           0 :         mnCol = rStrm.ReaduInt8();
      34      287232 : }
      35             : 
      36          58 : void XclAddress::Write( XclExpStream& rStrm, bool bCol16Bit ) const
      37             : {
      38          58 :     rStrm << static_cast<sal_uInt16> (mnRow);
      39          58 :     if( bCol16Bit )
      40          58 :         rStrm << mnCol;
      41             :     else
      42           0 :         rStrm << static_cast< sal_uInt8 >( mnCol );
      43          58 : }
      44             : 
      45          14 : bool XclRange::Contains( const XclAddress& rPos ) const
      46             : {
      47          42 :     return  (maFirst.mnCol <= rPos.mnCol) && (rPos.mnCol <= maLast.mnCol) &&
      48          42 :             (maFirst.mnRow <= rPos.mnRow) && (rPos.mnRow <= maLast.mnRow);
      49             : }
      50             : 
      51         992 : void XclRange::Read( XclImpStream& rStrm, bool bCol16Bit )
      52             : {
      53         992 :     maFirst.mnRow = rStrm.ReaduInt16();
      54         992 :     maLast.mnRow = rStrm.ReaduInt16();
      55             : 
      56         992 :     if( bCol16Bit )
      57             :     {
      58         747 :         maFirst.mnCol = rStrm.ReaduInt16();
      59         747 :         maLast.mnCol = rStrm.ReaduInt16();
      60             :     }
      61             :     else
      62             :     {
      63         245 :         maFirst.mnCol = rStrm.ReaduInt8();
      64         245 :         maLast.mnCol = rStrm.ReaduInt8();
      65             :     }
      66         992 : }
      67             : 
      68          98 : void XclRange::Write( XclExpStream& rStrm, bool bCol16Bit ) const
      69             : {
      70          98 :     rStrm << static_cast<sal_uInt16>(maFirst.mnRow) << static_cast<sal_uInt16>(maLast.mnRow);
      71          98 :     if( bCol16Bit )
      72           3 :         rStrm << maFirst.mnCol << maLast.mnCol;
      73             :     else
      74          95 :         rStrm << static_cast< sal_uInt8 >( maFirst.mnCol ) << static_cast< sal_uInt8 >( maLast.mnCol );
      75          98 : }
      76             : 
      77           0 : XclRange XclRangeList::GetEnclosingRange() const
      78             : {
      79           0 :     XclRange aXclRange;
      80           0 :     if( !mRanges.empty() )
      81             :     {
      82           0 :         XclRangeVector::const_iterator aIt = mRanges.begin(), aEnd = mRanges.end();
      83           0 :         aXclRange = *aIt;
      84           0 :         for( ++aIt; aIt != aEnd; ++aIt )
      85             :         {
      86           0 :             aXclRange.maFirst.mnCol = ::std::min( aXclRange.maFirst.mnCol, aIt->maFirst.mnCol );
      87           0 :             aXclRange.maFirst.mnRow = ::std::min( aXclRange.maFirst.mnRow, aIt->maFirst.mnRow );
      88           0 :             aXclRange.maLast.mnCol = ::std::max( aXclRange.maLast.mnCol, aIt->maLast.mnCol );
      89           0 :             aXclRange.maLast.mnRow = ::std::max( aXclRange.maLast.mnRow, aIt->maLast.mnRow );
      90             :         }
      91             :     }
      92           0 :     return aXclRange;
      93             : }
      94             : 
      95         252 : void XclRangeList::Read( XclImpStream& rStrm, bool bCol16Bit, sal_uInt16 nCountInStream )
      96             : {
      97             :     sal_uInt16 nCount;
      98         252 :     if (nCountInStream)
      99           5 :         nCount = nCountInStream;
     100             :     else
     101         247 :         nCount = rStrm.ReaduInt16();
     102         252 :     size_t nOldSize = mRanges.size();
     103         252 :     mRanges.resize( nOldSize + nCount );
     104         510 :     for( XclRangeVector::iterator aIt = mRanges.begin() + nOldSize; rStrm.IsValid() && (nCount > 0); --nCount, ++aIt )
     105         258 :         aIt->Read( rStrm, bCol16Bit );
     106         252 : }
     107             : 
     108          29 : void XclRangeList::Write( XclExpStream& rStrm, bool bCol16Bit, sal_uInt16 nCountInStream ) const
     109             : {
     110          29 :     WriteSubList( rStrm, 0, mRanges.size(), bCol16Bit, nCountInStream );
     111          29 : }
     112             : 
     113          31 : void XclRangeList::WriteSubList( XclExpStream& rStrm, size_t nBegin, size_t nCount, bool bCol16Bit,
     114             :         sal_uInt16 nCountInStream ) const
     115             : {
     116             :     OSL_ENSURE( nBegin <= mRanges.size(), "XclRangeList::WriteSubList - invalid start position" );
     117          31 :     size_t nEnd = ::std::min< size_t >( nBegin + nCount, mRanges.size() );
     118          31 :     if (!nCountInStream)
     119             :     {
     120          31 :         sal_uInt16 nXclCount = ulimit_cast< sal_uInt16 >( nEnd - nBegin );
     121          31 :         rStrm << nXclCount;
     122             :     }
     123          31 :     rStrm.SetSliceSize( bCol16Bit ? 8 : 6 );
     124          63 :     for( XclRangeVector::const_iterator aIt = mRanges.begin() + nBegin, aEnd = mRanges.begin() + nEnd; aIt != aEnd; ++aIt )
     125          32 :         aIt->Write( rStrm, bCol16Bit );
     126          31 : }
     127             : 
     128         156 : XclAddressConverterBase::XclAddressConverterBase( XclTracer& rTracer, const ScAddress& rMaxPos ) :
     129             :     mrTracer( rTracer ),
     130             :     maMaxPos( rMaxPos ),
     131         156 :     mnMaxCol( static_cast< sal_uInt16 >( rMaxPos.Col() ) ),
     132         156 :     mnMaxRow( static_cast< sal_uInt16 >( rMaxPos.Row() ) ),
     133             :     mbColTrunc( false ),
     134             :     mbRowTrunc( false ),
     135         468 :     mbTabTrunc( false )
     136             : {
     137             :     OSL_ENSURE( static_cast< size_t >( rMaxPos.Col() ) <= SAL_MAX_UINT16, "XclAddressConverterBase::XclAddressConverterBase - invalid max column" );
     138             :     OSL_ENSURE( static_cast< size_t >( rMaxPos.Row() ) <= SAL_MAX_UINT32, "XclAddressConverterBase::XclAddressConverterBase - invalid max row" );
     139         156 : }
     140             : 
     141         156 : XclAddressConverterBase::~XclAddressConverterBase()
     142             : {
     143         156 : }
     144             : 
     145           0 : bool XclAddressConverterBase::CheckScTab( SCTAB nScTab, bool bWarn )
     146             : {
     147           0 :     bool bValid = (0 <= nScTab) && (nScTab <= maMaxPos.Tab());
     148           0 :     if( !bValid && bWarn )
     149             :     {
     150           0 :         mbTabTrunc |= (nScTab > maMaxPos.Tab());  // do not warn for deleted refs
     151           0 :         mrTracer.TraceInvalidTab( nScTab, maMaxPos.Tab() );
     152             :     }
     153           0 :     return bValid;
     154          30 : }
     155             : 
     156             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.11