File: errorcodes.hxx

package info (click to toggle)
libreoffice 1%3A5.2.7-1%2Bdeb9u11
  • links: PTS, VCS
  • area: main
  • in suites: stretch
  • size: 2,603,628 kB
  • sloc: cpp: 4,054,182; java: 289,998; xml: 272,393; ansic: 48,279; python: 37,075; perl: 33,686; yacc: 12,078; sh: 9,840; makefile: 8,917; cs: 6,600; objc: 2,388; lex: 2,178; asm: 1,348; awk: 882; pascal: 876; php: 79; csh: 20; sed: 5
file content (121 lines) | stat: -rw-r--r-- 5,307 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
/*
 * This file is part of the LibreOffice project.
 *
 * This Source Code Form is subject to the terms of the Mozilla Public
 * License, v. 2.0. If a copy of the MPL was not distributed with this
 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
 *
 * This file incorporates work covered by the following license notice:
 *
 *   Licensed to the Apache Software Foundation (ASF) under one or more
 *   contributor license agreements. See the NOTICE file distributed
 *   with this work for additional information regarding copyright
 *   ownership. The ASF licenses this file to you under the Apache
 *   License, Version 2.0 (the "License"); you may not use this file
 *   except in compliance with the License. You may obtain a copy of
 *   the License at http://www.apache.org/licenses/LICENSE-2.0 .
 */

#ifndef INCLUDED_FORMULA_ERRORCODES_HXX
#define INCLUDED_FORMULA_ERRORCODES_HXX

#include <rtl/math.hxx>

namespace formula {

const sal_uInt16 errNONE                 = 0;
const sal_uInt16 errIllegalChar          = 501;
const sal_uInt16 errIllegalArgument      = 502;
const sal_uInt16 errIllegalFPOperation   = 503; // #NUM!
const sal_uInt16 errIllegalParameter     = 504;
const sal_uInt16 errIllegalJump          = 505;
const sal_uInt16 errSeparator            = 506;
const sal_uInt16 errPair                 = 507;
const sal_uInt16 errPairExpected         = 508;
const sal_uInt16 errOperatorExpected     = 509;
const sal_uInt16 errVariableExpected     = 510;
const sal_uInt16 errParameterExpected    = 511;
const sal_uInt16 errCodeOverflow         = 512;
const sal_uInt16 errStringOverflow       = 513;
const sal_uInt16 errStackOverflow        = 514;
const sal_uInt16 errUnknownState         = 515;
const sal_uInt16 errUnknownVariable      = 516;
const sal_uInt16 errUnknownOpCode        = 517;
const sal_uInt16 errUnknownStackVariable = 518;
const sal_uInt16 errNoValue              = 519; // #VALUE!
const sal_uInt16 errUnknownToken         = 520;
const sal_uInt16 errNoCode               = 521; // #NULL!
const sal_uInt16 errCircularReference    = 522;
const sal_uInt16 errNoConvergence        = 523;
const sal_uInt16 errNoRef                = 524; // #REF!
const sal_uInt16 errNoName               = 525; // #NAME?
const sal_uInt16 errDoubleRef            = 526;
// Not displayed, temporary for TrackFormulas,
// Cell depends on another cell that has errCircularReference
const sal_uInt16 errTrackFromCircRef     = 528;
// ScInterpreter internal:  no numeric value but numeric queried. If this is
// set as mnStringNoValueError no error is generated but 0 returned.
const sal_uInt16 errCellNoValue          = 529;
// Interpreter: needed AddIn not found
const sal_uInt16 errNoAddin              = 530;
// Interpreter: needed Macro not found
const sal_uInt16 errNoMacro              = 531;
// Interpreter: Division by zero
const sal_uInt16 errDivisionByZero       = 532; // #DIV/0!
// Compiler: a non-simple (str,err,val) value was put in an array
const sal_uInt16 errNestedArray          = 533;
// ScInterpreter internal:  no numeric value but numeric queried. If this is
// temporarily (!) set as mnStringNoValueError, the error is generated and can
// be used to distinguish that condition from all other (inherited) errors. Do
// not use for anything else! Never push or inherit the error otherwise!
const sal_uInt16 errNotNumericString     = 534;
// ScInterpreter internal:  jump matrix already has a result at this position,
// do not overwrite in case of empty code path.
const sal_uInt16 errJumpMatHasResult     = 535;
// ScInterpreter internal:  (matrix) element is not a numeric value, i.e.
// string or empty, to be distinguished from the general errNoValue NAN and not
// to be used as result.
const sal_uInt16 errElementNaN           = 536;
// ScInterpreter/ScFormulaCell internal:  keep dirty, retry interpreting next
// round.
const sal_uInt16 errRetryCircular        = 537;
// If matrix could not be allocated.
const sal_uInt16 errMatrixSize           = 538;

// Interpreter: NA() not available condition, not a real error
const sal_uInt16 NOTAVAILABLE            = 0x7fff;


/** Unconditionally construct a double value of NAN where the lower bits
    represent an interpreter error code. */
inline double CreateDoubleError( sal_uInt16 nErr )
{
    sal_math_Double smVal;
    ::rtl::math::setNan( &smVal.value );
    smVal.nan_parts.fraction_lo = nErr;
    return smVal.value;
}

/** Recreate the error code of a coded double error, if any. */
inline sal_uInt16 GetDoubleErrorValue( double fVal )
{
    if ( ::rtl::math::isFinite( fVal ) )
        return 0;
    if ( ::rtl::math::isInf( fVal ) )
        return errIllegalFPOperation;       // normal INF
    sal_uInt32 nErr = reinterpret_cast< sal_math_Double * >( &fVal)->nan_parts.fraction_lo;
    if ( nErr & 0xffff0000 )
        return errNoValue;                  // just a normal NAN
    if (!nErr)
        // Another NAN, e.g. -nan(0x8000000000000) from calculating with -inf
        return errIllegalFPOperation;
    // Any other error known to us as error code.
    return (sal_uInt16)(nErr & 0x0000ffff);
}

} // namespace formula

#endif // INCLUDED_FORMULA_ERRORCODES_HXX

/* vim:set shiftwidth=4 softtabstop=4 expandtab: */