LCOV - code coverage report
Current view: top level - sc/source/core/data - formulaiter.cxx (source / functions) Hit Total Coverage
Test: commit 10e77ab3ff6f4314137acd6e2702a6e5c1ce1fae Lines: 28 31 90.3 %
Date: 2014-11-03 Functions: 6 6 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          46 : ScDetectiveRefIter::ScDetectiveRefIter( ScFormulaCell* pCell )
      29             : {
      30          46 :     pCode = pCell->GetCode();
      31          46 :     pCode->Reset();
      32          46 :     aPos = pCell->aPos;
      33          46 : }
      34             : 
      35          54 : static bool lcl_ScDetectiveRefIter_SkipRef( formula::FormulaToken* p, const ScAddress& rPos )
      36             : {
      37          54 :     ScSingleRefData& rRef1 = *p->GetSingleRef();
      38          54 :     ScAddress aAbs1 = rRef1.toAbs(rPos);
      39          54 :     if (!ValidAddress(aAbs1))
      40           0 :         return true;
      41          54 :     if ( p->GetType() == svDoubleRef || p->GetType() == svExternalDoubleRef )
      42             :     {
      43           8 :         ScSingleRefData& rRef2 = p->GetDoubleRef()->Ref2;
      44           8 :         ScAddress aAbs2 = rRef2.toAbs(rPos);
      45           8 :         if (!ValidAddress(aAbs2))
      46           0 :             return true;
      47             :     }
      48          54 :     return false;
      49             : }
      50             : 
      51          76 : bool ScDetectiveRefIter::GetNextRef( ScRange& rRange )
      52             : {
      53          76 :     bool bRet = false;
      54          76 :     formula::FormulaToken* p = GetNextRefToken();
      55          76 :     if( p )
      56             :     {
      57          38 :         SingleDoubleRefProvider aProv( *p );
      58          38 :         rRange.aStart = aProv.Ref1.toAbs(aPos);
      59          38 :         rRange.aEnd = aProv.Ref2.toAbs(aPos);
      60          38 :         bRet = true;
      61             :     }
      62             : 
      63          76 :     return bRet;
      64             : }
      65             : 
      66         100 : formula::FormulaToken* ScDetectiveRefIter::GetNextRefToken()
      67             : {
      68         100 :     formula::FormulaToken* p = pCode->GetNextReferenceRPN();
      69         200 :     while (p && lcl_ScDetectiveRefIter_SkipRef(p, aPos))
      70             :     {
      71           0 :         p = pCode->GetNextReferenceRPN();
      72             :     }
      73         100 :     return p;
      74         228 : }
      75             : 
      76             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10