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