LCOV - code coverage report
Current view: top level - sc/source/filter/excel - xladdress.cxx (source / functions) Hit Total Coverage
Test: commit e02a6cb2c3e2b23b203b422e4e0680877f232636 Lines: 0 75 0.0 %
Date: 2014-04-14 Functions: 0 15 0.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           0 : void XclAddress::Read( XclImpStream& rStrm, bool bCol16Bit )
      26             : {
      27           0 :     mnRow = rStrm.ReaduInt16();
      28           0 :     if( bCol16Bit )
      29           0 :         rStrm >> mnCol;
      30             :     else
      31           0 :         mnCol = rStrm.ReaduInt8();
      32           0 : }
      33             : 
      34           0 : void XclAddress::Write( XclExpStream& rStrm, bool bCol16Bit ) const
      35             : {
      36           0 :     rStrm << static_cast<sal_uInt16> (mnRow);
      37           0 :     if( bCol16Bit )
      38           0 :         rStrm << mnCol;
      39             :     else
      40           0 :         rStrm << static_cast< sal_uInt8 >( mnCol );
      41           0 : }
      42             : 
      43           0 : bool XclRange::Contains( const XclAddress& rPos ) const
      44             : {
      45           0 :     return  (maFirst.mnCol <= rPos.mnCol) && (rPos.mnCol <= maLast.mnCol) &&
      46           0 :             (maFirst.mnRow <= rPos.mnRow) && (rPos.mnRow <= maLast.mnRow);
      47             : }
      48             : 
      49           0 : void XclRange::Read( XclImpStream& rStrm, bool bCol16Bit )
      50             : {
      51           0 :     maFirst.mnRow = rStrm.ReaduInt16();
      52           0 :     maLast.mnRow = rStrm.ReaduInt16();
      53             : 
      54           0 :     if( bCol16Bit )
      55           0 :         rStrm >> maFirst.mnCol >> maLast.mnCol;
      56             :     else
      57             :     {
      58           0 :         maFirst.mnCol = rStrm.ReaduInt8();
      59           0 :         maLast.mnCol = rStrm.ReaduInt8();
      60             :     }
      61           0 : }
      62             : 
      63           0 : void XclRange::Write( XclExpStream& rStrm, bool bCol16Bit ) const
      64             : {
      65           0 :     rStrm << static_cast<sal_uInt16>(maFirst.mnRow) << static_cast<sal_uInt16>(maLast.mnRow);
      66           0 :     if( bCol16Bit )
      67           0 :         rStrm << maFirst.mnCol << maLast.mnCol;
      68             :     else
      69           0 :         rStrm << static_cast< sal_uInt8 >( maFirst.mnCol ) << static_cast< sal_uInt8 >( maLast.mnCol );
      70           0 : }
      71             : 
      72           0 : XclRange XclRangeList::GetEnclosingRange() const
      73             : {
      74           0 :     XclRange aXclRange;
      75           0 :     if( !empty() )
      76             :     {
      77           0 :         const_iterator aIt = begin(), aEnd = 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           0 : void XclRangeList::Read( XclImpStream& rStrm, bool bCol16Bit, sal_uInt16 nCountInStream )
      91             : {
      92             :     sal_uInt16 nCount;
      93           0 :     if (nCountInStream)
      94           0 :         nCount = nCountInStream;
      95             :     else
      96           0 :         rStrm >> nCount;
      97           0 :     size_t nOldSize = size();
      98           0 :     resize( nOldSize + nCount );
      99           0 :     for( iterator aIt = begin() + nOldSize; rStrm.IsValid() && (nCount > 0); --nCount, ++aIt )
     100           0 :         aIt->Read( rStrm, bCol16Bit );
     101           0 : }
     102             : 
     103           0 : void XclRangeList::Write( XclExpStream& rStrm, bool bCol16Bit, sal_uInt16 nCountInStream ) const
     104             : {
     105           0 :     WriteSubList( rStrm, 0, size(), bCol16Bit, nCountInStream );
     106           0 : }
     107             : 
     108           0 : void XclRangeList::WriteSubList( XclExpStream& rStrm, size_t nBegin, size_t nCount, bool bCol16Bit,
     109             :         sal_uInt16 nCountInStream ) const
     110             : {
     111             :     OSL_ENSURE( nBegin <= size(), "XclRangeList::WriteSubList - invalid start position" );
     112           0 :     size_t nEnd = ::std::min< size_t >( nBegin + nCount, size() );
     113           0 :     if (!nCountInStream)
     114             :     {
     115           0 :         sal_uInt16 nXclCount = ulimit_cast< sal_uInt16 >( nEnd - nBegin );
     116           0 :         rStrm << nXclCount;
     117             :     }
     118           0 :     rStrm.SetSliceSize( bCol16Bit ? 8 : 6 );
     119           0 :     for( const_iterator aIt = begin() + nBegin, aEnd = begin() + nEnd; aIt != aEnd; ++aIt )
     120           0 :         aIt->Write( rStrm, bCol16Bit );
     121           0 : }
     122             : 
     123           0 : XclAddressConverterBase::XclAddressConverterBase( XclTracer& rTracer, const ScAddress& rMaxPos ) :
     124             :     mrTracer( rTracer ),
     125             :     maMaxPos( rMaxPos ),
     126           0 :     mnMaxCol( static_cast< sal_uInt16 >( rMaxPos.Col() ) ),
     127           0 :     mnMaxRow( static_cast< sal_uInt16 >( rMaxPos.Row() ) ),
     128             :     mbColTrunc( false ),
     129             :     mbRowTrunc( false ),
     130           0 :     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           0 : }
     135             : 
     136           0 : XclAddressConverterBase::~XclAddressConverterBase()
     137             : {
     138           0 : }
     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           0 : }
     150             : 
     151             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10