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

Generated by: LCOV version 1.10