LCOV - code coverage report
Current view: top level - usr/local/src/libreoffice/sc/source/core/data - formulaiter.cxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 29 34 85.3 %
Date: 2013-07-09 Functions: 4 4 100.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 "formulaiter.hxx"
      21             : 
      22             : #include "formulacell.hxx"
      23             : #include "tokenarray.hxx"
      24             : #include "formula/token.hxx"
      25             : 
      26             : using namespace formula;
      27             : 
      28          24 : ScDetectiveRefIter::ScDetectiveRefIter( ScFormulaCell* pCell )
      29             : {
      30          24 :     pCode = pCell->GetCode();
      31          24 :     pCode->Reset();
      32          24 :     aPos = pCell->aPos;
      33          24 : }
      34             : 
      35          28 : static bool lcl_ScDetectiveRefIter_SkipRef( ScToken* p )
      36             : {
      37          28 :     ScSingleRefData& rRef1 = p->GetSingleRef();
      38          84 :     if ( rRef1.IsColDeleted() || rRef1.IsRowDeleted() || rRef1.IsTabDeleted()
      39          56 :             || !rRef1.Valid() )
      40           0 :         return true;
      41          28 :     if ( p->GetType() == svDoubleRef || p->GetType() == svExternalDoubleRef )
      42             :     {
      43           4 :         ScSingleRefData& rRef2 = p->GetDoubleRef().Ref2;
      44          12 :         if ( rRef2.IsColDeleted() || rRef2.IsRowDeleted() || rRef2.IsTabDeleted()
      45           8 :                 || !rRef2.Valid() )
      46           0 :             return true;
      47             :     }
      48          28 :     return false;
      49             : }
      50             : 
      51          40 : bool ScDetectiveRefIter::GetNextRef( ScRange& rRange )
      52             : {
      53          40 :     bool bRet = false;
      54          40 :     ScToken* p = GetNextRefToken();
      55          40 :     if( p )
      56             :     {
      57          20 :         SingleDoubleRefProvider aProv( *p );
      58          20 :         rRange.aStart.Set( aProv.Ref1.nCol, aProv.Ref1.nRow, aProv.Ref1.nTab );
      59          20 :         rRange.aEnd.Set( aProv.Ref2.nCol, aProv.Ref2.nRow, aProv.Ref2.nTab );
      60          20 :         bRet = true;
      61             :     }
      62             : 
      63          40 :     return bRet;
      64             : }
      65             : 
      66          52 : ScToken* ScDetectiveRefIter::GetNextRefToken()
      67             : {
      68          52 :     ScToken* p = static_cast<ScToken*>(pCode->GetNextReferenceRPN());
      69          52 :     if (p)
      70          28 :         p->CalcAbsIfRel( aPos );
      71             : 
      72         104 :     while ( p && lcl_ScDetectiveRefIter_SkipRef( p ) )
      73             :     {
      74           0 :         p = static_cast<ScToken*>(pCode->GetNextReferenceRPN());
      75           0 :         if (p)
      76           0 :             p->CalcAbsIfRel( aPos );
      77             :     }
      78          52 :     return p;
      79             : }
      80             : 
      81             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10