LCOV - code coverage report
Current view: top level - include/formula - errorcodes.hxx (source / functions) Hit Total Coverage
Test: commit 10e77ab3ff6f4314137acd6e2702a6e5c1ce1fae Lines: 11 13 84.6 %
Date: 2014-11-03 Functions: 2 2 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             : #ifndef INCLUDED_FORMULA_ERRORCODES_HXX
      21             : #define INCLUDED_FORMULA_ERRORCODES_HXX
      22             : 
      23             : #include <rtl/math.hxx>
      24             : 
      25             : namespace ScErrorCodes
      26             : {
      27             : 
      28             : const sal_uInt16 errIllegalChar          = 501;
      29             : const sal_uInt16 errIllegalArgument      = 502;
      30             : const sal_uInt16 errIllegalFPOperation   = 503; // #NUM!
      31             : const sal_uInt16 errIllegalParameter     = 504;
      32             : const sal_uInt16 errIllegalJump          = 505;
      33             : const sal_uInt16 errSeparator            = 506;
      34             : const sal_uInt16 errPair                 = 507;
      35             : const sal_uInt16 errPairExpected         = 508;
      36             : const sal_uInt16 errOperatorExpected     = 509;
      37             : const sal_uInt16 errVariableExpected     = 510;
      38             : const sal_uInt16 errParameterExpected    = 511;
      39             : const sal_uInt16 errCodeOverflow         = 512;
      40             : const sal_uInt16 errStringOverflow       = 513;
      41             : const sal_uInt16 errStackOverflow        = 514;
      42             : const sal_uInt16 errUnknownState         = 515;
      43             : const sal_uInt16 errUnknownVariable      = 516;
      44             : const sal_uInt16 errUnknownOpCode        = 517;
      45             : const sal_uInt16 errUnknownStackVariable = 518;
      46             : const sal_uInt16 errNoValue              = 519; // #VALUE!
      47             : const sal_uInt16 errUnknownToken         = 520;
      48             : const sal_uInt16 errNoCode               = 521; // #NULL!
      49             : const sal_uInt16 errCircularReference    = 522;
      50             : const sal_uInt16 errNoConvergence        = 523;
      51             : const sal_uInt16 errNoRef                = 524; // #REF!
      52             : const sal_uInt16 errNoName               = 525; // #NAME?
      53             : const sal_uInt16 errDoubleRef            = 526;
      54             : const sal_uInt16 errInterpOverflow       = 527;
      55             : // Not displayed, temporary for TrackFormulas,
      56             : // Cell depends on another cell that has errCircularReference
      57             : const sal_uInt16 errTrackFromCircRef     = 528;
      58             : // ScInterpreter internal:  no numeric value but numeric queried. If this is
      59             : // set as mnStringNoValueError no error is generated but 0 returned.
      60             : const sal_uInt16 errCellNoValue          = 529;
      61             : // Interpreter: needed AddIn not found
      62             : const sal_uInt16 errNoAddin              = 530;
      63             : // Interpreter: needed Macro not found
      64             : const sal_uInt16 errNoMacro              = 531;
      65             : // Interpreter: Division by zero
      66             : const sal_uInt16 errDivisionByZero       = 532; // #DIV/0!
      67             : // Compiler: a non-simple (str,err,val) value was put in an array
      68             : const sal_uInt16 errNestedArray          = 533;
      69             : // ScInterpreter internal:  no numeric value but numeric queried. If this is
      70             : // temporarily (!) set as mnStringNoValueError, the error is generated and can
      71             : // be used to distinguish that condition from all other (inherited) errors. Do
      72             : // not use for anything else! Never push or inherit the error otherwise!
      73             : const sal_uInt16 errNotNumericString     = 534;
      74             : // ScInterpreter internal:  jump matrix already has a result at this position,
      75             : // do not overwrite in case of empty code path.
      76             : const sal_uInt16 errJumpMatHasResult     = 535;
      77             : // ScInterpreter internal:  (matrix) element is not a numeric value, i.e.
      78             : // string or empty, to be distinguished from the general errNoValue NAN and not
      79             : // to be used as result.
      80             : const sal_uInt16 errElementNaN           = 536;
      81             : 
      82             : // Interpreter: NA() not available condition, not a real error
      83             : const sal_uInt16 NOTAVAILABLE            = 0x7fff;
      84             : 
      85             : 
      86             : /** Unconditionally construct a double value of NAN where the lower bits
      87             :     represent an interpreter error code. */
      88         100 : inline double CreateDoubleError( sal_uInt16 nErr )
      89             : {
      90             :     union
      91             :     {
      92             :         double fVal;
      93             :         sal_math_Double smVal;
      94             :     };
      95         100 :     ::rtl::math::setNan( &fVal );
      96         100 :     smVal.nan_parts.fraction_lo = nErr;
      97         100 :     return fVal;
      98             : }
      99             : 
     100             : /** Recreate the error code of a coded double error, if any. */
     101        1294 : inline sal_uInt16 GetDoubleErrorValue( double fVal )
     102             : {
     103        1294 :     if ( ::rtl::math::isFinite( fVal ) )
     104        1226 :         return 0;
     105          68 :     if ( ::rtl::math::isInf( fVal ) )
     106           0 :         return errIllegalFPOperation;       // normal INF
     107             :     sal_uInt32 nErr = reinterpret_cast< sal_math_Double * >(
     108          68 :             &fVal)->nan_parts.fraction_lo;
     109          68 :     if ( nErr & 0xffff0000 )
     110           0 :         return errNoValue;                  // just a normal NAN
     111          68 :     return (sal_uInt16)(nErr & 0x0000ffff);     // any other error
     112             : }
     113             : 
     114             : } // namespace ScErrorCodes
     115             : 
     116             : // yes, exceptionally we put a "using namespace" in a header file..
     117             : using namespace ScErrorCodes;
     118             : 
     119             : #endif // INCLUDED_FORMULA_ERRORCODES_HXX
     120             : 
     121             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10