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 : // ScInterpreter internal: jump matrix already has a result at this position,
76 : // do not overwrite in case of empty code path.
77 : const sal_uInt16 errJumpMatHasResult = 535;
78 :
79 : // Interpreter: NA() not available condition, not a real error
80 : const sal_uInt16 NOTAVAILABLE = 0x7fff;
81 :
82 :
83 : /** Unconditionally construct a double value of NAN where the lower bits
84 : represent an interpreter error code. */
85 21 : inline double CreateDoubleError( sal_uInt16 nErr )
86 : {
87 : union
88 : {
89 : double fVal;
90 : sal_math_Double smVal;
91 : };
92 21 : ::rtl::math::setNan( &fVal );
93 21 : smVal.nan_parts.fraction_lo = nErr;
94 21 : return fVal;
95 : }
96 :
97 :
98 : /** Recreate the error code of a coded double error, if any. */
99 79 : inline sal_uInt16 GetDoubleErrorValue( double fVal )
100 : {
101 79 : if ( ::rtl::math::isFinite( fVal ) )
102 57 : return 0;
103 22 : if ( ::rtl::math::isInf( fVal ) )
104 0 : return errIllegalFPOperation; // normal INF
105 : sal_uInt32 nErr = reinterpret_cast< sal_math_Double * >(
106 22 : &fVal)->nan_parts.fraction_lo;
107 22 : if ( nErr & 0xffff0000 )
108 0 : return errNoValue; // just a normal NAN
109 22 : return (sal_uInt16)(nErr & 0x0000ffff); // any other error
110 : }
111 :
112 : } // namespace ScErrorCodes
113 :
114 : // yes, exceptionally we put a "using namespace" in a header file..
115 : using namespace ScErrorCodes;
116 :
117 : #endif // SC_ERRORCODES_HXX
118 :
119 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|