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

Generated by: LCOV version 1.10