LCOV - code coverage report
Current view: top level - sc/source/core/data - simpleformulacalc.cxx (source / functions) Hit Total Coverage
Test: commit 0e63ca4fde4e446f346e35849c756a30ca294aab Lines: 0 45 0.0 %
Date: 2014-04-11 Functions: 0 9 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             : 
      10             : #include "simpleformulacalc.hxx"
      11             : #include "document.hxx"
      12             : #include "tokenarray.hxx"
      13             : #include "interpre.hxx"
      14             : #include "compiler.hxx"
      15             : 
      16             : 
      17           0 : ScSimpleFormulaCalculator::ScSimpleFormulaCalculator( ScDocument* pDoc, const ScAddress& rAddr,
      18             :         const OUString& rFormula, formula::FormulaGrammar::Grammar eGram )
      19             :     : mnFormatType(0)
      20             :     , mnFormatIndex(0)
      21             :     , mbCalculated(false)
      22             :     , maAddr(rAddr)
      23           0 :     , mpDoc(pDoc)
      24             : {
      25             :     // compile already here
      26           0 :     ScCompiler aComp(pDoc, rAddr);
      27           0 :     aComp.SetGrammar(eGram);
      28           0 :     mpCode.reset(aComp.CompileString(rFormula));
      29           0 :     if(!mpCode->GetCodeError() && mpCode->GetLen())
      30           0 :         aComp.CompileTokenArray();
      31           0 : }
      32             : 
      33           0 : ScSimpleFormulaCalculator::~ScSimpleFormulaCalculator()
      34             : {
      35           0 : }
      36             : 
      37           0 : void ScSimpleFormulaCalculator::Calculate()
      38             : {
      39           0 :     if(mbCalculated)
      40           0 :         return;
      41             : 
      42           0 :     mbCalculated = true;
      43           0 :     ScInterpreter aInt(NULL, mpDoc, maAddr, *mpCode.get());
      44           0 :     aInt.Interpret();
      45             : 
      46           0 :     mnFormatType = aInt.GetRetFormatType();
      47           0 :     mnFormatIndex = aInt.GetRetFormatIndex();
      48           0 :     maResult.SetToken(aInt.GetResultToken().get());
      49             : }
      50             : 
      51           0 : bool ScSimpleFormulaCalculator::IsValue()
      52             : {
      53           0 :     Calculate();
      54             : 
      55           0 :     return maResult.IsValue();
      56             : }
      57             : 
      58           0 : sal_uInt16 ScSimpleFormulaCalculator::GetErrCode()
      59             : {
      60           0 :     Calculate();
      61             : 
      62           0 :     sal_uInt16 nErr = mpCode->GetCodeError();
      63           0 :     if (nErr)
      64           0 :         return nErr;
      65           0 :     return maResult.GetResultError();
      66             : }
      67             : 
      68             : 
      69           0 : double ScSimpleFormulaCalculator::GetValue()
      70             : {
      71           0 :     Calculate();
      72             : 
      73           0 :     if ((!mpCode->GetCodeError() || mpCode->GetCodeError() == errDoubleRef) &&
      74           0 :             !maResult.GetResultError())
      75           0 :         return maResult.GetDouble();
      76             : 
      77           0 :     return 0.0;
      78             : }
      79             : 
      80           0 : svl::SharedString ScSimpleFormulaCalculator::GetString()
      81             : {
      82           0 :     Calculate();
      83             : 
      84           0 :     if ((!mpCode->GetCodeError() || mpCode->GetCodeError() == errDoubleRef) &&
      85           0 :             !maResult.GetResultError())
      86           0 :         return maResult.GetString();
      87             : 
      88           0 :     return svl::SharedString::getEmptyString();
      89             : }
      90             : 
      91           0 : bool ScSimpleFormulaCalculator::HasColRowName()
      92             : {
      93           0 :     mpCode->Reset();
      94           0 :     return mpCode->GetNextColRowName() != NULL;
      95             : }
      96             : 
      97           0 : ScTokenArray* ScSimpleFormulaCalculator::GetCode()
      98             : {
      99           0 :     return mpCode.get();
     100             : }
     101             : 
     102             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10