diff options
Diffstat (limited to 'sc')
97 files changed, 1509 insertions, 1490 deletions
diff --git a/sc/inc/addincol.hxx b/sc/inc/addincol.hxx index 09d6fc524146..49d30b6a7b7a 100644 --- a/sc/inc/addincol.hxx +++ b/sc/inc/addincol.hxx @@ -187,7 +187,7 @@ private: css::uno::Reference<css::uno::XInterface> xCaller; bool bValidCount; // result: - sal_uInt16 nErrCode; + FormulaError nErrCode; bool bHasString; double fValue; OUString aString; @@ -214,7 +214,7 @@ public: void SetResult( const css::uno::Any& rNewRes ); - sal_uInt16 GetErrCode() const { return nErrCode; } + FormulaError GetErrCode() const { return nErrCode; } bool HasString() const { return bHasString; } bool HasMatrix() const { return xMatrix.get(); } bool HasVarRes() const { return ( xVarRes.is() ); } diff --git a/sc/inc/column.hxx b/sc/inc/column.hxx index 186e41565048..2041ce79f87c 100644 --- a/sc/inc/column.hxx +++ b/sc/inc/column.hxx @@ -360,7 +360,7 @@ public: void SetValue( SCROW nRow, double fVal ); void SetValues( SCROW nRow, const std::vector<double>& rVals ); void SetValue( sc::ColumnBlockPosition& rBlockPos, SCROW nRow, double fVal, bool bBroadcast = true ); - void SetError( SCROW nRow, const sal_uInt16 nError); + void SetError( SCROW nRow, const FormulaError nError); void GetString( SCROW nRow, OUString& rString ) const; double* GetValueCell( SCROW nRow ); @@ -376,7 +376,7 @@ public: SCSIZE GetCellCount() const; sal_uInt32 GetWeightedCount() const; sal_uInt32 GetCodeCount() const; // RPN-Code in formulas - sal_uInt16 GetErrCode( SCROW nRow ) const; + FormulaError GetErrCode( SCROW nRow ) const; bool HasStringData( SCROW nRow ) const; bool HasValueData( SCROW nRow ) const; @@ -403,7 +403,7 @@ public: position broadcasted. */ bool BroadcastBroadcasters( SCROW nRow1, SCROW nRow2, ScHint& rHint ); - bool CompileErrorCells( sc::CompileFormulaContext& rCxt, sal_uInt16 nErrCode ); + bool CompileErrorCells( sc::CompileFormulaContext& rCxt, FormulaError nErrCode ); void ResetChanged( SCROW nStartRow, SCROW nEndRow ); diff --git a/sc/inc/compiler.hxx b/sc/inc/compiler.hxx index 26be57dee30f..8c6485627cd1 100644 --- a/sc/inc/compiler.hxx +++ b/sc/inc/compiler.hxx @@ -130,7 +130,7 @@ public: rtl_uString* mpDataIgnoreCase; } sharedstring; ScMatrix* pMat; - sal_uInt16 nError; + FormulaError nError; sal_Unicode cStr[ MAXSTRLEN+1 ]; // string (up to 255 characters + 0) short nJump[ FORMULA_MAXJUMPCOUNT + 1 ]; // If/Chose token }; @@ -152,7 +152,7 @@ public: void SetSingleReference( const ScSingleRefData& rRef ); void SetDoubleReference( const ScComplexRefData& rRef ); void SetDouble( double fVal ); - void SetErrorConstant( sal_uInt16 nErr ); + void SetErrorConstant( FormulaError nErr ); // These methods are ok to use, reference count not cleared. void SetName(sal_Int16 nSheet, sal_uInt16 nIndex); @@ -304,7 +304,7 @@ private: bool NextNewToken(bool bInArray); - virtual void SetError(sal_uInt16 nError) override; + virtual void SetError(FormulaError nError) override; sal_Int32 NextSymbol(bool bInArray); bool IsValue( const OUString& ); bool IsOpCode( const OUString&, bool bInArray ); diff --git a/sc/inc/dociter.hxx b/sc/inc/dociter.hxx index 088ca7f37fc3..21f5ffcdac3e 100644 --- a/sc/inc/dociter.hxx +++ b/sc/inc/dociter.hxx @@ -77,7 +77,7 @@ class ScValueIterator // walk through all values in an area * See if the cell at the current position is a non-empty cell. If not, * move to the next non-empty cell position. */ - bool GetThis( double& rValue, sal_uInt16& rErr ); + bool GetThis( double& rValue, FormulaError& rErr ); public: @@ -88,10 +88,10 @@ public: void GetCurNumFmtInfo( short& nType, sal_uLong& nIndex ); /// Does NOT reset rValue if no value found! - bool GetFirst( double& rValue, sal_uInt16& rErr ); + bool GetFirst( double& rValue, FormulaError& rErr ); /// Does NOT reset rValue if no value found! - bool GetNext( double& rValue, sal_uInt16& rErr ); + bool GetNext( double& rValue, FormulaError& rErr ); }; class ScDBQueryDataIterator @@ -99,9 +99,9 @@ class ScDBQueryDataIterator public: struct Value { - OUString maString; + OUString maString; double mfValue; - sal_uInt16 mnError; + FormulaError mnError; bool mbIsNumber; Value(); @@ -466,7 +466,7 @@ public: const ScRange& rRange ); ~ScHorizontalValueIterator(); /// Does NOT reset rValue if no value found! - bool GetNext( double& rValue, sal_uInt16& rErr ); + bool GetNext( double& rValue, FormulaError& rErr ); }; // returns all areas with non-default formatting (horizontal) diff --git a/sc/inc/document.hxx b/sc/inc/document.hxx index 289d6df8a8f0..979257ec71ac 100644 --- a/sc/inc/document.hxx +++ b/sc/inc/document.hxx @@ -49,6 +49,7 @@ enum class SvtScriptType; enum class ScMF; +enum class FormulaError : sal_uInt16; namespace editeng { class SvxBorderLine; } namespace formula { struct VectorRefArray; } namespace svl { @@ -1000,7 +1001,7 @@ public: void SetValues( const ScAddress& rPos, const std::vector<double>& rVals ); - void SetError( SCCOL nCol, SCROW nRow, SCTAB nTab, const sal_uInt16 nError); + void SetError( SCCOL nCol, SCROW nRow, SCTAB nTab, const FormulaError nError); SC_DLLPUBLIC void SetFormula( const ScAddress& rPos, const ScTokenArray& rArray ); @@ -1057,7 +1058,7 @@ public: std::shared_ptr<sc::FormulaGroupContext>& GetFormulaGroupContext(); SC_DLLPUBLIC void GetInputString( SCCOL nCol, SCROW nRow, SCTAB nTab, OUString& rString ); - sal_uInt16 GetStringForFormula( const ScAddress& rPos, OUString& rString ); + FormulaError GetStringForFormula( const ScAddress& rPos, OUString& rString ); SC_DLLPUBLIC double GetValue( const ScAddress& rPos ) const; SC_DLLPUBLIC double GetValue( SCCOL nCol, SCROW nRow, SCTAB nTab ) const; SC_DLLPUBLIC void GetValue( SCCOL nCol, SCROW nRow, SCTAB nTab, double& rValue ) const; @@ -1188,7 +1189,7 @@ public: * @return true if at least one cell is re-compiled, false if no cells are * re-compiled. */ - bool CompileErrorCells(sal_uInt16 nErrCode); + bool CompileErrorCells(FormulaError nErrCode); ScAutoNameCache* GetAutoNameCache() { return pAutoNameCache; } void SetPreviewFont( SfxItemSet* pFontSet ); @@ -1225,7 +1226,7 @@ public: // if CalcFormulaTree() is currently running bool IsCalculatingFormulaTree() { return bCalculatingFormulaTree; } - sal_uInt16 GetErrCode( const ScAddress& ) const; + FormulaError GetErrCode( const ScAddress& ) const; /** Shrink a range to only include data area. diff --git a/sc/inc/formulacell.hxx b/sc/inc/formulacell.hxx index cec4b2d64db3..d30facaf4ce0 100644 --- a/sc/inc/formulacell.hxx +++ b/sc/inc/formulacell.hxx @@ -296,13 +296,13 @@ public: bool GetMatrixOrigin( ScAddress& rPos ) const; void GetResultDimensions( SCSIZE& rCols, SCSIZE& rRows ); sc::MatrixEdge GetMatrixEdge( ScAddress& rOrgPos ) const; - sal_uInt16 GetErrCode(); // interpret first if necessary - sal_uInt16 GetRawError(); // don't interpret, just return code or result error - bool GetErrorOrValue( sal_uInt16& rErr, double& rVal ); + FormulaError GetErrCode(); // interpret first if necessary + FormulaError GetRawError(); // don't interpret, just return code or result error + bool GetErrorOrValue( FormulaError& rErr, double& rVal ); sc::FormulaResultValue GetResult(); sc::FormulaResultValue GetResult() const; sal_uInt8 GetMatrixFlag() const { return cMatrixFlag;} - ScTokenArray* GetCode() { return pCode;} + ScTokenArray* GetCode() { return pCode;} const ScTokenArray* GetCode() const { return pCode;} void SetCode( ScTokenArray* pNew ); @@ -364,10 +364,10 @@ public: svl::SharedString GetResultString() const; /* Sets the shared code array to error state in addition to the cell result */ - void SetErrCode( sal_uInt16 n ); + void SetErrCode( FormulaError n ); /* Sets just the result to error */ - void SetResultError( sal_uInt16 n ); + void SetResultError( FormulaError n ); bool IsHyperLinkCell() const; EditTextObject* CreateURLObject(); diff --git a/sc/inc/formularesult.hxx b/sc/inc/formularesult.hxx index 68a08e52d797..0a977dcf043a 100644 --- a/sc/inc/formularesult.hxx +++ b/sc/inc/formularesult.hxx @@ -33,12 +33,12 @@ struct FormulaResultValue double mfValue; svl::SharedString maString; - sal_uInt16 mnError; + FormulaError mnError; FormulaResultValue(); FormulaResultValue( double fValue ); - FormulaResultValue(const svl::SharedString& rStr ); - FormulaResultValue( sal_uInt16 nErr ); + FormulaResultValue( const svl::SharedString& rStr ); + FormulaResultValue( FormulaError nErr ); }; } @@ -71,7 +71,7 @@ class ScFormulaResult double mfValue; // double result direct for performance and memory consumption const formula::FormulaToken* mpToken; // if not, result token obtained from interpreter }; - sal_uInt16 mnError; // error code + FormulaError mnError; // error code bool mbToken :1; // whether content of union is a token bool mbEmpty :1; // empty cell result bool mbEmptyDisplayedAsString :1; // only if mbEmpty @@ -154,15 +154,15 @@ public: one paragraph */ bool IsMultiline() const; - bool GetErrorOrDouble( sal_uInt16& rErr, double& rVal ) const; + bool GetErrorOrDouble( FormulaError& rErr, double& rVal ) const; sc::FormulaResultValue GetResult() const; /** Get error code if set or GetCellResultType() is formula::svError or svUnknown, else 0. */ - sal_uInt16 GetResultError() const; + FormulaError GetResultError() const; /** Set error code, don't touch token or double. */ - void SetResultError( sal_uInt16 nErr ); + void SetResultError( FormulaError nErr ); /** Set direct double. Shouldn't be used externally except in ScFormulaCell for rounded CalcAsShown or SetErrCode() or diff --git a/sc/inc/global.hxx b/sc/inc/global.hxx index 0e606f8563eb..63a716457c94 100644 --- a/sc/inc/global.hxx +++ b/sc/inc/global.hxx @@ -35,6 +35,7 @@ class SfxItemSet; class Color; struct ScCalcConfig; enum class SvtScriptType; +enum class FormulaError : sal_uInt16; #define SC_COLLATOR_IGNORES ( \ css::i18n::CollatorOptions::CollatorOptions_IGNORE_CASE ) @@ -571,8 +572,8 @@ public: static ScFunctionMgr* GetStarCalcFunctionMgr(); static void ResetFunctionList(); - static OUString GetErrorString(sal_uInt16 nErrNumber); - static OUString GetLongErrorString(sal_uInt16 nErrNumber); + static OUString GetErrorString(FormulaError nErrNumber); + static OUString GetLongErrorString(FormulaError nErrNumber); static bool EETextObjEqual( const EditTextObject* pObj1, const EditTextObject* pObj2 ); static bool CheckWidthInvalidate( bool& bNumFormatChanged, @@ -676,11 +677,11 @@ SC_DLLPUBLIC static const sal_Unicode* FindUnquoted( const sal_Unicode* pStri In any case, if rError is set 0.0 is returned. - If nStringNoValueError is errCellNoValue, that is unconditionally + If nStringNoValueError is FormulaError::CellNoValue, that is unconditionally assigned to rError and 0.0 is returned. The caller is expected to handle this situation. Used by the interpreter. - Usually errNoValue is passed as nStringNoValueError. + Usually FormulaError::NoValue is passed as nStringNoValueError. Otherwise, depending on the string conversion configuration different approaches are taken: @@ -778,7 +779,7 @@ SC_DLLPUBLIC static const sal_Unicode* FindUnquoted( const sal_Unicode* pStri */ static double ConvertStringToValue( const OUString& rStr, const ScCalcConfig& rConfig, - sal_uInt16 & rError, sal_uInt16 nStringNoValueError, + FormulaError & rError, FormulaError nStringNoValueError, SvNumberFormatter* pFormatter, short & rCurFmtType ); }; diff --git a/sc/inc/math.hxx b/sc/inc/math.hxx index ecea704052a4..c2a3b992dd00 100644 --- a/sc/inc/math.hxx +++ b/sc/inc/math.hxx @@ -30,7 +30,7 @@ namespace sc { inline double div( const double& fNumerator, const double& fDenominator ) { return (fDenominator != 0.0) ? (fNumerator / fDenominator) : - formula::CreateDoubleError( formula::errDivisionByZero); + CreateDoubleError( FormulaError::DivisionByZero); } /** Return fNumerator/fDenominator if fDenominator!=0 else +-Infinity if diff --git a/sc/inc/rangenam.hxx b/sc/inc/rangenam.hxx index e5a6dfea8a21..a1924de86a26 100644 --- a/sc/inc/rangenam.hxx +++ b/sc/inc/rangenam.hxx @@ -119,7 +119,7 @@ public: ScTokenArray* GetCode() { return pCode; } SC_DLLPUBLIC void SetCode( ScTokenArray& ); const ScTokenArray* GetCode() const { return pCode; } - SC_DLLPUBLIC sal_uInt16 GetErrCode() const; + SC_DLLPUBLIC FormulaError GetErrCode() const; bool HasReferences() const; void AddType( Type nType ); Type GetType() const { return eType; } diff --git a/sc/inc/scmatrix.hxx b/sc/inc/scmatrix.hxx index b4899681b70b..d26961d155fd 100644 --- a/sc/inc/scmatrix.hxx +++ b/sc/inc/scmatrix.hxx @@ -40,6 +40,7 @@ class ScInterpreter; class SvNumberFormatter; class ScMatrixImpl; +enum class FormulaError : sal_uInt16; namespace formula { class DoubleVectorRefToken; } @@ -64,7 +65,7 @@ struct ScMatrixValue const svl::SharedString& GetString() const { return aStr; } /// Only valid if ScMatrix methods indicate that this is no string! - sal_uInt16 GetError() const { return formula::GetDoubleErrorValue( fVal); } + FormulaError GetError() const { return GetDoubleErrorValue(fVal); } /// Only valid if ScMatrix methods indicate that this is a boolean bool GetBoolean() const { return fVal != 0.0; } @@ -274,7 +275,7 @@ public: /// Jump sal_False without path virtual void PutEmptyPath( SCSIZE nC, SCSIZE nR) = 0; - virtual void PutError( sal_uInt16 nErrorCode, SCSIZE nC, SCSIZE nR ) = 0; + virtual void PutError( FormulaError nErrorCode, SCSIZE nC, SCSIZE nR ) = 0; virtual void PutBoolean( bool bVal, SCSIZE nC, SCSIZE nR) = 0; virtual void FillDouble( double fVal, @@ -300,12 +301,12 @@ public: @ATTENTION: MUST NOT be used if the element is a string! Use GetErrorIfNotString() instead if not sure. @returns 0 if no error, else one of err... constants */ - virtual sal_uInt16 GetError( SCSIZE nC, SCSIZE nR) const = 0; + virtual FormulaError GetError( SCSIZE nC, SCSIZE nR) const = 0; /** Use in ScInterpreter to obtain the error code, if any. @returns 0 if no error or string element, else one of err... constants */ - sal_uInt16 GetErrorIfNotString( SCSIZE nC, SCSIZE nR) const - { return IsValue( nC, nR) ? GetError( nC, nR) : 0; } + FormulaError GetErrorIfNotString( SCSIZE nC, SCSIZE nR) const + { return IsValue( nC, nR) ? GetError( nC, nR) : FormulaError::NONE; } /// @return 0.0 if empty or empty path, else value or DoubleError. virtual double GetDouble( SCSIZE nC, SCSIZE nR) const = 0; @@ -493,7 +494,7 @@ public: /// Jump sal_False without path virtual void PutEmptyPath( SCSIZE nC, SCSIZE nR) override; - virtual void PutError( sal_uInt16 nErrorCode, SCSIZE nC, SCSIZE nR ) override; + virtual void PutError( FormulaError nErrorCode, SCSIZE nC, SCSIZE nR ) override; virtual void PutBoolean( bool bVal, SCSIZE nC, SCSIZE nR) override; virtual void FillDouble( double fVal, @@ -519,7 +520,7 @@ public: @ATTENTION: MUST NOT be used if the element is a string! Use GetErrorIfNotString() instead if not sure. @returns 0 if no error, else one of err... constants */ - virtual sal_uInt16 GetError( SCSIZE nC, SCSIZE nR) const override; + virtual FormulaError GetError( SCSIZE nC, SCSIZE nR) const override; /// @return 0.0 if empty or empty path, else value or DoubleError. virtual double GetDouble( SCSIZE nC, SCSIZE nR) const override; @@ -711,7 +712,7 @@ public: /// Jump sal_False without path virtual void PutEmptyPath(SCSIZE nC, SCSIZE nR) override; - virtual void PutError(sal_uInt16 nErrorCode, SCSIZE nC, SCSIZE nR ) override; + virtual void PutError(FormulaError nErrorCode, SCSIZE nC, SCSIZE nR ) override; virtual void PutBoolean(bool bVal, SCSIZE nC, SCSIZE nR) override; virtual void FillDouble(double fVal, SCSIZE nC1, SCSIZE nR1, SCSIZE nC2, SCSIZE nR2) override; @@ -736,7 +737,7 @@ public: @ATTENTION: MUST NOT be used if the element is a string! Use GetErrorIfNotString() instead if not sure. @returns 0 if no error, else one of err... constants */ - virtual sal_uInt16 GetError(SCSIZE nC, SCSIZE nR) const override; + virtual FormulaError GetError(SCSIZE nC, SCSIZE nR) const override; /// @return 0.0 if empty or empty path, else value or DoubleError. virtual double GetDouble(SCSIZE nC, SCSIZE nR) const override; diff --git a/sc/inc/simpleformulacalc.hxx b/sc/inc/simpleformulacalc.hxx index fef4fe9400a7..64229aff77ce 100644 --- a/sc/inc/simpleformulacalc.hxx +++ b/sc/inc/simpleformulacalc.hxx @@ -45,7 +45,7 @@ public: void Calculate(); bool IsValue(); bool IsMatrix(); - sal_uInt16 GetErrCode(); + FormulaError GetErrCode(); double GetValue(); svl::SharedString GetString(); short GetFormatType() const { return mnFormatType; } diff --git a/sc/inc/table.hxx b/sc/inc/table.hxx index 8e35256f48c0..d987071274a5 100644 --- a/sc/inc/table.hxx +++ b/sc/inc/table.hxx @@ -34,6 +34,7 @@ #include "cellvalue.hxx" #include <formula/types.hxx> #include "calcmacros.hxx" +#include "formula/errorcodes.hxx" #include <set> #include <map> @@ -362,7 +363,7 @@ public: void SetValue( SCCOL nCol, SCROW nRow, const double& rVal ); void SetValues( SCCOL nCol, SCROW nRow, const std::vector<double>& rVals ); - void SetError( SCCOL nCol, SCROW nRow, sal_uInt16 nError); + void SetError( SCCOL nCol, SCROW nRow, FormulaError nError); SCSIZE GetPatternCount( SCCOL nCol ) const; SCSIZE GetPatternCount( SCCOL nCol, SCROW nRow1, SCROW nRow2 ) const; bool ReservePatternCount( SCCOL nCol, SCSIZE nReserve ); @@ -522,11 +523,11 @@ public: bool HasStringCells( SCCOL nStartCol, SCROW nStartRow, SCCOL nEndCol, SCROW nEndRow ) const; - sal_uInt16 GetErrCode( const ScAddress& rPos ) const + FormulaError GetErrCode( const ScAddress& rPos ) const { return ValidColRow(rPos.Col(),rPos.Row()) ? aCol[rPos.Col()].GetErrCode( rPos.Row() ) : - 0; + FormulaError::NONE; } void ResetChanged( const ScRange& rRange ); @@ -549,7 +550,7 @@ public: position broadcasted. */ bool BroadcastBroadcasters( SCCOL nCol1, SCROW nRow1, SCCOL nCol2, SCROW nRow2, ScHint& rHint ); - bool CompileErrorCells( sc::CompileFormulaContext& rCxt, sal_uInt16 nErrCode ); + bool CompileErrorCells( sc::CompileFormulaContext& rCxt, FormulaError nErrCode ); void UpdateReference( sc::RefUpdateContext& rCxt, ScDocument* pUndoDoc = nullptr, diff --git a/sc/qa/unit/helper/qahelper.cxx b/sc/qa/unit/helper/qahelper.cxx index 7e74465a5cf1..7153c4b69c49 100644 --- a/sc/qa/unit/helper/qahelper.cxx +++ b/sc/qa/unit/helper/qahelper.cxx @@ -18,7 +18,7 @@ #include <svx/svdoole2.hxx> #include <editeng/brushitem.hxx> #include <editeng/justifyitem.hxx> - +#include <formula/errorcodes.hxx> #include <cppunit/Asserter.h> #include <cppunit/AdditionalMessage.h> @@ -522,7 +522,7 @@ bool isFormulaWithoutError(ScDocument& rDoc, const ScAddress& rPos) if (!pFC) return false; - return pFC->GetErrCode() == 0; + return pFC->GetErrCode() == FormulaError::NONE; } OUString toString( diff --git a/sc/qa/unit/helper/shared_test_impl.hxx b/sc/qa/unit/helper/shared_test_impl.hxx index 0c274816c20c..7a27d31a5927 100644 --- a/sc/qa/unit/helper/shared_test_impl.hxx +++ b/sc/qa/unit/helper/shared_test_impl.hxx @@ -14,6 +14,7 @@ #include "conditio.hxx" #include "document.hxx" #include "formulacell.hxx" +#include <formula/errorcodes.hxx> struct FindCondFormatByEnclosingRange { @@ -259,8 +260,8 @@ void testFunctionsExcel2010_Impl( ScDocument& rDoc ) OString::number( rDoc.GetValue( ScAddress( 2, nRow, 0)) ); ScFormulaCell* pFC = rDoc.GetFormulaCell( ScAddress( 1, nRow, 0) ); - if ( pFC && pFC->GetErrCode() != 0 ) - aStr += ", error code =" + OString::number( pFC->GetErrCode() ); + if ( pFC && pFC->GetErrCode() != FormulaError::NONE ) + aStr += ", error code =" + OString::number( (int)pFC->GetErrCode() ); CPPUNIT_ASSERT_MESSAGE( OString( "Expected a formula cell without error at row " + aStr ).getStr(), isFormulaWithoutError( rDoc, ScAddress( 1, nRow, 0))); diff --git a/sc/qa/unit/subsequent_filters-test.cxx b/sc/qa/unit/subsequent_filters-test.cxx index 9adc1a055d67..4b53e2d4a3ff 100644 --- a/sc/qa/unit/subsequent_filters-test.cxx +++ b/sc/qa/unit/subsequent_filters-test.cxx @@ -3364,8 +3364,8 @@ void ScFiltersTest::testVBAUserFunctionXLSM() CPPUNIT_ASSERT_EQUAL(OUString("=MYFUNC()"), aFormula); // Check the formula state after the load. - sal_uInt16 nErrCode = pFC->GetErrCode(); - CPPUNIT_ASSERT_EQUAL(static_cast<sal_uInt16>(0), nErrCode); + FormulaError nErrCode = pFC->GetErrCode(); + CPPUNIT_ASSERT_EQUAL(0, (int)nErrCode); // Check the result. CPPUNIT_ASSERT_EQUAL(42.0, rDoc.GetValue(ScAddress(0,0,0))); @@ -3409,7 +3409,7 @@ void ScFiltersTest::testErrorOnExternalReferences() ScFormulaCell* pFC = rDoc.GetFormulaCell(ScAddress(0,0,0)); CPPUNIT_ASSERT(pFC); - CPPUNIT_ASSERT_EQUAL(formula::errNoName, pFC->GetErrCode()); + CPPUNIT_ASSERT_EQUAL((int)FormulaError::NoName, (int)pFC->GetErrCode()); if (!checkFormula(rDoc, ScAddress(0,0,0), "'file:///Path/To/FileA.ods'#$Sheet1.A1A")) CPPUNIT_FAIL("Formula changed"); diff --git a/sc/qa/unit/ucalc.cxx b/sc/qa/unit/ucalc.cxx index 7e8654f3ea0e..0db6a1c270be 100644 --- a/sc/qa/unit/ucalc.cxx +++ b/sc/qa/unit/ucalc.cxx @@ -900,12 +900,12 @@ void Test::testValueIterator() bool bHas = false; size_t nCheckPos = 0; double fVal; - sal_uInt16 nErr; + FormulaError nErr; for (bHas = aIter.GetFirst(fVal, nErr); bHas; bHas = aIter.GetNext(fVal, nErr), ++nCheckPos) { CPPUNIT_ASSERT_MESSAGE("Iteration longer than expected.", nCheckPos < nCheckLen); CPPUNIT_ASSERT_EQUAL(aChecks[nCheckPos], fVal); - CPPUNIT_ASSERT_EQUAL(static_cast<sal_uInt16>(0), nErr); + CPPUNIT_ASSERT_EQUAL(0, (int)nErr); } } @@ -5776,8 +5776,8 @@ void Test::testFormulaWizardSubformula() m_pDoc->SetString(ScAddress(1,2,0), "=gibberish"); // B3 ScSimpleFormulaCalculator aFCell1( m_pDoc, ScAddress(0,0,0), "=B1:B3", true ); - sal_uInt16 nErrCode = aFCell1.GetErrCode(); - CPPUNIT_ASSERT( nErrCode == 0 || aFCell1.IsMatrix() ); + FormulaError nErrCode = aFCell1.GetErrCode(); + CPPUNIT_ASSERT( nErrCode == FormulaError::NONE || aFCell1.IsMatrix() ); CPPUNIT_ASSERT_EQUAL( OUString("{1;#DIV/0!;#NAME?}"), aFCell1.GetString().getString() ); m_pDoc->SetString(ScAddress(1,0,0), "=NA()"); // B1 @@ -5785,7 +5785,7 @@ void Test::testFormulaWizardSubformula() m_pDoc->SetString(ScAddress(1,2,0), "=1+2"); // B3 ScSimpleFormulaCalculator aFCell2( m_pDoc, ScAddress(0,0,0), "=B1:B3", true ); nErrCode = aFCell2.GetErrCode(); - CPPUNIT_ASSERT( nErrCode == 0 || aFCell2.IsMatrix() ); + CPPUNIT_ASSERT( nErrCode == FormulaError::NONE || aFCell2.IsMatrix() ); CPPUNIT_ASSERT_EQUAL( OUString("{#N/A;2;3}"), aFCell2.GetString().getString() ); m_pDoc->DeleteTab(0); diff --git a/sc/qa/unit/ucalc_formula.cxx b/sc/qa/unit/ucalc_formula.cxx index 38f15fadcafd..c3436863c09a 100644 --- a/sc/qa/unit/ucalc_formula.cxx +++ b/sc/qa/unit/ucalc_formula.cxx @@ -1141,11 +1141,11 @@ void Test::testFormulaRefUpdate() aPos = ScAddress(2,1,0); ScFormulaCell* pFC = m_pDoc->GetFormulaCell(aPos); CPPUNIT_ASSERT_MESSAGE("This should be a formula cell.", pFC); - CPPUNIT_ASSERT_EQUAL(formula::errNoRef, pFC->GetErrCode()); + CPPUNIT_ASSERT_EQUAL((int)FormulaError::NoRef, (int)pFC->GetErrCode()); aPos = ScAddress(2,2,0); pFC = m_pDoc->GetFormulaCell(aPos); CPPUNIT_ASSERT_MESSAGE("This should be a formula cell.", pFC); - CPPUNIT_ASSERT_EQUAL(formula::errNoRef, pFC->GetErrCode()); + CPPUNIT_ASSERT_EQUAL((int)FormulaError::NoRef, (int)pFC->GetErrCode()); // Clear all and start over. clearRange(m_pDoc, ScRange(0,0,0,10,10,0)); @@ -1245,11 +1245,11 @@ void Test::testFormulaRefUpdate() // Both A4 and A5 should show #REF! errors. pFC = m_pDoc->GetFormulaCell(ScAddress(0,3,0)); CPPUNIT_ASSERT_MESSAGE("This should be a formula cell.", pFC); - CPPUNIT_ASSERT_EQUAL(formula::errNoRef, pFC->GetErrCode()); + CPPUNIT_ASSERT_EQUAL((int)FormulaError::NoRef, (int)pFC->GetErrCode()); pFC = m_pDoc->GetFormulaCell(ScAddress(0,4,0)); CPPUNIT_ASSERT_MESSAGE("This should be a formula cell.", pFC); - CPPUNIT_ASSERT_EQUAL(formula::errNoRef, pFC->GetErrCode()); + CPPUNIT_ASSERT_EQUAL((int)FormulaError::NoRef, (int)pFC->GetErrCode()); m_pDoc->DeleteTab(0); } @@ -1862,7 +1862,7 @@ void Test::testFormulaRefUpdateInsertRows() rFunc.InsertCells(ScRange(0,1,0,MAXCOL,3,0), &aMark, INS_INSROWS_BEFORE, false, true); ScFormulaCell* pFC = m_pDoc->GetFormulaCell(ScAddress(0,5,0)); CPPUNIT_ASSERT(pFC); - CPPUNIT_ASSERT_EQUAL_MESSAGE("This formula cell should not be an error.", static_cast<sal_uInt16>(0), pFC->GetErrCode()); + CPPUNIT_ASSERT_EQUAL_MESSAGE("This formula cell should not be an error.", 0, (int)pFC->GetErrCode()); ASSERT_DOUBLES_EQUAL(3.0, m_pDoc->GetValue(ScAddress(0,5,0))); ASSERT_FORMULA_EQUAL(*m_pDoc, ScAddress(0,5,0), "MAX(A7:A9)", "Wrong formula!"); @@ -3547,19 +3547,19 @@ void Test::testFuncSUM() // Set #DIV/0! error to A3. A4 should also inherit this error. m_pDoc->SetString(ScAddress(0,2,0), "=1/0"); - sal_uInt16 nErr = m_pDoc->GetErrCode(ScAddress(0,2,0)); + FormulaError nErr = m_pDoc->GetErrCode(ScAddress(0,2,0)); CPPUNIT_ASSERT_EQUAL_MESSAGE("Cell should have a division by zero error.", - errDivisionByZero, nErr); + (int)FormulaError::DivisionByZero, (int)nErr); nErr = m_pDoc->GetErrCode(ScAddress(0,3,0)); CPPUNIT_ASSERT_EQUAL_MESSAGE("SUM should have also inherited a div-by-zero error.", - errDivisionByZero, nErr); + (int)FormulaError::DivisionByZero, (int)nErr); // Set #NA! to A2. A4 should now inherit this error. m_pDoc->SetString(ScAddress(0,1,0), "=NA()"); nErr = m_pDoc->GetErrCode(ScAddress(0,1,0)); - CPPUNIT_ASSERT_MESSAGE("A2 should be an error.", nErr); + CPPUNIT_ASSERT_MESSAGE("A2 should be an error.", nErr != FormulaError::NONE); CPPUNIT_ASSERT_EQUAL_MESSAGE("A4 should have inherited the same error as A2.", - nErr, m_pDoc->GetErrCode(ScAddress(0,3,0))); + (int)nErr, (int)m_pDoc->GetErrCode(ScAddress(0,3,0))); m_pDoc->DeleteTab(0); } @@ -3642,8 +3642,8 @@ void Test::testFuncSUMPRODUCT() // Force an error in C2 and test ForcedArray matrix error propagation. m_pDoc->SetString( 2, 1, 0, "=1/0"); - sal_uInt16 nError = m_pDoc->GetErrCode(aPos); - CPPUNIT_ASSERT_MESSAGE("Formula result should be a propagated error", nError); + FormulaError nError = m_pDoc->GetErrCode(aPos); + CPPUNIT_ASSERT_MESSAGE("Formula result should be a propagated error", nError != FormulaError::NONE); // Test ForceArray propagation of SUMPRODUCT parameters to ABS and + operator. // => ABS({-3,4})*({-3,4}+{-3,4}) => {3,4}*{-6,8} => {-18,32} => 14 @@ -3715,8 +3715,8 @@ void Test::testFuncMIN() CPPUNIT_ASSERT_EQUAL(static_cast<SCCOL>(1), nCols); CPPUNIT_ASSERT_EQUAL(static_cast<SCROW>(2), nRows); - CPPUNIT_ASSERT_EQUAL_MESSAGE("Formula in C1 is invalid.", static_cast<sal_uInt16>(0), m_pDoc->GetErrCode(ScAddress(2,0,0))); - CPPUNIT_ASSERT_EQUAL_MESSAGE("Formula in C2 is invalid.", static_cast<sal_uInt16>(0), m_pDoc->GetErrCode(ScAddress(2,1,0))); + CPPUNIT_ASSERT_EQUAL_MESSAGE("Formula in C1 is invalid.", 0, (int)m_pDoc->GetErrCode(ScAddress(2,0,0))); + CPPUNIT_ASSERT_EQUAL_MESSAGE("Formula in C2 is invalid.", 0, (int)m_pDoc->GetErrCode(ScAddress(2,1,0))); CPPUNIT_ASSERT_EQUAL(0.0, m_pDoc->GetValue(ScAddress(2,0,0))); CPPUNIT_ASSERT_EQUAL(0.0, m_pDoc->GetValue(ScAddress(2,1,0))); @@ -3962,8 +3962,8 @@ void Test::testFuncCHOOSE() m_pDoc->InsertTab(0, "Formula"); m_pDoc->SetString(ScAddress(0,0,0), "=CHOOSE(B1;\"one\";\"two\";\"three\")"); - sal_uInt16 nError = m_pDoc->GetErrCode(ScAddress(0,0,0)); - CPPUNIT_ASSERT_MESSAGE("Formula result should be an error since B1 is still empty.", nError); + FormulaError nError = m_pDoc->GetErrCode(ScAddress(0,0,0)); + CPPUNIT_ASSERT_MESSAGE("Formula result should be an error since B1 is still empty.", nError != FormulaError::NONE); m_pDoc->SetValue(ScAddress(1,0,0), 1.0); CPPUNIT_ASSERT_EQUAL(OUString("one"), m_pDoc->GetString(ScAddress(0,0,0))); m_pDoc->SetValue(ScAddress(1,0,0), 2.0); @@ -3972,7 +3972,7 @@ void Test::testFuncCHOOSE() CPPUNIT_ASSERT_EQUAL(OUString("three"), m_pDoc->GetString(ScAddress(0,0,0))); m_pDoc->SetValue(ScAddress(1,0,0), 4.0); nError = m_pDoc->GetErrCode(ScAddress(0,0,0)); - CPPUNIT_ASSERT_MESSAGE("Formula result should be an error due to out-of-bound input..", nError); + CPPUNIT_ASSERT_MESSAGE("Formula result should be an error due to out-of-bound input..", nError != FormulaError::NONE); m_pDoc->DeleteTab(0); } @@ -4285,9 +4285,9 @@ void Test::testFuncLOOKUP() printRange(m_pDoc, ScRange(0,4,0,1,6,0), "Data range for LOOKUP."); // Values for B5:B7 should be 1, 2, and 3. - CPPUNIT_ASSERT_EQUAL_MESSAGE("This formula should not have an error code.", static_cast<sal_uInt16>(0), m_pDoc->GetErrCode(ScAddress(1,4,0))); - CPPUNIT_ASSERT_EQUAL_MESSAGE("This formula should not have an error code.", static_cast<sal_uInt16>(0), m_pDoc->GetErrCode(ScAddress(1,5,0))); - CPPUNIT_ASSERT_EQUAL_MESSAGE("This formula should not have an error code.", static_cast<sal_uInt16>(0), m_pDoc->GetErrCode(ScAddress(1,6,0))); + CPPUNIT_ASSERT_EQUAL_MESSAGE("This formula should not have an error code.", 0, (int)m_pDoc->GetErrCode(ScAddress(1,4,0))); + CPPUNIT_ASSERT_EQUAL_MESSAGE("This formula should not have an error code.", 0, (int)m_pDoc->GetErrCode(ScAddress(1,5,0))); + CPPUNIT_ASSERT_EQUAL_MESSAGE("This formula should not have an error code.", 0, (int)m_pDoc->GetErrCode(ScAddress(1,6,0))); ASSERT_DOUBLES_EQUAL(1.0, m_pDoc->GetValue(ScAddress(1,4,0))); ASSERT_DOUBLES_EQUAL(2.0, m_pDoc->GetValue(ScAddress(1,5,0))); @@ -4923,7 +4923,7 @@ void Test::testFuncINDIRECT2() // Check formula cell error ScFormulaCell* pFC = m_pDoc->GetFormulaCell(ScAddress(0,9,2)); CPPUNIT_ASSERT_MESSAGE("This should be a formula cell.", pFC); - CPPUNIT_ASSERT_MESSAGE("This formula cell should be an error.", pFC->GetErrCode() != 0); + CPPUNIT_ASSERT_MESSAGE("This formula cell should be an error.", pFC->GetErrCode() != FormulaError::NONE); m_pDoc->DeleteTab(2); m_pDoc->DeleteTab(1); @@ -5620,15 +5620,15 @@ void Test::testExternalRefFunctions() // areas these tests may be adapted. m_pDoc->SetString(0, 0, 0, "=SUM('file:///extdata.fake'#Data.B1:AMJ1048575)"); ScFormulaCell* pFC = m_pDoc->GetFormulaCell( ScAddress(0,0,0)); - sal_uInt16 nErr = pFC->GetErrCode(); - CPPUNIT_ASSERT_EQUAL_MESSAGE("huge external range reference expected to yield errMatrixSize", errMatrixSize, nErr); + FormulaError nErr = pFC->GetErrCode(); + CPPUNIT_ASSERT_EQUAL_MESSAGE("huge external range reference expected to yield FormulaError::MatrixSize", (int)FormulaError::MatrixSize, (int)nErr); ScMarkData aMark; aMark.SelectOneTable(0); m_pDoc->InsertMatrixFormula(0,0,0,0, aMark, "'file:///extdata.fake'#Data.B1:AMJ1048575"); pFC = m_pDoc->GetFormulaCell( ScAddress(0,0,0)); nErr = pFC->GetErrCode(); - CPPUNIT_ASSERT_EQUAL_MESSAGE("huge external range reference expected to yield errMatrixSize", errMatrixSize, nErr); + CPPUNIT_ASSERT_EQUAL_MESSAGE("huge external range reference expected to yield FormulaError::MatrixSize", (int)FormulaError::MatrixSize, (int)nErr); SCSIZE nMatCols, nMatRows; const ScMatrix* pMat = pFC->GetMatrix(); CPPUNIT_ASSERT_MESSAGE("matrix expected", pMat != nullptr); diff --git a/sc/qa/unit/ucalc_pivottable.cxx b/sc/qa/unit/ucalc_pivottable.cxx index c8aa1b3930cf..9bf5522186bf 100644 --- a/sc/qa/unit/ucalc_pivottable.cxx +++ b/sc/qa/unit/ucalc_pivottable.cxx @@ -19,6 +19,7 @@ #include "stringutil.hxx" #include "dbdocfun.hxx" +#include <formula/errorcodes.hxx> #include <com/sun/star/sheet/DataPilotFieldOrientation.hpp> #include <com/sun/star/sheet/DataPilotFieldGroupBy.hpp> #include <com/sun/star/sheet/DataPilotFieldReference.hpp> @@ -2304,11 +2305,10 @@ void Test::testFuncGETPIVOTDATALeafAccess() m_pDoc->CalcAll(); - const sal_uInt16 nNoError = 0; // no error for (size_t i = 0; i < SAL_N_ELEMENTS(aChecks); ++i) { - sal_uInt16 nErr = m_pDoc->GetErrCode(ScAddress(4,i,1)); - CPPUNIT_ASSERT_EQUAL(nNoError, nErr); + FormulaError nErr = m_pDoc->GetErrCode(ScAddress(4,i,1)); + CPPUNIT_ASSERT_EQUAL((sal_uInt16)FormulaError::NONE, (sal_uInt16)nErr); double fVal = m_pDoc->GetValue(ScAddress(4,i,1)); CPPUNIT_ASSERT_EQUAL(aChecks[i].mfResult, fVal); } diff --git a/sc/source/core/data/clipcontext.cxx b/sc/source/core/data/clipcontext.cxx index b0ac3019c67c..16084be70c6d 100644 --- a/sc/source/core/data/clipcontext.cxx +++ b/sc/source/core/data/clipcontext.cxx @@ -17,6 +17,7 @@ #include <clipparam.hxx> #include <svl/intitem.hxx> +#include <formula/errorcodes.hxx> namespace sc { @@ -203,8 +204,8 @@ void CopyFromClipContext::setSingleCell( const ScAddress& rSrcPos, const ScColum // Good. break; - sal_uInt16 nErr = rSrcCell.mpFormula->GetErrCode(); - if (nErr) + FormulaError nErr = rSrcCell.mpFormula->GetErrCode(); + if (nErr != FormulaError::NONE) { // error codes are cloned with values if (!bNumeric) diff --git a/sc/source/core/data/column.cxx b/sc/source/core/data/column.cxx index 67c51a4f54d5..dfe343ec46ca 100644 --- a/sc/source/core/data/column.cxx +++ b/sc/source/core/data/column.cxx @@ -51,6 +51,7 @@ #include <svl/sharedstringpool.hxx> #include <editeng/scripttypeitem.hxx> #include <editeng/fieldupdater.hxx> +#include <formula/errorcodes.hxx> #include <osl/diagnose.h> #include <cstring> @@ -1125,7 +1126,7 @@ void ScColumn::CopyStaticToDocument( if (rFC.GetDirty() && pDocument->GetAutoCalc()) rFC.Interpret(); - if (rFC.GetErrCode()) + if (rFC.GetErrCode() != FormulaError::NONE) // Skip cells with error. break; @@ -1445,8 +1446,8 @@ class CopyByCloneHandler if (bCloneValue) { - sal_uInt16 nErr = rSrcCell.GetErrCode(); - if (nErr) + FormulaError nErr = rSrcCell.GetErrCode(); + if (nErr != FormulaError::NONE) { // error codes are cloned with values ScFormulaCell* pErrCell = new ScFormulaCell(&mrDestCol.GetDoc(), aDestPos); @@ -2875,7 +2876,7 @@ public: { // for unconditional compilation // bCompile=true and pCode->nError=0 - pCell->GetCode()->SetCodeError(0); + pCell->GetCode()->SetCodeError(FormulaError::NONE); pCell->SetCompile(true); pCell->CompileTokenArray(mrCxt); } @@ -2913,10 +2914,10 @@ class CompileErrorCellsHandler sc::CompileFormulaContext& mrCxt; ScColumn& mrColumn; sc::CellStoreType::iterator miPos; - sal_uInt16 mnErrCode; + FormulaError mnErrCode; bool mbCompiled; public: - CompileErrorCellsHandler( sc::CompileFormulaContext& rCxt, ScColumn& rColumn, sal_uInt16 nErrCode ) : + CompileErrorCellsHandler( sc::CompileFormulaContext& rCxt, ScColumn& rColumn, FormulaError nErrCode ) : mrCxt(rCxt), mrColumn(rColumn), miPos(mrColumn.GetCellStore().begin()), @@ -2927,19 +2928,19 @@ public: void operator() (size_t nRow, ScFormulaCell* pCell) { - sal_uInt16 nCurError = pCell->GetRawError(); - if (!nCurError) + FormulaError nCurError = pCell->GetRawError(); + if (nCurError == FormulaError::NONE) // It's not an error cell. Skip it. return; - if (mnErrCode && nCurError != mnErrCode) + if (mnErrCode != FormulaError::NONE && nCurError != mnErrCode) // Error code is specified, and it doesn't match. Skip it. return; sc::CellStoreType::position_type aPos = mrColumn.GetCellStore().position(miPos, nRow); miPos = aPos.first; sc::SharedFormulaUtil::unshareFormulaCell(aPos, *pCell); - pCell->GetCode()->SetCodeError(0); + pCell->GetCode()->SetCodeError(FormulaError::NONE); OUString aFormula = pCell->GetFormula(mrCxt); pCell->Compile(mrCxt, aFormula); ScColumn::JoinNewFormulaCell(aPos, *pCell); @@ -3456,7 +3457,7 @@ void ScColumn::CompileXML( sc::CompileFormulaContext& rCxt, ScProgress& rProgres RegroupFormulaCells(); } -bool ScColumn::CompileErrorCells( sc::CompileFormulaContext& rCxt, sal_uInt16 nErrCode ) +bool ScColumn::CompileErrorCells( sc::CompileFormulaContext& rCxt, FormulaError nErrCode ) { CompileErrorCellsHandler aHdl(rCxt, *this, nErrCode); sc::ProcessFormula(maCells, aHdl); diff --git a/sc/source/core/data/column2.cxx b/sc/source/core/data/column2.cxx index 37d8ccd7cf65..60035652315b 100644 --- a/sc/source/core/data/column2.cxx +++ b/sc/source/core/data/column2.cxx @@ -2224,14 +2224,14 @@ public: continue; } - sal_uInt16 nErr; + FormulaError nErr; double fVal; if (rCell.GetErrorOrValue(nErr, fVal)) { ScAddress aAdr(mnCol, nThisRow, mnTab); - if (nErr) - fVal = formula::CreateDoubleError(nErr); + if (nErr != FormulaError::NONE) + fVal = CreateDoubleError(nErr); if (!aBucket.maNumVals.empty() && nThisRow == nPrevRow + 1) { @@ -2362,12 +2362,12 @@ bool appendToBlock( sc::FormulaResultValue aRes = rFC.GetResult(); - if (aRes.meType == sc::FormulaResultValue::Invalid || aRes.mnError) + if (aRes.meType == sc::FormulaResultValue::Invalid || aRes.mnError != FormulaError::NONE) { - if (aRes.mnError == formula::errCircularReference) + if (aRes.mnError == FormulaError::CircularReference) { // This cell needs to be recalculated on next visit. - rFC.SetErrCode(0); + rFC.SetErrCode(FormulaError::NONE); rFC.SetDirtyVar(); } return false; @@ -2483,12 +2483,12 @@ copyFirstFormulaBlock( { ScFormulaCell& rFC = **it; sc::FormulaResultValue aRes = rFC.GetResult(); - if (aRes.meType == sc::FormulaResultValue::Invalid || aRes.mnError) + if (aRes.meType == sc::FormulaResultValue::Invalid || aRes.mnError != FormulaError::NONE) { - if (aRes.mnError == formula::errCircularReference) + if (aRes.mnError == FormulaError::CircularReference) { // This cell needs to be recalculated on next visit. - rFC.SetErrCode(0); + rFC.SetErrCode(FormulaError::NONE); rFC.SetDirtyVar(); } return nullptr; @@ -2730,8 +2730,8 @@ void ScColumn::SetFormulaResults( SCROW nRow, const double* pResults, size_t nLe for (; pResults != pResEnd; ++pResults, ++itCell) { ScFormulaCell& rCell = **itCell; - sal_uInt16 nErr = formula::GetDoubleErrorValue(*pResults); - if (nErr != 0) + FormulaError nErr = GetDoubleErrorValue(*pResults); + if (nErr != FormulaError::NONE) rCell.SetResultError(nErr); else rCell.SetResultDouble(*pResults); @@ -3151,7 +3151,7 @@ public: if (mrData.eFunc != SUBTOTAL_FUNC_CNT2) // it doesn't interest us { - if (pCell->GetErrCode()) + if (pCell->GetErrCode() != FormulaError::NONE) { if (mrData.eFunc != SUBTOTAL_FUNC_CNT) // simply remove from count mrData.bError = true; diff --git a/sc/source/core/data/column3.cxx b/sc/source/core/data/column3.cxx index 27abbbf249fe..89aa5e05e6c2 100644 --- a/sc/source/core/data/column3.cxx +++ b/sc/source/core/data/column3.cxx @@ -936,8 +936,8 @@ public: // Always just copy the original row to the Undo Documen; // do not create Value/string cells from formulas - sal_uInt16 nErr = rSrcCell.GetErrCode(); - if (nErr) + FormulaError nErr = rSrcCell.GetErrCode(); + if (nErr != FormulaError::NONE) { // error codes are cloned with values if (bNumeric) @@ -1190,7 +1190,7 @@ class MixDataHandler ScAddress aPos(mrDestColumn.GetCol(), nDestRow, mrDestColumn.GetTab()); ScFormulaCell* pFC = new ScFormulaCell(&mrDestColumn.GetDoc(), aPos); - pFC->SetErrCode(errNoValue); + pFC->SetErrCode(FormulaError::NoValue); miNewCellsPos = maNewCells.set(miNewCellsPos, nDestRow-mnRowOffset, pFC); } @@ -1998,8 +1998,8 @@ class FilterEntriesHandler case CELLTYPE_FORMULA: { ScFormulaCell* pFC = rCell.mpFormula; - sal_uInt16 nErr = pFC->GetErrCode(); - if (nErr) + FormulaError nErr = pFC->GetErrCode(); + if (nErr != FormulaError::NONE) { // Error cell is evaluated as string (for now). OUString aErr = ScGlobal::GetErrorString(nErr); @@ -2365,7 +2365,7 @@ void ScColumn::RemoveProtected( SCROW nStartRow, SCROW nEndRow ) aFunc.commitCells(*this); } -void ScColumn::SetError( SCROW nRow, const sal_uInt16 nError) +void ScColumn::SetError( SCROW nRow, const FormulaError nError) { if (!ValidRow(nRow)) return; @@ -2605,15 +2605,15 @@ SCSIZE ScColumn::GetCellCount() const return aFunc.getCount(); } -sal_uInt16 ScColumn::GetErrCode( SCROW nRow ) const +FormulaError ScColumn::GetErrCode( SCROW nRow ) const { std::pair<sc::CellStoreType::const_iterator,size_t> aPos = maCells.position(nRow); sc::CellStoreType::const_iterator it = aPos.first; if (it == maCells.end()) - return 0; + return FormulaError::NONE; if (it->type != sc::element_type_formula) - return 0; + return FormulaError::NONE; const ScFormulaCell* p = sc::formula_block::at(*it->data, aPos.second); return const_cast<ScFormulaCell*>(p)->GetErrCode(); diff --git a/sc/source/core/data/conditio.cxx b/sc/source/core/data/conditio.cxx index 2a6b48aeb07a..c5d712cac926 100644 --- a/sc/source/core/data/conditio.cxx +++ b/sc/source/core/data/conditio.cxx @@ -41,6 +41,7 @@ #include "editutil.hxx" #include "tokenarray.hxx" #include "refupdatecontext.hxx" +#include <formula/errorcodes.hxx> #include <svl/sharedstring.hxx> #include <svl/sharedstringpool.hxx> #include <memory> @@ -1037,7 +1038,7 @@ bool ScConditionEntry::IsError( const ScAddress& rPos ) const if (rCell.meType == CELLTYPE_FORMULA) { - if (rCell.mpFormula->GetErrCode()) + if (rCell.mpFormula->GetErrCode() != FormulaError::NONE) return true; } diff --git a/sc/source/core/data/dbdocutl.cxx b/sc/source/core/data/dbdocutl.cxx index 6e681f645148..60a7610e478d 100644 --- a/sc/source/core/data/dbdocutl.cxx +++ b/sc/source/core/data/dbdocutl.cxx @@ -157,7 +157,7 @@ void ScDatabaseDocUtil::PutData( ScDocument* pDoc, SCCOL nCol, SCROW nRow, SCTAB pDoc->SetEmptyCell(aPos); else if (bError) { - pDoc->SetError( nCol, nRow, nTab, formula::NOTAVAILABLE ); + pDoc->SetError( nCol, nRow, nTab, FormulaError::NotAvailable ); } else if (bValue) { diff --git a/sc/source/core/data/dociter.cxx b/sc/source/core/data/dociter.cxx index b9bc4db58ac6..ed391238baac 100644 --- a/sc/source/core/data/dociter.cxx +++ b/sc/source/core/data/dociter.cxx @@ -151,7 +151,7 @@ void ScValueIterator::SetPos(size_t nPos) maCurPos = mpCells->position(maCurPos.first, nPos); } -bool ScValueIterator::GetThis(double& rValue, sal_uInt16& rErr) +bool ScValueIterator::GetThis(double& rValue, FormulaError& rErr) { while (true) { @@ -175,7 +175,7 @@ bool ScValueIterator::GetThis(double& rValue, sal_uInt16& rErr) ++mnTab; if (mnTab > maEndPos.Tab()) { - rErr = 0; + rErr = FormulaError::NONE; return false; // Over and out } } @@ -205,7 +205,7 @@ bool ScValueIterator::GetThis(double& rValue, sal_uInt16& rErr) { bNumValid = false; rValue = sc::numeric_block::at(*maCurPos.first->data, maCurPos.second); - rErr = 0; + rErr = FormulaError::NONE; if (bCalcAsShown) { ScAttrArray_IterGetNumberFormat(nNumFormat, pAttrArray, @@ -227,7 +227,7 @@ bool ScValueIterator::GetThis(double& rValue, sal_uInt16& rErr) if (rCell.GetErrorOrValue(rErr, rValue)) { - if ( rErr && ( mnSubTotalFlags & SUBTOTAL_IGN_ERR_VAL ) ) + if ( rErr != FormulaError::NONE && ( mnSubTotalFlags & SUBTOTAL_IGN_ERR_VAL ) ) { IncPos(); break; @@ -249,7 +249,7 @@ bool ScValueIterator::GetThis(double& rValue, sal_uInt16& rErr) { if (bTextAsZero) { - rErr = 0; + rErr = FormulaError::NONE; rValue = 0.0; nNumFmtType = css::util::NumberFormat::NUMBER; nNumFmtIndex = 0; @@ -282,7 +282,7 @@ void ScValueIterator::GetCurNumFmtInfo( short& nType, sal_uLong& nIndex ) nIndex = nNumFmtIndex; } -bool ScValueIterator::GetFirst(double& rValue, sal_uInt16& rErr) +bool ScValueIterator::GetFirst(double& rValue, FormulaError& rErr) { mnCol = maStartPos.Col(); mnTab = maStartPos.Tab(); @@ -300,7 +300,7 @@ bool ScValueIterator::GetFirst(double& rValue, sal_uInt16& rErr) return GetThis(rValue, rErr); } -bool ScValueIterator::GetNext(double& rValue, sal_uInt16& rErr) +bool ScValueIterator::GetNext(double& rValue, FormulaError& rErr) { IncPos(); return GetThis(rValue, rErr); @@ -388,7 +388,7 @@ bool ScDBQueryDataIterator::DataAccessInternal::getCurrent(Value& rValue) if (maCurPos.first == mpCells->end() || nRow > mpParam->nRow2) { // Bottom of the range reached. Bail out. - rValue.mnError = 0; + rValue.mnError = FormulaError::NONE; return false; } @@ -426,7 +426,7 @@ bool ScDBQueryDataIterator::DataAccessInternal::getCurrent(Value& rValue) } nNumFmtType = css::util::NumberFormat::NUMBER; nNumFmtIndex = 0; - rValue.mnError = 0; + rValue.mnError = FormulaError::NONE; return true; // Found it! } @@ -461,7 +461,7 @@ bool ScDBQueryDataIterator::DataAccessInternal::getCurrent(Value& rValue) { rValue.maString = aCell.getString(mpDoc); rValue.mfValue = 0.0; - rValue.mnError = 0; + rValue.mnError = FormulaError::NONE; rValue.mbIsNumber = false; return true; } @@ -554,7 +554,7 @@ bool ScDBQueryDataIterator::DataAccessMatrix::getCurrent(Value& rValue) rValue.maString = rMat.GetString(mpParam->mnField, mnCurRow).getString(); rValue.mfValue = rMat.GetDouble(mpParam->mnField, mnCurRow); rValue.mbIsNumber = !bIsStrVal; - rValue.mnError = 0; + rValue.mnError = FormulaError::NONE; return true; } } @@ -748,7 +748,7 @@ bool ScDBQueryDataIterator::DataAccessMatrix::isValidQuery(SCROW nRow, const ScM } ScDBQueryDataIterator::Value::Value() : - mnError(0), mbIsNumber(true) + mnError(FormulaError::NONE), mbIsNumber(true) { ::rtl::math::setNan(&mfValue); } @@ -965,7 +965,7 @@ bool ScCellIterator::getCurrent() ScFormulaCell* pCell = sc::formula_block::at(*maCurColPos.first->data, maCurColPos.second); // Skip formula cells with Subtotal formulae or errors, depending on mnSubTotalFlags if ( ( ( mnSubTotalFlags & SUBTOTAL_IGN_NESTED_ST_AG ) && pCell->IsSubTotal() ) || - ( ( mnSubTotalFlags & SUBTOTAL_IGN_ERR_VAL ) && pCell->GetErrCode() ) ) + ( ( mnSubTotalFlags & SUBTOTAL_IGN_ERR_VAL ) && pCell->GetErrCode() != FormulaError::NONE ) ) { incPos(); continue; @@ -2204,7 +2204,7 @@ ScHorizontalValueIterator::~ScHorizontalValueIterator() delete pCellIter; } -bool ScHorizontalValueIterator::GetNext( double& rValue, sal_uInt16& rErr ) +bool ScHorizontalValueIterator::GetNext( double& rValue, FormulaError& rErr ) { bool bFound = false; while ( !bFound ) @@ -2225,7 +2225,7 @@ bool ScHorizontalValueIterator::GetNext( double& rValue, sal_uInt16& rErr ) case CELLTYPE_VALUE: { rValue = pCell->mfValue; - rErr = 0; + rErr = FormulaError::NONE; if ( bCalcAsShown ) { ScColumn* pCol = &pDoc->maTabs[nCurTab]->aCol[nCurCol]; @@ -2239,7 +2239,7 @@ bool ScHorizontalValueIterator::GetNext( double& rValue, sal_uInt16& rErr ) case CELLTYPE_FORMULA: { rErr = pCell->mpFormula->GetErrCode(); - if (rErr || pCell->mpFormula->IsValue()) + if (rErr != FormulaError::NONE || pCell->mpFormula->IsValue()) { rValue = pCell->mpFormula->GetValue(); bFound = true; diff --git a/sc/source/core/data/documen2.cxx b/sc/source/core/data/documen2.cxx index 1de362027221..534a78849e38 100644 --- a/sc/source/core/data/documen2.cxx +++ b/sc/source/core/data/documen2.cxx @@ -1095,7 +1095,7 @@ sal_uLong ScDocument::TransferTab( ScDocument* pSrcDoc, SCTAB nSrcPos, return nRetVal; } -void ScDocument::SetError( SCCOL nCol, SCROW nRow, SCTAB nTab, const sal_uInt16 nError) +void ScDocument::SetError( SCCOL nCol, SCROW nRow, SCTAB nTab, const FormulaError nError) { if (ValidTab(nTab) && nTab < static_cast<SCTAB>(maTabs.size())) if (maTabs[nTab]) diff --git a/sc/source/core/data/documen4.cxx b/sc/source/core/data/documen4.cxx index d2dcdb28c8bd..c503b2fa6137 100644 --- a/sc/source/core/data/documen4.cxx +++ b/sc/source/core/data/documen4.cxx @@ -110,7 +110,7 @@ bool ScDocument::Solver(SCCOL nFCol, SCROW nFRow, SCTAB nFTab, fBestX = fXPrev = fSaveVal; pFormula->Interpret(); - bool bError = ( pFormula->GetErrCode() != 0 ); + bool bError = ( pFormula->GetErrCode() != FormulaError::NONE ); // bError always corresponds with fF fFPrev = pFormula->GetValue() - fTargetVal; @@ -132,7 +132,7 @@ bool ScDocument::Solver(SCCOL nFCol, SCROW nFRow, SCTAB nFTab, *pVCell = fX; SetDirty( aVRange, false ); pFormula->Interpret(); - bError = ( pFormula->GetErrCode() != 0 ); + bError = ( pFormula->GetErrCode() != FormulaError::NONE ); fF = pFormula->GetValue() - fTargetVal; if ( fF == fFPrev && !bError ) @@ -166,7 +166,7 @@ bool ScDocument::Solver(SCCOL nFCol, SCROW nFRow, SCTAB nFTab, *pVCell = fHorX; SetDirty( aVRange, false ); pFormula->Interpret(); - bHorMoveError = ( pFormula->GetErrCode() != 0 ); + bHorMoveError = ( pFormula->GetErrCode() != FormulaError::NONE ); if ( bHorMoveError ) break; @@ -243,12 +243,12 @@ bool ScDocument::Solver(SCCOL nFCol, SCROW nFRow, SCTAB nFTab, pFormula->Interpret(); if ( !bDoneIteration ) { - SetError( nVCol, nVRow, nVTab, NOTAVAILABLE ); + SetError( nVCol, nVRow, nVTab, FormulaError::NotAvailable ); } } else { - SetError( nVCol, nVRow, nVTab, NOTAVAILABLE ); + SetError( nVCol, nVRow, nVTab, FormulaError::NotAvailable ); } } return bRet; diff --git a/sc/source/core/data/document.cxx b/sc/source/core/data/document.cxx index 2d698accfb43..adcf0c93ffc5 100644 --- a/sc/source/core/data/document.cxx +++ b/sc/source/core/data/document.cxx @@ -3498,7 +3498,7 @@ void ScDocument::GetInputString( SCCOL nCol, SCROW nRow, SCTAB nTab, OUString& r rString.clear(); } -sal_uInt16 ScDocument::GetStringForFormula( const ScAddress& rPos, OUString& rString ) +FormulaError ScDocument::GetStringForFormula( const ScAddress& rPos, OUString& rString ) { // Used in formulas (add-in parameters etc), so it must use the same semantics as // ScInterpreter::GetCellString: always format values as numbers. @@ -3508,10 +3508,10 @@ sal_uInt16 ScDocument::GetStringForFormula( const ScAddress& rPos, OUString& rSt if (aCell.isEmpty()) { rString = EMPTY_OUSTRING; - return 0; + return FormulaError::NONE; } - sal_uInt16 nErr = 0; + FormulaError nErr = FormulaError::NONE; OUString aStr; SvNumberFormatter* pFormatter = GetFormatTable(); switch (aCell.meType) @@ -3948,7 +3948,7 @@ void ScDocument::CompileXML() SetAutoCalc( bOldAutoCalc ); } -bool ScDocument::CompileErrorCells(sal_uInt16 nErrCode) +bool ScDocument::CompileErrorCells(FormulaError nErrCode) { bool bCompiled = false; sc::CompileFormulaContext aCxt(this); @@ -4000,12 +4000,12 @@ void ScDocument::CalcAfterLoad( bool bStartListening ) } } -sal_uInt16 ScDocument::GetErrCode( const ScAddress& rPos ) const +FormulaError ScDocument::GetErrCode( const ScAddress& rPos ) const { SCTAB nTab = rPos.Tab(); if ( nTab < static_cast<SCTAB>(maTabs.size()) && maTabs[nTab] ) return maTabs[nTab]->GetErrCode( rPos ); - return 0; + return FormulaError::NONE; } void ScDocument::ResetChanged( const ScRange& rRange ) diff --git a/sc/source/core/data/dpcache.cxx b/sc/source/core/data/dpcache.cxx index 85de53846244..25a500c96ff3 100644 --- a/sc/source/core/data/dpcache.cxx +++ b/sc/source/core/data/dpcache.cxx @@ -33,6 +33,7 @@ #include <rtl/math.hxx> #include <unotools/textsearch.hxx> #include <unotools/localedatawrapper.hxx> +#include <formula/errorcodes.hxx> #include <svl/zforlist.hxx> #include <o3tl/make_unique.hxx> @@ -129,7 +130,7 @@ void initFromCell( ScAddress aPos(nCol, nRow, nTab); - if (pDoc->GetErrCode(aPos)) + if (pDoc->GetErrCode(aPos) != FormulaError::NONE) { rData.SetErrorString(rCache.InternString(aDocStr)); } diff --git a/sc/source/core/data/dpoutput.cxx b/sc/source/core/data/dpoutput.cxx index 5d4550df61e2..390aaf67592d 100644 --- a/sc/source/core/data/dpoutput.cxx +++ b/sc/source/core/data/dpoutput.cxx @@ -751,7 +751,7 @@ void ScDPOutput::DataCell( SCCOL nCol, SCROW nRow, SCTAB nTab, const sheet::Data long nFlags = rData.Flags; if ( nFlags & sheet::DataResultFlags::ERROR ) { - pDoc->SetError( nCol, nRow, nTab, formula::errNoValue ); + pDoc->SetError( nCol, nRow, nTab, FormulaError::NoValue ); } else if ( nFlags & sheet::DataResultFlags::HASDATA ) { diff --git a/sc/source/core/data/formulacell.cxx b/sc/source/core/data/formulacell.cxx index 322f0d5180c1..cb4bb4de5340 100644 --- a/sc/source/core/data/formulacell.cxx +++ b/sc/source/core/data/formulacell.cxx @@ -557,7 +557,7 @@ void ScFormulaCellGroup::compileCode( if (!mpCode) return; - if (mpCode->GetLen() && !mpCode->GetCodeError() && !mpCode->GetCodeLen()) + if (mpCode->GetLen() && mpCode->GetCodeError() == FormulaError::NONE && !mpCode->GetCodeLen()) { ScCompiler aComp(&rDoc, rPos, *mpCode); aComp.SetGrammar(eGram); @@ -700,7 +700,7 @@ ScFormulaCell::ScFormulaCell( assert(pArray); // Never pass a NULL pointer here. // Generate RPN token array. - if (pCode->GetLen() && !pCode->GetCodeError() && !pCode->GetCodeLen()) + if (pCode->GetLen() && pCode->GetCodeError() == FormulaError::NONE && !pCode->GetCodeLen()) { ScCompiler aComp( pDocument, aPos, *pCode); aComp.SetGrammar(eTempGrammar); @@ -750,7 +750,7 @@ ScFormulaCell::ScFormulaCell( SAL_INFO( "sc.core.formulacell", "ScFormulaCell ctor this " << this); // RPN array generation - if( pCode->GetLen() && !pCode->GetCodeError() && !pCode->GetCodeLen() ) + if( pCode->GetLen() && pCode->GetCodeError() == FormulaError::NONE && !pCode->GetCodeLen() ) { ScCompiler aComp( pDocument, aPos, *pCode); aComp.SetGrammar(eTempGrammar); @@ -838,9 +838,9 @@ ScFormulaCell::ScFormulaCell(const ScFormulaCell& rCell, ScDocument& rDoc, const // set back any errors and recompile // not in the Clipboard - it must keep the received error flag // Special Length=0: as bad cells are generated, then they are also retained - if ( pCode->GetCodeError() && !pDocument->IsClipboard() && pCode->GetLen() ) + if ( pCode->GetCodeError() != FormulaError::NONE && !pDocument->IsClipboard() && pCode->GetLen() ) { - pCode->SetCodeError( 0 ); + pCode->SetCodeError( FormulaError::NONE ); bCompile = true; } // Compile ColRowNames on URM_MOVE/URM_COPY _after_ UpdateReference ! @@ -975,7 +975,7 @@ ScFormulaVectorState ScFormulaCell::GetVectorState() const void ScFormulaCell::GetFormula( OUStringBuffer& rBuffer, const FormulaGrammar::Grammar eGrammar ) const { - if( pCode->GetCodeError() && !pCode->GetLen() ) + if( pCode->GetCodeError() != FormulaError::NONE && !pCode->GetLen() ) { rBuffer = OUStringBuffer( ScGlobal::GetErrorString( pCode->GetCodeError())); return; @@ -1039,7 +1039,7 @@ void ScFormulaCell::GetFormula( OUString& rFormula, const FormulaGrammar::Gramma OUString ScFormulaCell::GetFormula( sc::CompileFormulaContext& rCxt ) const { OUStringBuffer aBuf; - if (pCode->GetCodeError() && !pCode->GetLen()) + if (pCode->GetCodeError() != FormulaError::NONE && !pCode->GetLen()) { aBuf = OUStringBuffer( ScGlobal::GetErrorString( pCode->GetCodeError())); return aBuf.makeStringAndClear(); @@ -1097,7 +1097,7 @@ void ScFormulaCell::GetResultDimensions( SCSIZE& rCols, SCSIZE& rRows ) MaybeInterpret(); const ScMatrix* pMat = nullptr; - if (!pCode->GetCodeError() && aResult.GetType() == svMatrixCell && + if (pCode->GetCodeError() == FormulaError::NONE && aResult.GetType() == svMatrixCell && ((pMat = aResult.GetToken().get()->GetMatrix()) != nullptr)) pMat->GetDimensions( rCols, rRows ); else @@ -1136,7 +1136,7 @@ void ScFormulaCell::Compile( const OUString& rFormula, bool bNoListening, aComp.SetGrammar(eGrammar); pCode = aComp.CompileString( rFormula ); delete pCodeOld; - if( !pCode->GetCodeError() ) + if( pCode->GetCodeError() == FormulaError::NONE ) { if ( !pCode->GetLen() && !aResult.GetHybridFormula().isEmpty() && rFormula == aResult.GetHybridFormula() ) { // not recursive CompileTokenArray/Compile/CompileTokenArray @@ -1170,7 +1170,7 @@ void ScFormulaCell::Compile( ScCompiler aComp(rCxt, aPos); pCode = aComp.CompileString( rFormula ); delete pCodeOld; - if( !pCode->GetCodeError() ) + if( pCode->GetCodeError() == FormulaError::NONE ) { if ( !pCode->GetLen() && !aResult.GetHybridFormula().isEmpty() && rFormula == aResult.GetHybridFormula() ) { // not recursive CompileTokenArray/Compile/CompileTokenArray @@ -1196,7 +1196,7 @@ void ScFormulaCell::CompileTokenArray( bool bNoListening ) { Compile( aResult.GetHybridFormula(), bNoListening, eTempGrammar); } - else if( bCompile && !pDocument->IsClipOrUndo() && !pCode->GetCodeError() ) + else if( bCompile && !pDocument->IsClipOrUndo() && pCode->GetCodeError() == FormulaError::NONE ) { // RPN length may get changed bool bWasInFormulaTree = pDocument->IsInFormulaTree( this ); @@ -1212,7 +1212,7 @@ void ScFormulaCell::CompileTokenArray( bool bNoListening ) ScCompiler aComp(pDocument, aPos, *pCode); aComp.SetGrammar(pDocument->GetGrammar()); bSubTotal = aComp.CompileTokenArray(); - if( !pCode->GetCodeError() ) + if( pCode->GetCodeError() == FormulaError::NONE ) { nFormatType = aComp.GetNumFormatType(); bChanged = true; @@ -1237,7 +1237,7 @@ void ScFormulaCell::CompileTokenArray( sc::CompileFormulaContext& rCxt, bool bNo rCxt.setGrammar(eTempGrammar); Compile(rCxt, aResult.GetHybridFormula(), bNoListening); } - else if( bCompile && !pDocument->IsClipOrUndo() && !pCode->GetCodeError() ) + else if( bCompile && !pDocument->IsClipOrUndo() && pCode->GetCodeError() == FormulaError::NONE) { // RPN length may get changed bool bWasInFormulaTree = pDocument->IsInFormulaTree( this ); @@ -1252,7 +1252,7 @@ void ScFormulaCell::CompileTokenArray( sc::CompileFormulaContext& rCxt, bool bNo EndListeningTo( pDocument ); ScCompiler aComp(rCxt, aPos, *pCode); bSubTotal = aComp.CompileTokenArray(); - if( !pCode->GetCodeError() ) + if( pCode->GetCodeError() == FormulaError::NONE ) { nFormatType = aComp.GetNumFormatType(); bChanged = true; @@ -1345,7 +1345,7 @@ void ScFormulaCell::CompileXML( sc::CompileFormulaContext& rCxt, ScProgress& rPr pCode = aComp.CompileString( aFormula, aFormulaNmsp ); delete pCodeOld; - if( !pCode->GetCodeError() ) + if( pCode->GetCodeError() == FormulaError::NONE ) { if ( !pCode->GetLen() ) { @@ -1355,7 +1355,7 @@ void ScFormulaCell::CompileXML( sc::CompileFormulaContext& rCxt, ScProgress& rPr pCode->AddBad( aFormula ); } bSubTotal = aComp.CompileTokenArray(); - if( !pCode->GetCodeError() ) + if( pCode->GetCodeError() == FormulaError::NONE ) { nFormatType = aComp.GetNumFormatType(); bChanged = true; @@ -1402,7 +1402,7 @@ void ScFormulaCell::CalcAfterLoad( sc::CompileFormulaContext& rCxt, bool bStartL bNewCompiled = true; } // The RPN array is not created when a Calc 3.0-Doc has been read as the Range Names exist until now. - if( pCode->GetLen() && !pCode->GetCodeLen() && !pCode->GetCodeError() ) + if( pCode->GetLen() && !pCode->GetCodeLen() && pCode->GetCodeError() == FormulaError::NONE ) { ScCompiler aComp(rCxt, aPos, *pCode); bSubTotal = aComp.CompileTokenArray(); @@ -1421,7 +1421,7 @@ void ScFormulaCell::CalcAfterLoad( sc::CompileFormulaContext& rCxt, bool bStartL if ( aResult.IsValue() && !::rtl::math::isFinite( aResult.GetDouble() ) ) { OSL_FAIL("Formula cell INFINITY!!! Where does this document come from?"); - aResult.SetResultError( errIllegalFPOperation ); + aResult.SetResultError( FormulaError::IllegalFPOperation ); bDirty = true; } @@ -1436,7 +1436,7 @@ void ScFormulaCell::CalcAfterLoad( sc::CompileFormulaContext& rCxt, bool bStartL // Do the cells need to be calculated? After Load cells can contain an error code, and then start // the listener and Recalculate (if needed) if not ScRecalcMode::NORMAL - if( !bNewCompiled || !pCode->GetCodeError() ) + if( !bNewCompiled || pCode->GetCodeError() == FormulaError::NONE ) { if (bStartListening) StartListeningTo(pDocument); @@ -1505,12 +1505,12 @@ void ScFormulaCell::Interpret() { if (!pDocument->GetDocOptions().IsIter()) { - aResult.SetResultError( errCircularReference ); + aResult.SetResultError( FormulaError::CircularReference ); return; } - if (aResult.GetResultError() == errCircularReference) - aResult.SetResultError( 0 ); + if (aResult.GetResultError() == FormulaError::CircularReference) + aResult.SetResultError( FormulaError::NONE ); // Start or add to iteration list. if (!pDocument->GetRecursionHelper().IsDoingIteration() || @@ -1684,7 +1684,7 @@ void ScFormulaCell::Interpret() // circular dependency don't, no matter whether // single cells did. pIterCell->ResetDirty(); - pIterCell->aResult.SetResultError( errNoConvergence); + pIterCell->aResult.SetResultError( FormulaError::NoConvergence); pIterCell->bChanged = true; } } @@ -1750,7 +1750,7 @@ void ScFormulaCell::InterpretTail( ScInterpretTailParameter eTailParam ) { RecursionCounter aRecursionCounter( pDocument->GetRecursionHelper(), this); nSeenInIteration = pDocument->GetRecursionHelper().GetIteration(); - if( !pCode->GetCodeLen() && !pCode->GetCodeError() ) + if( !pCode->GetCodeLen() && pCode->GetCodeError() == FormulaError::NONE ) { // #i11719# no RPN and no error and no token code but result string present // => interpretation of this cell during name-compilation and unknown names @@ -1763,7 +1763,7 @@ void ScFormulaCell::InterpretTail( ScInterpretTailParameter eTailParam ) // condition further down. if ( !pCode->GetLen() && !aResult.GetHybridFormula().isEmpty() ) { - pCode->SetCodeError( errNoCode ); + pCode->SetCodeError( FormulaError::NoCode ); // This is worth an assertion; if encountered in daily work // documents we might need another solution. Or just confirm correctness. OSL_FAIL( "ScFormulaCell::Interpret: no RPN, no error, no token, but hybrid formula string" ); @@ -1791,20 +1791,21 @@ void ScFormulaCell::InterpretTail( ScInterpretTailParameter eTailParam ) pDocument->IncInterpretLevel(); ScInterpreter* p = new ScInterpreter( this, pDocument, aPos, *pCode ); StackCleaner aStackCleaner( pDocument, p); - sal_uInt16 nOldErrCode = aResult.GetResultError(); + FormulaError nOldErrCode = aResult.GetResultError(); if ( nSeenInIteration == 0 ) { // Only the first time // With bChanged=false, if a newly compiled cell has a result of // 0.0, no change is detected and the cell will not be repainted. // bChanged = false; - aResult.SetResultError( 0 ); + aResult.SetResultError( FormulaError::NONE ); } switch ( aResult.GetResultError() ) { - case errCircularReference : // will be determined again if so - aResult.SetResultError( 0 ); + case FormulaError::CircularReference : // will be determined again if so + aResult.SetResultError( FormulaError::NONE ); break; + default: break; } bool bOldRunning = bRunning; @@ -1823,20 +1824,20 @@ void ScFormulaCell::InterpretTail( ScInterpretTailParameter eTailParam ) bool bContentChanged = false; // Do not create a HyperLink() cell if the formula results in an error. - if( p->GetError() && pCode->IsHyperLink()) + if( p->GetError() != FormulaError::NONE && pCode->IsHyperLink()) pCode->SetHyperLink(false); - if( p->GetError() && p->GetError() != errCircularReference) + if( p->GetError() != FormulaError::NONE && p->GetError() != FormulaError::CircularReference) { bChanged = true; - if (p->GetError() == errRetryCircular) + if (p->GetError() == FormulaError::RetryCircular) { // Array formula matrix calculation corner case. Keep dirty // state, do not remove from formula tree or anything else, but - // store errCircularReference in case this cell does not get + // store FormulaError::CircularReference in case this cell does not get // recalculated. - aResult.SetResultError( errCircularReference); + aResult.SetResultError( FormulaError::CircularReference); return; } @@ -2068,7 +2069,7 @@ void ScFormulaCell::InterpretTail( ScInterpretTailParameter eTailParam ) } // Precision as shown? - if ( aResult.IsValue() && !p->GetError() + if ( aResult.IsValue() && p->GetError() == FormulaError::NONE && pDocument->GetDocOptions().IsCalcAsShown() && nFormatType != css::util::NumberFormat::DATE && nFormatType != css::util::NumberFormat::TIME @@ -2092,7 +2093,7 @@ void ScFormulaCell::InterpretTail( ScInterpretTailParameter eTailParam ) if ( aResult.IsValue() && !::rtl::math::isFinite( aResult.GetDouble() ) ) { // Coded double error may occur via filter import. - sal_uInt16 nErr = GetDoubleErrorValue( aResult.GetDouble()); + FormulaError nErr = GetDoubleErrorValue( aResult.GetDouble()); aResult.SetResultError( nErr); bChanged = bContentChanged = true; } @@ -2162,7 +2163,7 @@ void ScFormulaCell::InterpretTail( ScInterpretTailParameter eTailParam ) else { // Cells with compiler errors should not be marked dirty forever - OSL_ENSURE( pCode->GetCodeError(), "no RPN code und no errors ?!?!" ); + OSL_ENSURE( pCode->GetCodeError() != FormulaError::NONE, "no RPN code and no errors ?!?!" ); ResetDirty(); } } @@ -2427,7 +2428,7 @@ void ScFormulaCell::SetResultMatrix( SCCOL nCols, SCROW nRows, const ScConstMatr aResult.SetMatrix(nCols, nRows, pMat, pUL); } -void ScFormulaCell::SetErrCode( sal_uInt16 n ) +void ScFormulaCell::SetErrCode( FormulaError n ) { /* FIXME: check the numerous places where ScTokenArray::GetCodeError() is * used whether it is solely for transport of a simple result error and get @@ -2439,7 +2440,7 @@ void ScFormulaCell::SetErrCode( sal_uInt16 n ) aResult.SetResultError( n ); } -void ScFormulaCell::SetResultError( sal_uInt16 n ) +void ScFormulaCell::SetResultError( FormulaError n ) { aResult.SetResultError( n ); } @@ -2576,7 +2577,7 @@ bool ScFormulaCell::IsValue() bool ScFormulaCell::IsValueNoError() { MaybeInterpret(); - if (pCode->GetCodeError()) + if (pCode->GetCodeError() != FormulaError::NONE) return false; return aResult.IsValueNoError(); @@ -2588,7 +2589,7 @@ bool ScFormulaCell::IsValueNoError() const // false if the cell is dirty & needs to be interpreted. return false; - if (pCode->GetCodeError()) + if (pCode->GetCodeError() != FormulaError::NONE) return false; return aResult.IsValueNoError(); @@ -2602,8 +2603,8 @@ bool ScFormulaCell::IsHybridValueCell() double ScFormulaCell::GetValue() { MaybeInterpret(); - if ((!pCode->GetCodeError() || pCode->GetCodeError() == errDoubleRef) && - !aResult.GetResultError()) + if ((pCode->GetCodeError() == FormulaError::NONE || pCode->GetCodeError() == FormulaError::DoubleRef) && + aResult.GetResultError() == FormulaError::NONE) return aResult.GetDouble(); return 0.0; } @@ -2611,8 +2612,8 @@ double ScFormulaCell::GetValue() svl::SharedString ScFormulaCell::GetString() { MaybeInterpret(); - if ((!pCode->GetCodeError() || pCode->GetCodeError() == errDoubleRef) && - !aResult.GetResultError()) + if ((pCode->GetCodeError() == FormulaError::NONE || pCode->GetCodeError() == FormulaError::DoubleRef) && + aResult.GetResultError() == FormulaError::NONE) return aResult.GetString(); return svl::SharedString::getEmptyString(); @@ -2780,33 +2781,33 @@ sc::MatrixEdge ScFormulaCell::GetMatrixEdge( ScAddress& rOrgPos ) const } } -sal_uInt16 ScFormulaCell::GetErrCode() +FormulaError ScFormulaCell::GetErrCode() { MaybeInterpret(); /* FIXME: If ScTokenArray::SetCodeError() was really only for code errors * and not also abused for signaling other error conditions we could bail * out even before attempting to interpret broken code. */ - sal_uInt16 nErr = pCode->GetCodeError(); - if (nErr) + FormulaError nErr = pCode->GetCodeError(); + if (nErr != FormulaError::NONE) return nErr; return aResult.GetResultError(); } -sal_uInt16 ScFormulaCell::GetRawError() +FormulaError ScFormulaCell::GetRawError() { - sal_uInt16 nErr = pCode->GetCodeError(); - if (nErr) + FormulaError nErr = pCode->GetCodeError(); + if (nErr != FormulaError::NONE) return nErr; return aResult.GetResultError(); } -bool ScFormulaCell::GetErrorOrValue( sal_uInt16& rErr, double& rVal ) +bool ScFormulaCell::GetErrorOrValue( FormulaError& rErr, double& rVal ) { MaybeInterpret(); rErr = pCode->GetCodeError(); - if (rErr) + if (rErr != FormulaError::NONE) return true; return aResult.GetErrorOrDouble(rErr, rVal); @@ -2816,8 +2817,8 @@ sc::FormulaResultValue ScFormulaCell::GetResult() { MaybeInterpret(); - sal_uInt16 nErr = pCode->GetCodeError(); - if (nErr) + FormulaError nErr = pCode->GetCodeError(); + if (nErr != FormulaError::NONE) return sc::FormulaResultValue(nErr); return aResult.GetResult(); @@ -2825,8 +2826,8 @@ sc::FormulaResultValue ScFormulaCell::GetResult() sc::FormulaResultValue ScFormulaCell::GetResult() const { - sal_uInt16 nErr = pCode->GetCodeError(); - if (nErr) + FormulaError nErr = pCode->GetCodeError(); + if (nErr != FormulaError::NONE) return sc::FormulaResultValue(nErr); return aResult.GetResult(); @@ -3539,7 +3540,7 @@ void ScFormulaCell::UpdateCompile( bool bForceIfNameInUse ) if ( bForceIfNameInUse && !bCompile ) bCompile = pCode->HasNameOrColRowName(); if ( bCompile ) - pCode->SetCodeError( 0 ); // make sure it will really be compiled + pCode->SetCodeError( FormulaError::NONE ); // make sure it will really be compiled CompileTokenArray(); } diff --git a/sc/source/core/data/global.cxx b/sc/source/core/data/global.cxx index 2605f9835788..9966874e313d 100644 --- a/sc/source/core/data/global.cxx +++ b/sc/source/core/data/global.cxx @@ -355,118 +355,111 @@ const OUString& ScGlobal::GetRscString( sal_uInt16 nIndex ) return *ppRscString[ nIndex ]; } -OUString ScGlobal::GetErrorString(sal_uInt16 nErrNumber) +OUString ScGlobal::GetErrorString(FormulaError nErr) { - OUString sResStr; - switch (nErrNumber) + sal_uInt16 nErrNumber; + switch (nErr) { - case formula::NOTAVAILABLE : nErrNumber = STR_NV_STR; break; - case formula::errNoRef : nErrNumber = STR_NO_REF_TABLE; break; - case formula::errNoName : nErrNumber = STR_NO_NAME_REF; break; - case formula::errNoAddin : nErrNumber = STR_NO_ADDIN; break; - case formula::errNoMacro : nErrNumber = STR_NO_MACRO; break; - case formula::errDoubleRef : - case formula::errNoValue : nErrNumber = STR_NO_VALUE; break; - case formula::errNoCode : nErrNumber = STR_NULL_ERROR; break; - case formula::errDivisionByZero : nErrNumber = STR_DIV_ZERO; break; - case formula::errIllegalFPOperation : nErrNumber = STR_NUM_ERROR; break; - - default : sResStr = GetRscString(STR_ERROR_STR) + OUString::number( nErrNumber ); - nErrNumber = 0; - break; + case FormulaError::NotAvailable : nErrNumber = STR_NV_STR; break; + case FormulaError::NoRef : nErrNumber = STR_NO_REF_TABLE; break; + case FormulaError::NoName : nErrNumber = STR_NO_NAME_REF; break; + case FormulaError::NoAddin : nErrNumber = STR_NO_ADDIN; break; + case FormulaError::NoMacro : nErrNumber = STR_NO_MACRO; break; + case FormulaError::DoubleRef : + case FormulaError::NoValue : nErrNumber = STR_NO_VALUE; break; + case FormulaError::NoCode : nErrNumber = STR_NULL_ERROR; break; + case FormulaError::DivisionByZero : nErrNumber = STR_DIV_ZERO; break; + case FormulaError::IllegalFPOperation : nErrNumber = STR_NUM_ERROR; break; + + default : return GetRscString(STR_ERROR_STR) + OUString::number( (int)nErr ); } - if( nErrNumber ) - sResStr = GetRscString( nErrNumber ); - return sResStr; + return GetRscString( nErrNumber ); } -OUString ScGlobal::GetLongErrorString(sal_uInt16 nErrNumber) +OUString ScGlobal::GetLongErrorString(FormulaError nErr) { - switch (nErrNumber) + sal_uInt16 nErrNumber; + switch (nErr) { - case 0: + case FormulaError::NONE: + nErrNumber = 0; break; - case 1: - case formula::errIllegalArgument: + case FormulaError::IllegalArgument: nErrNumber = STR_LONG_ERR_ILL_ARG; break; - case 2: - case 3: - case 4: - case 5: - case formula::errIllegalFPOperation: + case FormulaError::IllegalFPOperation: nErrNumber = STR_LONG_ERR_ILL_FPO; break; - case formula::errIllegalChar: + case FormulaError::IllegalChar: nErrNumber = STR_LONG_ERR_ILL_CHAR; break; - case formula::errIllegalParameter: + case FormulaError::IllegalParameter: nErrNumber = STR_LONG_ERR_ILL_PAR; break; - case formula::errSeparator: + case FormulaError::Separator: nErrNumber = STR_LONG_ERR_ILL_SEP; break; - case formula::errPair: - case formula::errPairExpected: + case FormulaError::Pair: + case FormulaError::PairExpected: nErrNumber = STR_LONG_ERR_PAIR; break; - case formula::errOperatorExpected: + case FormulaError::OperatorExpected: nErrNumber = STR_LONG_ERR_OP_EXP; break; - case formula::errVariableExpected: - case formula::errParameterExpected: + case FormulaError::VariableExpected: + case FormulaError::ParameterExpected: nErrNumber = STR_LONG_ERR_VAR_EXP; break; - case formula::errCodeOverflow: + case FormulaError::CodeOverflow: nErrNumber = STR_LONG_ERR_CODE_OVF; break; - case formula::errStringOverflow: + case FormulaError::StringOverflow: nErrNumber = STR_LONG_ERR_STR_OVF; break; - case formula::errStackOverflow: + case FormulaError::StackOverflow: nErrNumber = STR_LONG_ERR_STACK_OVF; break; - case formula::errMatrixSize: + case FormulaError::MatrixSize: nErrNumber = STR_LONG_ERR_MATRIX_SIZE; break; - case formula::errIllegalJump: - case formula::errUnknownState: - case formula::errUnknownVariable: - case formula::errUnknownOpCode: - case formula::errUnknownStackVariable: - case formula::errUnknownToken: - case formula::errNoCode: - case formula::errDoubleRef: + case FormulaError::IllegalJump: + case FormulaError::UnknownState: + case FormulaError::UnknownVariable: + case FormulaError::UnknownOpCode: + case FormulaError::UnknownStackVariable: + case FormulaError::UnknownToken: + case FormulaError::NoCode: + case FormulaError::DoubleRef: nErrNumber = STR_LONG_ERR_SYNTAX; break; - case formula::errCircularReference: + case FormulaError::CircularReference: nErrNumber = STR_LONG_ERR_CIRC_REF; break; - case formula::errNoConvergence: + case FormulaError::NoConvergence: nErrNumber = STR_LONG_ERR_NO_CONV; break; - case formula::errNoRef: + case FormulaError::NoRef: nErrNumber = STR_LONG_ERR_NO_REF; break; - case formula::errNoName: + case FormulaError::NoName: nErrNumber = STR_LONG_ERR_NO_NAME; break; - case formula::errNoAddin: + case FormulaError::NoAddin: nErrNumber = STR_LONG_ERR_NO_ADDIN; break; - case formula::errNoMacro: + case FormulaError::NoMacro: nErrNumber = STR_LONG_ERR_NO_MACRO; break; - case formula::errDivisionByZero: + case FormulaError::DivisionByZero: nErrNumber = STR_LONG_ERR_DIV_ZERO; break; - case formula::errNestedArray: + case FormulaError::NestedArray: nErrNumber = STR_ERR_LONG_NESTED_ARRAY; break; - case formula::errNoValue: + case FormulaError::NoValue: nErrNumber = STR_LONG_ERR_NO_VALUE; break; - case formula::NOTAVAILABLE: + case FormulaError::NotAvailable: nErrNumber = STR_LONG_ERR_NV; break; default: diff --git a/sc/source/core/data/global2.cxx b/sc/source/core/data/global2.cxx index 5be7bf0f9272..b4b189b60de7 100644 --- a/sc/source/core/data/global2.cxx +++ b/sc/source/core/data/global2.cxx @@ -378,14 +378,14 @@ bool isEmptyString( const OUString& rStr ) } double ScGlobal::ConvertStringToValue( const OUString& rStr, const ScCalcConfig& rConfig, - sal_uInt16 & rError, sal_uInt16 nStringNoValueError, + FormulaError & rError, FormulaError nStringNoValueError, SvNumberFormatter* pFormatter, short & rCurFmtType ) { // We keep ScCalcConfig::StringConversion::LOCALE default until // we provide a friendly way to convert string numbers into numbers in the UI. double fValue = 0.0; - if (nStringNoValueError == formula::errCellNoValue) + if (nStringNoValueError == FormulaError::CellNoValue) { // Requested that all strings result in 0, error handled by caller. rError = nStringNoValueError; @@ -482,7 +482,7 @@ Label_fallback_to_unambiguous: if (p < pStop && !rtl::isAsciiDigit(*p)) rError = nStringNoValueError; p = pLastStart; - while (p < pStop && !rError && eState < blank) + while (p < pStop && rError == FormulaError::NONE && eState < blank) { if (eState == minute) rCurFmtType |= css::util::NumberFormat::TIME; @@ -563,7 +563,7 @@ Label_fallback_to_unambiguous: eState == hour || (eState == minute && p <= pLastStart)) rError = nStringNoValueError; - if (!rError) + if (rError == FormulaError::NONE) { // Catch the very last unit at end of string. if (p > pLastStart && eState < done) @@ -574,7 +574,7 @@ Label_fallback_to_unambiguous: } if (bDate && nUnit[hour] > 23) rError = nStringNoValueError; - if (!rError) + if (rError == FormulaError::NONE) { if (bDate && nUnit[day] == 0) nUnit[day] = 1; @@ -611,7 +611,7 @@ Label_fallback_to_unambiguous: default: rError = nStringNoValueError; } - if (rError) + if (rError != FormulaError::NONE) fValue = 0.0; } return fValue; diff --git a/sc/source/core/data/simpleformulacalc.cxx b/sc/source/core/data/simpleformulacalc.cxx index df2755f41280..6a64dcfd1c81 100644 --- a/sc/source/core/data/simpleformulacalc.cxx +++ b/sc/source/core/data/simpleformulacalc.cxx @@ -31,7 +31,7 @@ ScSimpleFormulaCalculator::ScSimpleFormulaCalculator( ScDocument* pDoc, const Sc ScCompiler aComp(mpDoc, maAddr); aComp.SetGrammar(eGram); mpCode.reset(aComp.CompileString(rFormula)); - if(!mpCode->GetCodeError() && mpCode->GetLen()) + if(mpCode->GetCodeError() == FormulaError::NONE && mpCode->GetLen()) aComp.CompileTokenArray(); } @@ -99,12 +99,12 @@ bool ScSimpleFormulaCalculator::IsMatrix() return mbMatrixResult; } -sal_uInt16 ScSimpleFormulaCalculator::GetErrCode() +FormulaError ScSimpleFormulaCalculator::GetErrCode() { Calculate(); - sal_uInt16 nErr = mpCode->GetCodeError(); - if (nErr) + FormulaError nErr = mpCode->GetCodeError(); + if (nErr != FormulaError::NONE) return nErr; return maResult.GetResultError(); } @@ -113,8 +113,8 @@ double ScSimpleFormulaCalculator::GetValue() { Calculate(); - if ((!mpCode->GetCodeError() || mpCode->GetCodeError() == formula::errDoubleRef) && - !maResult.GetResultError()) + if ((mpCode->GetCodeError() == FormulaError::NONE || mpCode->GetCodeError() == FormulaError::DoubleRef) && + maResult.GetResultError() == FormulaError::NONE) return maResult.GetDouble(); return 0.0; @@ -127,8 +127,8 @@ svl::SharedString ScSimpleFormulaCalculator::GetString() if (mbMatrixResult) return svl::SharedString( maMatrixFormulaResult); // string not interned - if ((!mpCode->GetCodeError() || mpCode->GetCodeError() == formula::errDoubleRef) && - !maResult.GetResultError()) + if ((mpCode->GetCodeError() == FormulaError::NONE || mpCode->GetCodeError() == FormulaError::DoubleRef) && + maResult.GetResultError() == FormulaError::NONE) return maResult.GetString(); return svl::SharedString::getEmptyString(); diff --git a/sc/source/core/data/table2.cxx b/sc/source/core/data/table2.cxx index ef1a0ce327ce..341eeea0b864 100644 --- a/sc/source/core/data/table2.cxx +++ b/sc/source/core/data/table2.cxx @@ -1815,7 +1815,7 @@ void ScTable::CompileXML( sc::CompileFormulaContext& rCxt, ScProgress& rProgress mpCondFormatList->CompileXML(); } -bool ScTable::CompileErrorCells( sc::CompileFormulaContext& rCxt, sal_uInt16 nErrCode ) +bool ScTable::CompileErrorCells( sc::CompileFormulaContext& rCxt, FormulaError nErrCode ) { bool bCompiled = false; for (SCCOL i = 0; i <= MAXCOL; ++i) diff --git a/sc/source/core/data/table3.cxx b/sc/source/core/data/table3.cxx index 355978ad19cc..158686e9fbcf 100644 --- a/sc/source/core/data/table3.cxx +++ b/sc/source/core/data/table3.cxx @@ -2267,7 +2267,7 @@ public: if (!rCell.isEmpty()) { - if (rCell.meType == CELLTYPE_FORMULA && rCell.mpFormula->GetErrCode()) + if (rCell.meType == CELLTYPE_FORMULA && rCell.mpFormula->GetErrCode() != FormulaError::NONE) // Error values are compared as string. return false; @@ -2392,7 +2392,7 @@ public: if (!rCell.isEmpty()) { - if (rCell.meType == CELLTYPE_FORMULA && rCell.mpFormula->GetErrCode()) + if (rCell.meType == CELLTYPE_FORMULA && rCell.mpFormula->GetErrCode() != FormulaError::NONE) { // Error cell is evaluated as string (for now). aCellStr = mrStrPool.intern(ScGlobal::GetErrorString(rCell.mpFormula->GetErrCode())); @@ -2590,7 +2590,7 @@ public: { if (rItem.meType == ScQueryEntry::ByString) { - if (rCell.meType == CELLTYPE_FORMULA && rCell.mpFormula->GetErrCode()) + if (rCell.meType == CELLTYPE_FORMULA && rCell.mpFormula->GetErrCode() != FormulaError::NONE) // Error values are compared as string. return std::pair<bool,bool>(false, bTestEqual); diff --git a/sc/source/core/data/table4.cxx b/sc/source/core/data/table4.cxx index 52df776be131..5ed7af8e19a2 100644 --- a/sc/source/core/data/table4.cxx +++ b/sc/source/core/data/table4.cxx @@ -1732,9 +1732,9 @@ void ScTable::FillSeries( SCCOL nCol1, SCROW nRow1, SCCOL nCol2, SCROW nRow2, } if (bError) - aCol[nCol].SetError(static_cast<SCROW>(nRow), formula::errNoValue); + aCol[nCol].SetError(static_cast<SCROW>(nRow), FormulaError::NoValue); else if (bOverflow) - aCol[nCol].SetError(static_cast<SCROW>(nRow), formula::errIllegalFPOperation); + aCol[nCol].SetError(static_cast<SCROW>(nRow), FormulaError::IllegalFPOperation); else aCol[nCol].SetValue(static_cast<SCROW>(nRow), nVal); } @@ -1834,9 +1834,9 @@ void ScTable::FillSeries( SCCOL nCol1, SCROW nRow1, SCCOL nCol2, SCROW nRow2, } if (bError) - aCol[nCol].SetError(static_cast<SCROW>(nRow), formula::errNoValue); + aCol[nCol].SetError(static_cast<SCROW>(nRow), FormulaError::NoValue); else if (bOverflow) - aCol[nCol].SetError(static_cast<SCROW>(nRow), formula::errIllegalFPOperation); + aCol[nCol].SetError(static_cast<SCROW>(nRow), FormulaError::IllegalFPOperation); else { nStringValue = (sal_Int32)nVal; @@ -2183,7 +2183,7 @@ void ScTable::GetAutoFormatData(SCCOL nStartCol, SCROW nStartRow, SCCOL nEndCol, } } -void ScTable::SetError( SCCOL nCol, SCROW nRow, sal_uInt16 nError) +void ScTable::SetError( SCCOL nCol, SCROW nRow, FormulaError nError) { if (ValidColRow(nCol, nRow)) aCol[nCol].SetError( nRow, nError ); diff --git a/sc/source/core/data/validat.cxx b/sc/source/core/data/validat.cxx index 2a6f8c572b34..46971e08ac8e 100644 --- a/sc/source/core/data/validat.cxx +++ b/sc/source/core/data/validat.cxx @@ -645,8 +645,8 @@ bool ScValidationData::GetSelectionFromFormula( // Use an interim matrix to create the TypedStrData below. xMatRef = new ScFullMatrix(1, 1, 0.0); - sal_uInt16 nErrCode = aValidationSrc.GetErrCode(); - if (nErrCode) + FormulaError nErrCode = aValidationSrc.GetErrCode(); + if (nErrCode != FormulaError::NONE) { /* TODO : to use later in an alert box? * OUString rStrResult = "..."; @@ -750,9 +750,9 @@ bool ScValidationData::GetSelectionFromFormula( } else { - sal_uInt16 nErr = nMatVal.GetError(); + FormulaError nErr = nMatVal.GetError(); - if( 0 != nErr ) + if( FormulaError::NONE != nErr ) { aValStr = ScGlobal::GetErrorString( nErr ); } diff --git a/sc/source/core/inc/doubleref.hxx b/sc/source/core/inc/doubleref.hxx index da6bfa3f9117..b4a94897fa54 100644 --- a/sc/source/core/inc/doubleref.hxx +++ b/sc/source/core/inc/doubleref.hxx @@ -30,6 +30,7 @@ class ScDocument; struct ScDBQueryParamBase; struct ScQueryParamBase; +enum class FormulaError : sal_uInt16; /** * Base class for abstracting range data backends for database functions. @@ -71,7 +72,7 @@ public: * @return 0-based column index */ virtual SCCOL findFieldColumn(SCCOL nIndex) const = 0; - virtual SCCOL findFieldColumn(const OUString& rStr, sal_uInt16* pErr = nullptr) const = 0; + virtual SCCOL findFieldColumn(const OUString& rStr, FormulaError* pErr = nullptr) const = 0; virtual std::unique_ptr<ScDBQueryParamBase> createQueryParam(const ScDBRangeBase* pQueryRef) const = 0; virtual bool isRangeEqual(const ScRange& rRange) const = 0; @@ -122,7 +123,7 @@ public: * @return 0-based column index */ virtual SCCOL findFieldColumn(SCCOL nIndex) const override; - virtual SCCOL findFieldColumn(const OUString& rStr, sal_uInt16* pErr = nullptr) const override; + virtual SCCOL findFieldColumn(const OUString& rStr, FormulaError* pErr = nullptr) const override; virtual std::unique_ptr<ScDBQueryParamBase> createQueryParam(const ScDBRangeBase* pQueryRef) const override; virtual bool isRangeEqual(const ScRange& rRange) const override; @@ -162,7 +163,7 @@ public: * @return 0-based column index */ virtual SCCOL findFieldColumn(SCCOL nIndex) const override; - virtual SCCOL findFieldColumn(const OUString& rStr, sal_uInt16* pErr = nullptr) const override; + virtual SCCOL findFieldColumn(const OUString& rStr, FormulaError* pErr = nullptr) const override; virtual std::unique_ptr<ScDBQueryParamBase> createQueryParam(const ScDBRangeBase* pQueryRef) const override; virtual bool isRangeEqual(const ScRange& rRange) const override; diff --git a/sc/source/core/inc/interpre.hxx b/sc/source/core/inc/interpre.hxx index 296ad4be9b53..f4ea691457f1 100644 --- a/sc/source/core/inc/interpre.hxx +++ b/sc/source/core/inc/interpre.hxx @@ -157,7 +157,7 @@ public: */ static utl::SearchParam::SearchType DetectSearchType( const OUString& rStr, const ScDocument* pDoc ); - /// Fail safe division, returning an errDivisionByZero coded into a double + /// Fail safe division, returning an FormulaError::DivisionByZero coded into a double /// if denominator is 0.0 static inline double div( const double& fNumerator, const double& fDenominator ); @@ -195,7 +195,7 @@ private: pCur; // current token ScTokenStack* pStackObj; // contains the stacks const formula::FormulaToken ** pStack; // the current stack - sal_uInt16 nGlobalError; // global (local to this formula expression) error + FormulaError nGlobalError; // global (local to this formula expression) error sal_uInt16 sp; // stack pointer sal_uInt16 maxsp; // the maximal used stack pointer sal_uLong nFuncFmtIndex; // NumberFormatIndex of a function @@ -204,7 +204,7 @@ private: short nFuncFmtType; // NumberFormatType of a function short nCurFmtType; // current NumberFormatType short nRetFmtType; // NumberFormatType of an expression - sal_uInt16 mnStringNoValueError; // the error set in ConvertStringToValue() if no value + FormulaError mnStringNoValueError; // the error set in ConvertStringToValue() if no value sal_uInt16 mnSubTotalFlags; // flags for subtotal and aggregate functions sal_uInt8 cPar; // current count of parameters bool bCalcAsShown; // precision as shown @@ -235,13 +235,13 @@ double ConvertStringToValue( const OUString& ); public: /** For matrix back calls into the current interpreter. Uses rError instead of nGlobalError and rCurFmtType instead of nCurFmtType. */ -double ConvertStringToValue( const OUString&, sal_uInt16& rError, short& rCurFmtType ); +double ConvertStringToValue( const OUString&, FormulaError& rError, short& rCurFmtType ); private: double GetCellValue( const ScAddress&, ScRefCellValue& rCell ); double GetCellValueOrZero( const ScAddress&, ScRefCellValue& rCell ); double GetValueCellValue( const ScAddress&, double fOrig ); void GetCellString( svl::SharedString& rStr, ScRefCellValue& rCell ); -static sal_uInt16 GetCellErrCode( const ScRefCellValue& rCell ); +static FormulaError GetCellErrCode( const ScRefCellValue& rCell ); bool CreateDoubleArr(SCCOL nCol1, SCROW nRow1, SCTAB nTab1, SCCOL nCol2, SCROW nRow2, SCTAB nTab2, sal_uInt8* pCellArr); @@ -267,7 +267,7 @@ void PushWithoutError( const formula::FormulaToken& r ); Increments RefCount of the original token if not substituted. ATTENTION! The token had to be allocated with `new' and must not be used after this call if no RefCount was set because possibly it gets immediately - deleted in case of an errStackOverflow or if substituted with formula::FormulaErrorToken! */ + deleted in case of an FormulaError::StackOverflow or if substituted with formula::FormulaErrorToken! */ void PushTempToken( formula::FormulaToken* ); /** Pushes the token or substitutes with formula::FormulaErrorToken in case @@ -280,7 +280,7 @@ void PushTokenRef( const formula::FormulaConstTokenRef& ); explicit formula::FormulaErrorToken. Increments RefCount. ATTENTION! The token had to be allocated with `new' and must not be used after this call if no RefCount was set because possibly it gets immediately - decremented again and thus deleted in case of an errStackOverflow! */ + decremented again and thus deleted in case of an FormulaError::StackOverflow! */ void PushTempTokenWithoutError( const formula::FormulaToken* ); /** If nGlobalError is set push formula::FormulaErrorToken. @@ -289,7 +289,7 @@ void PushTempTokenWithoutError( const formula::FormulaToken* ); @return: <TRUE/> if nGlobalError. */ inline bool IfErrorPushError() { - if (nGlobalError) + if (nGlobalError != FormulaError::NONE) { PushTempTokenWithoutError( new formula::FormulaErrorToken( nGlobalError)); return true; @@ -395,7 +395,7 @@ void PushSingleRef( const ScRefAddress& rRef ); void PushDoubleRef( const ScRefAddress& rRef1, const ScRefAddress& rRef2 ); void PushMatrix( const sc::RangeMatrix& rMat ); void PushMatrix(const ScMatrixRef& pMat); -void PushError( sal_uInt16 nError ); +void PushError( FormulaError nError ); /// Raw stack type without default replacements. formula::StackVar GetRawStackType(); /// Stack type with replacement of defaults, e.g. svMissing and formula::svEmptyCell will result in formula::svDouble. @@ -651,7 +651,7 @@ void ScExternal(); void ScMissing(); void ScMacro(); bool SetSbxVariable( SbxVariable* pVar, const ScAddress& ); -sal_uInt16 GetErrorType(); +FormulaError GetErrorType(); void ScErrorType(); void ScErrorType_ODF(); void ScDBArea(); @@ -689,9 +689,9 @@ void ScGetWeekOfYear(); void ScGetIsoWeekOfYear(); void ScWeeknumOOo(); void ScEasterSunday(); -sal_uInt16 GetWeekendAndHolidayMasks( const sal_uInt8 nParamCount, const sal_uInt32 nNullDate, +FormulaError GetWeekendAndHolidayMasks( const sal_uInt8 nParamCount, const sal_uInt32 nNullDate, ::std::vector<double>& rSortArray, bool bWeekendMask[ 7 ] ); -sal_uInt16 GetWeekendAndHolidayMasks_MS( const sal_uInt8 nParamCount, const sal_uInt32 nNullDate, +FormulaError GetWeekendAndHolidayMasks_MS( const sal_uInt8 nParamCount, const sal_uInt32 nNullDate, ::std::vector<double>& rSortArray, bool bWeekendMask[ 7 ], bool bWorkdayFunction ); static inline sal_Int16 GetDayOfWeek( sal_Int32 n ); void ScNetWorkdays( bool bOOXML_Version ); @@ -965,14 +965,14 @@ public: formula::StackVar Interpret(); - void SetError(sal_uInt16 nError) - { if (nError && !nGlobalError) nGlobalError = nError; } + void SetError(FormulaError nError) + { if (nError != FormulaError::NONE && nGlobalError == FormulaError::NONE) nGlobalError = nError; } void AssertFormulaMatrix(); void SetLinkManager(sfx2::LinkManager* pLinkMgr) { mpLinkManager = pLinkMgr; } - sal_uInt16 GetError() const { return nGlobalError; } + FormulaError GetError() const { return nGlobalError; } formula::StackVar GetResultType() const { return xResult->GetType(); } svl::SharedString GetStringResult() const; double GetNumResult() const { return xResult->GetDouble(); } @@ -1066,7 +1066,7 @@ inline bool ScInterpreter::CheckStringResultLen( OUString& rResult, const OUStri { if ( rResult.getLength() + rAdd.getLength() > SAL_MAX_UINT16 ) { - SetError( formula::errStringOverflow ); + SetError( FormulaError::StringOverflow ); rResult.clear(); return false; } @@ -1077,11 +1077,11 @@ inline void ScInterpreter::TreatDoubleError( double& rVal ) { if ( !::rtl::math::isFinite( rVal ) ) { - sal_uInt16 nErr = formula::GetDoubleErrorValue( rVal ); - if ( nErr ) + FormulaError nErr = GetDoubleErrorValue( rVal ); + if ( nErr != FormulaError::NONE ) SetError( nErr ); else - SetError( formula::errNoValue ); + SetError( FormulaError::NoValue ); rVal = 0.0; } } diff --git a/sc/source/core/opencl/formulagroupcl.cxx b/sc/source/core/opencl/formulagroupcl.cxx index e5f0a1ecc63f..862b73ab20ea 100644 --- a/sc/source/core/opencl/formulagroupcl.cxx +++ b/sc/source/core/opencl/formulagroupcl.cxx @@ -36,9 +36,9 @@ static const char* publicFunc = "\n" - "#define errIllegalFPOperation 503 // #NUM!\n" - "#define errNoValue 519 // #VALUE!\n" - "#define errDivisionByZero 532 // #DIV/0!\n" + "#define FormulaError::IllegalFPOperation 503 // #NUM!\n" + "#define FormulaError::NoValue 519 // #VALUE!\n" + "#define FormulaError::DivisionByZero 532 // #DIV/0!\n" "#define NOTAVAILABLE 0x7fff // #N/A\n" "\n" "double CreateDoubleError(ulong nErr)\n" @@ -51,9 +51,9 @@ static const char* publicFunc = " if (isfinite(fVal))\n" " return 0;\n" " if (isinf(fVal))\n" - " return errIllegalFPOperation; // normal INF\n" + " return FormulaError::IllegalFPOperation; // normal INF\n" " if (as_ulong(fVal) & 0XFFFF0000u)\n" - " return errNoValue; // just a normal NAN\n" + " return FormulaError::NoValue; // just a normal NAN\n" " return (as_ulong(fVal) & 0XFFFF); // any other error\n" "}\n" "\n" @@ -1763,7 +1763,7 @@ public: if (isAverage()) ss << "if (nCount==0)\n" - " return CreateDoubleError(errDivisionByZero);\n"; + " return CreateDoubleError(FormulaError::DivisionByZero);\n"; else if (isMinOrMax()) ss << "if (nCount==0)\n" @@ -2157,7 +2157,7 @@ public: virtual std::string GetBottom() override { return "1.0"; } virtual std::string Gen2( const std::string& lhs, const std::string& rhs ) const override { - return "(" + rhs + "==0 ? CreateDoubleError(errDivisionByZero) : (" + lhs + "/" + rhs + ") )"; + return "(" + rhs + "==0 ? CreateDoubleError(FormulaError::DivisionByZero) : (" + lhs + "/" + rhs + ") )"; } virtual std::string BinFuncName() const override { return "fdiv"; } @@ -2167,7 +2167,7 @@ public: { ss << "if (isnan(" << vSubArguments[argno]->GenSlidingWindowDeclRef() << ")) {\n" - " return CreateDoubleError(errDivisionByZero);\n" + " return CreateDoubleError(FormulaError::DivisionByZero);\n" "}\n"; return true; } diff --git a/sc/source/core/opencl/op_statistical.cxx b/sc/source/core/opencl/op_statistical.cxx index ebb35d4df08d..203b54810a0a 100644 --- a/sc/source/core/opencl/op_statistical.cxx +++ b/sc/source/core/opencl/op_statistical.cxx @@ -194,7 +194,7 @@ void OpVar::GenSlidingWindowFunction(std::stringstream &ss, } } ss << " if (fCount <= 1.0)\n"; - ss << " return CreateDoubleError(errDivisionByZero);\n"; + ss << " return CreateDoubleError(FormulaError::DivisionByZero);\n"; ss << " else\n"; ss << " return vSum * pow(fCount - 1.0,-1.0);\n"; ss << "}\n"; @@ -2657,7 +2657,7 @@ void OpSlope::GenSlidingWindowFunction(std::stringstream &ss, ss << " }\n"; ss << " if (fCount < 1.0)\n"; - ss << " return CreateDoubleError(errNoValue);\n"; + ss << " return CreateDoubleError(FormulaError::NoValue);\n"; ss << " else\n"; ss << " {\n"; ss << " fMeanX = fSumX * pow(fCount,-1.0);\n"; @@ -2701,7 +2701,7 @@ void OpSlope::GenSlidingWindowFunction(std::stringstream &ss, ss << " fSumSqrDeltaX += (argX-fMeanX) * (argX-fMeanX);\n"; ss << " }\n"; ss << " if(fSumSqrDeltaX == 0.0)\n"; - ss << " return CreateDoubleError(errDivisionByZero);\n"; + ss << " return CreateDoubleError(FormulaError::DivisionByZero);\n"; ss << " else\n"; ss << " {\n"; ss << " return fSumDeltaXDeltaY*pow(fSumSqrDeltaX,-1.0);\n"; @@ -3321,7 +3321,7 @@ void OpPearson::GenSlidingWindowFunction( ss << " double tmp = ( fSumDeltaXDeltaY / "; ss << "sqrt( fSumX * fSumY));\n\t"; ss << " if (isnan(tmp))\n"; - ss << " return CreateDoubleError(errNoValue);\n"; + ss << " return CreateDoubleError(FormulaError::NoValue);\n"; ss << " return tmp;\n"; ss << "}\n"; } @@ -4738,7 +4738,7 @@ void OpNormsinv:: GenSlidingWindowFunction ss << "z = q < 0.0 ? (-1)*z : z;\n"; ss <<"}\n"; ss <<"if (isnan(z))\n"; - ss <<" return CreateDoubleError(errNoValue);\n"; + ss <<" return CreateDoubleError(FormulaError::NoValue);\n"; ss <<"return z;\n"; ss <<"}\n"; } @@ -7012,7 +7012,7 @@ void OpCovar::GenSlidingWindowFunction(std::stringstream& ss, ss << " }\n"; } ss << " if(cnt < 1) {\n"; - ss << " return CreateDoubleError(errNoValue);\n"; + ss << " return CreateDoubleError(FormulaError::NoValue);\n"; ss << " }\n"; ss << " else {\n"; ss << " vMean0 = vSum0 / cnt;\n"; diff --git a/sc/source/core/tool/addincol.cxx b/sc/source/core/tool/addincol.cxx index 4d5fd7497f1a..15c4e92bfb27 100644 --- a/sc/source/core/tool/addincol.cxx +++ b/sc/source/core/tool/addincol.cxx @@ -1298,7 +1298,7 @@ bool ScUnoAddInCollection::FillFunctionDescFromData( const ScUnoAddInFuncData& r ScUnoAddInCall::ScUnoAddInCall( ScUnoAddInCollection& rColl, const OUString& rName, long nParamCount ) : bValidCount( false ), - nErrCode( formula::errNoCode ), // before function was called + nErrCode( FormulaError::NoCode ), // before function was called bHasString( true ), fValue( 0.0 ), xMatrix( nullptr ) @@ -1464,7 +1464,7 @@ void ScUnoAddInCall::ExecuteCallWithArgs(uno::Sequence<uno::Any>& rCallArgs) if ( xFunction.is() ) { uno::Any aAny; - nErrCode = 0; + nErrCode = FormulaError::NONE; try { @@ -1472,34 +1472,32 @@ void ScUnoAddInCall::ExecuteCallWithArgs(uno::Sequence<uno::Any>& rCallArgs) } catch(lang::IllegalArgumentException&) { - nErrCode = formula::errIllegalArgument; + nErrCode = FormulaError::IllegalArgument; } - catch(const reflection::InvocationTargetException& rWrapped) { if ( rWrapped.TargetException.getValueType().equals( cppu::UnoType<lang::IllegalArgumentException>::get()) ) - nErrCode = formula::errIllegalArgument; + nErrCode = FormulaError::IllegalArgument; else if ( rWrapped.TargetException.getValueType().equals( cppu::UnoType<sheet::NoConvergenceException>::get()) ) - nErrCode = formula::errNoConvergence; + nErrCode = FormulaError::NoConvergence; else - nErrCode = formula::errNoValue; + nErrCode = FormulaError::NoValue; } - catch(uno::Exception&) { - nErrCode = formula::errNoValue; + nErrCode = FormulaError::NoValue; } - if (!nErrCode) + if (nErrCode == FormulaError::NONE) SetResult( aAny ); // convert result to Calc types } } void ScUnoAddInCall::SetResult( const uno::Any& rNewRes ) { - nErrCode = 0; + nErrCode = FormulaError::NONE; xVarRes = nullptr; // Reflection* pRefl = rNewRes.getReflection(); @@ -1509,7 +1507,7 @@ void ScUnoAddInCall::SetResult( const uno::Any& rNewRes ) switch (eClass) { case uno::TypeClass_VOID: - nErrCode = formula::NOTAVAILABLE; // #NA + nErrCode = FormulaError::NotAvailable; // #NA break; case uno::TypeClass_ENUM: @@ -1545,7 +1543,7 @@ void ScUnoAddInCall::SetResult( const uno::Any& rNewRes ) xVarRes.set( xInterface, uno::UNO_QUERY ); if (!xVarRes.is()) - nErrCode = formula::errNoValue; // unknown interface + nErrCode = FormulaError::NoValue; // unknown interface } break; @@ -1683,7 +1681,7 @@ void ScUnoAddInCall::SetResult( const uno::Any& rNewRes ) } if (!xMatrix) // no array found - nErrCode = formula::errNoValue; //TODO: code for error in return type??? + nErrCode = FormulaError::NoValue; //TODO: code for error in return type??? } } diff --git a/sc/source/core/tool/cellform.cxx b/sc/source/core/tool/cellform.cxx index 38bf70ff5d88..0507d7c17abf 100644 --- a/sc/source/core/tool/cellform.cxx +++ b/sc/source/core/tool/cellform.cxx @@ -94,9 +94,9 @@ void ScCellFormat::GetString( ScRefCellValue& rCell, sal_uLong nFormat, OUString } else { - sal_uInt16 nErrCode = pFCell->GetErrCode(); + FormulaError nErrCode = pFCell->GetErrCode(); - if (nErrCode != 0) + if (nErrCode != FormulaError::NONE) rString = ScGlobal::GetErrorString(nErrCode); else if ( pFCell->IsEmptyDisplayedAsString() ) rString.clear(); @@ -160,8 +160,8 @@ void ScCellFormat::GetInputString( else aString = pFC->GetString().getString(); - sal_uInt16 nErrCode = pFC->GetErrCode(); - if (nErrCode != 0) + FormulaError nErrCode = pFC->GetErrCode(); + if (nErrCode != FormulaError::NONE) aString = EMPTY_OUSTRING; } break; diff --git a/sc/source/core/tool/chartarr.cxx b/sc/source/core/tool/chartarr.cxx index e373b3b93cee..1cc85fdb7aa0 100644 --- a/sc/source/core/tool/chartarr.cxx +++ b/sc/source/core/tool/chartarr.cxx @@ -32,6 +32,7 @@ #include <comphelper/stl_types.hxx> #include <o3tl/make_unique.hxx> +#include <formula/errorcodes.hxx> #include <vector> @@ -122,7 +123,7 @@ double getCellValue( ScDocument& rDoc, const ScAddress& rPos, double fDefault, b case CELLTYPE_FORMULA: { ScFormulaCell* pFCell = aCell.mpFormula; - if (pFCell && !pFCell->GetErrCode() && pFCell->IsValue()) + if (pFCell && pFCell->GetErrCode() == FormulaError::NONE && pFCell->IsValue()) fRet = pFCell->GetValue(); } break; diff --git a/sc/source/core/tool/compiler.cxx b/sc/source/core/tool/compiler.cxx index 2a49e899b63b..488c893c9842 100644 --- a/sc/source/core/tool/compiler.cxx +++ b/sc/source/core/tool/compiler.cxx @@ -1903,9 +1903,9 @@ void ScCompiler::SetRefConvention( const ScCompiler::Convention *pConvP ) "ScCompiler::SetRefConvention: unsupported grammar resulting"); } -void ScCompiler::SetError(sal_uInt16 nError) +void ScCompiler::SetError(FormulaError nError) { - if( !pArr->GetCodeError() ) + if( pArr->GetCodeError() == FormulaError::NONE) pArr->SetCodeError( nError); } @@ -2158,7 +2158,7 @@ Label_MaskStateMachine: { // This catches also $Sheet1.A$1, for example. if( pSym == &cSymbol[ MAXSTRLEN-1 ] ) { - SetError(errStringOverflow); + SetError(FormulaError::StringOverflow); eState = ssStop; } else @@ -2178,7 +2178,7 @@ Label_MaskStateMachine: { if( pSym == &cSymbol[ MAXSTRLEN-1 ] ) { - SetError(errStringOverflow); + SetError(FormulaError::StringOverflow); eState = ssStop; break; // for } @@ -2198,7 +2198,7 @@ Label_MaskStateMachine: mnRangeOpPosInSymbol = pSym - &cSymbol[0]; if( pSym == &cSymbol[ MAXSTRLEN-1 ] ) { - SetError(errStringOverflow); + SetError(FormulaError::StringOverflow); eState = ssStop; } else @@ -2236,7 +2236,7 @@ Label_MaskStateMachine: { if( pSym == &cSymbol[ MAXSTRLEN-1 ] ) { - SetError(errStringOverflow); + SetError(FormulaError::StringOverflow); eState = ssStop; } else if (c == cDecSep) @@ -2307,7 +2307,7 @@ Label_MaskStateMachine: { if( pSym == &cSymbol[ MAXSTRLEN-1 ] ) { - SetError(errStringOverflow); + SetError(FormulaError::StringOverflow); eState = ssSkipString; } else @@ -2365,7 +2365,7 @@ Label_MaskStateMachine: { if (pSym == &cSymbol[ MAXSTRLEN-1 ]) { - SetError( errStringOverflow); + SetError( FormulaError::StringOverflow); eState = ssStop; } else @@ -2380,7 +2380,7 @@ Label_MaskStateMachine: { if( pSym == &cSymbol[ MAXSTRLEN-1 ] ) { - SetError( errStringOverflow); + SetError( FormulaError::StringOverflow); eState = ssStop; } else @@ -2400,7 +2400,7 @@ Label_MaskStateMachine: { if( pSym == &cSymbol[ MAXSTRLEN-1 ] ) { - SetError( errStringOverflow); + SetError( FormulaError::StringOverflow); eState = ssStop; } else @@ -2416,7 +2416,7 @@ Label_MaskStateMachine: case ssGetReference: if( pSym == &cSymbol[ MAXSTRLEN-1 ] ) { - SetError( errStringOverflow); + SetError( FormulaError::StringOverflow); eState = ssSkipReference; } SAL_FALLTHROUGH; @@ -2597,7 +2597,7 @@ Label_MaskStateMachine: nSrcPos = nSrcPos + nSpaces; OUStringBuffer aSymbol; mnRangeOpPosInSymbol = -1; - sal_uInt16 nErr = 0; + FormulaError nErr = FormulaError::NONE; do { bi18n = false; @@ -2608,10 +2608,10 @@ Label_MaskStateMachine: ParseResult aRes = pConv->parseAnyToken( aFormula, nSrcPos, pCharClass ); if ( !aRes.TokenType ) - SetError( nErr = errIllegalChar ); // parsed chars as string + SetError( nErr = FormulaError::IllegalChar ); // parsed chars as string if ( aRes.EndPos <= nSrcPos ) { // ?!? - SetError( nErr = errIllegalChar ); + SetError( nErr = FormulaError::IllegalChar ); nSrcPos = aFormula.getLength(); aSymbol.truncate(); } @@ -2645,11 +2645,11 @@ Label_MaskStateMachine: if ( bi18n ) aSymbol.append(pStart[nSrcPos++]); } - } while ( bi18n && !nErr ); + } while ( bi18n && nErr == FormulaError::NONE ); sal_Int32 nLen = aSymbol.getLength(); if ( nLen >= MAXSTRLEN ) { - SetError( errStringOverflow ); + SetError( FormulaError::StringOverflow ); nLen = MAXSTRLEN-1; } lcl_UnicodeStrNCpy( cSymbol, aSymbol.getStr(), nLen ); @@ -2926,7 +2926,7 @@ bool ScCompiler::IsValue( const OUString& rSym ) return false; } if (eStatus == rtl_math_ConversionStatus_OutOfRange) - SetError( errIllegalArgument ); + SetError( FormulaError::IllegalArgument ); maRawToken.SetDouble( fVal ); return true; } @@ -2955,7 +2955,7 @@ bool ScCompiler::IsValue( const OUString& rSym ) if( nType == css::util::NumberFormat::TEXT ) // HACK: number too big! - SetError( errIllegalArgument ); + SetError( FormulaError::IllegalArgument ); maRawToken.SetDouble( fVal ); return true; } @@ -2969,7 +2969,7 @@ bool ScCompiler::IsString() bool bQuote = ((cSymbol[0] == '"') && (cSymbol[nLen] == '"')); if ((bQuote ? nLen-2 : nLen) > MAXSTRLEN-1) { - SetError(errStringOverflow); + SetError(FormulaError::StringOverflow); return false; } if ( bQuote ) @@ -3693,8 +3693,8 @@ bool ScCompiler::IsBoolean( const OUString& rName ) bool ScCompiler::IsErrorConstant( const OUString& rName ) const { - sal_uInt16 nError = GetErrorConstant( rName); - if (nError) + FormulaError nError = GetErrorConstant( rName); + if (nError != FormulaError::NONE) { maRawToken.SetErrorConstant( nError); return true; @@ -4078,7 +4078,7 @@ bool ScCompiler::NextNewToken( bool bInArray ) aToken.sbyte.cByte = (sal_uInt8) ( nSpaces > 255 ? 255 : nSpaces ); if( !static_cast<ScTokenArray*>(pArr)->AddRawToken( aToken ) ) { - SetError(errCodeOverflow); + SetError(FormulaError::CodeOverflow); return false; } } @@ -4276,7 +4276,7 @@ bool ScCompiler::NextNewToken( bool bInArray ) if ( meExtendedErrorDetection != EXTENDED_ERROR_DETECTION_NONE ) { // set an error - SetError( errNoName ); + SetError( FormulaError::NoName ); if (meExtendedErrorDetection == EXTENDED_ERROR_DETECTION_NAME_BREAK) return false; // end compilation } @@ -4400,7 +4400,7 @@ ScTokenArray* ScCompiler::CompileString( const OUString& rFormula ) { if( !nBrackets ) { - SetError( errPairExpected ); + SetError( FormulaError::PairExpected ); if ( bAutoCorrect ) { bCorrected = true; @@ -4422,7 +4422,7 @@ ScTokenArray* ScCompiler::CompileString( const OUString& rFormula ) case ocArrayOpen: { if( bInArray ) - SetError( errNestedArray ); + SetError( FormulaError::NestedArray ); else bInArray = true; // Don't count following column separator as parameter separator. @@ -4442,7 +4442,7 @@ ScTokenArray* ScCompiler::CompileString( const OUString& rFormula ) } else { - SetError( errPairExpected ); + SetError( FormulaError::PairExpected ); if ( bAutoCorrect ) { bCorrected = true; @@ -4489,7 +4489,7 @@ ScTokenArray* ScCompiler::CompileString( const OUString& rFormula ) // args so the correction dialog can do better? if ( !static_cast<ScTokenArray*>(pArr)->Add( new FormulaMissingToken ) ) { - SetError(errCodeOverflow); break; + SetError(FormulaError::CodeOverflow); break; } } if (bOOXML) @@ -4504,7 +4504,7 @@ ScTokenArray* ScCompiler::CompileString( const OUString& rFormula ) if ( !static_cast<ScTokenArray*>(pArr)->Add( new FormulaToken( svSep, ocSep)) || !static_cast<ScTokenArray*>(pArr)->Add( new FormulaDoubleToken( 1.0))) { - SetError(errCodeOverflow); break; + SetError(FormulaError::CodeOverflow); break; } } } @@ -4520,7 +4520,7 @@ ScTokenArray* ScCompiler::CompileString( const OUString& rFormula ) if ( !static_cast<ScTokenArray*>(pArr)->Add( new FormulaToken( svSep, ocSep)) || !static_cast<ScTokenArray*>(pArr)->Add( new FormulaDoubleToken( 1.0))) { - SetError(errCodeOverflow); break; + SetError(FormulaError::CodeOverflow); break; } ++pFunctionStack[ nFunction ].nSep; } @@ -4528,7 +4528,7 @@ ScTokenArray* ScCompiler::CompileString( const OUString& rFormula ) FormulaToken* pNewToken = static_cast<ScTokenArray*>(pArr)->Add( maRawToken.CreateToken()); if (!pNewToken) { - SetError(errCodeOverflow); + SetError(FormulaError::CodeOverflow); break; } else if (eLastOp == ocRange && pNewToken->GetOpCode() == ocPush && pNewToken->GetType() == svSingleRef) @@ -4553,14 +4553,14 @@ ScTokenArray* ScCompiler::CompileString( const OUString& rFormula ) case ocTableRefOpen: SAL_WARN_IF( maTableRefs.empty(), "sc.core", "ocTableRefOpen without TableRefEntry"); if (maTableRefs.empty()) - SetError(errPair); + SetError(FormulaError::Pair); else ++maTableRefs.back().mnLevel; break; case ocTableRefClose: SAL_WARN_IF( maTableRefs.empty(), "sc.core", "ocTableRefClose without TableRefEntry"); if (maTableRefs.empty()) - SetError(errPair); + SetError(FormulaError::Pair); else { if (--maTableRefs.back().mnLevel == 0) @@ -4581,7 +4581,7 @@ ScTokenArray* ScCompiler::CompileString( const OUString& rFormula ) FormulaByteToken aToken( ocArrayClose ); if( !pArr->AddToken( aToken ) ) { - SetError(errCodeOverflow); + SetError(FormulaError::CodeOverflow); } else if ( bAutoCorrect ) aCorrectedFormula += mxSymbols->getSymbol(ocArrayClose); @@ -4594,7 +4594,7 @@ ScTokenArray* ScCompiler::CompileString( const OUString& rFormula ) { if( !pArr->AddToken( aToken ) ) { - SetError(errCodeOverflow); + SetError(FormulaError::CodeOverflow); break; // while } if ( bAutoCorrect ) @@ -4662,9 +4662,9 @@ bool ScCompiler::HandleRange() const ScRangeData* pRangeData = GetRangeData( *mpToken); if (pRangeData) { - sal_uInt16 nErr = pRangeData->GetErrCode(); - if( nErr ) - SetError( errNoName ); + FormulaError nErr = pRangeData->GetErrCode(); + if( nErr != FormulaError::NONE ) + SetError( FormulaError::NoName ); else if (mbJumpCommandReorder) { ScTokenArray* pNew; @@ -4716,7 +4716,7 @@ bool ScCompiler::HandleRange() } } else - SetError(errNoName); + SetError(FormulaError::NoName); return true; } @@ -4734,7 +4734,7 @@ bool ScCompiler::HandleExternalReference(const FormulaToken& _aToken) const OUString* pFile = pRefMgr->getExternalFileName(_aToken.GetIndex()); if (!pFile) { - SetError(errNoName); + SetError(FormulaError::NoName); return true; } @@ -4744,7 +4744,7 @@ bool ScCompiler::HandleExternalReference(const FormulaToken& _aToken) if (!xNew) { - SetError(errNoName); + SetError(FormulaError::NoName); return true; } @@ -4923,8 +4923,8 @@ void ScCompiler::CreateStringFromMatrix( OUStringBuffer& rBuffer, const FormulaT AppendBoolean(rBuffer, pMatrix->GetDouble(nC, nR) != 0.0); else { - sal_uInt16 nErr = pMatrix->GetError(nC, nR); - if (nErr) + FormulaError nErr = pMatrix->GetError(nC, nR); + if (nErr != FormulaError::NONE) rBuffer.append(ScGlobal::GetErrorString(nErr)); else AppendDouble(rBuffer, pMatrix->GetDouble(nC, nR)); @@ -5072,12 +5072,12 @@ void ScCompiler::CreateStringFromIndex( OUStringBuffer& rBuffer, const FormulaTo // Write the resulting reference if TableRef is not supported. const ScTableRefToken* pTR = dynamic_cast<const ScTableRefToken*>(_pTokenP); if (!pTR) - AppendErrorConstant( aBuffer, errNoCode); + AppendErrorConstant( aBuffer, FormulaError::NoCode); else { const FormulaToken* pRef = pTR->GetAreaRefRPN(); if (!pRef) - AppendErrorConstant( aBuffer, errNoCode); + AppendErrorConstant( aBuffer, FormulaError::NoCode); else { switch (pRef->GetType()) @@ -5092,7 +5092,7 @@ void ScCompiler::CreateStringFromIndex( OUStringBuffer& rBuffer, const FormulaTo AppendErrorConstant( aBuffer, pRef->GetError()); break; default: - AppendErrorConstant( aBuffer, errNoCode); + AppendErrorConstant( aBuffer, FormulaError::NoCode); } } } @@ -5184,7 +5184,7 @@ bool ScCompiler::HandleColRowName() const ScAddress aAbs = rRef.toAbs(aPos); if (!ValidAddress(aAbs)) { - SetError( errNoRef ); + SetError( FormulaError::NoRef ); return true; } SCCOL nCol = aAbs.Col(); @@ -5343,7 +5343,7 @@ bool ScCompiler::HandleColRowName() bFound = true; } if ( !bFound ) - SetError(errNoRef); + SetError(FormulaError::NoRef); else if (mbJumpCommandReorder) { ScTokenArray* pNew = new ScTokenArray(); @@ -5386,7 +5386,7 @@ bool ScCompiler::HandleColRowName() } } else - SetError(errNoName); + SetError(FormulaError::NoName); return true; } @@ -5394,7 +5394,7 @@ bool ScCompiler::HandleDbData() { ScDBData* pDBData = pDoc->GetDBCollection()->getNamedDBs().findByIndex(mpToken->GetIndex()); if ( !pDBData ) - SetError(errNoName); + SetError(FormulaError::NoName); else if (mbJumpCommandReorder) { ScComplexRefData aRefData; @@ -5433,20 +5433,20 @@ bool ScCompiler::HandleTableRef() ScTableRefToken* pTR = dynamic_cast<ScTableRefToken*>(mpToken.get()); if (!pTR) { - SetError(errUnknownToken); + SetError(FormulaError::UnknownToken); return true; } ScDBData* pDBData = pDoc->GetDBCollection()->getNamedDBs().findByIndex( pTR->GetIndex()); if ( !pDBData ) - SetError(errNoName); + SetError(FormulaError::NoName); else if (mbJumpCommandReorder) { ScRange aDBRange; pDBData->GetArea(aDBRange); aDBRange.aEnd.SetTab(aDBRange.aStart.Tab()); ScRange aRange( aDBRange); - sal_uInt16 nError = 0; + FormulaError nError = FormulaError::NONE; bool bForwardToClose = false; ScTableRefToken::Item eItem = pTR->GetItem(); switch (eItem) @@ -5460,7 +5460,7 @@ bool ScCompiler::HandleTableRef() if (pDBData->HasTotals()) aRange.aEnd.IncRow(-1); if (aRange.aEnd.Row() < aRange.aStart.Row()) - nError = errNoRef; + nError = FormulaError::NoRef; bForwardToClose = true; } break; @@ -5474,7 +5474,7 @@ bool ScCompiler::HandleTableRef() if (pDBData->HasHeader()) aRange.aEnd.SetRow( aRange.aStart.Row()); else - nError = errNoRef; + nError = FormulaError::NoRef; bForwardToClose = true; } break; @@ -5489,7 +5489,7 @@ bool ScCompiler::HandleTableRef() if (pDBData->HasTotals()) aRange.aEnd.IncRow(-1); if (aRange.aEnd.Row() < aRange.aStart.Row()) - nError = errNoRef; + nError = FormulaError::NoRef; bForwardToClose = true; } break; @@ -5498,7 +5498,7 @@ bool ScCompiler::HandleTableRef() if (pDBData->HasTotals()) aRange.aStart.SetRow( aRange.aEnd.Row()); else - nError = errNoRef; + nError = FormulaError::NoRef; bForwardToClose = true; } break; @@ -5507,7 +5507,7 @@ bool ScCompiler::HandleTableRef() if (pDBData->HasHeader()) aRange.aStart.IncRow(); if (aRange.aEnd.Row() < aRange.aStart.Row()) - nError = errNoRef; + nError = FormulaError::NoRef; bForwardToClose = true; } break; @@ -5520,7 +5520,7 @@ bool ScCompiler::HandleTableRef() } else { - nError = errNoValue; + nError = FormulaError::NoValue; // For *some* relative row reference in named // expressions' thisrow special handling below. aRange.aEnd.SetRow( aRange.aStart.Row()); @@ -5560,7 +5560,7 @@ bool ScCompiler::HandleTableRef() eState = ((eState == sOpen || eState == sSep) ? sOpen : sStop); if (++nLevel > 2) { - SetError( errPair); + SetError( FormulaError::Pair); eState = sStop; } break; @@ -5594,8 +5594,8 @@ bool ScCompiler::HandleTableRef() break; case ocBad: eState = sLast; - if (!nError) - nError = errNoName; + if (nError == FormulaError::NONE) + nError = FormulaError::NoName; break; default: eState = sStop; @@ -5608,9 +5608,9 @@ bool ScCompiler::HandleTableRef() } while (eState != sStop); } ScTokenArray* pNew = new ScTokenArray(); - if (!nError || nError == errNoValue) + if (nError == FormulaError::NONE || nError == FormulaError::NoValue) { - // The errNoValue case generates a thisrow reference that can be + // The FormulaError::NoValue case generates a thisrow reference that can be // used to save named expressions in A1 syntax notation. if (bColumnRange) { @@ -5664,7 +5664,7 @@ bool ScCompiler::HandleTableRef() } aRefData.SetRelName( bCol1RelName); aRefData.SetFlag3D( true); - if (nError) + if (nError != FormulaError::NONE) { aRefData.SetAddress( aRange.aStart, aRange.aStart); pTR->SetAreaRefRPN( new ScSingleRefToken( aRefData)); // set reference at TableRef @@ -5693,7 +5693,7 @@ bool ScCompiler::HandleTableRef() aRefData.Ref1.SetRelName( bRelName); aRefData.Ref2.SetRelName( bRelName); aRefData.Ref1.SetFlag3D( true); - if (nError) + if (nError != FormulaError::NONE) { aRefData.SetRange( aRange, aRange.aStart); pTR->SetAreaRefRPN( new ScDoubleRefToken( aRefData)); // set reference at TableRef @@ -5708,7 +5708,7 @@ bool ScCompiler::HandleTableRef() } else { - pTR->SetAreaRefRPN( pNew->Add( new FormulaErrorToken( errNoRef))); + pTR->SetAreaRefRPN( pNew->Add( new FormulaErrorToken( FormulaError::NoRef))); } } else @@ -5718,7 +5718,7 @@ bool ScCompiler::HandleTableRef() while (nLevel-- > 0) { if (!GetTokenIfOpCode( ocTableRefClose)) - SetError( errPair); + SetError( FormulaError::Pair); } PushTokenArray( pNew, true ); pNew->Reset(); diff --git a/sc/source/core/tool/consoli.cxx b/sc/source/core/tool/consoli.cxx index 67bf01d4ad07..651e14ed0551 100644 --- a/sc/source/core/tool/consoli.cxx +++ b/sc/source/core/tool/consoli.cxx @@ -662,7 +662,7 @@ void ScConsData::OutputToDocument( ScDocument* pDestDoc, SCCOL nCol, SCROW nRow, ppSumSqr[nArrX][nArrY]); if (ppCount[nArrX][nArrY] < 0.0) pDestDoc->SetError( sal::static_int_cast<SCCOL>(nCol+nArrX), - sal::static_int_cast<SCROW>(nRow+nArrY), nTab, formula::errNoValue ); + sal::static_int_cast<SCROW>(nRow+nArrY), nTab, FormulaError::NoValue ); else pDestDoc->SetValue( sal::static_int_cast<SCCOL>(nCol+nArrX), sal::static_int_cast<SCROW>(nRow+nArrY), nTab, fVal ); diff --git a/sc/source/core/tool/detfunc.cxx b/sc/source/core/tool/detfunc.cxx index 9e3a2c94833c..bec278847141 100644 --- a/sc/source/core/tool/detfunc.cxx +++ b/sc/source/core/tool/detfunc.cxx @@ -21,6 +21,7 @@ #include <svtools/colorcfg.hxx> #include <editeng/eeitem.hxx> #include <editeng/outlobj.hxx> +#include <formula/errorcodes.hxx> #include <svx/sdshitm.hxx> #include <svx/sdsxyitm.hxx> #include <svx/sdtditm.hxx> @@ -285,7 +286,7 @@ inline bool Intersect( SCCOL nStartCol1, SCROW nStartRow1, SCCOL nEndCol1, SCROW bool ScDetectiveFunc::HasError( const ScRange& rRange, ScAddress& rErrPos ) { rErrPos = rRange.aStart; - sal_uInt16 nError = 0; + FormulaError nError = FormulaError::NONE; ScCellIterator aIter( pDoc, rRange); for (bool bHasCell = aIter.first(); bHasCell; bHasCell = aIter.next()) @@ -294,11 +295,11 @@ bool ScDetectiveFunc::HasError( const ScRange& rRange, ScAddress& rErrPos ) continue; nError = aIter.getFormulaCell()->GetErrCode(); - if (nError) + if (nError != FormulaError::NONE) rErrPos = aIter.GetPos(); } - return (nError != 0); + return (nError != FormulaError::NONE); } Point ScDetectiveFunc::GetDrawPos( SCCOL nCol, SCROW nRow, DrawPosMode eMode ) const diff --git a/sc/source/core/tool/doubleref.cxx b/sc/source/core/tool/doubleref.cxx index d7ff17d74f8c..51b7c546f194 100644 --- a/sc/source/core/tool/doubleref.cxx +++ b/sc/source/core/tool/doubleref.cxx @@ -324,7 +324,7 @@ SCCOL ScDBInternalRange::findFieldColumn(SCCOL nIndex) const return nIndex + nDBCol1 - 1; } -SCCOL ScDBInternalRange::findFieldColumn(const OUString& rStr, sal_uInt16* pErr) const +SCCOL ScDBInternalRange::findFieldColumn(const OUString& rStr, FormulaError* pErr) const { const ScAddress& s = maRange.aStart; const ScAddress& e = maRange.aEnd; @@ -342,7 +342,7 @@ SCCOL ScDBInternalRange::findFieldColumn(const OUString& rStr, sal_uInt16* pErr) ScAddress aLook( nDBCol1, nDBRow1, nDBTab1 ); while (!bFound && (aLook.Col() <= nDBCol2)) { - sal_uInt16 nErr = getDoc()->GetStringForFormula( aLook, aCellStr ); + FormulaError nErr = getDoc()->GetStringForFormula( aLook, aCellStr ); if (pErr) *pErr = nErr; lcl_uppercase(aCellStr); @@ -433,10 +433,10 @@ SCCOL ScDBExternalRange::findFieldColumn(SCCOL nIndex) const return nIndex - 1; } -SCCOL ScDBExternalRange::findFieldColumn(const OUString& rStr, sal_uInt16* pErr) const +SCCOL ScDBExternalRange::findFieldColumn(const OUString& rStr, FormulaError* pErr) const { if (pErr) - *pErr = 0; + *pErr = FormulaError::NONE; OUString aUpper = rStr; lcl_uppercase(aUpper); diff --git a/sc/source/core/tool/formularesult.cxx b/sc/source/core/tool/formularesult.cxx index 3d757e1ad601..2c1b646f605a 100644 --- a/sc/source/core/tool/formularesult.cxx +++ b/sc/source/core/tool/formularesult.cxx @@ -12,15 +12,15 @@ namespace sc { -FormulaResultValue::FormulaResultValue() : meType(Invalid), mfValue(0.0), mnError(0) {} -FormulaResultValue::FormulaResultValue( double fValue ) : meType(Value), mfValue(fValue), mnError(0) {} -FormulaResultValue::FormulaResultValue( const svl::SharedString& rStr ) : meType(String), mfValue(0.0), maString(rStr), mnError(0) {} -FormulaResultValue::FormulaResultValue( sal_uInt16 nErr ) : meType(Error), mfValue(0.0), mnError(nErr) {} +FormulaResultValue::FormulaResultValue() : meType(Invalid), mfValue(0.0), mnError(FormulaError::NONE) {} +FormulaResultValue::FormulaResultValue( double fValue ) : meType(Value), mfValue(fValue), mnError(FormulaError::NONE) {} +FormulaResultValue::FormulaResultValue( const svl::SharedString& rStr ) : meType(String), mfValue(0.0), maString(rStr), mnError(FormulaError::NONE) {} +FormulaResultValue::FormulaResultValue( FormulaError nErr ) : meType(Error), mfValue(0.0), mnError(nErr) {} } ScFormulaResult::ScFormulaResult() : - mpToken(nullptr), mnError(0), mbToken(true), + mpToken(nullptr), mnError(FormulaError::NONE), mbToken(true), mbEmpty(false), mbEmptyDisplayedAsString(false), meMultiline(MULTILINE_UNKNOWN) {} @@ -55,7 +55,7 @@ ScFormulaResult::ScFormulaResult( const ScFormulaResult & r ) : } ScFormulaResult::ScFormulaResult( const formula::FormulaToken* p ) : - mnError(0), mbToken(false), mbEmpty(false), mbEmptyDisplayedAsString(false), + mnError(FormulaError::NONE), mbToken(false), mbEmpty(false), mbEmptyDisplayedAsString(false), meMultiline(MULTILINE_UNKNOWN) { SetToken( p); @@ -69,7 +69,7 @@ ScFormulaResult::~ScFormulaResult() void ScFormulaResult::ResetToDefaults() { - mnError = 0; + mnError = FormulaError::NONE; mbEmpty = false; mbEmptyDisplayedAsString = false; meMultiline = MULTILINE_UNKNOWN; @@ -219,7 +219,7 @@ void ScFormulaResult::SetDouble( double f ) formula::StackVar ScFormulaResult::GetType() const { // Order is significant. - if (mnError) + if (mnError != FormulaError::NONE) return formula::svError; if (mbEmpty) return formula::svEmptyCell; @@ -311,9 +311,9 @@ bool ScFormulaResult::IsMultiline() const return meMultiline == MULTILINE_TRUE; } -bool ScFormulaResult::GetErrorOrDouble( sal_uInt16& rErr, double& rVal ) const +bool ScFormulaResult::GetErrorOrDouble( FormulaError& rErr, double& rVal ) const { - if (mnError) + if (mnError != FormulaError::NONE) { rErr = mnError; return true; @@ -334,7 +334,7 @@ bool ScFormulaResult::GetErrorOrDouble( sal_uInt16& rErr, double& rVal ) const } } - if (rErr) + if (rErr != FormulaError::NONE) return true; if (!isValue(sv)) @@ -346,11 +346,11 @@ bool ScFormulaResult::GetErrorOrDouble( sal_uInt16& rErr, double& rVal ) const sc::FormulaResultValue ScFormulaResult::GetResult() const { - if (mnError) + if (mnError != FormulaError::NONE) return sc::FormulaResultValue(mnError); formula::StackVar sv = GetCellResultType(); - sal_uInt16 nErr = 0; + FormulaError nErr = FormulaError::NONE; if (sv == formula::svError) { if (GetType() == formula::svMatrixCell) @@ -365,7 +365,7 @@ sc::FormulaResultValue ScFormulaResult::GetResult() const } } - if (nErr) + if (nErr != FormulaError::NONE) return sc::FormulaResultValue(nErr); if (isValue(sv)) @@ -382,9 +382,9 @@ sc::FormulaResultValue ScFormulaResult::GetResult() const return sc::FormulaResultValue(); } -sal_uInt16 ScFormulaResult::GetResultError() const +FormulaError ScFormulaResult::GetResultError() const { - if (mnError) + if (mnError != FormulaError::NONE) return mnError; formula::StackVar sv = GetCellResultType(); if (sv == formula::svError) @@ -396,10 +396,10 @@ sal_uInt16 ScFormulaResult::GetResultError() const if (mpToken) return mpToken->GetError(); } - return 0; + return FormulaError::NONE; } -void ScFormulaResult::SetResultError( sal_uInt16 nErr ) +void ScFormulaResult::SetResultError( FormulaError nErr ) { mnError = nErr; } diff --git a/sc/source/core/tool/interpr1.cxx b/sc/source/core/tool/interpr1.cxx index 0c380dcd1211..c40a6e2e2202 100644 --- a/sc/source/core/tool/interpr1.cxx +++ b/sc/source/core/tool/interpr1.cxx @@ -134,7 +134,7 @@ void ScInterpreter::ScIfJump() // as error. bIsValue = (!pMat->IsString(nC, nR) || pMat->IsEmpty(nC, nR)); bTrue = false; - fVal = (bIsValue ? 0.0 : CreateDoubleError( errNoValue)); + fVal = (bIsValue ? 0.0 : CreateDoubleError( FormulaError::NoValue)); } if ( bTrue ) { // TRUE @@ -243,7 +243,7 @@ void ScInterpreter::ScIfError( bool bNAonly ) if (!sp || nJumpCount != 2) { // Reset nGlobalError here to not propagate the old error, if any. - nGlobalError = (sp ? errParameterExpected : errUnknownStackVariable); + nGlobalError = (sp ? FormulaError::ParameterExpected : FormulaError::UnknownStackVariable); PushError( nGlobalError); aCode.Jump( pJump[ nJumpCount ], pJump[ nJumpCount ] ); return; @@ -251,8 +251,8 @@ void ScInterpreter::ScIfError( bool bNAonly ) FormulaConstTokenRef xToken( pStack[ sp - 1 ] ); bool bError = false; - sal_uInt16 nOldGlobalError = nGlobalError; - nGlobalError = 0; + FormulaError nOldGlobalError = nGlobalError; + nGlobalError = FormulaError::NONE; MatrixJumpConditionToMatrix(); switch (GetStackType()) @@ -260,9 +260,9 @@ void ScInterpreter::ScIfError( bool bNAonly ) default: Pop(); // Act on implicitly propagated error, if any. - if (nOldGlobalError) + if (nOldGlobalError != FormulaError::NONE) nGlobalError = nOldGlobalError; - if (nGlobalError) + if (nGlobalError != FormulaError::NONE) bError = true; break; case svError: @@ -280,7 +280,7 @@ void ScInterpreter::ScIfError( bool bNAonly ) ScRefCellValue aCell(*pDok, aAdr); nGlobalError = GetCellErrCode(aCell); - if (nGlobalError) + if (nGlobalError != FormulaError::NONE) bError = true; } } @@ -293,14 +293,14 @@ void ScInterpreter::ScIfError( bool bNAonly ) // Handles also existing jump matrix case and sets error on // elements. GetDoubleOrStringFromMatrix( fVal, aStr); - if (nGlobalError) + if (nGlobalError != FormulaError::NONE) bError = true; } break; case svMatrix: { const ScMatrixRef pMat = PopMatrix(); - if (!pMat || (nGlobalError && (!bNAonly || nGlobalError == NOTAVAILABLE))) + if (!pMat || (nGlobalError != FormulaError::NONE && (!bNAonly || nGlobalError == FormulaError::NotAvailable))) { bError = true; break; // switch @@ -320,8 +320,8 @@ void ScInterpreter::ScIfError( bool bNAonly ) { for (SCSIZE nR=0; nR < nRows && !bError; ++nR) { - sal_uInt16 nErr = pMat->GetError( nC, nR ); - if (nErr && (!bNAonly || nErr == NOTAVAILABLE)) + FormulaError nErr = pMat->GetError( nC, nR ); + if (nErr != FormulaError::NONE && (!bNAonly || nErr == FormulaError::NotAvailable)) { bError = true; nErrorCol = nC; @@ -344,7 +344,7 @@ void ScInterpreter::ScIfError( bool bNAonly ) ScJumpMatrix* pJumpMat = new ScJumpMatrix( nCols, nRows ); // Init all jumps to no error to save single calls. Error // is the exceptional condition. - const double fFlagResult = CreateDoubleError( errJumpMatHasResult); + const double fFlagResult = CreateDoubleError( FormulaError::JumpMatHasResult); pJumpMat->SetAllJumps( fFlagResult, pJump[ nJumpCount ], pJump[ nJumpCount ] ); // Up to first error position simply store results, no need // to evaluate error conditions again. @@ -363,8 +363,8 @@ void ScInterpreter::ScIfError( bool bNAonly ) { for ( ; nR < nRows; ++nR) { - sal_uInt16 nErr = pMat->GetError( nC, nR ); - if (nErr && (!bNAonly || nErr == NOTAVAILABLE)) + FormulaError nErr = pMat->GetError( nC, nR ); + if (nErr != FormulaError::NONE && (!bNAonly || nErr == FormulaError::NotAvailable)) { // TRUE, THEN path pJumpMat->SetJump( nC, nR, 1.0, pJump[ 1 ], pJump[ nJumpCount ] ); } @@ -387,10 +387,10 @@ void ScInterpreter::ScIfError( bool bNAonly ) break; } - if (bError && (!bNAonly || nGlobalError == NOTAVAILABLE)) + if (bError && (!bNAonly || nGlobalError == FormulaError::NotAvailable)) { // error, calculate 2nd argument - nGlobalError = 0; + nGlobalError = FormulaError::NONE; aCode.Jump( pJump[ 1 ], pJump[ nJumpCount ] ); } else @@ -450,13 +450,13 @@ void ScInterpreter::ScChooseJump() { bIsValue = false; fVal = CreateDoubleError( - errIllegalArgument); + FormulaError::IllegalArgument); } } } else { - fVal = CreateDoubleError( errNoValue); + fVal = CreateDoubleError( FormulaError::NoValue); } if ( bIsValue ) { @@ -489,7 +489,7 @@ void ScInterpreter::ScChooseJump() default: { sal_Int16 nJumpIndex = GetInt16(); - if (!nGlobalError && (nJumpIndex >= 1) && (nJumpIndex < nJumpCount)) + if (nGlobalError == FormulaError::NONE && (nJumpIndex >= 1) && (nJumpIndex < nJumpCount)) { aCode.Jump( pJump[ (short) nJumpIndex ], pJump[ nJumpCount ] ); bHaveJump = true; @@ -548,7 +548,7 @@ bool ScInterpreter::JumpMatrix( short nStackLevel ) if ( !bHasResMat ) { Pop(); - SetError( errUnknownStackVariable ); + SetError( FormulaError::UnknownStackVariable ); } else { @@ -558,10 +558,10 @@ bool ScInterpreter::JumpMatrix( short nStackLevel ) case svDouble: { double fVal = GetDouble(); - if ( nGlobalError ) + if ( nGlobalError != FormulaError::NONE ) { fVal = CreateDoubleError( nGlobalError ); - nGlobalError = 0; + nGlobalError = FormulaError::NONE; } pJumpMatrix->PutResultDouble( fVal, nC, nR ); } @@ -569,11 +569,11 @@ bool ScInterpreter::JumpMatrix( short nStackLevel ) case svString: { svl::SharedString aStr = GetString(); - if ( nGlobalError ) + if ( nGlobalError != FormulaError::NONE ) { pJumpMatrix->PutResultDouble( CreateDoubleError( nGlobalError), nC, nR); - nGlobalError = 0; + nGlobalError = FormulaError::NONE; } else pJumpMatrix->PutResultString(aStr, nC, nR); @@ -583,11 +583,11 @@ bool ScInterpreter::JumpMatrix( short nStackLevel ) { ScAddress aAdr; PopSingleRef( aAdr ); - if ( nGlobalError ) + if ( nGlobalError != FormulaError::NONE ) { pJumpMatrix->PutResultDouble( CreateDoubleError( nGlobalError), nC, nR); - nGlobalError = 0; + nGlobalError = FormulaError::NONE; } else { @@ -597,11 +597,11 @@ bool ScInterpreter::JumpMatrix( short nStackLevel ) else if (aCell.hasNumeric()) { double fVal = GetCellValue(aAdr, aCell); - if ( nGlobalError ) + if ( nGlobalError != FormulaError::NONE ) { fVal = CreateDoubleError( nGlobalError); - nGlobalError = 0; + nGlobalError = FormulaError::NONE; } pJumpMatrix->PutResultDouble( fVal, nC, nR ); } @@ -609,11 +609,11 @@ bool ScInterpreter::JumpMatrix( short nStackLevel ) { svl::SharedString aStr; GetCellString(aStr, aCell); - if ( nGlobalError ) + if ( nGlobalError != FormulaError::NONE ) { pJumpMatrix->PutResultDouble( CreateDoubleError( nGlobalError), nC, nR); - nGlobalError = 0; + nGlobalError = FormulaError::NONE; } else pJumpMatrix->PutResultString(aStr, nC, nR); @@ -626,10 +626,10 @@ bool ScInterpreter::JumpMatrix( short nStackLevel ) double fVal; ScRange aRange; PopDoubleRef( aRange ); - if ( nGlobalError ) + if ( nGlobalError != FormulaError::NONE ) { fVal = CreateDoubleError( nGlobalError ); - nGlobalError = 0; + nGlobalError = FormulaError::NONE; pJumpMatrix->PutResultDouble( fVal, nC, nR ); } else @@ -644,7 +644,7 @@ bool ScInterpreter::JumpMatrix( short nStackLevel ) || (nRow > static_cast<sal_uLong>(aRange.aEnd.Row()) && aRange.aEnd.Row() != aRange.aStart.Row())) { - fVal = CreateDoubleError( NOTAVAILABLE ); + fVal = CreateDoubleError( FormulaError::NotAvailable ); pJumpMatrix->PutResultDouble( fVal, nC, nR ); } else @@ -664,11 +664,11 @@ bool ScInterpreter::JumpMatrix( short nStackLevel ) else if (aCell.hasNumeric()) { double fCellVal = GetCellValue(aAdr, aCell); - if ( nGlobalError ) + if ( nGlobalError != FormulaError::NONE ) { fCellVal = CreateDoubleError( nGlobalError); - nGlobalError = 0; + nGlobalError = FormulaError::NONE; } pJumpMatrix->PutResultDouble( fCellVal, nC, nR ); } @@ -676,11 +676,11 @@ bool ScInterpreter::JumpMatrix( short nStackLevel ) { svl::SharedString aStr; GetCellString(aStr, aCell); - if ( nGlobalError ) + if ( nGlobalError != FormulaError::NONE ) { pJumpMatrix->PutResultDouble( CreateDoubleError( nGlobalError), nC, nR); - nGlobalError = 0; + nGlobalError = FormulaError::NONE; } else pJumpMatrix->PutResultString(aStr, nC, nR); @@ -696,15 +696,15 @@ bool ScInterpreter::JumpMatrix( short nStackLevel ) { // match matrix offsets double fVal; ScMatrixRef pMat = PopMatrix(); - if ( nGlobalError ) + if ( nGlobalError != FormulaError::NONE ) { fVal = CreateDoubleError( nGlobalError ); - nGlobalError = 0; + nGlobalError = FormulaError::NONE; pJumpMatrix->PutResultDouble( fVal, nC, nR ); } else if ( !pMat ) { - fVal = CreateDoubleError( errUnknownVariable ); + fVal = CreateDoubleError( FormulaError::UnknownVariable ); pJumpMatrix->PutResultDouble( fVal, nC, nR ); } else @@ -714,7 +714,7 @@ bool ScInterpreter::JumpMatrix( short nStackLevel ) if ((nCols <= nC && nCols != 1) || (nRows <= nR && nRows != 1)) { - fVal = CreateDoubleError( NOTAVAILABLE ); + fVal = CreateDoubleError( FormulaError::NotAvailable ); pJumpMatrix->PutResultDouble( fVal, nC, nR ); } else @@ -729,14 +729,14 @@ bool ScInterpreter::JumpMatrix( short nStackLevel ) { PopError(); double fVal = CreateDoubleError( nGlobalError); - nGlobalError = 0; + nGlobalError = FormulaError::NONE; pJumpMatrix->PutResultDouble( fVal, nC, nR ); } break; default: { Pop(); - double fVal = CreateDoubleError( errIllegalArgument); + double fVal = CreateDoubleError( FormulaError::IllegalArgument); pJumpMatrix->PutResultDouble( fVal, nC, nR ); } } @@ -750,7 +750,7 @@ bool ScInterpreter::JumpMatrix( short nStackLevel ) pJumpMatrix->GetJump( nC, nR, fBool, nStart, nNext, nStop ); while ( bCont && nStart == nNext ) { // push all results that have no jump path - if ( bHasResMat && (GetDoubleErrorValue( fBool) != errJumpMatHasResult) ) + if ( bHasResMat && (GetDoubleErrorValue( fBool) != FormulaError::JumpMatHasResult) ) { // a false without path results in an empty path value if ( fBool == 0.0 ) @@ -849,7 +849,7 @@ double ScInterpreter::Compare( ScQueryOp eOp ) ScMatrixRef pMat = GetMatrix(); if (!pMat) { - SetError( errIllegalParameter); + SetError( FormulaError::IllegalParameter); break; } @@ -857,7 +857,7 @@ double ScInterpreter::Compare( ScQueryOp eOp ) pMat->GetDimensions(nC, nR); if (!nC || !nR) { - SetError( errIllegalParameter); + SetError( FormulaError::IllegalParameter); break; } if (pMat->IsEmpty(0, 0)) @@ -884,11 +884,11 @@ double ScInterpreter::Compare( ScQueryOp eOp ) // it currently is handled along with svMatrix. default: PopError(); - SetError( errIllegalParameter); + SetError( FormulaError::IllegalParameter); break; } } - if( nGlobalError ) + if( nGlobalError != FormulaError::NONE ) return 0; nCurFmtType = nFuncFmtType = css::util::NumberFormat::LOGICAL; return sc::CompareFunc(aComp); @@ -946,21 +946,21 @@ sc::RangeMatrix ScInterpreter::CompareMat( ScQueryOp eOp, sc::CompareOptions* pO case svMatrix: aMat[i] = GetRangeMatrix(); if (!aMat[i].mpMat) - SetError( errIllegalParameter); + SetError( FormulaError::IllegalParameter); else aMat[i].mpMat->SetErrorInterpreter(nullptr); // errors are transported as DoubleError inside matrix break; default: PopError(); - SetError( errIllegalParameter); + SetError( FormulaError::IllegalParameter); break; } } sc::RangeMatrix aRes; - if (nGlobalError) + if (nGlobalError != FormulaError::NONE) { nCurFmtType = nFuncFmtType = css::util::NumberFormat::LOGICAL; return aRes; @@ -1005,7 +1005,7 @@ sc::RangeMatrix ScInterpreter::CompareMat( ScQueryOp eOp, sc::CompareOptions* pO aRes.mpMat->PutDouble( sc::CompareFunc( aComp, pOptions), j, k); } else - aRes.mpMat->PutError( errNoValue, j, k); + aRes.mpMat->PutError( FormulaError::NoValue, j, k); } } @@ -1069,9 +1069,9 @@ ScMatrixRef ScInterpreter::QueryMat( const ScMatrixRef& pMat, sc::CompareOptions ScMatrixRef pResultMatrix = CompareMat(rOptions.aQueryEntry.eOp, &rOptions).mpMat; nCurFmtType = nSaveCurFmtType; nFuncFmtType = nSaveFuncFmtType; - if (nGlobalError || !pResultMatrix) + if (nGlobalError != FormulaError::NONE || !pResultMatrix) { - SetError( errIllegalParameter); + SetError( FormulaError::IllegalParameter); return pResultMatrix; } @@ -1191,7 +1191,7 @@ void ScInterpreter::ScAnd() size_t nRefInList = 0; while( nParamCount-- > 0) { - if ( !nGlobalError ) + if ( nGlobalError == FormulaError::NONE ) { switch ( GetStackType() ) { @@ -1201,13 +1201,13 @@ void ScInterpreter::ScAnd() break; case svString : Pop(); - SetError( errNoValue ); + SetError( FormulaError::NoValue ); break; case svSingleRef : { ScAddress aAdr; PopSingleRef( aAdr ); - if ( !nGlobalError ) + if ( nGlobalError == FormulaError::NONE ) { ScRefCellValue aCell(*pDok, aAdr); if (aCell.hasNumeric()) @@ -1224,18 +1224,18 @@ void ScInterpreter::ScAnd() { ScRange aRange; PopDoubleRef( aRange, nParamCount, nRefInList); - if ( !nGlobalError ) + if ( nGlobalError == FormulaError::NONE ) { double fVal; - sal_uInt16 nErr = 0; + FormulaError nErr = FormulaError::NONE; ScValueIterator aValIter( pDok, aRange ); - if ( aValIter.GetFirst( fVal, nErr ) && nErr == 0 ) + if ( aValIter.GetFirst( fVal, nErr ) && nErr == FormulaError::NONE ) { bHaveValue = true; do { bRes &= ( fVal != 0.0 ); - } while ( (nErr == 0) && + } while ( (nErr == FormulaError::NONE) && aValIter.GetNext( fVal, nErr ) ); } SetError( nErr ); @@ -1251,8 +1251,8 @@ void ScInterpreter::ScAnd() { bHaveValue = true; double fVal = pMat->And(); - sal_uInt16 nErr = GetDoubleErrorValue( fVal ); - if ( nErr ) + FormulaError nErr = GetDoubleErrorValue( fVal ); + if ( nErr != FormulaError::NONE ) { SetError( nErr ); bRes = false; @@ -1260,12 +1260,12 @@ void ScInterpreter::ScAnd() else bRes &= (fVal != 0.0); } - // else: GetMatrix did set errIllegalParameter + // else: GetMatrix did set FormulaError::IllegalParameter } break; default: Pop(); - SetError( errIllegalParameter); + SetError( FormulaError::IllegalParameter); } } else @@ -1289,7 +1289,7 @@ void ScInterpreter::ScOr() size_t nRefInList = 0; while( nParamCount-- > 0) { - if ( !nGlobalError ) + if ( nGlobalError == FormulaError::NONE ) { switch ( GetStackType() ) { @@ -1299,13 +1299,13 @@ void ScInterpreter::ScOr() break; case svString : Pop(); - SetError( errNoValue ); + SetError( FormulaError::NoValue ); break; case svSingleRef : { ScAddress aAdr; PopSingleRef( aAdr ); - if ( !nGlobalError ) + if ( nGlobalError == FormulaError::NONE ) { ScRefCellValue aCell(*pDok, aAdr); if (aCell.hasNumeric()) @@ -1322,10 +1322,10 @@ void ScInterpreter::ScOr() { ScRange aRange; PopDoubleRef( aRange, nParamCount, nRefInList); - if ( !nGlobalError ) + if ( nGlobalError == FormulaError::NONE ) { double fVal; - sal_uInt16 nErr = 0; + FormulaError nErr = FormulaError::NONE; ScValueIterator aValIter( pDok, aRange ); if ( aValIter.GetFirst( fVal, nErr ) ) { @@ -1333,7 +1333,7 @@ void ScInterpreter::ScOr() do { bRes |= ( fVal != 0.0 ); - } while ( (nErr == 0) && + } while ( (nErr == FormulaError::NONE) && aValIter.GetNext( fVal, nErr ) ); } SetError( nErr ); @@ -1350,8 +1350,8 @@ void ScInterpreter::ScOr() { bHaveValue = true; double fVal = pMat->Or(); - sal_uInt16 nErr = GetDoubleErrorValue( fVal ); - if ( nErr ) + FormulaError nErr = GetDoubleErrorValue( fVal ); + if ( nErr != FormulaError::NONE ) { SetError( nErr ); bRes = false; @@ -1359,12 +1359,12 @@ void ScInterpreter::ScOr() else bRes |= (fVal != 0.0); } - // else: GetMatrix did set errIllegalParameter + // else: GetMatrix did set FormulaError::IllegalParameter } break; default: Pop(); - SetError( errIllegalParameter); + SetError( FormulaError::IllegalParameter); } } else @@ -1389,7 +1389,7 @@ void ScInterpreter::ScXor() size_t nRefInList = 0; while( nParamCount-- > 0) { - if ( !nGlobalError ) + if ( nGlobalError == FormulaError::NONE ) { switch ( GetStackType() ) { @@ -1399,13 +1399,13 @@ void ScInterpreter::ScXor() break; case svString : Pop(); - SetError( errNoValue ); + SetError( FormulaError::NoValue ); break; case svSingleRef : { ScAddress aAdr; PopSingleRef( aAdr ); - if ( !nGlobalError ) + if ( nGlobalError == FormulaError::NONE ) { ScRefCellValue aCell(*pDok, aAdr); if (aCell.hasNumeric()) @@ -1424,10 +1424,10 @@ void ScInterpreter::ScXor() { ScRange aRange; PopDoubleRef( aRange, nParamCount, nRefInList); - if ( !nGlobalError ) + if ( nGlobalError == FormulaError::NONE ) { double fVal; - sal_uInt16 nErr = 0; + FormulaError nErr = FormulaError::NONE; ScValueIterator aValIter( pDok, aRange ); if ( aValIter.GetFirst( fVal, nErr ) ) { @@ -1435,7 +1435,7 @@ void ScInterpreter::ScXor() do { bRes ^= ( fVal != 0.0 ); - } while ( (nErr == 0) && + } while ( (nErr == FormulaError::NONE) && aValIter.GetNext( fVal, nErr ) ); } SetError( nErr ); @@ -1452,8 +1452,8 @@ void ScInterpreter::ScXor() { bHaveValue = true; double fVal = pMat->Xor(); - sal_uInt16 nErr = GetDoubleErrorValue( fVal ); - if ( nErr ) + FormulaError nErr = GetDoubleErrorValue( fVal ); + if ( nErr != FormulaError::NONE ) { SetError( nErr ); bRes = false; @@ -1461,12 +1461,12 @@ void ScInterpreter::ScXor() else bRes ^= ( fVal != 0.0 ); } - // else: GetMatrix did set errIllegalParameter + // else: GetMatrix did set FormulaError::IllegalParameter } break; default: Pop(); - SetError( errIllegalParameter); + SetError( FormulaError::IllegalParameter); } } else @@ -1854,7 +1854,7 @@ void ScInterpreter::ScIsEmpty() default: Pop(); } - nGlobalError = 0; + nGlobalError = FormulaError::NONE; PushInt( nRes ); } @@ -1876,7 +1876,7 @@ bool ScInterpreter::IsString() break; ScRefCellValue aCell(*pDok, aAdr); - if (GetCellErrCode(aCell) == 0) + if (GetCellErrCode(aCell) == FormulaError::NONE) { switch (aCell.meType) { @@ -1897,7 +1897,7 @@ bool ScInterpreter::IsString() { ScExternalRefCache::TokenRef pToken; PopExternalSingleRef(pToken); - if (!nGlobalError && pToken->GetType() == svString) + if (nGlobalError == FormulaError::NONE && pToken->GetType() == svString) bRes = true; } break; @@ -1922,7 +1922,7 @@ bool ScInterpreter::IsString() default: Pop(); } - nGlobalError = 0; + nGlobalError = FormulaError::NONE; return bRes; } @@ -1949,7 +1949,7 @@ void ScInterpreter::ScIsLogical() break; ScRefCellValue aCell(*pDok, aAdr); - if (GetCellErrCode(aCell) == 0) + if (GetCellErrCode(aCell) == FormulaError::NONE) { if (aCell.hasNumeric()) { @@ -1969,11 +1969,11 @@ void ScInterpreter::ScIsLogical() break; default: PopError(); - if ( !nGlobalError ) + if ( nGlobalError == FormulaError::NONE ) bRes = ( nCurFmtType == css::util::NumberFormat::LOGICAL ); } nCurFmtType = nFuncFmtType = css::util::NumberFormat::LOGICAL; - nGlobalError = 0; + nGlobalError = FormulaError::NONE; PushInt( int(bRes) ); } @@ -1990,7 +1990,7 @@ void ScInterpreter::ScType() break; ScRefCellValue aCell(*pDok, aAdr); - if (GetCellErrCode(aCell) == 0) + if (GetCellErrCode(aCell) == FormulaError::NONE) { switch (aCell.meType) { @@ -2021,20 +2021,20 @@ void ScInterpreter::ScType() break; case svString: PopError(); - if ( nGlobalError ) + if ( nGlobalError != FormulaError::NONE ) { nType = 16; - nGlobalError = 0; + nGlobalError = FormulaError::NONE; } else nType = 2; break; case svMatrix: PopMatrix(); - if ( nGlobalError ) + if ( nGlobalError != FormulaError::NONE ) { nType = 16; - nGlobalError = 0; + nGlobalError = FormulaError::NONE; } else nType = 64; @@ -2043,10 +2043,10 @@ void ScInterpreter::ScType() break; default: PopError(); - if ( nGlobalError ) + if ( nGlobalError != FormulaError::NONE ) { nType = 16; - nGlobalError = 0; + nGlobalError = FormulaError::NONE; } else nType = 1; @@ -2149,7 +2149,7 @@ void ScInterpreter::ScCell() bError = !PopDoubleRefOrSingleRef( aCellPos ); } OUString aInfoType = GetString().getString(); - if( bError || nGlobalError ) + if( bError || nGlobalError != FormulaError::NONE ) PushIllegalParameter(); else { @@ -2314,14 +2314,14 @@ void ScInterpreter::ScCellExternal() ScExternalRefCache::TokenRef pToken; ScExternalRefCache::CellFormat aFmt; PopExternalSingleRef(nFileId, aTabName, aRef, pToken, &aFmt); - if (nGlobalError) + if (nGlobalError != FormulaError::NONE) { PushError( nGlobalError); return; } OUString aInfoType = GetString().getString(); - if (nGlobalError) + if (nGlobalError != FormulaError::NONE) { PushError( nGlobalError); return; @@ -2332,7 +2332,7 @@ void ScInterpreter::ScCellExternal() SCTAB nTab; aRef.SetAbsTab(0); // external ref has a tab index of -1, which SingleRefToVars() don't like. SingleRefToVars(aRef, nCol, nRow, nTab); - if (nGlobalError) + if (nGlobalError != FormulaError::NONE) { PushIllegalParameter(); return; @@ -2354,7 +2354,7 @@ void ScInterpreter::ScCellExternal() if (pRefMgr->getCacheTable(nFileId, aTabName, false).get()) PushInt(1); else - SetError(errNoName); + SetError(FormulaError::NoName); } else if ( aInfoType == "ADDRESS" ) { @@ -2375,7 +2375,7 @@ void ScInterpreter::ScCellExternal() if (!p) { // In theory this should never happen... - SetError(errNoName); + SetError(FormulaError::NoName); return; } @@ -2462,7 +2462,7 @@ void ScInterpreter::ScIsRef() { ScAddress aAdr; PopSingleRef( aAdr ); - if ( !nGlobalError ) + if ( nGlobalError == FormulaError::NONE ) bRes = true; } break; @@ -2470,14 +2470,14 @@ void ScInterpreter::ScIsRef() { ScRange aRange; PopDoubleRef( aRange ); - if ( !nGlobalError ) + if ( nGlobalError == FormulaError::NONE ) bRes = true; } break; case svRefList : { FormulaConstTokenRef x = PopToken(); - if ( !nGlobalError ) + if ( nGlobalError == FormulaError::NONE ) bRes = !x.get()->GetRefList()->empty(); } break; @@ -2485,7 +2485,7 @@ void ScInterpreter::ScIsRef() { ScExternalRefCache::TokenRef pToken; PopExternalSingleRef(pToken); - if (!nGlobalError) + if (nGlobalError == FormulaError::NONE) bRes = true; } break; @@ -2493,14 +2493,14 @@ void ScInterpreter::ScIsRef() { ScExternalRefCache::TokenArrayRef pArray; PopExternalDoubleRef(pArray); - if (!nGlobalError) + if (nGlobalError == FormulaError::NONE) bRes = true; } break; default: Pop(); } - nGlobalError = 0; + nGlobalError = FormulaError::NONE; PushInt( int(bRes) ); } @@ -2522,7 +2522,7 @@ void ScInterpreter::ScIsValue() break; ScRefCellValue aCell(*pDok, aAdr); - if (GetCellErrCode(aCell) == 0) + if (GetCellErrCode(aCell) == FormulaError::NONE) { switch (aCell.meType) { @@ -2542,7 +2542,7 @@ void ScInterpreter::ScIsValue() { ScExternalRefCache::TokenRef pToken; PopExternalSingleRef(pToken); - if (!nGlobalError && pToken->GetType() == svDouble) + if (nGlobalError == FormulaError::NONE && pToken->GetType() == svDouble) bRes = true; } break; @@ -2554,7 +2554,7 @@ void ScInterpreter::ScIsValue() ; // nothing else if ( !pJumpMatrix ) { - if (pMat->GetErrorIfNotString( 0, 0) == 0) + if (pMat->GetErrorIfNotString( 0, 0) == FormulaError::NONE) bRes = pMat->IsValue( 0, 0); } else @@ -2563,7 +2563,7 @@ void ScInterpreter::ScIsValue() pMat->GetDimensions( nCols, nRows); pJumpMatrix->GetPos( nC, nR); if ( nC < nCols && nR < nRows ) - if (pMat->GetErrorIfNotString( nC, nR) == 0) + if (pMat->GetErrorIfNotString( nC, nR) == FormulaError::NONE) bRes = pMat->IsValue( nC, nR); } } @@ -2571,7 +2571,7 @@ void ScInterpreter::ScIsValue() default: Pop(); } - nGlobalError = 0; + nGlobalError = FormulaError::NONE; PushInt( int(bRes) ); } @@ -2594,7 +2594,7 @@ void ScInterpreter::ScIsFormula() default: Pop(); } - nGlobalError = 0; + nGlobalError = FormulaError::NONE; PushInt( int(bRes) ); } @@ -2610,12 +2610,12 @@ void ScInterpreter::ScFormula() SCROW nRow1, nRow2; SCTAB nTab1, nTab2; PopDoubleRef( nCol1, nRow1, nTab1, nCol2, nRow2, nTab2); - if (nGlobalError) + if (nGlobalError != FormulaError::NONE) break; if (nTab1 != nTab2) { - SetError( errIllegalArgument); + SetError( FormulaError::IllegalArgument); break; } @@ -2640,7 +2640,7 @@ void ScInterpreter::ScFormula() pResMat->PutString( mrStrPool.intern( aFormula), i,j); break; default: - pResMat->PutError( NOTAVAILABLE, i,j); + pResMat->PutError( FormulaError::NotAvailable, i,j); } ++j; } @@ -2665,13 +2665,13 @@ void ScInterpreter::ScFormula() aCell.mpFormula->GetFormula(aFormula); break; default: - SetError( NOTAVAILABLE ); + SetError( FormulaError::NotAvailable ); } } break; default: Pop(); - SetError( NOTAVAILABLE ); + SetError( FormulaError::NotAvailable ); } PushString( aFormula ); } @@ -2687,13 +2687,13 @@ void ScInterpreter::ScIsNV() { ScAddress aAdr; bool bOk = PopDoubleRefOrSingleRef( aAdr ); - if ( nGlobalError == NOTAVAILABLE ) + if ( nGlobalError == FormulaError::NotAvailable ) bRes = true; else if (bOk) { ScRefCellValue aCell(*pDok, aAdr); - sal_uInt16 nErr = GetCellErrCode(aCell); - bRes = (nErr == NOTAVAILABLE); + FormulaError nErr = GetCellErrCode(aCell); + bRes = (nErr == FormulaError::NotAvailable); } } break; @@ -2701,8 +2701,8 @@ void ScInterpreter::ScIsNV() { ScExternalRefCache::TokenRef pToken; PopExternalSingleRef(pToken); - if (nGlobalError == NOTAVAILABLE || - (pToken && pToken->GetType() == svError && pToken->GetError() == NOTAVAILABLE)) + if (nGlobalError == FormulaError::NotAvailable || + (pToken && pToken->GetType() == svError && pToken->GetError() == FormulaError::NotAvailable)) bRes = true; } break; @@ -2713,23 +2713,23 @@ void ScInterpreter::ScIsNV() if ( !pMat ) ; // nothing else if ( !pJumpMatrix ) - bRes = (pMat->GetErrorIfNotString( 0, 0) == NOTAVAILABLE); + bRes = (pMat->GetErrorIfNotString( 0, 0) == FormulaError::NotAvailable); else { SCSIZE nCols, nRows, nC, nR; pMat->GetDimensions( nCols, nRows); pJumpMatrix->GetPos( nC, nR); if ( nC < nCols && nR < nRows ) - bRes = (pMat->GetErrorIfNotString( nC, nR) == NOTAVAILABLE); + bRes = (pMat->GetErrorIfNotString( nC, nR) == FormulaError::NotAvailable); } } break; default: PopError(); - if ( nGlobalError == NOTAVAILABLE ) + if ( nGlobalError == FormulaError::NotAvailable ) bRes = true; } - nGlobalError = 0; + nGlobalError = FormulaError::NONE; PushInt( int(bRes) ); } @@ -2744,13 +2744,13 @@ void ScInterpreter::ScIsErr() { ScAddress aAdr; bool bOk = PopDoubleRefOrSingleRef( aAdr ); - if ( !bOk || (nGlobalError && nGlobalError != NOTAVAILABLE) ) + if ( !bOk || (nGlobalError != FormulaError::NONE && nGlobalError != FormulaError::NotAvailable) ) bRes = true; else { ScRefCellValue aCell(*pDok, aAdr); - sal_uInt16 nErr = GetCellErrCode(aCell); - bRes = (nErr && nErr != NOTAVAILABLE); + FormulaError nErr = GetCellErrCode(aCell); + bRes = (nErr != FormulaError::NONE && nErr != FormulaError::NotAvailable); } } break; @@ -2758,8 +2758,8 @@ void ScInterpreter::ScIsErr() { ScExternalRefCache::TokenRef pToken; PopExternalSingleRef(pToken); - if ((nGlobalError && nGlobalError != NOTAVAILABLE) || !pToken || - (pToken->GetType() == svError && pToken->GetError() != NOTAVAILABLE)) + if ((nGlobalError != FormulaError::NONE && nGlobalError != FormulaError::NotAvailable) || !pToken || + (pToken->GetType() == svError && pToken->GetError() != FormulaError::NotAvailable)) bRes = true; } break; @@ -2767,12 +2767,12 @@ void ScInterpreter::ScIsErr() case svMatrix: { ScMatrixRef pMat = GetMatrix(); - if ( nGlobalError || !pMat ) - bRes = ((nGlobalError && nGlobalError != NOTAVAILABLE) || !pMat); + if ( nGlobalError != FormulaError::NONE || !pMat ) + bRes = ((nGlobalError != FormulaError::NONE && nGlobalError != FormulaError::NotAvailable) || !pMat); else if ( !pJumpMatrix ) { - sal_uInt16 nErr = pMat->GetErrorIfNotString( 0, 0); - bRes = (nErr && nErr != NOTAVAILABLE); + FormulaError nErr = pMat->GetErrorIfNotString( 0, 0); + bRes = (nErr != FormulaError::NONE && nErr != FormulaError::NotAvailable); } else { @@ -2781,18 +2781,18 @@ void ScInterpreter::ScIsErr() pJumpMatrix->GetPos( nC, nR); if ( nC < nCols && nR < nRows ) { - sal_uInt16 nErr = pMat->GetErrorIfNotString( nC, nR); - bRes = (nErr && nErr != NOTAVAILABLE); + FormulaError nErr = pMat->GetErrorIfNotString( nC, nR); + bRes = (nErr != FormulaError::NONE && nErr != FormulaError::NotAvailable); } } } break; default: PopError(); - if ( nGlobalError && nGlobalError != NOTAVAILABLE ) + if ( nGlobalError != FormulaError::NONE && nGlobalError != FormulaError::NotAvailable ) bRes = true; } - nGlobalError = 0; + nGlobalError = FormulaError::NONE; PushInt( int(bRes) ); } @@ -2811,12 +2811,12 @@ void ScInterpreter::ScIsError() bRes = true; break; } - if ( nGlobalError ) + if ( nGlobalError != FormulaError::NONE ) bRes = true; else { ScRefCellValue aCell(*pDok, aAdr); - bRes = (GetCellErrCode(aCell) != 0); + bRes = (GetCellErrCode(aCell) != FormulaError::NONE); } } break; @@ -2824,7 +2824,7 @@ void ScInterpreter::ScIsError() { ScExternalRefCache::TokenRef pToken; PopExternalSingleRef(pToken); - if (nGlobalError || pToken->GetType() == svError) + if (nGlobalError != FormulaError::NONE || pToken->GetType() == svError) bRes = true; } break; @@ -2832,26 +2832,26 @@ void ScInterpreter::ScIsError() case svMatrix: { ScMatrixRef pMat = GetMatrix(); - if ( nGlobalError || !pMat ) + if ( nGlobalError != FormulaError::NONE || !pMat ) bRes = true; else if ( !pJumpMatrix ) - bRes = (pMat->GetErrorIfNotString( 0, 0) != 0); + bRes = (pMat->GetErrorIfNotString( 0, 0) != FormulaError::NONE); else { SCSIZE nCols, nRows, nC, nR; pMat->GetDimensions( nCols, nRows); pJumpMatrix->GetPos( nC, nR); if ( nC < nCols && nR < nRows ) - bRes = (pMat->GetErrorIfNotString( nC, nR) != 0); + bRes = (pMat->GetErrorIfNotString( nC, nR) != FormulaError::NONE); } } break; default: PopError(); - if ( nGlobalError ) + if ( nGlobalError != FormulaError::NONE ) bRes = true; } - nGlobalError = 0; + nGlobalError = FormulaError::NONE; PushInt( int(bRes) ); } @@ -2870,8 +2870,8 @@ bool ScInterpreter::IsEven() break; ScRefCellValue aCell(*pDok, aAdr); - sal_uInt16 nErr = GetCellErrCode(aCell); - if (nErr != 0) + FormulaError nErr = GetCellErrCode(aCell); + if (nErr != FormulaError::NONE) SetError(nErr); else { @@ -2904,7 +2904,7 @@ bool ScInterpreter::IsEven() { ScExternalRefCache::TokenRef pToken; PopExternalSingleRef(pToken); - if (!nGlobalError && pToken->GetType() == svDouble) + if (nGlobalError == FormulaError::NONE && pToken->GetType() == svDouble) { fVal = pToken->GetDouble(); bRes = true; @@ -2935,7 +2935,7 @@ bool ScInterpreter::IsEven() fVal = pMat->GetDouble( nC, nR); } else - SetError( errNoValue); + SetError( FormulaError::NoValue); } } break; @@ -2943,7 +2943,7 @@ bool ScInterpreter::IsEven() ; // nothing } if ( !bRes ) - SetError( errIllegalParameter); + SetError( FormulaError::IllegalParameter); else bRes = ( fmod( ::rtl::math::approxFloor( fabs( fVal ) ), 2.0 ) < 0.5 ); return bRes; @@ -2961,18 +2961,18 @@ void ScInterpreter::ScIsOdd() void ScInterpreter::ScN() { - sal_uInt16 nErr = nGlobalError; - nGlobalError = 0; + FormulaError nErr = nGlobalError; + nGlobalError = FormulaError::NONE; // Temporarily override the ConvertStringToValue() error for // GetCellValue() / GetCellValueOrZero() - sal_uInt16 nSErr = mnStringNoValueError; - mnStringNoValueError = errCellNoValue; + FormulaError nSErr = mnStringNoValueError; + mnStringNoValueError = FormulaError::CellNoValue; double fVal = GetDouble(); mnStringNoValueError = nSErr; - if (nErr) + if (nErr != FormulaError::NONE) nGlobalError = nErr; // preserve previous error if any - else if (nGlobalError == errCellNoValue) - nGlobalError = 0; // reset temporary detection error + else if (nGlobalError == FormulaError::CellNoValue) + nGlobalError = FormulaError::NONE; // reset temporary detection error PushDouble(fVal); } @@ -3048,7 +3048,7 @@ void ScInterpreter::ScT() } bool bValue = false; ScRefCellValue aCell(*pDok, aAdr); - if (GetCellErrCode(aCell) == 0) + if (GetCellErrCode(aCell) == FormulaError::NONE) { switch (aCell.meType) { @@ -3096,7 +3096,7 @@ void ScInterpreter::ScT() ; // leave on stack break; default : - PushError( errUnknownOpCode); + PushError( FormulaError::UnknownOpCode); } } @@ -3218,7 +3218,7 @@ void ScInterpreter::ScNumberValue() default: aInputString = GetString().getString(); } - if ( nGlobalError ) + if ( nGlobalError != FormulaError::NONE ) { PushError( nGlobalError ); return; @@ -3411,7 +3411,7 @@ void ScInterpreter::ScUnichar() if ( MustHaveParamCount( GetByte(), 1 ) ) { sal_uInt32 nCodePoint = GetUInt32(); - if (nGlobalError || !rtl::isUnicodeCodePoint(nCodePoint)) + if (nGlobalError != FormulaError::NONE || !rtl::isUnicodeCodePoint(nCodePoint)) PushIllegalArgument(); else { @@ -3462,7 +3462,7 @@ void ScInterpreter::ScMin( bool bTextAsZero ) case svDoubleRef : case svRefList : { - sal_uInt16 nErr = 0; + FormulaError nErr = FormulaError::NONE; PopDoubleRef( aRange, nParamCount, nRefInList); ScValueIterator aValIter( pDok, aRange, mnSubTotalFlags, bTextAsZero ); if (aValIter.GetFirst(nVal, nErr)) @@ -3470,7 +3470,7 @@ void ScInterpreter::ScMin( bool bTextAsZero ) if (nMin > nVal) nMin = nVal; aValIter.GetCurNumFmtInfo( nFuncFmtType, nFuncFmtIndex ); - while ((nErr == 0) && aValIter.GetNext(nVal, nErr)) + while ((nErr == FormulaError::NONE) && aValIter.GetNext(nVal, nErr)) { if (nMin > nVal) nMin = nVal; @@ -3502,12 +3502,12 @@ void ScInterpreter::ScMin( bool bTextAsZero ) nMin = 0.0; } else - SetError(errIllegalParameter); + SetError(FormulaError::IllegalParameter); } break; default : Pop(); - SetError(errIllegalParameter); + SetError(FormulaError::IllegalParameter); } } if ( nVal < nMin ) @@ -3557,7 +3557,7 @@ void ScInterpreter::ScMax( bool bTextAsZero ) case svDoubleRef : case svRefList : { - sal_uInt16 nErr = 0; + FormulaError nErr = FormulaError::NONE; PopDoubleRef( aRange, nParamCount, nRefInList); ScValueIterator aValIter( pDok, aRange, mnSubTotalFlags, bTextAsZero ); if (aValIter.GetFirst(nVal, nErr)) @@ -3565,7 +3565,7 @@ void ScInterpreter::ScMax( bool bTextAsZero ) if (nMax < nVal) nMax = nVal; aValIter.GetCurNumFmtInfo( nFuncFmtType, nFuncFmtIndex ); - while ((nErr == 0) && aValIter.GetNext(nVal, nErr)) + while ((nErr == FormulaError::NONE) && aValIter.GetNext(nVal, nErr)) { if (nMax < nVal) nMax = nVal; @@ -3597,12 +3597,12 @@ void ScInterpreter::ScMax( bool bTextAsZero ) nMax = 0.0; } else - SetError(errIllegalParameter); + SetError(FormulaError::IllegalParameter); } break; default : Pop(); - SetError(errIllegalParameter); + SetError(FormulaError::IllegalParameter); } } if ( nVal > nMax ) @@ -3623,14 +3623,14 @@ void ScInterpreter::GetStVarParams( double& rVal, double& rValCount, bool bTextA ScAddress aAdr; ScRange aRange; size_t nRefInList = 0; - while (!nGlobalError && nParamCount-- > 0) + while (nGlobalError == FormulaError::NONE && nParamCount-- > 0) { switch (GetStackType()) { case svDouble : { fVal = GetDouble(); - if (!nGlobalError) + if (nGlobalError == FormulaError::NONE) { values.push_back(fVal); fSum += fVal; @@ -3644,7 +3644,7 @@ void ScInterpreter::GetStVarParams( double& rVal, double& rValCount, bool bTextA if (aCell.hasNumeric()) { fVal = GetCellValue(aAdr, aCell); - if (!nGlobalError) + if (nGlobalError == FormulaError::NONE) { values.push_back(fVal); fSum += fVal; @@ -3659,7 +3659,7 @@ void ScInterpreter::GetStVarParams( double& rVal, double& rValCount, bool bTextA case svDoubleRef : case svRefList : { - sal_uInt16 nErr = 0; + FormulaError nErr = FormulaError::NONE; PopDoubleRef( aRange, nParamCount, nRefInList); ScValueIterator aValIter( pDok, aRange, mnSubTotalFlags, bTextAsZero ); if (aValIter.GetFirst(fVal, nErr)) @@ -3669,9 +3669,9 @@ void ScInterpreter::GetStVarParams( double& rVal, double& rValCount, bool bTextA values.push_back(fVal); fSum += fVal; } - while ((nErr == 0) && aValIter.GetNext(fVal, nErr)); + while ((nErr == FormulaError::NONE) && aValIter.GetNext(fVal, nErr)); } - if ( nErr ) + if ( nErr != FormulaError::NONE ) { SetError(nErr); } @@ -3691,7 +3691,7 @@ void ScInterpreter::GetStVarParams( double& rVal, double& rValCount, bool bTextA if (!pMat->IsString(nMatCol,nMatRow)) { fVal= pMat->GetDouble(nMatCol,nMatRow); - if (!nGlobalError) + if (nGlobalError == FormulaError::NONE) { values.push_back(fVal); fSum += fVal; @@ -3714,20 +3714,20 @@ void ScInterpreter::GetStVarParams( double& rVal, double& rValCount, bool bTextA values.push_back(0.0); } else - SetError(errIllegalParameter); + SetError(FormulaError::IllegalParameter); } break; default : Pop(); - SetError(errIllegalParameter); + SetError(FormulaError::IllegalParameter); } } ::std::vector<double>::size_type n = values.size(); rValCount = n; if (!n) - SetError( errDivisionByZero); - if (!nGlobalError) + SetError( FormulaError::DivisionByZero); + if (nGlobalError == FormulaError::NONE) { const double vMean = fSum / n; for (::std::vector<double>::size_type i = 0; i < n; i++) @@ -3743,7 +3743,7 @@ void ScInterpreter::ScVar( bool bTextAsZero ) GetStVarParams( nVal, nValCount, bTextAsZero ); if (nValCount <= 1.0) - PushError( errDivisionByZero ); + PushError( FormulaError::DivisionByZero ); else PushDouble( nVal / (nValCount - 1.0)); } @@ -3763,7 +3763,7 @@ void ScInterpreter::ScStDev( bool bTextAsZero ) double nValCount; GetStVarParams( nVal, nValCount, bTextAsZero ); if (nValCount <= 1.0) - PushError( errDivisionByZero ); + PushError( FormulaError::DivisionByZero ); else PushDouble( sqrt( nVal / (nValCount - 1.0))); } @@ -3774,7 +3774,7 @@ void ScInterpreter::ScStDevP( bool bTextAsZero ) double nValCount; GetStVarParams( nVal, nValCount, bTextAsZero ); if (nValCount == 0.0) - PushError( errDivisionByZero ); + PushError( FormulaError::DivisionByZero ); else PushDouble( sqrt( nVal / nValCount)); @@ -3847,7 +3847,7 @@ void ScInterpreter::ScColumns() break; default: PopError(); - SetError(errIllegalParameter); + SetError(FormulaError::IllegalParameter); } } PushDouble((double)nVal); @@ -3904,7 +3904,7 @@ void ScInterpreter::ScRows() break; default: PopError(); - SetError(errIllegalParameter); + SetError(FormulaError::IllegalParameter); } } PushDouble((double)nVal); @@ -3957,7 +3957,7 @@ void ScInterpreter::ScSheets() break; default: PopError(); - SetError( errIllegalParameter ); + SetError( FormulaError::IllegalParameter ); } } } @@ -4037,7 +4037,7 @@ void ScInterpreter::ScColumn() } break; default: - SetError( errIllegalParameter ); + SetError( FormulaError::IllegalParameter ); nVal = 0.0; } } @@ -4118,7 +4118,7 @@ void ScInterpreter::ScRow() } break; default: - SetError( errIllegalParameter ); + SetError( FormulaError::IllegalParameter ); nVal = 0.0; } } @@ -4144,7 +4144,7 @@ void ScInterpreter::ScSheet() if ( pDok->GetTable(aStr.getString(), nVal)) ++nVal; else - SetError( errIllegalArgument ); + SetError( FormulaError::IllegalArgument ); } break; case svSingleRef : @@ -4169,9 +4169,9 @@ void ScInterpreter::ScSheet() } break; default: - SetError( errIllegalParameter ); + SetError( FormulaError::IllegalParameter ); } - if ( nGlobalError ) + if ( nGlobalError != FormulaError::NONE ) nVal = 0; } PushDouble( (double) nVal ); @@ -4379,7 +4379,7 @@ void ScInterpreter::ScMatch() return; } - if (nGlobalError == 0) + if (nGlobalError == FormulaError::NONE) { double fVal; ScQueryParam rParam; @@ -4437,7 +4437,7 @@ void ScInterpreter::ScMatch() { ScExternalRefCache::TokenRef pToken; PopExternalSingleRef(pToken); - if (nGlobalError) + if (nGlobalError != FormulaError::NONE) { PushError( nGlobalError); return; @@ -4702,7 +4702,7 @@ void ScInterpreter::ScCountEmptyCells() } } break; - default : SetError(errIllegalParameter); break; + default : SetError(FormulaError::IllegalParameter); break; } PushDouble(nMaxCount - nCount); } @@ -4735,7 +4735,7 @@ double ScInterpreter::IterateParametersIf( ScIterFuncIf eFunc ) PopDoubleRef( nCol3, nRow3, nTab3, nColJunk, nRowJunk, nTabJunk ); if ( nTabJunk != nTab3 ) { - SetError( errIllegalParameter); + SetError( FormulaError::IllegalParameter); return 0; } } @@ -4752,7 +4752,7 @@ double ScInterpreter::IterateParametersIf( ScIterFuncIf eFunc ) pSumExtraMatrix = GetNewMat(1,1); ScExternalRefCache::TokenRef pToken; PopExternalSingleRef(pToken); - if (nGlobalError) + if (nGlobalError != FormulaError::NONE) return 0; if (pToken->GetType() == svDouble) @@ -4765,7 +4765,7 @@ double ScInterpreter::IterateParametersIf( ScIterFuncIf eFunc ) PopExternalDoubleRef(pSumExtraMatrix); break; default: - SetError( errIllegalParameter); + SetError( FormulaError::IllegalParameter); return 0; } } @@ -4822,7 +4822,7 @@ double ScInterpreter::IterateParametersIf( ScIterFuncIf eFunc ) { ScExternalRefCache::TokenRef pToken; PopExternalSingleRef(pToken); - if (!nGlobalError) + if (nGlobalError == FormulaError::NONE) { if (pToken->GetType() == svDouble) { @@ -4862,7 +4862,7 @@ double ScInterpreter::IterateParametersIf( ScIterFuncIf eFunc ) case svRefList : if (bSumExtraRange) { - SetError( errIllegalParameter); + SetError( FormulaError::IllegalParameter); } else { @@ -4887,7 +4887,7 @@ double ScInterpreter::IterateParametersIf( ScIterFuncIf eFunc ) pQueryMatrix = GetMatrix(); if (!pQueryMatrix) { - SetError( errIllegalParameter); + SetError( FormulaError::IllegalParameter); return 0; } nCol1 = 0; @@ -4901,11 +4901,11 @@ double ScInterpreter::IterateParametersIf( ScIterFuncIf eFunc ) } break; default: - SetError( errIllegalParameter); + SetError( FormulaError::IllegalParameter); } if ( nTab1 != nTab2 ) { - SetError( errIllegalParameter); + SetError( FormulaError::IllegalParameter); } if (bSumExtraRange) @@ -4953,7 +4953,7 @@ double ScInterpreter::IterateParametersIf( ScIterFuncIf eFunc ) nTab3 = nTab1; } - if (nGlobalError == 0) + if (nGlobalError == FormulaError::NONE) { ScQueryParam rParam; rParam.nRow1 = nRow1; @@ -4986,9 +4986,9 @@ double ScInterpreter::IterateParametersIf( ScIterFuncIf eFunc ) // Never case-sensitive. sc::CompareOptions aOptions( pDok, rEntry, rParam.eSearchType); ScMatrixRef pResultMatrix = QueryMat( pQueryMatrix, aOptions); - if (nGlobalError || !pResultMatrix) + if (nGlobalError != FormulaError::NONE || !pResultMatrix) { - SetError( errIllegalParameter); + SetError( FormulaError::IllegalParameter); } if (pSumExtraMatrix) @@ -5099,7 +5099,7 @@ double ScInterpreter::IterateParametersIf( ScIterFuncIf eFunc ) } else { - SetError( errIllegalParameter); + SetError( FormulaError::IllegalParameter); return 0; } } @@ -5245,7 +5245,7 @@ void ScInterpreter::ScCountIf() PushIllegalParameter(); return; } - if (nGlobalError == 0) + if (nGlobalError == FormulaError::NONE) { ScQueryParam rParam; rParam.nRow1 = nRow1; @@ -5274,7 +5274,7 @@ void ScInterpreter::ScCountIf() // Never case-sensitive. sc::CompareOptions aOptions( pDok, rEntry, rParam.eSearchType); ScMatrixRef pResultMatrix = QueryMat( pQueryMatrix, aOptions); - if (nGlobalError || !pResultMatrix) + if (nGlobalError != FormulaError::NONE || !pResultMatrix) { PushIllegalParameter(); return; @@ -5325,7 +5325,7 @@ double ScInterpreter::IterateParametersIfs( ScIterFuncIfs eFunc ) if ( !bCheck ) { - SetError( errParameterExpected); + SetError( FormulaError::ParameterExpected); } else { @@ -5344,7 +5344,7 @@ double ScInterpreter::IterateParametersIfs( ScIterFuncIfs eFunc ) SCCOL nDimensionCols = 0; SCROW nDimensionRows = 0; - while (nParamCount > 1 && !nGlobalError) + while (nParamCount > 1 && nGlobalError == FormulaError::NONE) { // take criteria svl::SharedString aString; @@ -5399,7 +5399,7 @@ double ScInterpreter::IterateParametersIfs( ScIterFuncIfs eFunc ) { ScExternalRefCache::TokenRef pToken; PopExternalSingleRef(pToken); - if (!nGlobalError) + if (nGlobalError == FormulaError::NONE) { if (pToken->GetType() == svDouble) { @@ -5418,7 +5418,7 @@ double ScInterpreter::IterateParametersIfs( ScIterFuncIfs eFunc ) } } - if (nGlobalError) + if (nGlobalError != FormulaError::NONE) return 0; // and bail out, no need to evaluate other arguments // take range @@ -5456,7 +5456,7 @@ double ScInterpreter::IterateParametersIfs( ScIterFuncIfs eFunc ) pQueryMatrix = PopMatrix(); if (!pQueryMatrix) { - SetError( errIllegalParameter); + SetError( FormulaError::IllegalParameter); return 0; } nCol1 = 0; @@ -5470,12 +5470,12 @@ double ScInterpreter::IterateParametersIfs( ScIterFuncIfs eFunc ) } break; default: - SetError( errIllegalParameter); + SetError( FormulaError::IllegalParameter); return 0; } if ( nTab1 != nTab2 ) { - SetError( errIllegalArgument); + SetError( FormulaError::IllegalArgument); return 0; } @@ -5486,12 +5486,12 @@ double ScInterpreter::IterateParametersIfs( ScIterFuncIfs eFunc ) nDimensionRows = nRow2 - nRow1 + 1; if ((nDimensionCols != (nCol2 - nCol1 + 1)) || (nDimensionRows != (nRow2 - nRow1 + 1))) { - SetError ( errIllegalArgument); + SetError ( FormulaError::IllegalArgument); return 0; } // recalculate matrix values - if (nGlobalError) + if (nGlobalError != FormulaError::NONE) return 0; // initialize temporary result matrix @@ -5533,9 +5533,9 @@ double ScInterpreter::IterateParametersIfs( ScIterFuncIfs eFunc ) // Never case-sensitive. sc::CompareOptions aOptions( pDok, rEntry, rParam.eSearchType); ScMatrixRef pResultMatrix = QueryMat( pQueryMatrix, aOptions); - if (nGlobalError || !pResultMatrix) + if (nGlobalError != FormulaError::NONE || !pResultMatrix) { - SetError( errIllegalParameter); + SetError( FormulaError::IllegalParameter); return 0; } @@ -5544,7 +5544,7 @@ double ScInterpreter::IterateParametersIfs( ScIterFuncIfs eFunc ) pResultMatrix->GetDoubleArray(aResValues); if (aResArray.size() != aResValues.size()) { - SetError( errIllegalParameter); + SetError( FormulaError::IllegalParameter); return 0; } @@ -5571,7 +5571,7 @@ double ScInterpreter::IterateParametersIfs( ScIterFuncIfs eFunc ) nParamCount -= 2; } - if (nGlobalError) + if (nGlobalError != FormulaError::NONE) return 0; // bail out // main range - only for AVERAGEIFS, SUMIFS, MINIFS and MAXIFS @@ -5612,7 +5612,7 @@ double ScInterpreter::IterateParametersIfs( ScIterFuncIfs eFunc ) pMainMatrix = PopMatrix(); if (!pMainMatrix) { - SetError( errIllegalParameter); + SetError( FormulaError::IllegalParameter); return 0; } nMainCol1 = 0; @@ -5626,23 +5626,23 @@ double ScInterpreter::IterateParametersIfs( ScIterFuncIfs eFunc ) } break; default: - SetError( errIllegalParameter); + SetError( FormulaError::IllegalParameter); return 0; } if ( nMainTab1 != nMainTab2 ) { - SetError( errIllegalArgument); + SetError( FormulaError::IllegalArgument); return 0; } // All reference ranges must be of same dimension and size. if ((nDimensionCols != (nMainCol2 - nMainCol1 + 1)) || (nDimensionRows != (nMainRow2 - nMainRow1 + 1))) { - SetError ( errIllegalArgument); + SetError ( FormulaError::IllegalArgument); return 0; } - if (nGlobalError) + if (nGlobalError != FormulaError::NONE) return 0; // bail out // end-result calculation @@ -5654,7 +5654,7 @@ double ScInterpreter::IterateParametersIfs( ScIterFuncIfs eFunc ) pMainMatrix->GetDoubleArray(aMainValues, false); // Map empty values to NaN's. if (aResArray.size() != aMainValues.size()) { - SetError( errIllegalArgument); + SetError( FormulaError::IllegalArgument); return 0; } @@ -5666,7 +5666,7 @@ double ScInterpreter::IterateParametersIfs( ScIterFuncIfs eFunc ) continue; fVal = *itMain; - if (GetDoubleErrorValue(fVal) == errElementNaN) + if (GetDoubleErrorValue(fVal) == FormulaError::ElementNaN) continue; ++fCount; @@ -5897,7 +5897,7 @@ void ScInterpreter::ScLookup() if (aCell.hasEmptyValue()) { // Empty cells aren't found anywhere, bail out early. - SetError( NOTAVAILABLE); + SetError( FormulaError::NotAvailable); } else if (aCell.hasNumeric()) { @@ -5909,10 +5909,10 @@ void ScInterpreter::ScLookup() } break; default: - SetError( errIllegalParameter); + SetError( FormulaError::IllegalParameter); } - if (nGlobalError) + if (nGlobalError != FormulaError::NONE) { PushError( nGlobalError); return; @@ -6395,7 +6395,7 @@ void ScInterpreter::CalculateLookup(bool bHLookup) nSpIndex = sal::static_int_cast<SCCOL>( nSpIndex + nCol1 ); // value column } - if (nGlobalError) + if (nGlobalError != FormulaError::NONE) { PushIllegalParameter(); return; @@ -6655,7 +6655,7 @@ void ScInterpreter::ScSubTotal() nFunc -= 100; } - if ( nGlobalError || nFunc < 1 || nFunc > 11 ) + if ( nGlobalError != FormulaError::NONE || nFunc < 1 || nFunc > 11 ) PushIllegalArgument(); // simulate return on stack, not SetError(...) else { @@ -6698,7 +6698,7 @@ void ScInterpreter::ScAggregate() PushWithoutError( *p2 ); sal_Int32 nOption = GetInt32(); - if ( nGlobalError || nFunc < 1 || nFunc > 19 ) + if ( nGlobalError != FormulaError::NONE || nFunc < 1 || nFunc > 19 ) PushIllegalArgument(); else { @@ -6821,7 +6821,7 @@ std::unique_ptr<ScDBQueryParamBase> ScInterpreter::GetDBParams( bool& rMissingFi else { PopError(); - SetError( errIllegalParameter ); + SetError( FormulaError::IllegalParameter ); } break; case svMissing : @@ -6829,19 +6829,19 @@ std::unique_ptr<ScDBQueryParamBase> ScInterpreter::GetDBParams( bool& rMissingFi if ( bAllowMissingField ) rMissingField = true; else - SetError( errIllegalParameter ); + SetError( FormulaError::IllegalParameter ); break; default: PopError(); - SetError( errIllegalParameter ); + SetError( FormulaError::IllegalParameter ); } - if (nGlobalError) + if (nGlobalError != FormulaError::NONE) return nullptr; unique_ptr<ScDBRangeBase> pDBRef( PopDBDoubleRef() ); - if (nGlobalError || !pDBRef.get()) + if (nGlobalError != FormulaError::NONE || !pDBRef.get()) return nullptr; if ( bRangeFake ) @@ -6850,10 +6850,10 @@ std::unique_ptr<ScDBQueryParamBase> ScInterpreter::GetDBParams( bool& rMissingFi if (pDBRef->isRangeEqual(aMissingRange)) rMissingField = true; else - SetError( errIllegalParameter ); + SetError( FormulaError::IllegalParameter ); } - if (nGlobalError) + if (nGlobalError != FormulaError::NONE) return nullptr; SCCOL nField = pDBRef->getFirstFieldColumn(); @@ -6863,7 +6863,7 @@ std::unique_ptr<ScDBQueryParamBase> ScInterpreter::GetDBParams( bool& rMissingFi nField = pDBRef->findFieldColumn(static_cast<SCCOL>(nVal)); else { - sal_uInt16 nErr = 0; + FormulaError nErr = FormulaError::NONE; nField = pDBRef->findFieldColumn(aStr.getString(), &nErr); SetError(nErr); } @@ -6916,12 +6916,12 @@ void ScInterpreter::DBIterator( ScIterFunc eFunc ) { if (!pQueryParam->IsValidFieldIndex()) { - SetError(errNoValue); + SetError(FormulaError::NoValue); return; } ScDBQueryDataIterator aValIter(pDok, pQueryParam.release()); ScDBQueryDataIterator::Value aValue; - if ( aValIter.GetFirst(aValue) && !aValue.mnError ) + if ( aValIter.GetFirst(aValue) && aValue.mnError == FormulaError::NONE ) { switch( eFunc ) { @@ -6962,12 +6962,12 @@ void ScInterpreter::DBIterator( ScIterFunc eFunc ) default: ; // nothing } } - while ( aValIter.GetNext(aValue) && !aValue.mnError ); + while ( aValIter.GetNext(aValue) && aValue.mnError == FormulaError::NONE ); } SetError(aValue.mnError); } else - SetError( errIllegalParameter); + SetError( FormulaError::IllegalParameter); switch( eFunc ) { case ifCOUNT: nErg = nCount; break; @@ -7020,18 +7020,18 @@ void ScInterpreter::ScDBCount() { // count only matching records with a value in the "result" field if (!pQueryParam->IsValidFieldIndex()) { - SetError(errNoValue); + SetError(FormulaError::NoValue); return; } ScDBQueryDataIterator aValIter( pDok, pQueryParam.release()); ScDBQueryDataIterator::Value aValue; - if ( aValIter.GetFirst(aValue) && !aValue.mnError ) + if ( aValIter.GetFirst(aValue) && aValue.mnError == FormulaError::NONE ) { do { nCount++; } - while ( aValIter.GetNext(aValue) && !aValue.mnError ); + while ( aValIter.GetNext(aValue) && aValue.mnError == FormulaError::NONE ); } SetError(aValue.mnError); } @@ -7049,20 +7049,20 @@ void ScInterpreter::ScDBCount2() { if (!pQueryParam->IsValidFieldIndex()) { - SetError(errNoValue); + SetError(FormulaError::NoValue); return; } sal_uLong nCount = 0; pQueryParam->mbSkipString = false; ScDBQueryDataIterator aValIter( pDok, pQueryParam.release()); ScDBQueryDataIterator::Value aValue; - if ( aValIter.GetFirst(aValue) && !aValue.mnError ) + if ( aValIter.GetFirst(aValue) && aValue.mnError == FormulaError::NONE ) { do { nCount++; } - while ( aValIter.GetNext(aValue) && !aValue.mnError ); + while ( aValIter.GetNext(aValue) && aValue.mnError == FormulaError::NONE ); } SetError(aValue.mnError); PushDouble( nCount ); @@ -7105,12 +7105,12 @@ void ScInterpreter::GetDBStVarParams( double& rVal, double& rValCount ) { if (!pQueryParam->IsValidFieldIndex()) { - SetError(errNoValue); + SetError(FormulaError::NoValue); return; } ScDBQueryDataIterator aValIter(pDok, pQueryParam.release()); ScDBQueryDataIterator::Value aValue; - if (aValIter.GetFirst(aValue) && !aValue.mnError) + if (aValIter.GetFirst(aValue) && aValue.mnError == FormulaError::NONE) { do { @@ -7118,12 +7118,12 @@ void ScInterpreter::GetDBStVarParams( double& rVal, double& rValCount ) values.push_back(aValue.mfValue); fSum += aValue.mfValue; } - while ((aValue.mnError == 0) && aValIter.GetNext(aValue)); + while ((aValue.mnError == FormulaError::NONE) && aValIter.GetNext(aValue)); } SetError(aValue.mnError); } else - SetError( errIllegalParameter); + SetError( FormulaError::IllegalParameter); vMean = fSum / values.size(); @@ -7327,7 +7327,7 @@ void ScInterpreter::ScIndirect() while (false); } - PushError( errNoRef); + PushError( FormulaError::NoRef); } } } @@ -7383,7 +7383,7 @@ void ScInterpreter::ScAddressFunc() --nCol; --nRow; - if (nGlobalError || !ValidCol( nCol) || !ValidRow( nRow)) + if (nGlobalError != FormulaError::NONE || !ValidCol( nCol) || !ValidRow( nRow)) { PushIllegalArgument(); return; @@ -7434,7 +7434,7 @@ void ScInterpreter::ScOffset() nRowNew = GetInt32WithDefault(-1); nColPlus = GetInt32(); nRowPlus = GetInt32(); - if (nGlobalError) + if (nGlobalError != FormulaError::NONE) { PushError( nGlobalError); return; @@ -7599,9 +7599,9 @@ void ScInterpreter::ScIndex() nAreaCount = (sp ? pStack[sp-1]->GetRefList()->size() : 0); else nAreaCount = 1; // one reference or array or whatever - if (nGlobalError || nAreaCount == 0 || (size_t)nArea > nAreaCount) + if (nGlobalError != FormulaError::NONE || nAreaCount == 0 || (size_t)nArea > nAreaCount) { - PushError( errNoRef); + PushError( FormulaError::NoRef); return; } else if (nArea < 1 || nCol < 0 || nRow < 0) @@ -7616,7 +7616,7 @@ void ScInterpreter::ScIndex() case svExternalDoubleRef: { if (nArea != 1) - SetError(errIllegalArgument); + SetError(FormulaError::IllegalArgument); sal_uInt16 nOldSp = sp; ScMatrixRef pMat = GetMatrix(); if (pMat) @@ -7718,7 +7718,7 @@ void ScInterpreter::ScIndex() if (GetStackType() == svRefList) { FormulaConstTokenRef xRef = PopToken(); - if (nGlobalError || !xRef) + if (nGlobalError != FormulaError::NONE || !xRef) { PushIllegalParameter(); return; @@ -7785,7 +7785,7 @@ void ScInterpreter::ScMultiArea() sal_uInt8 nParamCount = GetByte(); if (MustHaveParamCountMin( nParamCount, 1)) { - while (!nGlobalError && nParamCount-- > 1) + while (nGlobalError == FormulaError::NONE && nParamCount-- > 1) { ScUnionFunc(); } @@ -7822,7 +7822,7 @@ void ScInterpreter::ScAreas() } break; default: - SetError( errIllegalParameter); + SetError( FormulaError::IllegalParameter); } PushDouble( double(nCount)); } @@ -7875,7 +7875,7 @@ void ScInterpreter::ScCurrency() aStr, &pColor, ScGlobal::eLnge)) - SetError(errIllegalArgument); + SetError(FormulaError::IllegalArgument); } else { @@ -8314,19 +8314,19 @@ void ScInterpreter::ScText() default: { FormulaConstTokenRef xTok( PopToken()); - if (!nGlobalError) + if (nGlobalError == FormulaError::NONE) { PushTokenRef( xTok); // Temporarily override the ConvertStringToValue() // error for GetCellValue() / GetCellValueOrZero() - sal_uInt16 nSErr = mnStringNoValueError; - mnStringNoValueError = errNotNumericString; + FormulaError nSErr = mnStringNoValueError; + mnStringNoValueError = FormulaError::NotNumericString; fVal = GetDouble(); mnStringNoValueError = nSErr; - if (nGlobalError == errNotNumericString) + if (nGlobalError == FormulaError::NotNumericString) { // Not numeric. - nGlobalError = 0; + nGlobalError = FormulaError::NONE; PushTokenRef( xTok); aStr = GetString(); bString = true; @@ -8334,7 +8334,7 @@ void ScInterpreter::ScText() } } } - if (nGlobalError) + if (nGlobalError != FormulaError::NONE) PushError( nGlobalError); else { @@ -8431,7 +8431,7 @@ void ScInterpreter::ScRept() PushIllegalArgument(); else if ( fAnz * aStr.getLength() > SAL_MAX_UINT16 ) { - PushError( errStringOverflow ); + PushError( FormulaError::StringOverflow ); } else if ( fAnz == 0.0 ) PushString( EMPTY_OUSTRING ); @@ -8459,31 +8459,31 @@ void ScInterpreter::ScConcat() PushString( aRes ); } -sal_uInt16 ScInterpreter::GetErrorType() +FormulaError ScInterpreter::GetErrorType() { - sal_uInt16 nErr; - sal_uInt16 nOldError = nGlobalError; - nGlobalError = 0; + FormulaError nErr; + FormulaError nOldError = nGlobalError; + nGlobalError = FormulaError::NONE; switch ( GetStackType() ) { case svRefList : { FormulaConstTokenRef x = PopToken(); - if (nGlobalError) + if (nGlobalError != FormulaError::NONE) nErr = nGlobalError; else { const ScRefList* pRefList = x.get()->GetRefList(); size_t n = pRefList->size(); if (!n) - nErr = errNoRef; + nErr = FormulaError::NoRef; else if (n > 1) - nErr = errNoValue; + nErr = FormulaError::NoValue; else { ScRange aRange; DoubleRefToRange( (*pRefList)[0], aRange); - if (nGlobalError) + if (nGlobalError != FormulaError::NONE) nErr = nGlobalError; else { @@ -8501,7 +8501,7 @@ sal_uInt16 ScInterpreter::GetErrorType() { ScRange aRange; PopDoubleRef( aRange ); - if ( nGlobalError ) + if ( nGlobalError != FormulaError::NONE ) nErr = nGlobalError; else { @@ -8517,7 +8517,7 @@ sal_uInt16 ScInterpreter::GetErrorType() { ScAddress aAdr; PopSingleRef( aAdr ); - if ( nGlobalError ) + if ( nGlobalError != FormulaError::NONE ) nErr = nGlobalError; else nErr = pDok->GetErrCode( aAdr ); @@ -8533,11 +8533,11 @@ sal_uInt16 ScInterpreter::GetErrorType() void ScInterpreter::ScErrorType() { - sal_uInt16 nErr = GetErrorType(); - if ( nErr ) + FormulaError nErr = GetErrorType(); + if ( nErr != FormulaError::NONE ) { - nGlobalError = 0; - PushDouble( nErr ); + nGlobalError = FormulaError::NONE; + PushDouble( static_cast<double>(nErr) ); } else { @@ -8547,30 +8547,30 @@ void ScInterpreter::ScErrorType() void ScInterpreter::ScErrorType_ODF() { - sal_uInt16 nErr = GetErrorType(); + FormulaError nErr = GetErrorType(); sal_uInt16 nErrType; switch ( nErr ) { - case errParameterExpected : // #NULL! + case FormulaError::ParameterExpected : // #NULL! nErrType = 1; break; - case errDivisionByZero : // #DIV/0! + case FormulaError::DivisionByZero : // #DIV/0! nErrType = 2; break; - case errNoValue : // #VALUE! + case FormulaError::NoValue : // #VALUE! nErrType = 3; break; - case errNoRef : // #REF! + case FormulaError::NoRef : // #REF! nErrType = 4; break; - case errNoName : // #NAME? + case FormulaError::NoName : // #NAME? nErrType = 5; break; - case errIllegalFPOperation : // #NUM! + case FormulaError::IllegalFPOperation : // #NUM! nErrType = 6; break; - case NOTAVAILABLE : // #N/A + case FormulaError::NotAvailable : // #N/A nErrType = 7; break; /* @@ -8594,7 +8594,7 @@ void ScInterpreter::ScErrorType_ODF() if ( nErrType ) { - nGlobalError = 0; + nGlobalError =FormulaError::NONE; PushDouble( nErrType ); } else diff --git a/sc/source/core/tool/interpr2.cxx b/sc/source/core/tool/interpr2.cxx index 0d02066482ed..826796f80b4a 100644 --- a/sc/source/core/tool/interpr2.cxx +++ b/sc/source/core/tool/interpr2.cxx @@ -97,7 +97,7 @@ double ScInterpreter::GetDateSerial( sal_Int16 nYear, sal_Int16 nMonth, sal_Int1 return (double) (aDate - *(pFormatter->GetNullDate())); else { - SetError(errNoValue); + SetError(FormulaError::NoValue); return 0; } } @@ -226,7 +226,7 @@ void ScInterpreter::ScGetDayOfWeek() nVal -= nFlag - 12; // nVal -= ((nFlag - 11) - 1 = x - 1 = -1,0,1,2,3,4,5) break; default: - SetError( errIllegalArgument); + SetError( FormulaError::IllegalArgument); } PushInt( nVal ); } @@ -311,7 +311,7 @@ void ScInterpreter::ScEasterSunday() { sal_Int16 nDay, nMonth, nYear; nYear = GetInt16(); - if (nGlobalError) + if (nGlobalError != FormulaError::NONE) { PushError( nGlobalError); return; @@ -345,7 +345,7 @@ void ScInterpreter::ScEasterSunday() } } -sal_uInt16 ScInterpreter::GetWeekendAndHolidayMasks( +FormulaError ScInterpreter::GetWeekendAndHolidayMasks( const sal_uInt8 nParamCount, const sal_uInt32 nNullDate, vector< double >& rSortArray, bool bWeekendMask[ 7 ] ) { @@ -353,12 +353,12 @@ sal_uInt16 ScInterpreter::GetWeekendAndHolidayMasks( { vector< double > nWeekendDays; GetNumberSequenceArray( 1, nWeekendDays, false ); - if ( nGlobalError ) + if ( nGlobalError != FormulaError::NONE ) return nGlobalError; else { if ( nWeekendDays.size() != 7 ) - return errIllegalArgument; + return FormulaError::IllegalArgument; // Weekend days defined by string, Sunday...Saturday for ( int i = 0; i < 7; i++ ) @@ -385,11 +385,11 @@ sal_uInt16 ScInterpreter::GetWeekendAndHolidayMasks( return nGlobalError; } -sal_uInt16 ScInterpreter::GetWeekendAndHolidayMasks_MS( +FormulaError ScInterpreter::GetWeekendAndHolidayMasks_MS( const sal_uInt8 nParamCount, const sal_uInt32 nNullDate, vector< double >& rSortArray, bool bWeekendMask[ 7 ], bool bWorkdayFunction ) { - sal_uInt16 nErr = 0; + FormulaError nErr = FormulaError::NONE; OUString aWeekendDays; if ( nParamCount == 4 ) { @@ -409,7 +409,7 @@ sal_uInt16 ScInterpreter::GetWeekendAndHolidayMasks_MS( { case svDoubleRef : case svExternalDoubleRef : - return errNoValue; + return FormulaError::NoValue; break; default : @@ -422,13 +422,13 @@ sal_uInt16 ScInterpreter::GetWeekendAndHolidayMasks_MS( if ( fDouble >= 1.0 && fDouble <= 17 ) aWeekendDays = OUString::number( fDouble ); else - return errNoValue; + return FormulaError::NoValue; } else { if ( aSharedString.isEmpty() || aSharedString.getLength() != 7 || ( bWorkdayFunction && aSharedString.getString() == "1111111" ) ) - return errNoValue; + return FormulaError::NoValue; else aWeekendDays = aSharedString.getString(); } @@ -461,7 +461,7 @@ sal_uInt16 ScInterpreter::GetWeekendAndHolidayMasks_MS( case '5' : bWeekendMask[ WEDNESDAY ] = true; bWeekendMask[ THURSDAY ] = true; break; case '6' : bWeekendMask[ THURSDAY ] = true; bWeekendMask[ FRIDAY ] = true; break; case '7' : bWeekendMask[ FRIDAY ] = true; bWeekendMask[ SATURDAY ] = true; break; - default : nErr = errIllegalArgument; break; + default : nErr = FormulaError::IllegalArgument; break; } break; case 2 : @@ -477,26 +477,26 @@ sal_uInt16 ScInterpreter::GetWeekendAndHolidayMasks_MS( case '5' : bWeekendMask[ THURSDAY ] = true; break; case '6' : bWeekendMask[ FRIDAY ] = true; break; case '7' : bWeekendMask[ SATURDAY ] = true; break; - default : nErr = errIllegalArgument; break; + default : nErr = FormulaError::IllegalArgument; break; } } else - nErr = errIllegalArgument; + nErr = FormulaError::IllegalArgument; break; case 7 : // Weekend days defined by string - for ( int i = 0; i < 7 && !nErr; i++ ) + for ( int i = 0; i < 7 && nErr == FormulaError::NONE; i++ ) { switch ( aWeekendDays[ i ] ) { case '0' : bWeekendMask[ i ] = false; break; case '1' : bWeekendMask[ i ] = true; break; - default : nErr = errIllegalArgument; break; + default : nErr = FormulaError::IllegalArgument; break; } } break; default : - nErr = errIllegalArgument; + nErr = FormulaError::IllegalArgument; break; } } @@ -512,7 +512,7 @@ void ScInterpreter::ScNetWorkdays( bool bOOXML_Version ) bool bWeekendMask[ 7 ]; Date aNullDate = *( pFormatter->GetNullDate() ); sal_uInt32 nNullDate = Date::DateToDays( aNullDate.GetDay(), aNullDate.GetMonth(), aNullDate.GetYear() ); - sal_uInt16 nErr; + FormulaError nErr; if ( bOOXML_Version ) { nErr = GetWeekendAndHolidayMasks_MS( nParamCount, nNullDate, @@ -523,13 +523,13 @@ void ScInterpreter::ScNetWorkdays( bool bOOXML_Version ) nErr = GetWeekendAndHolidayMasks( nParamCount, nNullDate, nSortArray, bWeekendMask ); } - if ( nErr ) + if ( nErr != FormulaError::NONE ) PushError( nErr ); else { sal_uInt32 nDate2 = GetUInt32(); sal_uInt32 nDate1 = GetUInt32(); - if (nGlobalError || (nDate1 > SAL_MAX_UINT32 - nNullDate) || nDate2 > (SAL_MAX_UINT32 - nNullDate)) + if (nGlobalError != FormulaError::NONE || (nDate1 > SAL_MAX_UINT32 - nNullDate) || nDate2 > (SAL_MAX_UINT32 - nNullDate)) { PushIllegalArgument(); return; @@ -573,15 +573,15 @@ void ScInterpreter::ScWorkday_MS() bool bWeekendMask[ 7 ]; Date aNullDate = *( pFormatter->GetNullDate() ); sal_uInt32 nNullDate = Date::DateToDays( aNullDate.GetDay(), aNullDate.GetMonth(), aNullDate.GetYear() ); - sal_uInt16 nErr = GetWeekendAndHolidayMasks_MS( nParamCount, nNullDate, + FormulaError nErr = GetWeekendAndHolidayMasks_MS( nParamCount, nNullDate, nSortArray, bWeekendMask, true ); - if ( nErr ) + if ( nErr != FormulaError::NONE ) PushError( nErr ); else { sal_Int32 nDays = GetInt32(); sal_uInt32 nDate = GetUInt32(); - if (nGlobalError || (nDate > SAL_MAX_UINT32 - nNullDate)) + if (nGlobalError != FormulaError::NONE || (nDate > SAL_MAX_UINT32 - nNullDate)) { PushIllegalArgument(); return; @@ -643,9 +643,9 @@ void ScInterpreter::ScGetDate() sal_Int16 nDay = GetInt16(); sal_Int16 nMonth = GetInt16(); if (IsMissing()) - SetError( errParameterExpected); // Year must be given. + SetError( FormulaError::ParameterExpected); // Year must be given. sal_Int16 nYear = GetInt16(); - if (nGlobalError || nYear < 0) + if (nGlobalError != FormulaError::NONE || nYear < 0) PushIllegalArgument(); else { @@ -717,7 +717,7 @@ void ScInterpreter::ScGetDiffDate360() bFlag = false; double nDate2 = GetDouble(); double nDate1 = GetDouble(); - if (nGlobalError) + if (nGlobalError != FormulaError::NONE) PushError( nGlobalError); else { @@ -783,7 +783,7 @@ void ScInterpreter::ScGetDateDif() double nDate2 = GetDouble(); double nDate1 = GetDouble(); - if (nGlobalError) + if (nGlobalError != FormulaError::NONE) { PushError( nGlobalError); return; @@ -980,7 +980,7 @@ void ScInterpreter::RoundNumber( rtl_math_RoundingMode eMode ) else { sal_Int16 nDec = GetInt16(); - if ( nGlobalError || nDec < -20 || nDec > 20 ) + if ( nGlobalError != FormulaError::NONE || nDec < -20 || nDec > 20 ) PushIllegalArgument(); else fVal = ::rtl::math::round( GetDouble(), nDec, eMode ); @@ -1268,7 +1268,7 @@ void ScInterpreter::ScNPV() for( short i = 0; i < nParamCount; i++ ) pTemp[ i ] = pStack[ sp - i - 1 ]; memcpy( &pStack[ sp - nParamCount ], pTemp, nParamCount * sizeof( FormulaToken* ) ); - if (nGlobalError == 0) + if (nGlobalError == FormulaError::NONE) { double nCount = 1.0; double nInterest = GetDouble(); @@ -1301,16 +1301,16 @@ void ScInterpreter::ScNPV() case svDoubleRef : case svRefList : { - sal_uInt16 nErr = 0; + FormulaError nErr = FormulaError::NONE; double nCellVal; PopDoubleRef( aRange, nParamCount, nRefInList); ScHorizontalValueIterator aValIter( pDok, aRange ); - while ((nErr == 0) && aValIter.GetNext(nCellVal, nErr)) + while ((nErr == FormulaError::NONE) && aValIter.GetNext(nCellVal, nErr)) { nVal += (nCellVal / pow(1.0 + nInterest, (double)nCount)); nCount++; } - if ( nErr != 0 ) + if ( nErr != FormulaError::NONE ) SetError(nErr); } break; @@ -1349,7 +1349,7 @@ void ScInterpreter::ScNPV() } } break; - default : SetError(errIllegalParameter); break; + default : SetError(FormulaError::IllegalParameter); break; } } } @@ -1393,7 +1393,7 @@ void ScInterpreter::ScIRR() sp = sPos; // reset stack double fNom = 0.0; double fDenom = 0.0; - sal_uInt16 nErr = 0; + FormulaError nErr = FormulaError::NONE; PopDoubleRef( aRange ); ScValueIterator aValIter(pDok, aRange, mnSubTotalFlags); if (aValIter.GetFirst(fValue, nErr)) @@ -1402,7 +1402,7 @@ void ScInterpreter::ScIRR() fNom += fValue / pow(1.0+x,(double)nCount); fDenom += -nCount * fValue / pow(1.0+x,nCount+1.0); nCount++; - while ((nErr == 0) && aValIter.GetNext(fValue, nErr)) + while ((nErr == FormulaError::NONE) && aValIter.GetNext(fValue, nErr)) { fNom += fValue / pow(1.0+x,(double)nCount); fDenom += -nCount * fValue / pow(1.0+x,nCount+1.0); @@ -1420,7 +1420,7 @@ void ScInterpreter::ScIRR() if (fEps < SCdEpsilon) PushDouble(x); else - PushError( errNoConvergence); + PushError( FormulaError::NoConvergence); } void ScInterpreter::ScMIRR() @@ -1450,19 +1450,19 @@ void ScInterpreter::ScMIRR() { pMat->GetDimensions( nC, nR ); if ( nC == 0 || nR == 0 ) - SetError( errIllegalArgument ); + SetError( FormulaError::IllegalArgument ); bIsMatrix = true; } else - SetError( errIllegalArgument ); + SetError( FormulaError::IllegalArgument ); } break; default : - SetError( errIllegalParameter ); + SetError( FormulaError::IllegalParameter ); break; } - if ( nGlobalError ) + if ( nGlobalError != FormulaError::NONE ) PushError( nGlobalError ); else { @@ -1484,7 +1484,7 @@ void ScInterpreter::ScMIRR() if ( !pMat->IsValue( j, k ) ) continue; fX = pMat->GetDouble( j, k ); - if ( nGlobalError ) + if ( nGlobalError != FormulaError::NONE ) break; if ( fX > 0.0 ) @@ -1507,7 +1507,7 @@ void ScInterpreter::ScMIRR() { ScValueIterator aValIter( pDok, aRange, mnSubTotalFlags ); double fCellValue; - sal_uInt16 nIterError = 0; + FormulaError nIterError = FormulaError::NONE; bool bLoop = aValIter.GetFirst( fCellValue, nIterError ); while( bLoop ) @@ -1529,13 +1529,13 @@ void ScInterpreter::ScMIRR() bLoop = aValIter.GetNext( fCellValue, nIterError ); } - if ( nIterError ) + if ( nIterError != FormulaError::NONE ) SetError( nIterError ); } if ( !( bHasPosValue && bHasNegValue ) ) - SetError( errIllegalArgument ); + SetError( FormulaError::IllegalArgument ); - if ( nGlobalError ) + if ( nGlobalError != FormulaError::NONE ) PushError( nGlobalError ); else { @@ -1557,7 +1557,7 @@ void ScInterpreter::ScISPMT() double fPeriod = GetDouble(); double fRate = GetDouble(); - if( nGlobalError ) + if( nGlobalError != FormulaError::NONE ) PushError( nGlobalError); else PushDouble( fInvest * fRate * (fPeriod / fTotal - 1.0) ); @@ -2131,7 +2131,7 @@ void ScInterpreter::ScRate() } } if (!bValid) - SetError(errNoConvergence); + SetError(FormulaError::NoConvergence); } PushDouble(fGuess); } @@ -2356,7 +2356,7 @@ void ScInterpreter::ScIntersect() formula::FormulaConstTokenRef p2nd = PopToken(); formula::FormulaConstTokenRef p1st = PopToken(); - if (nGlobalError || !p2nd || !p1st) + if (nGlobalError != FormulaError::NONE || !p2nd || !p1st) { PushIllegalArgument(); return; @@ -2433,7 +2433,7 @@ void ScInterpreter::ScIntersect() } size_t n = pRefList->size(); if (!n) - PushError( errNoRef); + PushError( FormulaError::NoRef); else if (n == 1) { const ScComplexRefData& rRef = (*pRefList)[0]; @@ -2491,7 +2491,7 @@ void ScInterpreter::ScIntersect() SCROW nRow2 = ::std::min( nR2[0], nR2[1]); SCTAB nTab2 = ::std::min( nT2[0], nT2[1]); if (nCol2 < nCol1 || nRow2 < nRow1 || nTab2 < nTab1) - PushError( errNoRef); + PushError( FormulaError::NoRef); else if (nCol2 == nCol1 && nRow2 == nRow1 && nTab2 == nTab1) PushSingleRef( nCol1, nRow1, nTab1); else @@ -2504,7 +2504,7 @@ void ScInterpreter::ScRangeFunc() formula::FormulaConstTokenRef x2 = PopToken(); formula::FormulaConstTokenRef x1 = PopToken(); - if (nGlobalError || !x2 || !x1) + if (nGlobalError != FormulaError::NONE || !x2 || !x1) { PushIllegalArgument(); return; @@ -2524,7 +2524,7 @@ void ScInterpreter::ScUnionFunc() formula::FormulaConstTokenRef p2nd = PopToken(); formula::FormulaConstTokenRef p1st = PopToken(); - if (nGlobalError || !p2nd || !p1st) + if (nGlobalError != FormulaError::NONE || !p2nd || !p1st) { PushIllegalArgument(); return; @@ -2603,7 +2603,7 @@ void ScInterpreter::ScCurrent() PushTokenRef( xTok); } else - PushError( errUnknownStackVariable); + PushError( FormulaError::UnknownStackVariable); } void ScInterpreter::ScStyle() @@ -2685,7 +2685,7 @@ void ScInterpreter::ScDde() if (nParamCount == 4) { sal_uInt32 nTmp = GetUInt32(); - if (nGlobalError || nTmp > SAL_MAX_UINT8) + if (nGlobalError != FormulaError::NONE || nTmp > SAL_MAX_UINT8) { PushIllegalArgument(); return; @@ -2726,7 +2726,7 @@ void ScInterpreter::ScDde() //TODO: Save Dde-links (in addition) more efficient at document !!!!! // ScDdeLink* pLink = pDok->GetDdeLink( aAppl, aTopic, aItem ); - bool bWasError = ( pMyFormulaCell && pMyFormulaCell->GetRawError() != 0 ); + bool bWasError = ( pMyFormulaCell && pMyFormulaCell->GetRawError() != FormulaError::NONE ); if (!pLink) { @@ -2757,8 +2757,8 @@ void ScInterpreter::ScDde() // If an new Error from Reschedule appears when the link is executed then reset the errorflag - if ( pMyFormulaCell && pMyFormulaCell->GetRawError() && !bWasError ) - pMyFormulaCell->SetErrCode(0); + if ( pMyFormulaCell && pMyFormulaCell->GetRawError() != FormulaError::NONE && !bWasError ) + pMyFormulaCell->SetErrCode(FormulaError::NONE); // check the value @@ -2817,7 +2817,7 @@ void ScInterpreter::ScBase() if ( fChars >= SAL_MAX_UINT16 ) nMinLen = 0; // Error - if ( !nGlobalError && nMinLen && 2 <= fBase && fBase <= nDigits && 0 <= fVal ) + if ( nGlobalError == FormulaError::NONE && nMinLen && 2 <= fBase && fBase <= nDigits && 0 <= fVal ) { const sal_Int32 nConstBuf = 128; sal_Unicode aBuf[nConstBuf]; @@ -2895,7 +2895,7 @@ void ScInterpreter::ScBase() } } if ( fVal ) - PushError( errStringOverflow ); + PushError( FormulaError::StringOverflow ); else { if ( nBuf - (p - pBuf) <= nMinLen ) @@ -2916,7 +2916,7 @@ void ScInterpreter::ScDecimal() { double fBase = ::rtl::math::approxFloor( GetDouble() ); OUString aStr = GetString().getString(); - if ( !nGlobalError && 2 <= fBase && fBase <= 36 ) + if ( nGlobalError == FormulaError::NONE && 2 <= fBase && fBase <= 36 ) { double fVal = 0.0; int nBase = (int) fBase; @@ -2973,7 +2973,7 @@ void ScInterpreter::ScConvertOOo() OUString aToUnit = GetString().getString(); OUString aFromUnit = GetString().getString(); double fVal = GetDouble(); - if ( nGlobalError ) + if ( nGlobalError != FormulaError::NONE ) PushError( nGlobalError); else { @@ -2996,7 +2996,7 @@ void ScInterpreter::ScRoman() { double fMode = (nParamCount == 2) ? ::rtl::math::approxFloor( GetDouble() ) : 0.0; double fVal = ::rtl::math::approxFloor( GetDouble() ); - if( nGlobalError ) + if( nGlobalError != FormulaError::NONE ) PushError( nGlobalError); else if( (fMode >= 0.0) && (fMode < 5.0) && (fVal >= 0.0) && (fVal < 4000.0) ) { @@ -3079,7 +3079,7 @@ static bool lcl_GetArabicValue( sal_Unicode cChar, sal_uInt16& rnValue, bool& rb void ScInterpreter::ScArabic() { OUString aRoman = GetString().getString(); - if( nGlobalError ) + if( nGlobalError != FormulaError::NONE ) PushError( nGlobalError); else { @@ -3165,8 +3165,8 @@ void ScInterpreter::ScHyperLink() nResultType = SC_MATVAL_EMPTY; else { - sal_uInt16 nErr = GetCellErrCode(aCell); - if (nErr) + FormulaError nErr = GetCellErrCode(aCell); + if (nErr != FormulaError::NONE) SetError( nErr); else if (aCell.hasNumeric()) { @@ -3190,17 +3190,17 @@ void ScInterpreter::ScHyperLink() break; default: PopError(); - SetError( errIllegalArgument); + SetError( FormulaError::IllegalArgument); } } svl::SharedString aUrl = GetString(); ScMatrixRef pResMat = GetNewMat( 1, 2); - if (nGlobalError) + if (nGlobalError != FormulaError::NONE) { fVal = CreateDoubleError( nGlobalError); nResultType = SC_MATVAL_VALUE; } - if (nParamCount == 2 || nGlobalError) + if (nParamCount == 2 || nGlobalError != FormulaError::NONE) { if (ScMatrix::IsValueType( nResultType)) pResMat->PutDouble( fVal, 0); @@ -3283,7 +3283,7 @@ void ScInterpreter::ScEuroConvert() OUString aToUnit = GetString().getString(); OUString aFromUnit = GetString().getString(); double fVal = GetDouble(); - if ( nGlobalError ) + if ( nGlobalError != FormulaError::NONE ) PushError( nGlobalError); else { @@ -3441,7 +3441,7 @@ void ScInterpreter::ScBahtText() if ( MustHaveParamCount( nParamCount, 1 ) ) { double fValue = GetDouble(); - if( nGlobalError ) + if( nGlobalError != FormulaError::NONE ) { PushError( nGlobalError); return; @@ -3508,7 +3508,7 @@ void ScInterpreter::ScGetPivotData() if (!MustHaveParamCount(nParamCount, 2, 30) || (nParamCount % 2) == 1) { - PushError(errNoRef); + PushError(FormulaError::NoRef); return; } @@ -3542,7 +3542,7 @@ void ScInterpreter::ScGetPivotData() } break; default: - PushError(errNoRef); + PushError(FormulaError::NoRef); return; } } @@ -3574,7 +3574,7 @@ void ScInterpreter::ScGetPivotData() double fDouble; svl::SharedString aSharedString; bool bDouble = GetDoubleOrString( fDouble, aSharedString); - if (nGlobalError) + if (nGlobalError != FormulaError::NONE) { PushError( nGlobalError); return; @@ -3628,7 +3628,7 @@ void ScInterpreter::ScGetPivotData() } break; default: - PushError(errNoRef); + PushError(FormulaError::NoRef); return; } @@ -3636,7 +3636,7 @@ void ScInterpreter::ScGetPivotData() } // Early bail-out, don't grind through data pilot cache and all. - if (nGlobalError) + if (nGlobalError != FormulaError::NONE) { PushError( nGlobalError); return; @@ -3648,7 +3648,7 @@ void ScInterpreter::ScGetPivotData() ScDPObject* pDPObj = pDok->GetDPAtBlock(aBlock); if (!pDPObj) { - PushError(errNoRef); + PushError(FormulaError::NoRef); return; } @@ -3658,7 +3658,7 @@ void ScInterpreter::ScGetPivotData() std::vector<sheet::GeneralFunction> aFilterFuncs; if (!pDPObj->ParseFilters(aDataFieldName, aFilters, aFilterFuncs, aFilterStr)) { - PushError(errNoRef); + PushError(FormulaError::NoRef); return; } @@ -3670,7 +3670,7 @@ void ScInterpreter::ScGetPivotData() double fVal = pDPObj->GetPivotData(aDataFieldName, aFilters); if (rtl::math::isNan(fVal)) { - PushError(errNoRef); + PushError(FormulaError::NoRef); return; } PushDouble(fVal); diff --git a/sc/source/core/tool/interpr3.cxx b/sc/source/core/tool/interpr3.cxx index 5d51bade3c0d..9dcbbcf5fff8 100644 --- a/sc/source/core/tool/interpr3.cxx +++ b/sc/source/core/tool/interpr3.cxx @@ -166,7 +166,7 @@ static double lcl_IterateInverse( const ScDistFunc& rFunction, double fAx, doubl void ScInterpreter::ScNoName() { - PushError(errNoName); + PushError(FormulaError::NoName); } void ScInterpreter::ScBadName() @@ -176,7 +176,7 @@ void ScInterpreter::ScBadName() { PopError(); } - PushError( errNoName); + PushError( FormulaError::NoName); } double ScInterpreter::phi(double x) @@ -440,7 +440,7 @@ double ScInterpreter::Fakultaet(double x) } } else - SetError(errNoValue); + SetError(FormulaError::NoValue); return x; } @@ -576,7 +576,7 @@ double ScInterpreter::GetGamma(double fZ) if (fZ > fMaxGammaArgument) { - SetError(errIllegalFPOperation); + SetError(FormulaError::IllegalFPOperation); return HUGE_VAL; } @@ -591,7 +591,7 @@ double ScInterpreter::GetGamma(double fZ) double fLogTest = lcl_GetLogGammaHelper(fZ+2) - boost::math::log1p(fZ) - log( fabs(fZ)); if (fLogTest >= fLogDblMax) { - SetError( errIllegalFPOperation); + SetError( FormulaError::IllegalFPOperation); return HUGE_VAL; } return lcl_GetGammaHelper(fZ+2) / (fZ+1) / fZ; @@ -605,7 +605,7 @@ double ScInterpreter::GetGamma(double fZ) if (fLogDivisor<0.0) if (fLogPi - fLogDivisor > fLogDblMax) // overflow { - SetError(errIllegalFPOperation); + SetError(FormulaError::IllegalFPOperation); return HUGE_VAL; } @@ -647,7 +647,7 @@ double ScInterpreter::GetTDist( double T, double fDF, int nType ) double R = 0.5 * GetBetaDist( X, 0.5 * fDF, 0.5 ); return ( T < 0 ? R : 1 - R ); } - SetError( errIllegalArgument ); + SetError( FormulaError::IllegalArgument ); return HUGE_VAL; } @@ -766,7 +766,7 @@ void ScInterpreter::ScGamma() else { double fResult = GetGamma(x); - if (nGlobalError) + if (nGlobalError != FormulaError::NONE) { PushError( nGlobalError); return; @@ -857,7 +857,7 @@ double ScInterpreter::GetBetaDistPDF(double fX, double fA, double fB) return -2.0*fX + 2.0; if (fX == 1.0 && fB < 1.0) { - SetError(errIllegalArgument); + SetError(FormulaError::IllegalArgument); return HUGE_VAL; } if (fX <= 0.01) @@ -871,7 +871,7 @@ double ScInterpreter::GetBetaDistPDF(double fX, double fA, double fB) return fA * fX; if (fX == 0.0 && fA < 1.0) { - SetError(errIllegalArgument); + SetError(FormulaError::IllegalArgument); return HUGE_VAL; } return fA * pow(fX,fA-1); @@ -880,7 +880,7 @@ double ScInterpreter::GetBetaDistPDF(double fX, double fA, double fB) { if (fA < 1.0 && fX == 0.0) { - SetError(errIllegalArgument); + SetError(FormulaError::IllegalArgument); return HUGE_VAL; } else @@ -890,7 +890,7 @@ double ScInterpreter::GetBetaDistPDF(double fX, double fA, double fB) { if (fB < 1.0 && fX == 1.0) { - SetError(errIllegalArgument); + SetError(FormulaError::IllegalArgument); return HUGE_VAL; } else @@ -1431,7 +1431,7 @@ void ScInterpreter::ScCritBinom() for (i = 0; i < max && fSum < alpha; i++) { const double x = GetBetaDistPDF( p, ( i + 1 ), ( n - i + 1 ) )/( n + 1 ); - if ( !nGlobalError ) + if ( nGlobalError == FormulaError::NONE ) { fSum += x; } @@ -1468,7 +1468,7 @@ void ScInterpreter::ScCritBinom() for (i = 0; i < max && fSum < alpha; i++) { const double x = GetBetaDistPDF( q, ( i + 1 ), ( n - i + 1 ) )/( n + 1 ); - if ( !nGlobalError ) + if ( nGlobalError == FormulaError::NONE ) { fSum += x; } @@ -1735,7 +1735,7 @@ void ScInterpreter::ScChiDist() return; } fResult = GetChiDist( fChi, fDF); - if (nGlobalError) + if (nGlobalError != FormulaError::NONE) { PushError( nGlobalError); return; @@ -1888,7 +1888,7 @@ void ScInterpreter::ScHypGeomDist_MS() { double fVal = 0.0; - for ( int i = 0; i <= x && !nGlobalError; i++ ) + for ( int i = 0; i <= x && nGlobalError == FormulaError::NONE; i++ ) fVal += GetHypGeomDist( i, n, M, N ); PushDouble( fVal ); @@ -2207,7 +2207,7 @@ void ScInterpreter::ScGammaInv() double fStart = fAlpha * fBeta; double fVal = lcl_IterateInverse( aFunc, fStart*0.5, fStart, bConvError ); if (bConvError) - SetError(errNoConvergence); + SetError(FormulaError::NoConvergence); PushDouble(fVal); } } @@ -2257,7 +2257,7 @@ void ScInterpreter::ScBetaInv() // 0..1 as range for iteration so it isn't extended beyond the valid range double fVal = lcl_IterateInverse( aFunc, 0.0, 1.0, bConvError ); if (bConvError) - PushError( errNoConvergence); + PushError( FormulaError::NoConvergence); else PushDouble(fA + fVal*(fB-fA)); // scale to (A,B) } @@ -2310,7 +2310,7 @@ double ScInterpreter::GetTInv( double fAlpha, double fSize, int nType ) ScTDistFunction aFunc( *this, fAlpha, fSize, nType ); double fVal = lcl_IterateInverse( aFunc, fSize * 0.5, fSize, bConvError ); if (bConvError) - SetError(errNoConvergence); + SetError(FormulaError::NoConvergence); return fVal; } @@ -2345,7 +2345,7 @@ void ScInterpreter::ScFInv() ScFDistFunction aFunc( *this, fP, fF1, fF2 ); double fVal = lcl_IterateInverse( aFunc, fF1*0.5, fF1, bConvError ); if (bConvError) - SetError(errNoConvergence); + SetError(FormulaError::NoConvergence); PushDouble(fVal); } @@ -2366,7 +2366,7 @@ void ScInterpreter::ScFInv_LT() ScFDistFunction aFunc( *this, ( 1.0 - fP ), fF1, fF2 ); double fVal = lcl_IterateInverse( aFunc, fF1*0.5, fF1, bConvError ); if (bConvError) - SetError(errNoConvergence); + SetError(FormulaError::NoConvergence); PushDouble(fVal); } @@ -2400,7 +2400,7 @@ void ScInterpreter::ScChiInv() ScChiDistFunction aFunc( *this, fP, fDF ); double fVal = lcl_IterateInverse( aFunc, fDF*0.5, fDF, bConvError ); if (bConvError) - SetError(errNoConvergence); + SetError(FormulaError::NoConvergence); PushDouble(fVal); } @@ -2435,7 +2435,7 @@ void ScInterpreter::ScChiSqInv() ScChiSqDistFunction aFunc( *this, fP, fDF ); double fVal = lcl_IterateInverse( aFunc, fDF*0.5, fDF, bConvError ); if (bConvError) - SetError(errNoConvergence); + SetError(FormulaError::NoConvergence); PushDouble(fVal); } @@ -2520,7 +2520,7 @@ void ScInterpreter::ScZTest() while (nParam-- > 0) { ScRange aRange; - sal_uInt16 nErr = 0; + FormulaError nErr = FormulaError::NONE; PopDoubleRef( aRange, nParam, nRefInList); ScValueIterator aValIter( pDok, aRange, mnSubTotalFlags ); if (aValIter.GetFirst(fVal, nErr)) @@ -2528,7 +2528,7 @@ void ScInterpreter::ScZTest() fSum += fVal; fSumSqr += fVal*fVal; rValCount++; - while ((nErr == 0) && aValIter.GetNext(fVal, nErr)) + while ((nErr == FormulaError::NONE) && aValIter.GetNext(fVal, nErr)) { fSum += fVal; fSumSqr += fVal*fVal; @@ -2571,10 +2571,10 @@ void ScInterpreter::ScZTest() } } break; - default : SetError(errIllegalParameter); break; + default : SetError(FormulaError::IllegalParameter); break; } if (rValCount <= 1.0) - PushError( errDivisionByZero); + PushError( FormulaError::DivisionByZero); else { double mue = fSum/rValCount; @@ -2859,7 +2859,7 @@ void ScInterpreter::ScKurt() if (fCount == 0.0) { - PushError( errDivisionByZero); + PushError( FormulaError::DivisionByZero); return; } @@ -2873,7 +2873,7 @@ void ScInterpreter::ScKurt() if (fStdDev == 0.0) { - PushError( errDivisionByZero); + PushError( FormulaError::DivisionByZero); return; } @@ -2898,7 +2898,7 @@ void ScInterpreter::ScHarMean() ScAddress aAdr; ScRange aRange; size_t nRefInList = 0; - while ((nGlobalError == 0) && (nParamCount-- > 0)) + while ((nGlobalError == FormulaError::NONE) && (nParamCount-- > 0)) { switch (GetStackType()) { @@ -2911,7 +2911,7 @@ void ScInterpreter::ScHarMean() nValCount++; } else - SetError( errIllegalArgument); + SetError( FormulaError::IllegalArgument); break; } case svSingleRef : @@ -2927,14 +2927,14 @@ void ScInterpreter::ScHarMean() nValCount++; } else - SetError( errIllegalArgument); + SetError( FormulaError::IllegalArgument); } break; } case formula::svDoubleRef : case svRefList : { - sal_uInt16 nErr = 0; + FormulaError nErr = FormulaError::NONE; PopDoubleRef( aRange, nParamCount, nRefInList); double nCellVal; ScValueIterator aValIter( pDok, aRange, mnSubTotalFlags ); @@ -2946,9 +2946,9 @@ void ScInterpreter::ScHarMean() nValCount++; } else - SetError( errIllegalArgument); + SetError( FormulaError::IllegalArgument); SetError(nErr); - while ((nErr == 0) && aValIter.GetNext(nCellVal, nErr)) + while ((nErr == FormulaError::NONE) && aValIter.GetNext(nCellVal, nErr)) { if (nCellVal > 0.0) { @@ -2956,7 +2956,7 @@ void ScInterpreter::ScHarMean() nValCount++; } else - SetError( errIllegalArgument); + SetError( FormulaError::IllegalArgument); } SetError(nErr); } @@ -2981,7 +2981,7 @@ void ScInterpreter::ScHarMean() nValCount++; } else - SetError( errIllegalArgument); + SetError( FormulaError::IllegalArgument); } } else @@ -2996,16 +2996,16 @@ void ScInterpreter::ScHarMean() nValCount++; } else - SetError( errIllegalArgument); + SetError( FormulaError::IllegalArgument); } } } } break; - default : SetError(errIllegalParameter); break; + default : SetError(FormulaError::IllegalParameter); break; } } - if (nGlobalError == 0) + if (nGlobalError == FormulaError::NONE) PushDouble((double)nValCount/nVal); else PushError( nGlobalError); @@ -3020,7 +3020,7 @@ void ScInterpreter::ScGeoMean() ScRange aRange; size_t nRefInList = 0; - while ((nGlobalError == 0) && (nParamCount-- > 0)) + while ((nGlobalError == FormulaError::NONE) && (nParamCount-- > 0)) { switch (GetStackType()) { @@ -3033,7 +3033,7 @@ void ScInterpreter::ScGeoMean() nValCount++; } else - SetError( errIllegalArgument); + SetError( FormulaError::IllegalArgument); break; } case svSingleRef : @@ -3049,14 +3049,14 @@ void ScInterpreter::ScGeoMean() nValCount++; } else - SetError( errIllegalArgument); + SetError( FormulaError::IllegalArgument); } break; } case formula::svDoubleRef : case svRefList : { - sal_uInt16 nErr = 0; + FormulaError nErr = FormulaError::NONE; PopDoubleRef( aRange, nParamCount, nRefInList); double nCellVal; ScValueIterator aValIter( pDok, aRange, mnSubTotalFlags ); @@ -3068,9 +3068,9 @@ void ScInterpreter::ScGeoMean() nValCount++; } else - SetError( errIllegalArgument); + SetError( FormulaError::IllegalArgument); SetError(nErr); - while ((nErr == 0) && aValIter.GetNext(nCellVal, nErr)) + while ((nErr == FormulaError::NONE) && aValIter.GetNext(nCellVal, nErr)) { if (nCellVal > 0.0) { @@ -3078,7 +3078,7 @@ void ScInterpreter::ScGeoMean() nValCount++; } else - SetError( errIllegalArgument); + SetError( FormulaError::IllegalArgument); } SetError(nErr); } @@ -3103,7 +3103,7 @@ void ScInterpreter::ScGeoMean() nValCount++; } else - SetError( errIllegalArgument); + SetError( FormulaError::IllegalArgument); } } else @@ -3118,16 +3118,16 @@ void ScInterpreter::ScGeoMean() nValCount++; } else - SetError( errIllegalArgument); + SetError( FormulaError::IllegalArgument); } } } } break; - default : SetError(errIllegalParameter); break; + default : SetError(FormulaError::IllegalParameter); break; } } - if (nGlobalError == 0) + if (nGlobalError == FormulaError::NONE) PushDouble(exp(nVal / nValCount)); else PushError( nGlobalError); @@ -3141,9 +3141,9 @@ void ScInterpreter::ScStandard() double mue = GetDouble(); double x = GetDouble(); if (sigma < 0.0) - PushError( errIllegalArgument); + PushError( FormulaError::IllegalArgument); else if (sigma == 0.0) - PushError( errDivisionByZero); + PushError( FormulaError::DivisionByZero); else PushDouble((x-mue)/sigma); } @@ -3190,7 +3190,7 @@ bool ScInterpreter::CalculateSkew(double& fSum,double& fCount,double& vSum,std:: case svRefList : { PopDoubleRef( aRange, nParamCount, nRefInList); - sal_uInt16 nErr = 0; + FormulaError nErr = FormulaError::NONE; ScValueIterator aValIter( pDok, aRange, mnSubTotalFlags ); if (aValIter.GetFirst(fVal, nErr)) { @@ -3198,7 +3198,7 @@ bool ScInterpreter::CalculateSkew(double& fSum,double& fCount,double& vSum,std:: values.push_back(fVal); fCount++; SetError(nErr); - while ((nErr == 0) && aValIter.GetNext(fVal, nErr)) + while ((nErr == FormulaError::NONE) && aValIter.GetNext(fVal, nErr)) { fSum += fVal; values.push_back(fVal); @@ -3241,16 +3241,16 @@ bool ScInterpreter::CalculateSkew(double& fSum,double& fCount,double& vSum,std:: } break; default : - SetError(errIllegalParameter); + SetError(FormulaError::IllegalParameter); break; } } - if (nGlobalError) + if (nGlobalError != FormulaError::NONE) { PushError( nGlobalError); return false; - } // if (nGlobalError) + } // if (nGlobalError != FormulaError::NONE) return true; } @@ -3300,9 +3300,9 @@ void ScInterpreter::ScSkewp() double ScInterpreter::GetMedian( vector<double> & rArray ) { size_t nSize = rArray.size(); - if (rArray.empty() || nSize == 0 || nGlobalError) + if (rArray.empty() || nSize == 0 || nGlobalError != FormulaError::NONE) { - SetError( errNoValue); + SetError( FormulaError::NoValue); return 0.0; } @@ -3360,14 +3360,14 @@ double ScInterpreter::GetPercentile( vector<double> & rArray, double fPercentile double ScInterpreter::GetPercentileExclusive( vector<double> & rArray, double fPercentile ) { size_t nSize1 = rArray.size() + 1; - if ( rArray.empty() || nSize1 == 1 || nGlobalError ) + if ( rArray.empty() || nSize1 == 1 || nGlobalError != FormulaError::NONE) { - SetError( errNoValue ); + SetError( FormulaError::NoValue ); return 0.0; } if ( fPercentile * nSize1 < 1.0 || fPercentile * nSize1 > (double) ( nSize1 - 1 ) ) { - SetError( errIllegalParameter ); + SetError( FormulaError::IllegalParameter ); return 0.0; } @@ -3400,9 +3400,9 @@ void ScInterpreter::ScPercentile( bool bInclusive ) } vector<double> aArray; GetNumberSequenceArray( 1, aArray, false ); - if ( aArray.empty() || aArray.size() == 0 || nGlobalError ) + if ( aArray.empty() || aArray.size() == 0 || nGlobalError != FormulaError::NONE ) { - SetError( errNoValue ); + SetError( FormulaError::NoValue ); return; } if ( bInclusive ) @@ -3423,9 +3423,9 @@ void ScInterpreter::ScQuartile( bool bInclusive ) } vector<double> aArray; GetNumberSequenceArray( 1, aArray, false ); - if ( aArray.empty() || aArray.size() == 0 || nGlobalError ) + if ( aArray.empty() || aArray.size() == 0 || nGlobalError != FormulaError::NONE ) { - SetError( errNoValue ); + SetError( FormulaError::NoValue ); return; } if ( bInclusive ) @@ -3442,7 +3442,7 @@ void ScInterpreter::ScModalValue() vector<double> aSortArray; GetSortArray( nParamCount, aSortArray, nullptr, false, false ); SCSIZE nSize = aSortArray.size(); - if (aSortArray.empty() || nSize == 0 || nGlobalError) + if (aSortArray.empty() || nSize == 0 || nGlobalError != FormulaError::NONE) PushNoValue(); else { @@ -3497,7 +3497,7 @@ void ScInterpreter::CalculateSmallLarge(bool bSmall) * we may or will need a real sorted array again, see #i32345. */ GetNumberSequenceArray(1, aSortArray, false ); SCSIZE nSize = aSortArray.size(); - if (aSortArray.empty() || nSize == 0 || nGlobalError || nSize < k) + if (aSortArray.empty() || nSize == 0 || nGlobalError != FormulaError::NONE || nSize < k) PushNoValue(); else { @@ -3528,7 +3528,7 @@ void ScInterpreter::ScPercentrank( bool bInclusive ) vector<double> aSortArray; GetSortArray( 1, aSortArray, nullptr, false, false ); SCSIZE nSize = aSortArray.size(); - if ( aSortArray.empty() || nSize == 0 || nGlobalError ) + if ( aSortArray.empty() || nSize == 0 || nGlobalError != FormulaError::NONE ) PushNoValue(); else { @@ -3621,7 +3621,7 @@ void ScInterpreter::ScTrimMean() vector<double> aSortArray; GetSortArray( 1, aSortArray, nullptr, false, false ); SCSIZE nSize = aSortArray.size(); - if (aSortArray.empty() || nSize == 0 || nGlobalError) + if (aSortArray.empty() || nSize == 0 || nGlobalError != FormulaError::NONE) PushNoValue(); else { @@ -3663,7 +3663,7 @@ void ScInterpreter::GetNumberSequenceArray( sal_uInt8 nParamCount, vector<double case svRefList : { PopDoubleRef( aRange, nParam, nRefInList); - if (nGlobalError) + if (nGlobalError != FormulaError::NONE) break; aRange.PutInOrder(); @@ -3671,14 +3671,14 @@ void ScInterpreter::GetNumberSequenceArray( sal_uInt8 nParamCount, vector<double nCellCount *= aRange.aEnd.Row() - aRange.aStart.Row() + 1; rArray.reserve( rArray.size() + nCellCount); - sal_uInt16 nErr = 0; + FormulaError nErr = FormulaError::NONE; double fCellVal; ScValueIterator aValIter( pDok, aRange, mnSubTotalFlags ); if (aValIter.GetFirst( fCellVal, nErr)) { rArray.push_back( fCellVal); SetError(nErr); - while ((nErr == 0) && aValIter.GetNext( fCellVal, nErr)) + while ((nErr == FormulaError::NONE) && aValIter.GetNext( fCellVal, nErr)) rArray.push_back( fCellVal); SetError(nErr); } @@ -3711,23 +3711,23 @@ void ScInterpreter::GetNumberSequenceArray( sal_uInt8 nParamCount, vector<double OUString aStr = pMat->GetString( i ).getString(); if ( aStr.getLength() > 0 ) { - sal_uInt16 nErr = nGlobalError; - nGlobalError = 0; + FormulaError nErr = nGlobalError; + nGlobalError = FormulaError::NONE; double fVal = ConvertStringToValue( aStr ); - if ( !nGlobalError ) + if ( nGlobalError == FormulaError::NONE ) { rArray.push_back( fVal ); nGlobalError = nErr; } else { - rArray.push_back( CreateDoubleError( errNoValue)); + rArray.push_back( CreateDoubleError( FormulaError::NoValue)); // Propagate previous error if any, else // the current #VALUE! error. - if (nErr) + if (nErr != FormulaError::NONE) nGlobalError = nErr; else - nGlobalError = errNoValue; + nGlobalError = FormulaError::NoValue; } } } @@ -3745,10 +3745,10 @@ void ScInterpreter::GetNumberSequenceArray( sal_uInt8 nParamCount, vector<double break; default : PopError(); - SetError( errIllegalParameter); + SetError( FormulaError::IllegalParameter); break; } - if (nGlobalError) + if (nGlobalError != FormulaError::NONE) break; // while } // nParam > 0 in case of error, clean stack environment and obtain earlier @@ -3761,15 +3761,15 @@ void ScInterpreter::GetSortArray( sal_uInt8 nParamCount, vector<double>& rSortAr { GetNumberSequenceArray( nParamCount, rSortArray, bConvertTextInArray ); if (rSortArray.size() > MAX_ANZ_DOUBLE_FOR_SORT) - SetError( errMatrixSize); + SetError( FormulaError::MatrixSize); else if ( rSortArray.empty() ) { if ( bAllowEmptyArray ) return; - SetError( errNoValue); + SetError( FormulaError::NoValue); } - if (nGlobalError == 0) + if (nGlobalError == FormulaError::NONE) QuickSort( rSortArray, pIndexOrder); } @@ -3866,7 +3866,7 @@ void ScInterpreter::ScRank( bool bAverage ) GetSortArray( 1, aSortArray, nullptr, false, false ); double fVal = GetDouble(); SCSIZE nSize = aSortArray.size(); - if ( aSortArray.empty() || nSize == 0 || nGlobalError ) + if ( aSortArray.empty() || nSize == 0 || nGlobalError != FormulaError::NONE ) PushNoValue(); else { @@ -3878,7 +3878,7 @@ void ScInterpreter::ScRank( bool bAverage ) double fFirstPos = -1.0; bool bFinished = false; SCSIZE i; - for ( i = 0; i < nSize && !bFinished && !nGlobalError; i++ ) + for ( i = 0; i < nSize && !bFinished && nGlobalError == FormulaError::NONE; i++ ) { if ( aSortArray[ i ] == fVal ) { @@ -3949,7 +3949,7 @@ void ScInterpreter::ScAveDev() case formula::svDoubleRef : case svRefList : { - sal_uInt16 nErr = 0; + FormulaError nErr = FormulaError::NONE; double nCellVal; PopDoubleRef( aRange, nParam, nRefInList); ScValueIterator aValIter( pDok, aRange, mnSubTotalFlags ); @@ -3958,7 +3958,7 @@ void ScInterpreter::ScAveDev() rVal += nCellVal; rValCount++; SetError(nErr); - while ((nErr == 0) && aValIter.GetNext(nCellVal, nErr)) + while ((nErr == FormulaError::NONE) && aValIter.GetNext(nCellVal, nErr)) { rVal += nCellVal; rValCount++; @@ -3996,11 +3996,11 @@ void ScInterpreter::ScAveDev() } break; default : - SetError(errIllegalParameter); + SetError(FormulaError::IllegalParameter); break; } } - if (nGlobalError) + if (nGlobalError != FormulaError::NONE) { PushError( nGlobalError); return; @@ -4028,7 +4028,7 @@ void ScInterpreter::ScAveDev() case formula::svDoubleRef : case svRefList : { - sal_uInt16 nErr = 0; + FormulaError nErr = FormulaError::NONE; double nCellVal; PopDoubleRef( aRange, nParam, nRefInList); ScValueIterator aValIter( pDok, aRange, mnSubTotalFlags ); @@ -4066,7 +4066,7 @@ void ScInterpreter::ScAveDev() } } break; - default : SetError(errIllegalParameter); break; + default : SetError(FormulaError::IllegalParameter); break; } } PushDouble(rVal / rValCount); @@ -4134,7 +4134,7 @@ void ScInterpreter::ScProbability() } } else - SetError( errIllegalArgument); + SetError( FormulaError::IllegalArgument); } } if (bStop || fabs(fSum -1.0) > 1.0E-7) @@ -4238,7 +4238,7 @@ void ScInterpreter::CalculatePearsonCovar( bool _bPearson, bool _bStexy, bool _b if ( _bPearson ) { if (fSumSqrDeltaX == 0.0 || ( !_bStexy && fSumSqrDeltaY == 0.0) ) - PushError( errDivisionByZero); + PushError( FormulaError::DivisionByZero); else if ( _bStexy ) PushDouble( sqrt( (fSumSqrDeltaY - fSumDeltaXDeltaY * fSumDeltaXDeltaY / fSumSqrDeltaX) / (fCount-2))); @@ -4259,7 +4259,7 @@ void ScInterpreter::ScRSQ() { // Same as ScPearson()*ScPearson() ScPearson(); - if (!nGlobalError) + if (nGlobalError == FormulaError::NONE) { switch (GetStackType()) { @@ -4341,7 +4341,7 @@ void ScInterpreter::CalculateSlopeIntercept(bool bSlope) } } if (fSumSqrDeltaX == 0.0) - PushError( errDivisionByZero); + PushError( FormulaError::DivisionByZero); else { if ( bSlope ) @@ -4424,7 +4424,7 @@ void ScInterpreter::ScForecast() } } if (fSumSqrDeltaX == 0.0) - PushError( errDivisionByZero); + PushError( FormulaError::DivisionByZero); else PushDouble( fMeanY + fSumDeltaXDeltaY / fSumSqrDeltaX * (fVal - fMeanX)); } diff --git a/sc/source/core/tool/interpr4.cxx b/sc/source/core/tool/interpr4.cxx index 174eeb039ecc..2f1740c3a4bd 100644 --- a/sc/source/core/tool/interpr4.cxx +++ b/sc/source/core/tool/interpr4.cxx @@ -151,18 +151,18 @@ bool ScInterpreter::IsTableOpInRange( const ScRange& rRange ) sal_uLong ScInterpreter::GetCellNumberFormat( const ScAddress& rPos, ScRefCellValue& rCell ) { sal_uLong nFormat; - sal_uInt16 nErr; + FormulaError nErr; if (rCell.isEmpty()) { nFormat = pDok->GetNumberFormat( rPos ); - nErr = 0; + nErr = FormulaError::NONE; } else { if (rCell.meType == CELLTYPE_FORMULA) nErr = rCell.mpFormula->GetErrCode(); else - nErr = 0; + nErr = FormulaError::NONE; nFormat = pDok->GetNumberFormat( rPos ); } @@ -181,32 +181,32 @@ double ScInterpreter::GetValueCellValue( const ScAddress& rPos, double fOrig ) return fOrig; } -sal_uInt16 ScInterpreter::GetCellErrCode( const ScRefCellValue& rCell ) +FormulaError ScInterpreter::GetCellErrCode( const ScRefCellValue& rCell ) { - return rCell.meType == CELLTYPE_FORMULA ? rCell.mpFormula->GetErrCode() : 0; + return rCell.meType == CELLTYPE_FORMULA ? rCell.mpFormula->GetErrCode() : FormulaError::NONE; } double ScInterpreter::ConvertStringToValue( const OUString& rStr ) { - sal_uInt16 nError = 0; + FormulaError nError = FormulaError::NONE; double fValue = ScGlobal::ConvertStringToValue( rStr, maCalcConfig, nError, mnStringNoValueError, pFormatter, nCurFmtType); - if (nError) + if (nError != FormulaError::NONE) SetError(nError); return fValue; } -double ScInterpreter::ConvertStringToValue( const OUString& rStr, sal_uInt16& rError, short& rCurFmtType ) +double ScInterpreter::ConvertStringToValue( const OUString& rStr, FormulaError& rError, short& rCurFmtType ) { return ScGlobal::ConvertStringToValue( rStr, maCalcConfig, rError, mnStringNoValueError, pFormatter, rCurFmtType); } double ScInterpreter::GetCellValue( const ScAddress& rPos, ScRefCellValue& rCell ) { - sal_uInt16 nErr = nGlobalError; - nGlobalError = 0; + FormulaError nErr = nGlobalError; + nGlobalError = FormulaError::NONE; double nVal = GetCellValueOrZero(rPos, rCell); - if ( !nGlobalError || nGlobalError == errCellNoValue ) + if ( nGlobalError == FormulaError::NONE || nGlobalError == FormulaError::CellNoValue ) nGlobalError = nErr; return nVal; } @@ -221,8 +221,8 @@ double ScInterpreter::GetCellValueOrZero( const ScAddress& rPos, ScRefCellValue& case CELLTYPE_FORMULA: { ScFormulaCell* pFCell = rCell.mpFormula; - sal_uInt16 nErr = pFCell->GetErrCode(); - if( !nErr ) + FormulaError nErr = pFCell->GetErrCode(); + if( nErr == FormulaError::NONE ) { if (pFCell->IsValue()) { @@ -270,7 +270,7 @@ double ScInterpreter::GetCellValueOrZero( const ScAddress& rPos, ScRefCellValue& void ScInterpreter::GetCellString( svl::SharedString& rStr, ScRefCellValue& rCell ) { - sal_uInt16 nErr = 0; + FormulaError nErr = FormulaError::NONE; switch (rCell.meType) { @@ -354,7 +354,7 @@ bool ScInterpreter::CreateDoubleArr(SCCOL nCol1, SCROW nRow1, SCTAB nTab1, ScRefCellValue aCell(*pDok, aAdr); if (!aCell.isEmpty()) { - sal_uInt16 nErr = 0; + FormulaError nErr = FormulaError::NONE; double nVal = 0.0; bool bOk = true; switch (aCell.meType) @@ -382,7 +382,7 @@ bool ScInterpreter::CreateDoubleArr(SCCOL nCol1, SCROW nRow1, SCTAB nTab1, *p++ = static_cast<sal_uInt16>(nCol); *p++ = static_cast<sal_uInt16>(nRow); *p++ = static_cast<sal_uInt16>(nTab); - *p++ = nErr; + *p++ = static_cast<sal_uInt16>(nErr); memcpy( p, &nVal, sizeof(double)); nPos += 8 + sizeof(double); p = reinterpret_cast<sal_uInt16*>( pCellArr + nPos ); @@ -435,7 +435,7 @@ bool ScInterpreter::CreateStringArr(SCCOL nCol1, SCROW nRow1, SCTAB nTab1, if (!aCell.isEmpty()) { OUString aStr; - sal_uInt16 nErr = 0; + FormulaError nErr = FormulaError::NONE; bool bOk = true; switch (aCell.meType) { @@ -474,7 +474,7 @@ bool ScInterpreter::CreateStringArr(SCCOL nCol1, SCROW nRow1, SCTAB nTab1, *p++ = static_cast<sal_uInt16>(nCol); *p++ = static_cast<sal_uInt16>(nRow); *p++ = static_cast<sal_uInt16>(nTab); - *p++ = nErr; + *p++ = static_cast<sal_uInt16>(nErr); *p++ = nLen; memcpy( p, aTmp.getStr(), nStrLen + 1); nPos += 10 + nStrLen + 1; @@ -537,7 +537,7 @@ bool ScInterpreter::CreateCellArr(SCCOL nCol1, SCROW nRow1, SCTAB nTab1, ScRefCellValue aCell(*pDok, aAdr); if (!aCell.isEmpty()) { - sal_uInt16 nErr = 0; + FormulaError nErr = FormulaError::NONE; sal_uInt16 nType = 0; // 0 = Zahl; 1 = String double nVal = 0.0; OUString aStr; @@ -570,7 +570,7 @@ bool ScInterpreter::CreateCellArr(SCCOL nCol1, SCROW nRow1, SCTAB nTab1, *p++ = static_cast<sal_uInt16>(nCol); *p++ = static_cast<sal_uInt16>(nRow); *p++ = static_cast<sal_uInt16>(nTab); - *p++ = nErr; + *p++ = static_cast<sal_uInt16>(nErr); *p++ = nType; nPos += 10; if (nType == 0) @@ -625,7 +625,7 @@ bool ScInterpreter::CreateCellArr(SCCOL nCol1, SCROW nRow1, SCTAB nTab1, void ScInterpreter::PushWithoutError( const FormulaToken& r ) { if ( sp >= MAXSTACK ) - SetError( errStackOverflow ); + SetError( FormulaError::StackOverflow ); else { r.IncRef(); @@ -641,10 +641,10 @@ void ScInterpreter::PushWithoutError( const FormulaToken& r ) void ScInterpreter::Push( const FormulaToken& r ) { if ( sp >= MAXSTACK ) - SetError( errStackOverflow ); + SetError( FormulaError::StackOverflow ); else { - if (nGlobalError) + if (nGlobalError != FormulaError::NONE) { if (r.GetType() == svError) PushWithoutError( r); @@ -660,13 +660,13 @@ void ScInterpreter::PushTempToken( FormulaToken* p ) { if ( sp >= MAXSTACK ) { - SetError( errStackOverflow ); + SetError( FormulaError::StackOverflow ); // p may be a dangling pointer hereafter! p->DeleteIfZeroRef(); } else { - if (nGlobalError) + if (nGlobalError != FormulaError::NONE) { if (p->GetType() == svError) { @@ -690,7 +690,7 @@ void ScInterpreter::PushTempTokenWithoutError( const FormulaToken* p ) p->IncRef(); if ( sp >= MAXSTACK ) { - SetError( errStackOverflow ); + SetError( FormulaError::StackOverflow ); // p may be a dangling pointer hereafter! p->DecRef(); } @@ -709,11 +709,11 @@ void ScInterpreter::PushTokenRef( const formula::FormulaConstTokenRef& x ) { if ( sp >= MAXSTACK ) { - SetError( errStackOverflow ); + SetError( FormulaError::StackOverflow ); } else { - if (nGlobalError) + if (nGlobalError != FormulaError::NONE) { if (x->GetType() == svError && x->GetError() == nGlobalError) PushTempTokenWithoutError( x.get()); @@ -738,11 +738,11 @@ void ScInterpreter::PushCellResultToken( bool bDisplayEmptyAsString, return; } - sal_uInt16 nErr = 0; + FormulaError nErr = FormulaError::NONE; if (aCell.meType == CELLTYPE_FORMULA) nErr = aCell.mpFormula->GetErrCode(); - if (nErr) + if (nErr != FormulaError::NONE) { PushError( nErr); if (pRetTypeExpr) @@ -787,7 +787,7 @@ void ScInterpreter::Pop() if( sp ) sp--; else - SetError(errUnknownStackVariable); + SetError(FormulaError::UnknownStackVariable); } // Simply throw away TOS and set error code, used with ocIsError et al. @@ -801,7 +801,7 @@ void ScInterpreter::PopError() nGlobalError = pStack[sp]->GetError(); } else - SetError(errUnknownStackVariable); + SetError(FormulaError::UnknownStackVariable); } FormulaConstTokenRef ScInterpreter::PopToken() @@ -815,7 +815,7 @@ FormulaConstTokenRef ScInterpreter::PopToken() return p; } else - SetError(errUnknownStackVariable); + SetError(FormulaError::UnknownStackVariable); return nullptr; } @@ -843,11 +843,11 @@ double ScInterpreter::PopDouble() case svMissing: return 0.0; default: - SetError( errIllegalArgument); + SetError( FormulaError::IllegalArgument); } } else - SetError( errUnknownStackVariable); + SetError( FormulaError::UnknownStackVariable); return 0.0; } @@ -870,11 +870,11 @@ svl::SharedString ScInterpreter::PopString() case svMissing: return svl::SharedString::getEmptyString(); default: - SetError( errIllegalArgument); + SetError( FormulaError::IllegalArgument); } } else - SetError( errUnknownStackVariable); + SetError( FormulaError::UnknownStackVariable); return svl::SharedString::getEmptyString(); } @@ -923,17 +923,17 @@ void ScInterpreter::SingleRefToVars( const ScSingleRefData & rRef, if( !ValidCol( rCol) || rRef.IsColDeleted() ) { - SetError( errNoRef ); + SetError( FormulaError::NoRef ); rCol = 0; } if( !ValidRow( rRow) || rRef.IsRowDeleted() ) { - SetError( errNoRef ); + SetError( FormulaError::NoRef ); rRow = 0; } if( !ValidTab( rTab, pDok->GetTableCount() - 1) || rRef.IsTabDeleted() ) { - SetError( errNoRef ); + SetError( FormulaError::NoRef ); rTab = 0; } } @@ -955,11 +955,11 @@ void ScInterpreter::PopSingleRef(SCCOL& rCol, SCROW &rRow, SCTAB& rTab) ReplaceCell( rCol, rRow, rTab ); break; default: - SetError( errIllegalParameter); + SetError( FormulaError::IllegalParameter); } } else - SetError( errUnknownStackVariable); + SetError( FormulaError::UnknownStackVariable); } void ScInterpreter::PopSingleRef( ScAddress& rAdr ) @@ -985,11 +985,11 @@ void ScInterpreter::PopSingleRef( ScAddress& rAdr ) } break; default: - SetError( errIllegalParameter); + SetError( FormulaError::IllegalParameter); } } else - SetError( errUnknownStackVariable); + SetError( FormulaError::UnknownStackVariable); } void ScInterpreter::DoubleRefToVars( const formula::FormulaToken* p, @@ -1003,7 +1003,7 @@ void ScInterpreter::DoubleRefToVars( const formula::FormulaToken* p, { ScRange aRange( rCol1, rRow1, rTab1, rCol2, rRow2, rTab2 ); if ( IsTableOpInRange( aRange ) ) - SetError( errIllegalParameter ); + SetError( FormulaError::IllegalParameter ); } } @@ -1013,7 +1013,7 @@ ScDBRangeBase* ScInterpreter::PopDBDoubleRef() switch (eType) { case svUnknown: - SetError(errUnknownStackVariable); + SetError(FormulaError::UnknownStackVariable); break; case svError: PopError(); @@ -1024,7 +1024,7 @@ ScDBRangeBase* ScInterpreter::PopDBDoubleRef() SCROW nRow1, nRow2; SCTAB nTab1, nTab2; PopDoubleRef(nCol1, nRow1, nTab1, nCol2, nRow2, nTab2); - if (nGlobalError) + if (nGlobalError != FormulaError::NONE) break; return new ScDBInternalRange(pDok, ScRange(nCol1, nRow1, nTab1, nCol2, nRow2, nTab2)); @@ -1037,12 +1037,12 @@ ScDBRangeBase* ScInterpreter::PopDBDoubleRef() pMat = PopMatrix(); else PopExternalDoubleRef(pMat); - if (nGlobalError) + if (nGlobalError != FormulaError::NONE) break; return new ScDBExternalRange(pDok, pMat); } default: - SetError( errIllegalParameter); + SetError( FormulaError::IllegalParameter); } return nullptr; @@ -1064,11 +1064,11 @@ void ScInterpreter::PopDoubleRef(SCCOL& rCol1, SCROW &rRow1, SCTAB& rTab1, DoubleRefToVars( p, rCol1, rRow1, rTab1, rCol2, rRow2, rTab2); break; default: - SetError( errIllegalParameter); + SetError( FormulaError::IllegalParameter); } } else - SetError( errUnknownStackVariable); + SetError( FormulaError::UnknownStackVariable); } void ScInterpreter::DoubleRefToRange( const ScComplexRefData & rCRef, @@ -1085,7 +1085,7 @@ void ScInterpreter::DoubleRefToRange( const ScComplexRefData & rCRef, if (!pDok->m_TableOpList.empty() && !bDontCheckForTableOp) { if ( IsTableOpInRange( rRange ) ) - SetError( errIllegalParameter ); + SetError( FormulaError::IllegalParameter ); } } @@ -1121,16 +1121,16 @@ void ScInterpreter::PopDoubleRef( ScRange & rRange, short & rParam, size_t & rRe { --sp; rRefInList = 0; - SetError( errIllegalParameter); + SetError( FormulaError::IllegalParameter); } } break; default: - SetError( errIllegalParameter); + SetError( FormulaError::IllegalParameter); } } else - SetError( errUnknownStackVariable); + SetError( FormulaError::UnknownStackVariable); } void ScInterpreter::PopDoubleRef( ScRange& rRange, bool bDontCheckForTableOp ) @@ -1148,18 +1148,18 @@ void ScInterpreter::PopDoubleRef( ScRange& rRange, bool bDontCheckForTableOp ) DoubleRefToRange( *p->GetDoubleRef(), rRange, bDontCheckForTableOp); break; default: - SetError( errIllegalParameter); + SetError( FormulaError::IllegalParameter); } } else - SetError( errUnknownStackVariable); + SetError( FormulaError::UnknownStackVariable); } void ScInterpreter::PopExternalSingleRef(sal_uInt16& rFileId, OUString& rTabName, ScSingleRefData& rRef) { if (!sp) { - SetError(errUnknownStackVariable); + SetError(FormulaError::UnknownStackVariable); return; } @@ -1175,7 +1175,7 @@ void ScInterpreter::PopExternalSingleRef(sal_uInt16& rFileId, OUString& rTabName if (eType != svExternalSingleRef) { - SetError( errIllegalParameter); + SetError( FormulaError::IllegalParameter); return; } @@ -1197,21 +1197,21 @@ void ScInterpreter::PopExternalSingleRef( ScExternalRefCache::TokenRef& rToken, ScExternalRefCache::CellFormat* pFmt) { PopExternalSingleRef(rFileId, rTabName, rRef); - if (nGlobalError) + if (nGlobalError != FormulaError::NONE) return; ScExternalRefManager* pRefMgr = pDok->GetExternalRefManager(); const OUString* pFile = pRefMgr->getExternalFileName(rFileId); if (!pFile) { - SetError(errNoName); + SetError(FormulaError::NoName); return; } if (rRef.IsTabRel()) { OSL_FAIL("ScCompiler::GetToken: external single reference must have an absolute table reference!"); - SetError(errNoRef); + SetError(FormulaError::NoRef); return; } @@ -1222,7 +1222,7 @@ void ScInterpreter::PopExternalSingleRef( if (!xNew) { - SetError(errNoRef); + SetError(FormulaError::NoRef); return; } @@ -1238,7 +1238,7 @@ void ScInterpreter::PopExternalDoubleRef(sal_uInt16& rFileId, OUString& rTabName { if (!sp) { - SetError(errUnknownStackVariable); + SetError(FormulaError::UnknownStackVariable); return; } @@ -1254,7 +1254,7 @@ void ScInterpreter::PopExternalDoubleRef(sal_uInt16& rFileId, OUString& rTabName if (eType != svExternalDoubleRef) { - SetError( errIllegalParameter); + SetError( FormulaError::IllegalParameter); return; } @@ -1269,11 +1269,11 @@ void ScInterpreter::PopExternalDoubleRef(ScExternalRefCache::TokenArrayRef& rArr OUString aTabName; ScComplexRefData aData; PopExternalDoubleRef(nFileId, aTabName, aData); - if (nGlobalError) + if (nGlobalError != FormulaError::NONE) return; GetExternalDoubleRef(nFileId, aTabName, aData, rArray); - if (nGlobalError) + if (nGlobalError != FormulaError::NONE) return; } @@ -1281,7 +1281,7 @@ void ScInterpreter::PopExternalDoubleRef(ScMatrixRef& rMat) { ScExternalRefCache::TokenArrayRef pArray; PopExternalDoubleRef(pArray); - if (nGlobalError) + if (nGlobalError != FormulaError::NONE) return; // For now, we only support single range data for external @@ -1289,12 +1289,12 @@ void ScInterpreter::PopExternalDoubleRef(ScMatrixRef& rMat) // single matrix token. formula::FormulaToken* p = pArray->First(); if (!p || p->GetType() != svMatrix) - SetError( errIllegalParameter); + SetError( FormulaError::IllegalParameter); else { rMat = p->GetMatrix(); if (!rMat) - SetError( errUnknownVariable); + SetError( FormulaError::UnknownVariable); } } @@ -1305,13 +1305,13 @@ void ScInterpreter::GetExternalDoubleRef( const OUString* pFile = pRefMgr->getExternalFileName(nFileId); if (!pFile) { - SetError(errNoName); + SetError(FormulaError::NoName); return; } if (rData.Ref1.IsTabRel() || rData.Ref2.IsTabRel()) { OSL_FAIL("ScCompiler::GetToken: external double reference must have an absolute table reference!"); - SetError(errNoRef); + SetError(FormulaError::NoRef); return; } @@ -1322,7 +1322,7 @@ void ScInterpreter::GetExternalDoubleRef( if (!pArray) { - SetError(errIllegalArgument); + SetError(FormulaError::IllegalArgument); return; } @@ -1334,14 +1334,14 @@ void ScInterpreter::GetExternalDoubleRef( } if (pToken->GetType() != svMatrix) { - SetError(errIllegalArgument); + SetError(FormulaError::IllegalArgument); return; } if (pArray->Next()) { // Can't handle more than one matrix per parameter. - SetError( errIllegalArgument); + SetError( FormulaError::IllegalArgument); return; } @@ -1365,7 +1365,7 @@ bool ScInterpreter::PopDoubleRefOrSingleRef( ScAddress& rAdr ) } default: PopError(); - SetError( errNoRef ); + SetError( FormulaError::NoRef ); } return false; } @@ -1381,7 +1381,7 @@ void ScInterpreter::PopDoubleRefPushMatrix() PushIllegalParameter(); } else - SetError( errNoRef ); + SetError( FormulaError::NoRef ); } void ScInterpreter::ConvertMatrixJumpConditionToMatrix() @@ -1440,7 +1440,7 @@ bool ScInterpreter::ConvertMatrixParameters() { // only if single value expected ScConstMatrixRef pMat = p->GetMatrix(); if ( !pMat ) - SetError( errUnknownVariable); + SetError( FormulaError::UnknownVariable); else { SCSIZE nCols, nRows; @@ -1502,7 +1502,7 @@ bool ScInterpreter::ConvertMatrixParameters() const ScComplexRefData& rRef = *p->GetDoubleRef(); ScExternalRefCache::TokenArrayRef pArray; GetExternalDoubleRef(nFileId, aTabName, rRef, pArray); - if (nGlobalError || !pArray) + if (nGlobalError != FormulaError::NONE || !pArray) break; formula::FormulaToken* pTemp = pArray->First(); if (!pTemp) @@ -1527,7 +1527,7 @@ bool ScInterpreter::ConvertMatrixParameters() eType != ScParameterClassification::ReferenceOrForceArray) { // can't convert to matrix - SetError( errNoValue); + SetError( FormulaError::NoValue); } } break; @@ -1591,15 +1591,15 @@ ScMatrixRef ScInterpreter::PopMatrix() if ( pMat ) pMat->SetErrorInterpreter( this); else - SetError( errUnknownVariable); + SetError( FormulaError::UnknownVariable); return pMat; } default: - SetError( errIllegalParameter); + SetError( FormulaError::IllegalParameter); } } else - SetError( errUnknownStackVariable); + SetError( FormulaError::UnknownStackVariable); return nullptr; } @@ -1633,7 +1633,7 @@ sc::RangeMatrix ScInterpreter::PopRangeMatrix() } } else - SetError( errUnknownVariable); + SetError( FormulaError::UnknownVariable); } break; default: @@ -1679,9 +1679,9 @@ void ScInterpreter::QueryMatrixType(ScMatrixRef& xMat, short& rRetTypeExpr, sal_ } else { - sal_uInt16 nErr = GetDoubleErrorValue( nMatVal.fVal); + FormulaError nErr = GetDoubleErrorValue( nMatVal.fVal); FormulaTokenRef xRes; - if (nErr) + if (nErr != FormulaError::NONE) xRes = new FormulaErrorToken( nErr); else xRes = new FormulaDoubleToken( nMatVal.fVal); @@ -1693,7 +1693,7 @@ void ScInterpreter::QueryMatrixType(ScMatrixRef& xMat, short& rRetTypeExpr, sal_ xMat->SetErrorInterpreter( nullptr); } else - SetError( errUnknownStackVariable); + SetError( FormulaError::UnknownStackVariable); } formula::FormulaToken* ScInterpreter::CreateDoubleOrTypedToken( double fVal ) @@ -1817,7 +1817,7 @@ void ScInterpreter::PushMatrix( const sc::RangeMatrix& rMat ) } rMat.mpMat->SetErrorInterpreter(nullptr); - nGlobalError = 0; + nGlobalError = FormulaError::NONE; PushTempTokenWithoutError(new ScMatrixRangeToken(rMat)); } @@ -1828,11 +1828,11 @@ void ScInterpreter::PushMatrix(const ScMatrixRef& pMat) // but with notifying ScInterpreter via nGlobalError, substituting it would // mean to inherit the error on all array elements in all following // operations. - nGlobalError = 0; + nGlobalError = FormulaError::NONE; PushTempTokenWithoutError( new ScMatrixToken( pMat ) ); } -void ScInterpreter::PushError( sal_uInt16 nError ) +void ScInterpreter::PushError( FormulaError nError ) { SetError( nError ); // only sets error if not already set PushTempTokenWithoutError( new FormulaErrorToken( nGlobalError)); @@ -1840,27 +1840,27 @@ void ScInterpreter::PushError( sal_uInt16 nError ) void ScInterpreter::PushParameterExpected() { - PushError( errParameterExpected); + PushError( FormulaError::ParameterExpected); } void ScInterpreter::PushIllegalParameter() { - PushError( errIllegalParameter); + PushError( FormulaError::IllegalParameter); } void ScInterpreter::PushIllegalArgument() { - PushError( errIllegalArgument); + PushError( FormulaError::IllegalArgument); } void ScInterpreter::PushNA() { - PushError( NOTAVAILABLE); + PushError( FormulaError::NotAvailable); } void ScInterpreter::PushNoValue() { - PushError( errNoValue); + PushError( FormulaError::NoValue); } bool ScInterpreter::IsMissing() @@ -1877,7 +1877,7 @@ StackVar ScInterpreter::GetRawStackType() } else { - SetError(errUnknownStackVariable); + SetError(FormulaError::UnknownStackVariable); eRes = svUnknown; } return eRes; @@ -1894,7 +1894,7 @@ StackVar ScInterpreter::GetStackType() } else { - SetError(errUnknownStackVariable); + SetError(FormulaError::UnknownStackVariable); eRes = svUnknown; } return eRes; @@ -1943,7 +1943,7 @@ bool ScInterpreter::DoubleRefToPosSingleRef( const ScRange& rRange, ScAddress& r { bOk = rRange.aStart.Tab() == rRange.aEnd.Tab(); if ( !bOk ) - SetError( errIllegalArgument); + SetError( FormulaError::IllegalArgument); else { SCSIZE nC, nR; @@ -1955,7 +1955,7 @@ bool ScInterpreter::DoubleRefToPosSingleRef( const ScRange& rRange, ScAddress& r rRange.aEnd.Col() && rRange.aStart.Row() <= rAdr.Row() && rAdr.Row() <= rRange.aEnd.Row(); if ( !bOk ) - SetError( errNoValue); + SetError( FormulaError::NoValue); } return bOk; } @@ -2011,7 +2011,7 @@ bool ScInterpreter::DoubleRefToPosSingleRef( const ScRange& rRange, ScAddress& r rAdr.Set( nCol, nRow, nTab ); } if ( !bOk ) - SetError( errNoValue ); + SetError( FormulaError::NoValue ); return bOk; } @@ -2023,8 +2023,8 @@ double ScInterpreter::GetDoubleFromMatrix(const ScMatrixRef& pMat) if ( !pJumpMatrix ) { double fVal = pMat->GetDoubleWithStringConversion( 0, 0); - sal_uInt16 nErr = GetDoubleErrorValue( fVal); - if (nErr) + FormulaError nErr = GetDoubleErrorValue( fVal); + if (nErr != FormulaError::NONE) { // Do not propagate the coded double error, but set nGlobalError in // case the matrix did not have an error interpreter set. @@ -2041,8 +2041,8 @@ double ScInterpreter::GetDoubleFromMatrix(const ScMatrixRef& pMat) if ( (nC < nCols || nCols == 1) && (nR < nRows || nRows == 1) ) { double fVal = pMat->GetDoubleWithStringConversion( nC, nR); - sal_uInt16 nErr = GetDoubleErrorValue( fVal); - if (nErr) + FormulaError nErr = GetDoubleErrorValue( fVal); + if (nErr != FormulaError::NONE) { // Do not propagate the coded double error, but set nGlobalError in // case the matrix did not have an error interpreter set. @@ -2052,7 +2052,7 @@ double ScInterpreter::GetDoubleFromMatrix(const ScMatrixRef& pMat) return fVal; } - SetError( errNoValue); + SetError( FormulaError::NoValue); return 0.0; } @@ -2080,7 +2080,7 @@ double ScInterpreter::GetDouble() ScRange aRange; PopDoubleRef( aRange ); ScAddress aAdr; - if ( !nGlobalError && DoubleRefToPosSingleRef( aRange, aAdr ) ) + if ( nGlobalError == FormulaError::NONE && DoubleRefToPosSingleRef( aRange, aAdr ) ) { ScRefCellValue aCell(*pDok, aAdr); nVal = GetCellValue(aAdr, aCell); @@ -2093,7 +2093,7 @@ double ScInterpreter::GetDouble() { ScExternalRefCache::TokenRef pToken; PopExternalSingleRef(pToken); - if (!nGlobalError) + if (nGlobalError == FormulaError::NONE) { if (pToken->GetType() == svDouble || pToken->GetType() == svEmptyCell) nVal = pToken->GetDouble(); @@ -2106,7 +2106,7 @@ double ScInterpreter::GetDouble() { ScMatrixRef pMat; PopExternalDoubleRef(pMat); - if (nGlobalError) + if (nGlobalError != FormulaError::NONE) break; nVal = GetDoubleFromMatrix(pMat); @@ -2129,7 +2129,7 @@ double ScInterpreter::GetDouble() break; default: PopError(); - SetError( errIllegalParameter); + SetError( FormulaError::IllegalParameter); nVal = 0.0; } if ( nFuncFmtType == nCurFmtType ) @@ -2158,7 +2158,7 @@ sal_Int32 ScInterpreter::double_to_int32(double fVal) fVal = rtl::math::approxFloor( fVal); if (fVal > SAL_MAX_INT32) { - SetError( errIllegalArgument); + SetError( FormulaError::IllegalArgument); return SAL_MAX_INT32; } } @@ -2167,7 +2167,7 @@ sal_Int32 ScInterpreter::double_to_int32(double fVal) fVal = rtl::math::approxCeil( fVal); if (fVal < SAL_MIN_INT32) { - SetError( errIllegalArgument); + SetError( FormulaError::IllegalArgument); return SAL_MAX_INT32; } } @@ -2201,7 +2201,7 @@ sal_Int16 ScInterpreter::GetInt16() fVal = rtl::math::approxFloor( fVal); if (fVal > SAL_MAX_INT16) { - SetError( errIllegalArgument); + SetError( FormulaError::IllegalArgument); return SAL_MAX_INT16; } } @@ -2210,7 +2210,7 @@ sal_Int16 ScInterpreter::GetInt16() fVal = rtl::math::approxCeil( fVal); if (fVal < SAL_MIN_INT16) { - SetError( errIllegalArgument); + SetError( FormulaError::IllegalArgument); return SAL_MAX_INT16; } } @@ -2227,7 +2227,7 @@ sal_uInt32 ScInterpreter::GetUInt32() } if (fVal < 0.0 || fVal > SAL_MAX_UINT32) { - SetError( errIllegalArgument); + SetError( FormulaError::IllegalArgument); return SAL_MAX_UINT32; } return static_cast<sal_uInt32>(fVal); @@ -2285,7 +2285,7 @@ bool ScInterpreter::GetDoubleOrString( double& rDouble, svl::SharedString& rStri break; default: PopError(); - SetError( errIllegalParameter); + SetError( FormulaError::IllegalParameter); rDouble = 0.0; } if ( nFuncFmtType == nCurFmtType ) @@ -2320,7 +2320,7 @@ svl::SharedString ScInterpreter::GetString() { ScAddress aAdr; PopSingleRef( aAdr ); - if (nGlobalError == 0) + if (nGlobalError == FormulaError::NONE) { ScRefCellValue aCell(*pDok, aAdr); svl::SharedString aSS; @@ -2335,7 +2335,7 @@ svl::SharedString ScInterpreter::GetString() ScRange aRange; PopDoubleRef( aRange ); ScAddress aAdr; - if ( !nGlobalError && DoubleRefToPosSingleRef( aRange, aAdr ) ) + if ( nGlobalError == FormulaError::NONE && DoubleRefToPosSingleRef( aRange, aAdr ) ) { ScRefCellValue aCell(*pDok, aAdr); svl::SharedString aSS; @@ -2349,7 +2349,7 @@ svl::SharedString ScInterpreter::GetString() { ScExternalRefCache::TokenRef pToken; PopExternalSingleRef(pToken); - if (nGlobalError) + if (nGlobalError != FormulaError::NONE) return svl::SharedString::getEmptyString(); return pToken->GetString(); @@ -2368,7 +2368,7 @@ svl::SharedString ScInterpreter::GetString() break; default: PopError(); - SetError( errIllegalArgument); + SetError( FormulaError::IllegalArgument); } return svl::SharedString::getEmptyString(); } @@ -2390,7 +2390,7 @@ svl::SharedString ScInterpreter::GetStringFromMatrix(const ScMatrixRef& pMat) if ( (nC < nCols || nCols == 1) && (nR < nRows || nRows == 1) ) return pMat->GetString( *pFormatter, nC, nR); - SetError( errNoValue); + SetError( FormulaError::NoValue); } return svl::SharedString::getEmptyString(); } @@ -2412,7 +2412,7 @@ ScMatValType ScInterpreter::GetDoubleOrStringFromMatrix( else { PopError(); - SetError( errIllegalParameter); + SetError( FormulaError::IllegalParameter); return nMatValType; } @@ -2438,14 +2438,14 @@ ScMatValType ScInterpreter::GetDoubleOrStringFromMatrix( nMatValType = nMatVal.nType; } else - SetError( errNoValue); + SetError( FormulaError::NoValue); } if (ScMatrix::IsValueType( nMatValType)) { rDouble = nMatVal.fVal; - sal_uInt16 nError = nMatVal.GetError(); - if (nError) + FormulaError nError = nMatVal.GetError(); + if (nError != FormulaError::NONE) SetError( nError); } else @@ -2470,7 +2470,7 @@ void ScInterpreter::ScDBGet() pQueryParam->mbSkipString = false; ScDBQueryDataIterator aValIter(pDok, pQueryParam.release()); ScDBQueryDataIterator::Value aValue; - if (!aValIter.GetFirst(aValue) || aValue.mnError) + if (!aValIter.GetFirst(aValue) || aValue.mnError != FormulaError::NONE) { // No match found. PushNoValue(); @@ -2478,7 +2478,7 @@ void ScInterpreter::ScDBGet() } ScDBQueryDataIterator::Value aValNext; - if (aValIter.GetNext(aValNext) && !aValNext.mnError) + if (aValIter.GetNext(aValNext) && aValNext.mnError == FormulaError::NONE) { // There should be only one unique match. PushIllegalArgument(); @@ -2520,14 +2520,14 @@ void ScInterpreter::ScExternal() pCellArr[i] = nullptr; } - for (i = nParamCount; (i > 0) && (nGlobalError == 0); i--) + for (i = nParamCount; (i > 0) && (nGlobalError == FormulaError::NONE); i--) { if (IsMissing()) { // Old binary Add-In can't distinguish between missing // omitted argument and 0 (or any other value). Force // error. - SetError( errParameterExpected); + SetError( FormulaError::ParameterExpected); break; // for } switch (eParamType[i]) @@ -2543,7 +2543,7 @@ void ScInterpreter::ScExternal() OString aStr(OUStringToOString(GetString().getString(), osl_getThreadTextEncoding())); if ( aStr.getLength() >= ADDIN_MAXSTRLEN ) - SetError( errStringOverflow ); + SetError( FormulaError::StringOverflow ); else { pStr[i-1] = new sal_Char[ADDIN_MAXSTRLEN]; @@ -2564,7 +2564,7 @@ void ScInterpreter::ScExternal() PopDoubleRef(nCol1, nRow1, nTab1, nCol2, nRow2, nTab2); pCellArr[i-1] = new sal_uInt8[MAXARRSIZE]; if (!CreateDoubleArr(nCol1, nRow1, nTab1, nCol2, nRow2, nTab2, pCellArr[i-1])) - SetError(errCodeOverflow); + SetError(FormulaError::CodeOverflow); else ppParam[i] = pCellArr[i-1]; } @@ -2580,7 +2580,7 @@ void ScInterpreter::ScExternal() PopDoubleRef(nCol1, nRow1, nTab1, nCol2, nRow2, nTab2); pCellArr[i-1] = new sal_uInt8[MAXARRSIZE]; if (!CreateStringArr(nCol1, nRow1, nTab1, nCol2, nRow2, nTab2, pCellArr[i-1])) - SetError(errCodeOverflow); + SetError(FormulaError::CodeOverflow); else ppParam[i] = pCellArr[i-1]; } @@ -2596,20 +2596,20 @@ void ScInterpreter::ScExternal() PopDoubleRef(nCol1, nRow1, nTab1, nCol2, nRow2, nTab2); pCellArr[i-1] = new sal_uInt8[MAXARRSIZE]; if (!CreateCellArr(nCol1, nRow1, nTab1, nCol2, nRow2, nTab2, pCellArr[i-1])) - SetError(errCodeOverflow); + SetError(FormulaError::CodeOverflow); else ppParam[i] = pCellArr[i-1]; } break; default : - SetError(errIllegalParameter); + SetError(FormulaError::IllegalParameter); break; } } while ( i-- ) Pop(); // In case of error (otherwise i==0) pop all parameters - if (nGlobalError == 0) + if (nGlobalError == FormulaError::NONE) { if ( pLegacyFuncData->GetAsyncType() == ParamType::NONE ) { @@ -2633,7 +2633,7 @@ void ScInterpreter::ScExternal() } break; default: - PushError( errUnknownState ); + PushError( FormulaError::UnknownState ); } } else @@ -2671,7 +2671,7 @@ void ScInterpreter::ScExternal() PushString( pAs->GetString() ); break; default: - PushError( errUnknownState ); + PushError( FormulaError::UnknownState ); } } else @@ -2703,9 +2703,9 @@ void ScInterpreter::ScExternal() ScUnoAddInCall aCall( *ScGlobal::GetAddInCollection(), aUnoName, nParamCount ); if ( !aCall.ValidParamCount() ) - SetError( errIllegalParameter ); + SetError( FormulaError::IllegalParameter ); - if ( aCall.NeedsCaller() && !GetError() ) + if ( aCall.NeedsCaller() && GetError() == FormulaError::NONE ) { SfxObjectShell* pShell = pDok->GetDocumentShell(); if (pShell) @@ -2719,7 +2719,7 @@ void ScInterpreter::ScExternal() } short nPar = nParamCount; - while ( nPar > 0 && !GetError() ) + while ( nPar > 0 && GetError() == FormulaError::NONE ) { --nPar; // 0 .. (nParamCount-1) @@ -2741,7 +2741,7 @@ void ScInterpreter::ScExternal() case SC_ADDINARG_INTEGER: { sal_Int32 nVal = GetInt32(); - if (!nGlobalError) + if (nGlobalError == FormulaError::NONE) aParam <<= nVal; } break; @@ -2762,7 +2762,7 @@ void ScInterpreter::ScExternal() case svSingleRef: { sal_Int32 nVal = GetInt32(); - if (!nGlobalError) + if (nGlobalError == FormulaError::NONE) { uno::Sequence<sal_Int32> aInner( &nVal, 1 ); uno::Sequence< uno::Sequence<sal_Int32> > aOuter( &aInner, 1 ); @@ -2775,16 +2775,16 @@ void ScInterpreter::ScExternal() ScRange aRange; PopDoubleRef( aRange ); if (!ScRangeToSequence::FillLongArray( aParam, pDok, aRange )) - SetError(errIllegalParameter); + SetError(FormulaError::IllegalParameter); } break; case svMatrix: if (!ScRangeToSequence::FillLongArray( aParam, PopMatrix().get() )) - SetError(errIllegalParameter); + SetError(FormulaError::IllegalParameter); break; default: PopError(); - SetError(errIllegalParameter); + SetError(FormulaError::IllegalParameter); } break; @@ -2806,16 +2806,16 @@ void ScInterpreter::ScExternal() ScRange aRange; PopDoubleRef( aRange ); if (!ScRangeToSequence::FillDoubleArray( aParam, pDok, aRange )) - SetError(errIllegalParameter); + SetError(FormulaError::IllegalParameter); } break; case svMatrix: if (!ScRangeToSequence::FillDoubleArray( aParam, PopMatrix().get() )) - SetError(errIllegalParameter); + SetError(FormulaError::IllegalParameter); break; default: PopError(); - SetError(errIllegalParameter); + SetError(FormulaError::IllegalParameter); } break; @@ -2837,16 +2837,16 @@ void ScInterpreter::ScExternal() ScRange aRange; PopDoubleRef( aRange ); if (!ScRangeToSequence::FillStringArray( aParam, pDok, aRange )) - SetError(errIllegalParameter); + SetError(FormulaError::IllegalParameter); } break; case svMatrix: if (!ScRangeToSequence::FillStringArray( aParam, PopMatrix().get(), pFormatter )) - SetError(errIllegalParameter); + SetError(FormulaError::IllegalParameter); break; default: PopError(); - SetError(errIllegalParameter); + SetError(FormulaError::IllegalParameter); } break; @@ -2888,16 +2888,16 @@ void ScInterpreter::ScExternal() ScRange aRange; PopDoubleRef( aRange ); if (!ScRangeToSequence::FillMixedArray( aParam, pDok, aRange )) - SetError(errIllegalParameter); + SetError(FormulaError::IllegalParameter); } break; case svMatrix: if (!ScRangeToSequence::FillMixedArray( aParam, PopMatrix().get() )) - SetError(errIllegalParameter); + SetError(FormulaError::IllegalParameter); break; default: PopError(); - SetError(errIllegalParameter); + SetError(FormulaError::IllegalParameter); } break; @@ -2932,16 +2932,16 @@ void ScInterpreter::ScExternal() ScRange aRange; PopDoubleRef( aRange ); if (!ScRangeToSequence::FillMixedArray( aParam, pDok, aRange )) - SetError(errIllegalParameter); + SetError(FormulaError::IllegalParameter); } break; case svMatrix: if (!ScRangeToSequence::FillMixedArray( aParam, PopMatrix().get() )) - SetError(errIllegalParameter); + SetError(FormulaError::IllegalParameter); break; default: PopError(); - SetError(errIllegalParameter); + SetError(FormulaError::IllegalParameter); } break; @@ -2958,7 +2958,7 @@ void ScInterpreter::ScExternal() if (xObj.is()) aParam <<= xObj; else - SetError(errIllegalParameter); + SetError(FormulaError::IllegalParameter); } break; case svDoubleRef: @@ -2973,19 +2973,19 @@ void ScInterpreter::ScExternal() } else { - SetError(errIllegalParameter); + SetError(FormulaError::IllegalParameter); } } break; default: PopError(); - SetError(errIllegalParameter); + SetError(FormulaError::IllegalParameter); } break; default: PopError(); - SetError(errIllegalParameter); + SetError(FormulaError::IllegalParameter); } aCall.SetParam( nPar, aParam ); } @@ -2994,7 +2994,7 @@ void ScInterpreter::ScExternal() { Pop(); // in case of error, remove remaining args } - if ( !GetError() ) + if ( GetError() == FormulaError::NONE ) { aCall.ExecuteCall(); @@ -3023,7 +3023,7 @@ void ScInterpreter::ScExternal() aCall.SetResult( pLis->GetResult() ); // use result from async } - if ( aCall.GetErrCode() ) + if ( aCall.GetErrCode() != FormulaError::NONE ) { PushError( aCall.GetErrCode() ); } @@ -3050,7 +3050,7 @@ void ScInterpreter::ScExternal() { Pop(); } - PushError( errNoAddin ); + PushError( FormulaError::NoAddin ); } } @@ -3166,7 +3166,7 @@ void ScInterpreter::ScMacro() SbxVariable* pVar = pRoot ? pRoot->Find(aMacro, SbxClassType::Method) : nullptr; if( !pVar || pVar->GetType() == SbxVOID || dynamic_cast<const SbMethod*>( pVar) == nullptr ) { - PushError( errNoMacro ); + PushError( FormulaError::NoMacro ); return; } @@ -3207,7 +3207,7 @@ void ScInterpreter::ScMacro() { ScExternalRefCache::TokenRef pToken; PopExternalSingleRef(pToken); - if (nGlobalError) + if (nGlobalError != FormulaError::NONE) bOk = false; else { @@ -3217,7 +3217,7 @@ void ScInterpreter::ScMacro() pPar->PutDouble( pToken->GetDouble() ); else { - SetError( errIllegalArgument ); + SetError( FormulaError::IllegalArgument ); bOk = false; } } @@ -3249,7 +3249,7 @@ void ScInterpreter::ScMacro() PopDoubleRef( nCol1, nRow1, nTab1, nCol2, nRow2, nTab2 ); if( nTab1 != nTab2 ) { - SetError( errIllegalParameter ); + SetError( FormulaError::IllegalParameter ); bOk = false; } else @@ -3288,7 +3288,7 @@ void ScInterpreter::ScMacro() { ScMatrixRef pMat = GetMatrix(); SCSIZE nC, nR; - if (pMat && !nGlobalError) + if (pMat && nGlobalError == FormulaError::NONE) { pMat->GetDimensions(nC, nR); SbxDimArrayRef refArray = new SbxDimArray; @@ -3316,12 +3316,12 @@ void ScInterpreter::ScMacro() } else { - SetError( errIllegalParameter ); + SetError( FormulaError::IllegalParameter ); } } break; default: - SetError( errIllegalParameter ); + SetError( FormulaError::IllegalParameter ); bOk = false; } } @@ -3344,7 +3344,7 @@ void ScInterpreter::ScMacro() SbxDataType eResType = refRes->GetType(); if( SbxBase::GetError() ) { - SetError( errNoValue); + SetError( FormulaError::NoValue); } if ( eRet != ERRCODE_NONE ) { @@ -3440,7 +3440,7 @@ bool ScInterpreter::SetSbxVariable( SbxVariable* pVar, const ScAddress& rPos ) ScRefCellValue aCell(*pDok, rPos); if (!aCell.isEmpty()) { - sal_uInt16 nErr; + FormulaError nErr; double nVal; switch (aCell.meType) { @@ -3454,7 +3454,7 @@ bool ScInterpreter::SetSbxVariable( SbxVariable* pVar, const ScAddress& rPos ) break; case CELLTYPE_FORMULA : nErr = aCell.mpFormula->GetErrCode(); - if( !nErr ) + if( nErr == FormulaError::NONE ) { if (aCell.mpFormula->IsValue()) { @@ -3612,7 +3612,7 @@ void ScInterpreter::ScDBArea() PushTempToken( new ScDoubleRefToken( aRefData ) ); } else - PushError( errNoName); + PushError( FormulaError::NoName); } void ScInterpreter::ScColRowNameAuto() @@ -3621,7 +3621,7 @@ void ScInterpreter::ScColRowNameAuto() ScRange aAbs = aRefData.toAbs(aPos); if (!ValidRange(aAbs)) { - PushError( errNoRef ); + PushError( FormulaError::NoRef ); return; } @@ -3706,7 +3706,7 @@ void ScInterpreter::ScTTT() // clean up Stack while ( nParamCount-- > 0) Pop(); - PushError(errNoValue); + PushError(FormulaError::NoValue); } ScInterpreter::ScInterpreter( ScFormulaCell* pCell, ScDocument* pDoc, @@ -3722,7 +3722,7 @@ ScInterpreter::ScInterpreter( ScFormulaCell* pCell, ScDocument* pDoc, , pMyFormulaCell(pCell) , pFormatter(pDoc->GetFormatTable()) , pCur(nullptr) - , nGlobalError(0) + , nGlobalError(FormulaError::NONE) , sp(0) , maxsp(0) , nFuncFmtIndex(0) @@ -3731,7 +3731,7 @@ ScInterpreter::ScInterpreter( ScFormulaCell* pCell, ScDocument* pDoc, , nFuncFmtType(0) , nCurFmtType(0) , nRetFmtType(0) - , mnStringNoValueError(errNoValue) + , mnStringNoValueError(FormulaError::NoValue) , mnSubTotalFlags(0) , cPar(0) , bCalcAsShown(pDoc->GetDocOptions().IsCalcAsShown()) @@ -3862,7 +3862,7 @@ StackVar ScInterpreter::Interpret() std::stack<sal_uInt16> aErrorFunctionStack; sal_uInt16 nStackBase; - nGlobalError = 0; + nGlobalError = FormulaError::NONE; nStackBase = sp = maxsp = 0; nRetFmtType = css::util::NumberFormat::UNDEFINED; nFuncFmtType = css::util::NumberFormat::UNDEFINED; @@ -3881,7 +3881,7 @@ StackVar ScInterpreter::Interpret() aCode.Reset(); while( ( pCur = aCode.Next() ) != nullptr - && (!nGlobalError || nErrorFunction <= nErrorFunctionCount) ) + && (nGlobalError == FormulaError::NONE || nErrorFunction <= nErrorFunctionCount) ) { OpCode eOp = pCur->GetOpCode(); cPar = pCur->GetByte(); @@ -3971,7 +3971,7 @@ StackVar ScInterpreter::Interpret() case ocFalse : ScFalse(); break; case ocGetActDate : ScGetActDate(); break; case ocGetActTime : ScGetActTime(); break; - case ocNotAvail : PushError( NOTAVAILABLE); break; + case ocNotAvail : PushError( FormulaError::NotAvailable); break; case ocDeg : ScDeg(); break; case ocRad : ScRad(); break; case ocSin : ScSin(); break; @@ -4355,7 +4355,7 @@ StackVar ScInterpreter::Interpret() case ocTTT : ScTTT(); break; case ocDebugVar : ScDebugVar(); break; case ocNone : nFuncFmtType = css::util::NumberFormat::UNDEFINED; break; - default : PushError( errUnknownOpCode); break; + default : PushError( FormulaError::UnknownOpCode); break; } // If the function pushed a subroutine as result, continue with @@ -4394,7 +4394,7 @@ StackVar ScInterpreter::Interpret() } // Need a clean stack environment for the JumpMatrix to work. - if (nGlobalError && eOp != ocPush && sp > nStackBase + 1) + if (nGlobalError != FormulaError::NONE && eOp != ocPush && sp > nStackBase + 1) { // Not all functions pop all parameters in case an error is // generated. Clean up stack. Assumes that every function pushes a @@ -4437,7 +4437,7 @@ StackVar ScInterpreter::Interpret() if( IsErrFunc(eOp) ) ++nErrorFunction; - if ( nGlobalError ) + if ( nGlobalError != FormulaError::NONE ) { if ( !nErrorFunctionCount ) { // count of errorcode functions in formula @@ -4496,13 +4496,13 @@ StackVar ScInterpreter::Interpret() { ScAddress aAdr; PopSingleRef( aAdr ); - if( !nGlobalError ) + if( nGlobalError == FormulaError::NONE) PushCellResultToken( false, aAdr, &nRetTypeExpr, &nRetIndexExpr, true); } break; case svRefList : PopError(); // maybe #REF! takes precedence over #VALUE! - PushError( errNoValue); + PushError( FormulaError::NoValue); break; case svDoubleRef : { @@ -4517,7 +4517,7 @@ StackVar ScInterpreter::Interpret() ScRange aRange; PopDoubleRef( aRange ); ScAddress aAdr; - if ( !nGlobalError && DoubleRefToPosSingleRef( aRange, aAdr)) + if ( nGlobalError == FormulaError::NONE && DoubleRefToPosSingleRef( aRange, aAdr)) PushCellResultToken( false, aAdr, &nRetTypeExpr, &nRetIndexExpr, true); } } @@ -4551,7 +4551,7 @@ StackVar ScInterpreter::Interpret() FormulaTokenRef xToken; ScExternalRefCache::CellFormat aFmt; PopExternalSingleRef(xToken, &aFmt); - if (nGlobalError) + if (nGlobalError != FormulaError::NONE) break; PushTokenRef(xToken); @@ -4564,14 +4564,14 @@ StackVar ScInterpreter::Interpret() } break; default : - SetError( errUnknownStackVariable); + SetError( FormulaError::UnknownStackVariable); } } else - SetError( errUnknownStackVariable); + SetError( FormulaError::UnknownStackVariable); } else - SetError( errNoCode); + SetError( FormulaError::NoCode); if( nRetTypeExpr != css::util::NumberFormat::UNDEFINED ) { @@ -4586,13 +4586,13 @@ StackVar ScInterpreter::Interpret() else nRetFmtType = css::util::NumberFormat::NUMBER; - if (nGlobalError && GetStackType() != svError ) + if (nGlobalError != FormulaError::NONE && GetStackType() != svError ) PushError( nGlobalError); // THE final result. xResult = PopToken(); if (!xResult) - xResult = new FormulaErrorToken( errUnknownStackVariable); + xResult = new FormulaErrorToken( FormulaError::UnknownStackVariable); // release tokens in expression stack const FormulaToken** p = pStack; diff --git a/sc/source/core/tool/interpr5.cxx b/sc/source/core/tool/interpr5.cxx index d5f09f7fc291..43a80861d612 100644 --- a/sc/source/core/tool/interpr5.cxx +++ b/sc/source/core/tool/interpr5.cxx @@ -134,7 +134,7 @@ void ScInterpreter::ScGCD() double fx, fy = 0.0; ScRange aRange; size_t nRefInList = 0; - while (!nGlobalError && nParamCount-- > 0) + while (nGlobalError == FormulaError::NONE && nParamCount-- > 0) { switch (GetStackType()) { @@ -154,7 +154,7 @@ void ScInterpreter::ScGCD() case svDoubleRef : case svRefList : { - sal_uInt16 nErr = 0; + FormulaError nErr = FormulaError::NONE; PopDoubleRef( aRange, nParamCount, nRefInList); double nCellVal; ScValueIterator aValIter( pDok, aRange, mnSubTotalFlags ); @@ -169,7 +169,7 @@ void ScInterpreter::ScGCD() return; } fy = ScGetGCD(fx, fy); - } while (nErr == 0 && aValIter.GetNext(nCellVal, nErr)); + } while (nErr == FormulaError::NONE && aValIter.GetNext(nCellVal, nErr)); } SetError(nErr); } @@ -184,7 +184,7 @@ void ScInterpreter::ScGCD() SCSIZE nC, nR; pMat->GetDimensions(nC, nR); if (nC == 0 || nR == 0) - SetError(errIllegalArgument); + SetError(FormulaError::IllegalArgument); else { for ( SCSIZE j = 0; j < nC; j++ ) @@ -209,7 +209,7 @@ void ScInterpreter::ScGCD() } } break; - default : SetError(errIllegalParameter); break; + default : SetError(FormulaError::IllegalParameter); break; } } PushDouble(fy); @@ -224,7 +224,7 @@ void ScInterpreter:: ScLCM() double fx, fy = 1.0; ScRange aRange; size_t nRefInList = 0; - while (!nGlobalError && nParamCount-- > 0) + while (nGlobalError == FormulaError::NONE && nParamCount-- > 0) { switch (GetStackType()) { @@ -247,7 +247,7 @@ void ScInterpreter:: ScLCM() case svDoubleRef : case svRefList : { - sal_uInt16 nErr = 0; + FormulaError nErr = FormulaError::NONE; PopDoubleRef( aRange, nParamCount, nRefInList); double nCellVal; ScValueIterator aValIter( pDok, aRange, mnSubTotalFlags ); @@ -265,7 +265,7 @@ void ScInterpreter:: ScLCM() fy = 0.0; else fy = fx * fy / ScGetGCD(fx, fy); - } while (nErr == 0 && aValIter.GetNext(nCellVal, nErr)); + } while (nErr == FormulaError::NONE && aValIter.GetNext(nCellVal, nErr)); } SetError(nErr); } @@ -280,7 +280,7 @@ void ScInterpreter:: ScLCM() SCSIZE nC, nR; pMat->GetDimensions(nC, nR); if (nC == 0 || nR == 0) - SetError(errIllegalArgument); + SetError(FormulaError::IllegalArgument); else { for ( SCSIZE j = 0; j < nC; j++ ) @@ -308,7 +308,7 @@ void ScInterpreter:: ScLCM() } } break; - default : SetError(errIllegalParameter); break; + default : SetError(FormulaError::IllegalParameter); break; } } PushDouble(fy); @@ -331,7 +331,7 @@ ScMatrixRef ScInterpreter::GetNewMat(SCSIZE nC, SCSIZE nR, bool bEmpty) pMat->GetDimensions( nCols, nRows); if ( nCols != nC || nRows != nR ) { // arbitray limit of elements exceeded - SetError( errMatrixSize); + SetError( FormulaError::MatrixSize); pMat.reset(); } return pMat; @@ -341,10 +341,10 @@ ScMatrixRef ScInterpreter::CreateMatrixFromDoubleRef( const FormulaToken* pToken SCCOL nCol1, SCROW nRow1, SCTAB nTab1, SCCOL nCol2, SCROW nRow2, SCTAB nTab2 ) { - if (nTab1 != nTab2 || nGlobalError) + if (nTab1 != nTab2 || nGlobalError != FormulaError::NONE) { // Not a 2D matrix. - SetError(errIllegalParameter); + SetError(FormulaError::IllegalParameter); return nullptr; } @@ -353,7 +353,7 @@ ScMatrixRef ScInterpreter::CreateMatrixFromDoubleRef( const FormulaToken* pToken if (!ScMatrix::IsSizeAllocatable( nMatCols, nMatRows)) { - SetError(errMatrixSize); + SetError(FormulaError::MatrixSize); return nullptr; } @@ -370,7 +370,7 @@ ScMatrixRef ScInterpreter::CreateMatrixFromDoubleRef( const FormulaToken* pToken } ScMatrixRef pMat = GetNewMat( nMatCols, nMatRows, true); - if (!pMat || nGlobalError) + if (!pMat || nGlobalError != FormulaError::NONE) return nullptr; pDok->FillMatrix(*pMat, nTab1, nCol1, nRow1, nCol2, nRow2); @@ -429,10 +429,10 @@ ScMatrixRef ScInterpreter::GetMatrix() pMat = GetNewMat( 1, 1); if ( pMat ) { - if ( nGlobalError ) + if ( nGlobalError != FormulaError::NONE ) { fVal = CreateDoubleError( nGlobalError); - nGlobalError = 0; + nGlobalError = FormulaError::NONE; } pMat->PutDouble( fVal, 0); } @@ -444,11 +444,11 @@ ScMatrixRef ScInterpreter::GetMatrix() pMat = GetNewMat( 1, 1); if ( pMat ) { - if ( nGlobalError ) + if ( nGlobalError != FormulaError::NONE ) { double fVal = CreateDoubleError( nGlobalError); pMat->PutDouble( fVal, 0); - nGlobalError = 0; + nGlobalError = FormulaError::NONE; } else pMat->PutString(aStr, 0); @@ -462,13 +462,13 @@ ScMatrixRef ScInterpreter::GetMatrix() pMat = GetNewMat( 1, 1, true); if (!pMat) { - SetError( errIllegalArgument); + SetError( FormulaError::IllegalArgument); break; } - if (nGlobalError) + if (nGlobalError != FormulaError::NONE) { pMat->PutError( nGlobalError, 0, 0); - nGlobalError = 0; + nGlobalError = FormulaError::NONE; break; } switch (pToken->GetType()) @@ -492,7 +492,7 @@ ScMatrixRef ScInterpreter::GetMatrix() break; default: PopError(); - SetError( errIllegalArgument); + SetError( FormulaError::IllegalArgument); break; } return pMat; @@ -521,7 +521,7 @@ void ScInterpreter::ScMatValue() // really, practically ... SCSIZE nR = static_cast<SCSIZE>(GetUInt32()); SCSIZE nC = static_cast<SCSIZE>(GetUInt32()); - if (nGlobalError) + if (nGlobalError != FormulaError::NONE) { PushError( nGlobalError); return; @@ -535,8 +535,8 @@ void ScInterpreter::ScMatValue() ScRefCellValue aCell(*pDok, aAdr); if (aCell.meType == CELLTYPE_FORMULA) { - sal_uInt16 nErrCode = aCell.mpFormula->GetErrCode(); - if (nErrCode != 0) + FormulaError nErrCode = aCell.mpFormula->GetErrCode(); + if (nErrCode != FormulaError::NONE) PushError( nErrCode); else { @@ -618,10 +618,10 @@ void ScInterpreter::ScEMat() if ( MustHaveParamCount( GetByte(), 1 ) ) { SCSIZE nDim = static_cast<SCSIZE>(GetUInt32()); - if (nGlobalError || nDim == 0) + if (nGlobalError != FormulaError::NONE || nDim == 0) PushIllegalArgument(); else if (!ScMatrix::IsSizeAllocatable( nDim, nDim)) - PushError( errMatrixSize); + PushError( FormulaError::MatrixSize); else { ScMatrixRef pRMat = GetNewMat(nDim, nDim); @@ -822,13 +822,13 @@ void ScInterpreter::ScMatDet() if ( nC != nR || nC == 0 ) PushIllegalArgument(); else if (!ScMatrix::IsSizeAllocatable( nC, nR)) - PushError( errMatrixSize); + PushError( FormulaError::MatrixSize); else { // LUP decomposition is done inplace, use copy. ScMatrixRef xLU = pMat->Clone(); if (!xLU) - PushError( errCodeOverflow); + PushError( FormulaError::CodeOverflow); else { ::std::vector< SCSIZE> P(nR); @@ -857,7 +857,7 @@ void ScInterpreter::ScModalValue_Multi() vector<double> aSortArray; GetSortArray( nParamCount, aSortArray, nullptr, false, false ); SCSIZE nSize = aSortArray.size(); - if ( aSortArray.empty() || nSize == 0 || nGlobalError ) + if ( aSortArray.empty() || nSize == 0 || nGlobalError != FormulaError::NONE ) PushNoValue(); else { @@ -947,7 +947,7 @@ void ScInterpreter::ScMatInv() if ( nC != nR || nC == 0 ) PushIllegalArgument(); else if (!ScMatrix::IsSizeAllocatable( nC, nR)) - PushError( errMatrixSize); + PushError( FormulaError::MatrixSize); else { // LUP decomposition is done inplace, use copy. @@ -955,7 +955,7 @@ void ScInterpreter::ScMatInv() // The result matrix. ScMatrixRef xY = GetNewMat( nR, nR); if (!xLU || !xY) - PushError( errCodeOverflow); + PushError( FormulaError::CodeOverflow); else { ::std::vector< SCSIZE> P(nR); @@ -1008,13 +1008,13 @@ void ScInterpreter::ScMatInv() double fTmp = pR->GetDouble( j, i); fprintf( stderr, "%8.2g ", fTmp); if (fabs( fTmp - (i == j)) > fInvEpsilon) - SetError( errIllegalArgument); + SetError( FormulaError::IllegalArgument); } fprintf( stderr, "\n%s\n", ""); } } #endif - if (nGlobalError) + if (nGlobalError != FormulaError::NONE) PushError( nGlobalError); else PushMatrix( xY); @@ -1135,32 +1135,32 @@ static ScMatrixRef lcl_MatrixCalculation( { bool bVal1 = rMat1.IsValueOrEmpty(i,j); bool bVal2 = rMat2.IsValueOrEmpty(i,j); - sal_uInt16 nErr; + FormulaError nErr; if (bVal1 && bVal2) { double d = Op(rMat1.GetDouble(i,j), rMat2.GetDouble(i,j)); xResMat->PutDouble( d, i, j); } - else if (((nErr = rMat1.GetErrorIfNotString(i,j)) != 0) || - ((nErr = rMat2.GetErrorIfNotString(i,j)) != 0)) + else if (((nErr = rMat1.GetErrorIfNotString(i,j)) != FormulaError::NONE) || + ((nErr = rMat2.GetErrorIfNotString(i,j)) != FormulaError::NONE)) { xResMat->PutError( nErr, i, j); } else if ((!bVal1 && rMat1.IsString(i,j)) || (!bVal2 && rMat2.IsString(i,j))) { - sal_uInt16 nError1 = 0; + FormulaError nError1 = FormulaError::NONE; short nFmt1 = 0; double fVal1 = (bVal1 ? rMat1.GetDouble(i,j) : pInterpreter->ConvertStringToValue( rMat1.GetString(i,j).getString(), nError1, nFmt1)); - sal_uInt16 nError2 = 0; + FormulaError nError2 = FormulaError::NONE; short nFmt2 = 0; double fVal2 = (bVal2 ? rMat2.GetDouble(i,j) : pInterpreter->ConvertStringToValue( rMat2.GetString(i,j).getString(), nError2, nFmt2)); - if (nError1) + if (nError1 != FormulaError::NONE) xResMat->PutError( nError1, i, j); - else if (nError2) + else if (nError2 != FormulaError::NONE) xResMat->PutError( nError2, i, j); else { @@ -1169,7 +1169,7 @@ static ScMatrixRef lcl_MatrixCalculation( } } else - xResMat->PutError( errNoValue, i, j); + xResMat->PutError( FormulaError::NoValue, i, j); } } } @@ -1394,7 +1394,7 @@ void ScInterpreter::ScAmpersand() ScMatrixRef pResMat = GetNewMat(nC, nR); if (pResMat) { - if (nGlobalError) + if (nGlobalError != FormulaError::NONE) { for (SCSIZE i = 0; i < nC; ++i) for (SCSIZE j = 0; j < nR; ++j) @@ -1405,8 +1405,8 @@ void ScInterpreter::ScAmpersand() for (SCSIZE i = 0; i < nC; ++i) for (SCSIZE j = 0; j < nR; ++j) { - sal_uInt16 nErr = pMat->GetErrorIfNotString( i, j); - if (nErr) + FormulaError nErr = pMat->GetErrorIfNotString( i, j); + if (nErr != FormulaError::NONE) pResMat->PutError( nErr, i, j); else { @@ -1421,8 +1421,8 @@ void ScInterpreter::ScAmpersand() for (SCSIZE i = 0; i < nC; ++i) for (SCSIZE j = 0; j < nR; ++j) { - sal_uInt16 nErr = pMat->GetErrorIfNotString( i, j); - if (nErr) + FormulaError nErr = pMat->GetErrorIfNotString( i, j); + if (nErr != FormulaError::NONE) pResMat->PutError( nErr, i, j); else { @@ -1687,10 +1687,10 @@ public: if (mbError) return; - sal_uInt16 nErr = GetDoubleErrorValue(f); - if (!nErr) + FormulaError nErr = GetDoubleErrorValue(f); + if (nErr == FormulaError::NONE) mfSum += f; - else if (nErr != errElementNaN) + else if (nErr != FormulaError::ElementNaN) { // Propagate the first error encountered, ignore "this is not a // number" elements. @@ -1842,7 +1842,7 @@ void ScInterpreter::ScFrequency() GetSortArray( 1, aBinArray, &aBinIndexOrder, false, false ); SCSIZE nBinSize = aBinArray.size(); - if (nGlobalError) + if (nGlobalError != FormulaError::NONE) { PushNoValue(); return; @@ -1852,7 +1852,7 @@ void ScInterpreter::ScFrequency() GetSortArray( 1, aDataArray, nullptr, false, false ); SCSIZE nDataSize = aDataArray.size(); - if (aDataArray.empty() || nGlobalError) + if (aDataArray.empty() || nGlobalError != FormulaError::NONE) { PushNoValue(); return; @@ -2434,7 +2434,7 @@ void ScInterpreter::CalculateRGPRKP(bool _bRKP) pResMat = GetNewMat(K+1,1); if (!pResMat) { - PushError(errCodeOverflow); + PushError(FormulaError::CodeOverflow); return; } // Fill unused cells in pResMat; order (column,row) @@ -2442,9 +2442,9 @@ void ScInterpreter::CalculateRGPRKP(bool _bRKP) { for (SCSIZE i=2; i<K+1; i++) { - pResMat->PutError( NOTAVAILABLE, i, 2); - pResMat->PutError( NOTAVAILABLE, i, 3); - pResMat->PutError( NOTAVAILABLE, i, 4); + pResMat->PutError( FormulaError::NotAvailable, i, 2); + pResMat->PutError( FormulaError::NotAvailable, i, 3); + pResMat->PutError( FormulaError::NotAvailable, i, 4); } } @@ -2457,7 +2457,7 @@ void ScInterpreter::CalculateRGPRKP(bool _bRKP) ScMatrixRef pNewY = pMatY->CloneIfConst(); if (!pNewX || !pNewY) { - PushError(errCodeOverflow); + PushError(FormulaError::CodeOverflow); return; } pMatX = pNewX; @@ -2511,13 +2511,13 @@ void ScInterpreter::CalculateRGPRKP(bool _bRKP) { // exact fit; test SSreg too, because SSresid might be // unequal zero due to round of errors pResMat->PutDouble(0.0, 1, 4); // SSresid - pResMat->PutError( NOTAVAILABLE, 0, 3); // F + pResMat->PutError( FormulaError::NotAvailable, 0, 3); // F pResMat->PutDouble(0.0, 1, 2); // RMSE pResMat->PutDouble(0.0, 0, 1); // SigmaSlope if (bConstant) pResMat->PutDouble(0.0, 1, 1); //SigmaIntercept else - pResMat->PutError( NOTAVAILABLE, 1, 1); + pResMat->PutError( FormulaError::NotAvailable, 1, 1); pResMat->PutDouble(1.0, 0, 2); // R^2 } else @@ -2541,7 +2541,7 @@ void ScInterpreter::CalculateRGPRKP(bool _bRKP) } else { - pResMat->PutError( NOTAVAILABLE, 1, 1); + pResMat->PutError( FormulaError::NotAvailable, 1, 1); } double fR2 = fSSreg / (fSSreg + fSSresid); @@ -2567,7 +2567,7 @@ void ScInterpreter::CalculateRGPRKP(bool _bRKP) ScMatrixRef pSlopes = GetNewMat(1,K); // from b1 to bK if (!pMeans || !pMatZ || !pSlopes) { - PushError(errCodeOverflow); + PushError(FormulaError::CodeOverflow); return; } if (bConstant) @@ -2639,7 +2639,7 @@ void ScInterpreter::CalculateRGPRKP(bool _bRKP) { // exact fit; incl. observed values Y are identical pResMat->PutDouble(0.0, 1, 4); // SSresid // F = (SSreg/K) / (SSresid/df) = #DIV/0! - pResMat->PutError( NOTAVAILABLE, 0, 3); // F + pResMat->PutError( FormulaError::NotAvailable, 0, 3); // F // RMSE = sqrt(SSresid / df) = sqrt(0 / df) = 0 pResMat->PutDouble(0.0, 1, 2); // RMSE // SigmaSlope[i] = RMSE * sqrt(matrix[i,i]) = 0 * sqrt(...) = 0 @@ -2650,7 +2650,7 @@ void ScInterpreter::CalculateRGPRKP(bool _bRKP) if (bConstant) pResMat->PutDouble(0.0, K, 1); //SigmaIntercept else - pResMat->PutError( NOTAVAILABLE, K, 1); + pResMat->PutError( FormulaError::NotAvailable, K, 1); // R^2 = SSreg / (SSreg + SSresid) = 1.0 pResMat->PutDouble(1.0, 0, 2); // R^2 @@ -2700,7 +2700,7 @@ void ScInterpreter::CalculateRGPRKP(bool _bRKP) } else { - pResMat->PutError( NOTAVAILABLE, K, 1); + pResMat->PutError( FormulaError::NotAvailable, K, 1); } double fR2 = fSSreg / (fSSreg + fSSresid); @@ -2722,7 +2722,7 @@ void ScInterpreter::CalculateRGPRKP(bool _bRKP) ScMatrixRef pSlopes = GetNewMat(K,1); // from b1 to bK if (!pMeans || !pMatZ || !pSlopes) { - PushError(errCodeOverflow); + PushError(FormulaError::CodeOverflow); return; } if (bConstant) @@ -2796,7 +2796,7 @@ void ScInterpreter::CalculateRGPRKP(bool _bRKP) { // exact fit; incl. case observed values Y are identical pResMat->PutDouble(0.0, 1, 4); // SSresid // F = (SSreg/K) / (SSresid/df) = #DIV/0! - pResMat->PutError( NOTAVAILABLE, 0, 3); // F + pResMat->PutError( FormulaError::NotAvailable, 0, 3); // F // RMSE = sqrt(SSresid / df) = sqrt(0 / df) = 0 pResMat->PutDouble(0.0, 1, 2); // RMSE // SigmaSlope[i] = RMSE * sqrt(matrix[i,i]) = 0 * sqrt(...) = 0 @@ -2807,7 +2807,7 @@ void ScInterpreter::CalculateRGPRKP(bool _bRKP) if (bConstant) pResMat->PutDouble(0.0, K, 1); //SigmaIntercept else - pResMat->PutError( NOTAVAILABLE, K, 1); + pResMat->PutError( FormulaError::NotAvailable, K, 1); // R^2 = SSreg / (SSreg + SSresid) = 1.0 pResMat->PutDouble(1.0, 0, 2); // R^2 @@ -2857,7 +2857,7 @@ void ScInterpreter::CalculateRGPRKP(bool _bRKP) } else { - pResMat->PutError( NOTAVAILABLE, K, 1); + pResMat->PutError( FormulaError::NotAvailable, K, 1); } double fR2 = fSSreg / (fSSreg + fSSresid); @@ -2991,7 +2991,7 @@ void ScInterpreter::CalculateTrendGrowth(bool _bGrowth) } if (!pResMat) { - PushError(errCodeOverflow); + PushError(FormulaError::CodeOverflow); return; } // Uses sum(x-MeanX)^2 and not [sum x^2]-N * MeanX^2 in case bConstant. @@ -3003,7 +3003,7 @@ void ScInterpreter::CalculateTrendGrowth(bool _bGrowth) ScMatrixRef pCopyY = pMatY->CloneIfConst(); if (!pCopyX || !pCopyY) { - PushError(errMatrixSize); + PushError(FormulaError::MatrixSize); return; } pMatX = pCopyX; @@ -3065,7 +3065,7 @@ void ScInterpreter::CalculateTrendGrowth(bool _bGrowth) ScMatrixRef pSlopes = GetNewMat(1,K); // from b1 to bK if (!pMeans || !pSlopes) { - PushError(errCodeOverflow); + PushError(FormulaError::CodeOverflow); return; } if (bConstant) @@ -3124,7 +3124,7 @@ void ScInterpreter::CalculateTrendGrowth(bool _bGrowth) ScMatrixRef pSlopes = GetNewMat(K,1); // row from b1 to bK if (!pMeans || !pSlopes) { - PushError(errCodeOverflow); + PushError(FormulaError::CodeOverflow); return; } if (bConstant) @@ -3189,7 +3189,7 @@ void ScInterpreter::ScMatRef() if (aCell.meType != CELLTYPE_FORMULA) { - PushError( errNoRef ); + PushError( FormulaError::NoRef ); return; } @@ -3198,8 +3198,8 @@ void ScInterpreter::ScMatRef() // Twisted odd corner case where an array element's cell tries to // access the top left matrix while it is still running, see tdf#88737 // This is a hackish workaround, not a general solution, the matrix - // isn't available anyway and errCircularReference would be set. - PushError( errRetryCircular ); + // isn't available anyway and FormulaError::CircularReference would be set. + PushError( FormulaError::RetryCircular ); return; } @@ -3249,8 +3249,8 @@ void ScInterpreter::ScMatRef() nFuncFmtType = nCurFmtType; nFuncFmtIndex = nCurFmtIndex; // If not a result matrix, obtain the cell value. - sal_uInt16 nErr = aCell.mpFormula->GetErrCode(); - if (nErr) + FormulaError nErr = aCell.mpFormula->GetErrCode(); + if (nErr != FormulaError::NONE) PushError( nErr ); else if (aCell.mpFormula->IsValue()) PushDouble(aCell.mpFormula->GetValue()); diff --git a/sc/source/core/tool/interpr6.cxx b/sc/source/core/tool/interpr6.cxx index c46606891c95..ebf1a9b434d6 100644 --- a/sc/source/core/tool/interpr6.cxx +++ b/sc/source/core/tool/interpr6.cxx @@ -85,7 +85,7 @@ double ScInterpreter::GetGammaContFraction( double fA, double fX ) // most iterations, if fX==fAlpha+1.0; approx sqrt(fAlpha) iterations then if (!bFinished) { - SetError(errNoConvergence); + SetError(FormulaError::NoConvergence); } return fApprox; } @@ -110,7 +110,7 @@ double ScInterpreter::GetGammaSeries( double fA, double fX ) // if fX <= fAlpha+1.0 if (nCount>10000) { - SetError(errNoConvergence); + SetError(FormulaError::NoConvergence); } return fSum; } @@ -150,7 +150,7 @@ double ScInterpreter::GetGammaDistPDF( double fX, double fAlpha, double fLambda { if (fAlpha < 1.0) { - SetError(errDivisionByZero); // should be #DIV/0 + SetError(FormulaError::DivisionByZero); // should be #DIV/0 return HUGE_VAL; } else if (fAlpha == 1) @@ -207,10 +207,10 @@ class NumericCellAccumulator { double mfFirst; double mfRest; - sal_uInt16 mnError; + FormulaError mnError; public: - NumericCellAccumulator() : mfFirst(0.0), mfRest(0.0), mnError(0) {} + NumericCellAccumulator() : mfFirst(0.0), mfRest(0.0), mnError(FormulaError::NONE) {} void operator() (const sc::CellStoreType::value_type& rNode, size_t nOffset, size_t nDataSize) { @@ -252,13 +252,13 @@ public: for (; it != itEnd; ++it) { double fVal = 0.0; - sal_uInt16 nErr = 0; + FormulaError nErr = FormulaError::NONE; ScFormulaCell& rCell = const_cast<ScFormulaCell&>(*(*it)); if (!rCell.GetErrorOrValue(nErr, fVal)) // The cell has neither error nor value. Perhaps string result. continue; - if (nErr) + if (nErr != FormulaError::NONE) { // Cell has error - skip all the rest mnError = nErr; @@ -277,7 +277,7 @@ public: } } - sal_uInt16 getError() const { return mnError; } + FormulaError getError() const { return mnError; } double getFirst() const { return mfFirst; } double getRest() const { return mfRest; } }; @@ -353,11 +353,11 @@ class FuncSum : public sc::ColumnSpanSet::ColumnAction sc::ColumnBlockConstPosition maPos; ScColumn* mpCol; double mfSum; - sal_uInt16 mnError; + FormulaError mnError; sal_uInt32 mnNumFmt; public: - FuncSum() : mpCol(nullptr), mfSum(0.0), mnError(0), mnNumFmt(0) {} + FuncSum() : mpCol(nullptr), mfSum(0.0), mnError(FormulaError::NONE), mnNumFmt(0) {} virtual void startColumn(ScColumn* pCol) override { @@ -372,13 +372,13 @@ public: if (!bVal) return; - if (mnError) + if (mnError != FormulaError::NONE) return; NumericCellAccumulator aFunc; maPos.miCellPos = sc::ParseBlock(maPos.miCellPos, mpCol->GetCellStore(), aFunc, nRow1, nRow2); mnError = aFunc.getError(); - if (mnError) + if (mnError != FormulaError::NONE) return; if ( fMem ) @@ -392,7 +392,7 @@ public: mnNumFmt = mpCol->GetNumberFormat(nRow2); }; - sal_uInt16 getError() const { return mnError; } + FormulaError getError() const { return mnError; } double getSum() const { return mfSum; } sal_uInt32 getNumberFormat() const { return mnNumFmt; } }; @@ -469,9 +469,9 @@ double ScInterpreter::IterateParameters( ScIterFunc eFunc, bool bTextAsZero ) ScAddress aAdr; ScRange aRange; size_t nRefInList = 0; - if ( nGlobalError && ( eFunc == ifCOUNT2 || eFunc == ifCOUNT || + if ( nGlobalError != FormulaError::NONE && ( eFunc == ifCOUNT2 || eFunc == ifCOUNT || ( mnSubTotalFlags & SUBTOTAL_IGN_ERR_VAL ) ) ) - nGlobalError = 0; + nGlobalError = FormulaError::NONE; while (nParamCount-- > 0) { switch (GetStackType()) @@ -487,10 +487,10 @@ double ScInterpreter::IterateParameters( ScIterFunc eFunc, bool bTextAsZero ) { // Only check if string can be converted to number, no // error propagation. - sal_uInt16 nErr = nGlobalError; - nGlobalError = 0; + FormulaError nErr = nGlobalError; + nGlobalError = FormulaError::NONE; ConvertStringToValue( aStr ); - if (!nGlobalError) + if (nGlobalError == FormulaError::NONE) ++nCount; nGlobalError = nErr; } @@ -515,7 +515,7 @@ double ScInterpreter::IterateParameters( ScIterFunc eFunc, bool bTextAsZero ) { while (nParamCount-- > 0) Pop(); - SetError( errNoValue ); + SetError( FormulaError::NoValue ); } } break; @@ -549,10 +549,10 @@ double ScInterpreter::IterateParameters( ScIterFunc eFunc, bool bTextAsZero ) ScExternalRefCache::TokenRef pToken; ScExternalRefCache::CellFormat aFmt; PopExternalSingleRef(pToken, &aFmt); - if ( nGlobalError && ( eFunc == ifCOUNT2 || eFunc == ifCOUNT || + if ( nGlobalError != FormulaError::NONE && ( eFunc == ifCOUNT2 || eFunc == ifCOUNT || ( mnSubTotalFlags & SUBTOTAL_IGN_ERR_VAL ) ) ) { - nGlobalError = 0; + nGlobalError = FormulaError::NONE; if ( eFunc == ifCOUNT2 && !( mnSubTotalFlags & SUBTOTAL_IGN_ERR_VAL ) ) ++nCount; break; @@ -569,8 +569,8 @@ double ScInterpreter::IterateParameters( ScIterFunc eFunc, bool bTextAsZero ) pToken->GetOpCode() != ocAggregate ) || ( mnSubTotalFlags & SUBTOTAL_IGN_NESTED_ST_AG ) ) ) nCount++; - if (nGlobalError) - nGlobalError = 0; + if (nGlobalError != FormulaError::NONE) + nGlobalError = FormulaError::NONE; } else if (eType == formula::svDouble) { @@ -593,9 +593,9 @@ double ScInterpreter::IterateParameters( ScIterFunc eFunc, bool bTextAsZero ) case ifSUMSQ: fRes += fVal * fVal; break; case ifPRODUCT: fRes *= fVal; break; case ifCOUNT: - if ( nGlobalError ) + if ( nGlobalError != FormulaError::NONE ) { - nGlobalError = 0; + nGlobalError = FormulaError::NONE; nCount--; } break; @@ -613,10 +613,10 @@ double ScInterpreter::IterateParameters( ScIterFunc eFunc, bool bTextAsZero ) case svSingleRef : { PopSingleRef( aAdr ); - if ( nGlobalError && ( eFunc == ifCOUNT2 || eFunc == ifCOUNT || + if ( nGlobalError != FormulaError::NONE && ( eFunc == ifCOUNT2 || eFunc == ifCOUNT || ( mnSubTotalFlags & SUBTOTAL_IGN_ERR_VAL ) ) ) { - nGlobalError = 0; + nGlobalError = FormulaError::NONE; if ( eFunc == ifCOUNT2 && !( mnSubTotalFlags & SUBTOTAL_IGN_ERR_VAL ) ) ++nCount; break; @@ -634,8 +634,8 @@ double ScInterpreter::IterateParameters( ScIterFunc eFunc, bool bTextAsZero ) CellType eCellType = aCell.meType; if ( eCellType != CELLTYPE_NONE ) nCount++; - if ( nGlobalError ) - nGlobalError = 0; + if ( nGlobalError != FormulaError::NONE ) + nGlobalError = FormulaError::NONE; } else if (aCell.hasNumeric()) { @@ -654,9 +654,9 @@ double ScInterpreter::IterateParameters( ScIterFunc eFunc, bool bTextAsZero ) case ifSUMSQ: fRes += fVal * fVal; break; case ifPRODUCT: fRes *= fVal; break; case ifCOUNT: - if ( nGlobalError ) + if ( nGlobalError != FormulaError::NONE ) { - nGlobalError = 0; + nGlobalError = FormulaError::NONE; nCount--; } break; @@ -676,10 +676,10 @@ double ScInterpreter::IterateParameters( ScIterFunc eFunc, bool bTextAsZero ) case svRefList : { PopDoubleRef( aRange, nParamCount, nRefInList); - if ( nGlobalError && ( eFunc == ifCOUNT2 || eFunc == ifCOUNT || + if ( nGlobalError != FormulaError::NONE && ( eFunc == ifCOUNT2 || eFunc == ifCOUNT || ( mnSubTotalFlags & SUBTOTAL_IGN_ERR_VAL ) ) ) { - nGlobalError = 0; + nGlobalError = FormulaError::NONE; if ( eFunc == ifCOUNT2 && !( mnSubTotalFlags & SUBTOTAL_IGN_ERR_VAL ) ) ++nCount; if ( eFunc == ifCOUNT2 || eFunc == ifCOUNT ) @@ -696,8 +696,8 @@ double ScInterpreter::IterateParameters( ScIterFunc eFunc, bool bTextAsZero ) } } - if ( nGlobalError ) - nGlobalError = 0; + if ( nGlobalError != FormulaError::NONE ) + nGlobalError = FormulaError::NONE; } else if ( ( eFunc == ifSUM || eFunc == ifCOUNT ) && !mnSubTotalFlags ) { @@ -708,8 +708,8 @@ double ScInterpreter::IterateParameters( ScIterFunc eFunc, bool bTextAsZero ) { FuncSum aAction; aSet.executeColumnAction( *pDok, aAction, fMem ); - sal_uInt16 nErr = aAction.getError(); - if ( nErr ) + FormulaError nErr = aAction.getError(); + if ( nErr != FormulaError::NONE ) { SetError( nErr ); return fRes; @@ -734,7 +734,7 @@ double ScInterpreter::IterateParameters( ScIterFunc eFunc, bool bTextAsZero ) else { ScValueIterator aValIter( pDok, aRange, mnSubTotalFlags, bTextAsZero ); - sal_uInt16 nErr = 0; + FormulaError nErr = FormulaError::NONE; if (aValIter.GetFirst(fVal, nErr)) { // placed the loop on the inside for performance reasons: @@ -747,7 +747,7 @@ double ScInterpreter::IterateParameters( ScIterFunc eFunc, bool bTextAsZero ) { do { - if ( !nErr ) + if ( nErr == FormulaError::NONE ) { SetError(nErr); if ( fMem ) @@ -778,7 +778,7 @@ double ScInterpreter::IterateParameters( ScIterFunc eFunc, bool bTextAsZero ) { do { - if ( !nErr ) + if ( nErr == FormulaError::NONE ) { SetError(nErr); fRes += fVal * fVal; @@ -801,7 +801,7 @@ double ScInterpreter::IterateParameters( ScIterFunc eFunc, bool bTextAsZero ) case ifPRODUCT: do { - if ( !( nErr && ( mnSubTotalFlags & SUBTOTAL_IGN_ERR_VAL ) ) ) + if ( !( nErr != FormulaError::NONE && ( mnSubTotalFlags & SUBTOTAL_IGN_ERR_VAL ) ) ) { SetError(nErr); fRes *= fVal; @@ -813,7 +813,7 @@ double ScInterpreter::IterateParameters( ScIterFunc eFunc, bool bTextAsZero ) case ifCOUNT: do { - if ( !nErr ) + if ( nErr == FormulaError::NONE ) nCount++; } while (aValIter.GetNext(fVal, nErr)); @@ -829,7 +829,7 @@ double ScInterpreter::IterateParameters( ScIterFunc eFunc, bool bTextAsZero ) { ScMatrixRef pMat; PopExternalDoubleRef(pMat); - if ( nGlobalError && !( mnSubTotalFlags & SUBTOTAL_IGN_ERR_VAL ) ) + if ( nGlobalError != FormulaError::NONE && !( mnSubTotalFlags & SUBTOTAL_IGN_ERR_VAL ) ) break; IterateMatrix( pMat, eFunc, bTextAsZero, nCount, nFuncFmtType, fRes, fMem ); @@ -847,19 +847,19 @@ double ScInterpreter::IterateParameters( ScIterFunc eFunc, bool bTextAsZero ) PopError(); if ( eFunc == ifCOUNT || ( mnSubTotalFlags & SUBTOTAL_IGN_ERR_VAL ) ) { - nGlobalError = 0; + nGlobalError = FormulaError::NONE; } else if ( eFunc == ifCOUNT2 && !( mnSubTotalFlags & SUBTOTAL_IGN_ERR_VAL ) ) { nCount++; - nGlobalError = 0; + nGlobalError = FormulaError::NONE; } } break; default : while (nParamCount-- > 0) PopError(); - SetError(errIllegalParameter); + SetError(FormulaError::IllegalParameter); } } switch( eFunc ) @@ -920,7 +920,7 @@ void ScInterpreter::ScRawSubtract() // Obtain the minuend. double fRes = GetDouble(); - while (!nGlobalError && nParamCount-- > 1) + while (nGlobalError == FormulaError::NONE && nParamCount-- > 1) { // Simple single values without matrix support. fRes -= GetDouble(); diff --git a/sc/source/core/tool/interpr7.cxx b/sc/source/core/tool/interpr7.cxx index 2d48c6b74ad0..69eed575810b 100644 --- a/sc/source/core/tool/interpr7.cxx +++ b/sc/source/core/tool/interpr7.cxx @@ -88,7 +88,7 @@ void ScInterpreter::ScFilterXML() OUString aString = GetString().getString(); if(aString.isEmpty() || aXPathExpression.isEmpty()) { - PushError( formula::errNoValue ); + PushError( FormulaError::NoValue ); return; } @@ -105,7 +105,7 @@ void ScInterpreter::ScFilterXML() if(!pDoc) { - PushError( formula::errNoValue ); + PushError( FormulaError::NoValue ); return; } @@ -117,7 +117,7 @@ void ScInterpreter::ScFilterXML() if(!pXPathObj) { - PushError( formula::errNoValue ); + PushError( FormulaError::NoValue ); return; } @@ -130,7 +130,7 @@ void ScInterpreter::ScFilterXML() xmlNodeSetPtr pNodeSet = pXPathObj->nodesetval; if(!pNodeSet) { - PushError( formula::errNoValue ); + PushError( FormulaError::NoValue ); return; } @@ -138,7 +138,7 @@ void ScInterpreter::ScFilterXML() if (nNode >= nSize) { // For pJumpMatrix - PushError( formula::NOTAVAILABLE); + PushError( FormulaError::NotAvailable); return; } @@ -153,7 +153,7 @@ void ScInterpreter::ScFilterXML() xResMat = GetNewMat( 1, nMatRows, true); if (!xResMat) { - PushError( formula::errCodeOverflow); + PushError( FormulaError::CodeOverflow); return; } } @@ -184,9 +184,9 @@ void ScInterpreter::ScFilterXML() else { if (xResMat) - xResMat->PutError( formula::NOTAVAILABLE, 0, nNode); + xResMat->PutError( FormulaError::NotAvailable, 0, nNode); else - PushError( formula::NOTAVAILABLE ); + PushError( FormulaError::NotAvailable ); } } if (xResMat) @@ -237,14 +237,14 @@ void ScInterpreter::ScWebservice() if(aURI.isEmpty()) { - PushError( formula::errNoValue ); + PushError( FormulaError::NoValue ); return; } uno::Reference< ucb::XSimpleFileAccess3 > xFileAccess( ucb::SimpleFileAccess::create( comphelper::getProcessComponentContext() ), uno::UNO_QUERY ); if(!xFileAccess.is()) { - PushError( formula::errNoValue ); + PushError( FormulaError::NoValue ); return; } @@ -255,12 +255,12 @@ void ScInterpreter::ScWebservice() catch (...) { // don't let any exceptions pass - PushError( formula::errNoValue ); + PushError( FormulaError::NoValue ); return; } if ( !xStream.is() ) { - PushError( formula::errNoValue ); + PushError( FormulaError::NoValue ); return; } @@ -304,7 +304,7 @@ void ScInterpreter::ScEncodeURL() OUString aStr = GetString().getString(); if ( aStr.isEmpty() ) { - PushError( formula::errNoValue ); + PushError( FormulaError::NoValue ); return; } @@ -335,7 +335,7 @@ void ScInterpreter::ScDebugVar() SvtMiscOptions aMiscOptions; if (!aMiscOptions.IsExperimentalMode()) { - PushError(formula::errNoName); + PushError(FormulaError::NoName); return; } diff --git a/sc/source/core/tool/interpr8.cxx b/sc/source/core/tool/interpr8.cxx index d85372117cc5..894c62351375 100644 --- a/sc/source/core/tool/interpr8.cxx +++ b/sc/source/core/tool/interpr8.cxx @@ -89,7 +89,7 @@ private: double mfMSE; // mean squared error (variation) double mfRMSE; // root mean squared error (standard deviation) double mfSMAPE; // symmetric mean absolute error - sal_uInt16 mnErrorValue; + FormulaError mnErrorValue; bool bAdditive; // true: additive method, false: mulitplicative method bool bEDS; // true: EDS, false: ETS @@ -119,7 +119,7 @@ public: bool PreprocessDataRange( const ScMatrixRef& rMatX, const ScMatrixRef& rMatY, int& rSmplInPrd, bool bDataCompletion, int nAggregation, const ScMatrixRef& rTMat, ScETSType eETSType ); - sal_uInt16 GetError() { return mnErrorValue; }; + FormulaError GetError() { return mnErrorValue; }; bool GetForecastRange( const ScMatrixRef& rTMat, const ScMatrixRef& rFcMat ); bool GetStatisticValue( const ScMatrixRef& rTypeMat, const ScMatrixRef& rStatMat ); bool GetSamplesInPeriod( double& rVal ); @@ -146,7 +146,7 @@ ScETSForecastCalculation::ScETSForecastCalculation( SCSIZE nSize, SvNumberFormat , mfMSE(0.0) , mfRMSE(0.0) , mfSMAPE(0.0) - , mnErrorValue(0) + , mnErrorValue(FormulaError::NONE) , bAdditive(false) , bEDS(false) { @@ -180,7 +180,7 @@ bool ScETSForecastCalculation::PreprocessDataRange( const ScMatrixRef& rMatX, co if ( rTMat->GetDouble( 0 ) < maRange[ 0 ].X ) { // target cannot be less than start of X-range - mnErrorValue = errIllegalFPOperation; + mnErrorValue = FormulaError::IllegalFPOperation; return false; } } @@ -189,7 +189,7 @@ bool ScETSForecastCalculation::PreprocessDataRange( const ScMatrixRef& rMatX, co if ( rTMat->GetDouble( 0 ) < maRange[ mnCount - 1 ].X ) { // target cannot be before end of X-range - mnErrorValue = errIllegalFPOperation; + mnErrorValue = FormulaError::IllegalFPOperation; return false; } } @@ -237,7 +237,7 @@ bool ScETSForecastCalculation::PreprocessDataRange( const ScMatrixRef& rMatX, co if ( nAggregation == 0 ) { // identical X-values are not allowed - mnErrorValue = errNoValue; + mnErrorValue = FormulaError::NoValue; return false; } double fTmp = maRange[ i - 1 ].Y; @@ -340,7 +340,7 @@ bool ScETSForecastCalculation::PreprocessDataRange( const ScMatrixRef& rMatX, co if ( fmod( fStep, mfStepSize ) != 0.0 ) { // step not constant nor multiple of mfStepSize in case of gaps - mnErrorValue = errNoValue; + mnErrorValue = FormulaError::NoValue; return false; } bHasGap = true; @@ -379,7 +379,7 @@ bool ScETSForecastCalculation::PreprocessDataRange( const ScMatrixRef& rMatX, co if ( static_cast< double >( nMissingXCount ) / fOriginalCount > 0.3 ) { // maximum of 30% missing points exceeded - mnErrorValue = errNoValue; + mnErrorValue = FormulaError::NoValue; return false; } } @@ -422,7 +422,7 @@ bool ScETSForecastCalculation::prefillTrendData() // we need at least 2 periods in the data range if ( mnCount < 2 * mnSmplInPrd ) { - mnErrorValue = errNoValue; + mnErrorValue = FormulaError::NoValue; return false; } @@ -445,7 +445,7 @@ bool ScETSForecastCalculation::prefillPerIdx() if ( mnSmplInPrd == 0 ) { // should never happen; if mnSmplInPrd equals 0, bEDS is true - mnErrorValue = errUnknownState; + mnErrorValue = FormulaError::UnknownState; return false; } SCSIZE nPeriods = mnCount / mnSmplInPrd; @@ -458,7 +458,7 @@ bool ScETSForecastCalculation::prefillPerIdx() if ( aPeriodAverage[ i ] == 0.0 ) { SAL_WARN( "sc.core", "prefillPerIdx(), average of 0 will cause divide by zero error, quitting calculation" ); - mnErrorValue = errDivisionByZero; + mnErrorValue = FormulaError::DivisionByZero; return false; } } @@ -1243,7 +1243,7 @@ void ScInterpreter::ScForecast_Ets( ScETSType eETSType ) double fVal = GetDoubleWithDefault( 1.0 ); if ( fmod( fVal, 1.0 ) != 0 || fVal < 0.0 ) { - PushError( errIllegalFPOperation ); + PushError( FormulaError::IllegalFPOperation ); return; } nSmplInPrd = static_cast< int >( fVal ); @@ -1399,7 +1399,7 @@ void ScInterpreter::ScConcat_MS() ReverseStack( nParamCount ); size_t nRefInList = 0; - while ( nParamCount-- > 0 && !nGlobalError ) + while ( nParamCount-- > 0 && nGlobalError == FormulaError::NONE ) { switch ( GetStackType() ) { @@ -1411,7 +1411,7 @@ void ScInterpreter::ScConcat_MS() { ScAddress aAdr; PopSingleRef( aAdr ); - if ( nGlobalError ) + if ( nGlobalError != FormulaError::NONE ) break; ScRefCellValue aCell( *pDok, aAdr ); if ( !aCell.isEmpty() ) @@ -1430,7 +1430,7 @@ void ScInterpreter::ScConcat_MS() { ScRange aRange; PopDoubleRef( aRange, nParamCount, nRefInList); - if ( nGlobalError ) + if ( nGlobalError != FormulaError::NONE ) break; // we need to read row for row, so we can't use ScCellIter SCCOL nCol1, nCol2; @@ -1439,7 +1439,7 @@ void ScInterpreter::ScConcat_MS() aRange.GetVars( nCol1, nRow1, nTab1, nCol2, nRow2, nTab2 ); if ( nTab1 != nTab2 ) { - SetError( errIllegalParameter); + SetError( FormulaError::IllegalParameter); break; } if ( nRow1 > nRow2 ) @@ -1478,7 +1478,7 @@ void ScInterpreter::ScConcat_MS() SCSIZE nC, nR; pMat->GetDimensions(nC, nR); if (nC == 0 || nR == 0) - SetError(errIllegalArgument); + SetError(FormulaError::IllegalArgument); else { for ( SCSIZE j = 0; j < nC; j++ ) @@ -1500,7 +1500,7 @@ void ScInterpreter::ScConcat_MS() break; default: PopError(); - SetError( errIllegalArgument); + SetError( FormulaError::IllegalArgument); break; } } @@ -1529,7 +1529,7 @@ void ScInterpreter::ScTextJoin_MS() { ScAddress aAdr; PopSingleRef( aAdr ); - if ( nGlobalError ) + if ( nGlobalError != FormulaError::NONE ) break; ScRefCellValue aCell( *pDok, aAdr ); if ( !aCell.isEmpty() ) @@ -1548,7 +1548,7 @@ void ScInterpreter::ScTextJoin_MS() { ScRange aRange; PopDoubleRef( aRange, nParamCount, nRefInList); - if ( nGlobalError ) + if ( nGlobalError != FormulaError::NONE ) break; // we need to read row for row, so we can't use ScCellIterator SCCOL nCol1, nCol2; @@ -1557,7 +1557,7 @@ void ScInterpreter::ScTextJoin_MS() aRange.GetVars( nCol1, nRow1, nTab1, nCol2, nRow2, nTab2 ); if ( nTab1 != nTab2 ) { - SetError( errIllegalParameter); + SetError( FormulaError::IllegalParameter); break; } if ( nRow1 > nRow2 ) @@ -1598,7 +1598,7 @@ void ScInterpreter::ScTextJoin_MS() SCSIZE nC, nR; pMat->GetDimensions(nC, nR); if (nC == 0 || nR == 0) - SetError(errIllegalArgument); + SetError(FormulaError::IllegalArgument); else { for ( SCSIZE j = 0; j < nC; j++ ) @@ -1625,7 +1625,7 @@ void ScInterpreter::ScTextJoin_MS() break; default: PopError(); - SetError( errIllegalArgument); + SetError( FormulaError::IllegalArgument); break; } if ( aDelimiters.empty() ) @@ -1642,7 +1642,7 @@ void ScInterpreter::ScTextJoin_MS() SCSIZE nIdx = 0; nRefInList = 0; // get the strings to be joined - while ( nParamCount-- > 0 && !nGlobalError ) + while ( nParamCount-- > 0 && nGlobalError == FormulaError::NONE ) { switch ( GetStackType() ) { @@ -1671,7 +1671,7 @@ void ScInterpreter::ScTextJoin_MS() { ScAddress aAdr; PopSingleRef( aAdr ); - if ( nGlobalError ) + if ( nGlobalError != FormulaError::NONE ) break; ScRefCellValue aCell( *pDok, aAdr ); OUString aStr; @@ -1708,7 +1708,7 @@ void ScInterpreter::ScTextJoin_MS() { ScRange aRange; PopDoubleRef( aRange, nParamCount, nRefInList); - if ( nGlobalError ) + if ( nGlobalError != FormulaError::NONE ) break; // we need to read row for row, so we can't use ScCellIterator SCCOL nCol1, nCol2; @@ -1717,7 +1717,7 @@ void ScInterpreter::ScTextJoin_MS() aRange.GetVars( nCol1, nRow1, nTab1, nCol2, nRow2, nTab2 ); if ( nTab1 != nTab2 ) { - SetError( errIllegalParameter); + SetError( FormulaError::IllegalParameter); break; } if ( nRow1 > nRow2 ) @@ -1774,7 +1774,7 @@ void ScInterpreter::ScTextJoin_MS() SCSIZE nC, nR; pMat->GetDimensions(nC, nR); if (nC == 0 || nR == 0) - SetError(errIllegalArgument); + SetError(FormulaError::IllegalArgument); else { OUString aStr; @@ -1835,7 +1835,7 @@ void ScInterpreter::ScTextJoin_MS() break; default: PopError(); - SetError( errIllegalArgument); + SetError( FormulaError::IllegalArgument); break; } } @@ -1850,9 +1850,9 @@ void ScInterpreter::ScIfs_MS() ReverseStack( nParamCount ); - nGlobalError = 0; // propagate only for condition or active result path + nGlobalError = FormulaError::NONE; // propagate only for condition or active result path bool bFinished = false; - while ( nParamCount > 0 && !bFinished && !nGlobalError ) + while ( nParamCount > 0 && !bFinished && nGlobalError == FormulaError::NONE ) { bool bVal = GetBool(); nParamCount--; @@ -1885,11 +1885,11 @@ void ScInterpreter::ScIfs_MS() } } - if ( nGlobalError || !bFinished ) + if ( nGlobalError != FormulaError::NONE || !bFinished ) { if ( !bFinished ) PushNA(); // no true expression found - if ( nGlobalError ) + if ( nGlobalError != FormulaError::NONE ) PushNoValue(); // expression returned something other than true or false return; } @@ -1907,7 +1907,7 @@ void ScInterpreter::ScIfs_MS() PushTokenRef( xToken ); } else - PushError( errUnknownStackVariable ); + PushError( FormulaError::UnknownStackVariable ); } @@ -1920,7 +1920,7 @@ void ScInterpreter::ScSwitch_MS() ReverseStack( nParamCount ); - nGlobalError = 0; // propagate only for match or active result path + nGlobalError = FormulaError::NONE; // propagate only for match or active result path bool isValue = false; double fRefVal = 0; svl::SharedString aRefStr; @@ -1960,7 +1960,7 @@ void ScInterpreter::ScSwitch_MS() } nParamCount--; bool bFinished = false; - while ( nParamCount > 1 && !bFinished && !nGlobalError ) + while ( nParamCount > 1 && !bFinished && nGlobalError == FormulaError::NONE ) { double fVal = 0; svl::SharedString aStr; @@ -1969,7 +1969,7 @@ void ScInterpreter::ScSwitch_MS() else aStr = GetString(); nParamCount--; - if ( nGlobalError || (( isValue && rtl::math::approxEqual( fRefVal, fVal ) ) || + if ( nGlobalError != FormulaError::NONE || (( isValue && rtl::math::approxEqual( fRefVal, fVal ) ) || ( !isValue && aRefStr.getDataIgnoreCase() == aStr.getDataIgnoreCase() )) ) { // TRUE @@ -1992,11 +1992,11 @@ void ScInterpreter::ScSwitch_MS() PushNA(); return; } - nGlobalError = 0; + nGlobalError = FormulaError::NONE; } } - if ( nGlobalError || !bFinished ) + if ( nGlobalError != FormulaError::NONE || !bFinished ) { if ( !bFinished ) PushNA(); // no true expression found @@ -2018,7 +2018,7 @@ void ScInterpreter::ScSwitch_MS() PushTokenRef( xToken ); } else - PushError( errUnknownStackVariable ); + PushError( FormulaError::UnknownStackVariable ); } /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sc/source/core/tool/jumpmatrix.cxx b/sc/source/core/tool/jumpmatrix.cxx index b31d2f64e4cb..0961e78ff49d 100644 --- a/sc/source/core/tool/jumpmatrix.cxx +++ b/sc/source/core/tool/jumpmatrix.cxx @@ -46,7 +46,7 @@ ScJumpMatrix::ScJumpMatrix(SCSIZE nColsP, SCSIZE nRowsP) // Initialize result matrix in case of // a premature end of the interpreter // due to errors. - pMat->FillDouble(formula::CreateDoubleError(formula::NOTAVAILABLE), 0, 0, nCols - 1, nRows - 1); + pMat->FillDouble(CreateDoubleError(FormulaError::NotAvailable), 0, 0, nCols - 1, nRows - 1); /*! pJump not initialized */ } @@ -152,13 +152,13 @@ void ScJumpMatrix::SetNewResMat(SCSIZE nNewCols, SCSIZE nNewRows) if (nResMatCols < nNewCols) { pMat->FillDouble( - formula::CreateDoubleError(formula::NOTAVAILABLE), + CreateDoubleError(FormulaError::NotAvailable), nResMatCols, 0, nNewCols - 1, nResMatRows - 1); } if (nResMatRows < nNewRows) { pMat->FillDouble( - formula::CreateDoubleError(formula::NOTAVAILABLE), + CreateDoubleError(FormulaError::NotAvailable), 0, nResMatRows, nNewCols - 1, nNewRows - 1); } if (nRows == 1 && nCurCol != 0) diff --git a/sc/source/core/tool/rangenam.cxx b/sc/source/core/tool/rangenam.cxx index 19d403d64632..eae117c08434 100644 --- a/sc/source/core/tool/rangenam.cxx +++ b/sc/source/core/tool/rangenam.cxx @@ -122,7 +122,7 @@ ScRangeData::ScRangeData( ScDocument* pDok, ScCompiler aComp( pDoc, aPos, *pCode ); aComp.SetGrammar(pDoc->GetGrammar()); aComp.CompileTokenArray(); - if ( !pCode->GetCodeError() ) + if ( pCode->GetCodeError() == FormulaError::NONE ) eType |= Type::AbsPos; } @@ -165,7 +165,7 @@ void ScRangeData::CompileRangeData( const OUString& rSymbol, bool bSetError ) std::unique_ptr<ScTokenArray> pOldCode( pCode); // old pCode will be deleted pCode = pNewCode; pCode->SetFromRangeName(true); - if( !pCode->GetCodeError() ) + if( pCode->GetCodeError() == FormulaError::NONE ) { pCode->Reset(); FormulaToken* p = pCode->GetNextReference(); @@ -189,7 +189,7 @@ void ScRangeData::CompileRangeData( const OUString& rSymbol, bool bSetError ) void ScRangeData::CompileUnresolvedXML( sc::CompileFormulaContext& rCxt ) { - if (pCode->GetCodeError() == errNoName) + if (pCode->GetCodeError() == FormulaError::NoName) { // Reconstruct the symbol/formula and then recompile. OUString aSymbol; @@ -518,9 +518,9 @@ SCCOL ScRangeData::GetMaxCol() const return mnMaxCol >= 0 ? mnMaxCol : MAXCOL; } -sal_uInt16 ScRangeData::GetErrCode() const +FormulaError ScRangeData::GetErrCode() const { - return pCode ? pCode->GetCodeError() : 0; + return pCode ? pCode->GetCodeError() : FormulaError::NONE; } bool ScRangeData::HasReferences() const @@ -634,7 +634,7 @@ void ScRangeData::SetCode( ScTokenArray& rArr ) void ScRangeData::InitCode() { - if( !pCode->GetCodeError() ) + if( pCode->GetCodeError() == FormulaError::NONE ) { pCode->Reset(); FormulaToken* p = pCode->GetNextReference(); diff --git a/sc/source/core/tool/rangeseq.cxx b/sc/source/core/tool/rangeseq.cxx index 20b94191f1d2..b1c39ff56a31 100644 --- a/sc/source/core/tool/rangeseq.cxx +++ b/sc/source/core/tool/rangeseq.cxx @@ -42,7 +42,7 @@ static bool lcl_HasErrors( ScDocument* pDoc, const ScRange& rRange ) continue; ScFormulaCell* pCell = aIter.getFormulaCell(); - if (pCell->GetErrCode() != 0) + if (pCell->GetErrCode() != FormulaError::NONE) return true; } return false; // no error found @@ -182,10 +182,10 @@ bool ScRangeToSequence::FillStringArray( uno::Any& rAny, ScDocument* pDoc, const OUString* pColAry = aColSeq.getArray(); for (long nCol = 0; nCol < nColCount; nCol++) { - sal_uInt16 nErrCode = pDoc->GetStringForFormula( + FormulaError nErrCode = pDoc->GetStringForFormula( ScAddress((SCCOL)(nStartCol+nCol), (SCROW)(nStartRow+nRow), nTab), pColAry[nCol] ); - if ( nErrCode != 0 ) + if ( nErrCode != FormulaError::NONE ) bHasErrors = true; } pRowAry[nRow] = aColSeq; @@ -265,7 +265,7 @@ bool ScRangeToSequence::FillMixedArray( uno::Any& rAny, ScDocument* pDoc, const continue; } - if (aCell.meType == CELLTYPE_FORMULA && aCell.mpFormula->GetErrCode() != 0) + if (aCell.meType == CELLTYPE_FORMULA && aCell.mpFormula->GetErrCode() != FormulaError::NONE) { // if NV is allowed, leave empty for errors bHasErrors = true; diff --git a/sc/source/core/tool/scmatrix.cxx b/sc/source/core/tool/scmatrix.cxx index 3b035c2c868b..e9dc4f8eb97e 100644 --- a/sc/source/core/tool/scmatrix.cxx +++ b/sc/source/core/tool/scmatrix.cxx @@ -73,17 +73,17 @@ double convertStringToValue( ScInterpreter* pErrorInterpreter, const OUString& r { if (pErrorInterpreter) { - sal_uInt16 nError = 0; + FormulaError nError = FormulaError::NONE; short nCurFmtType = 0; double fValue = pErrorInterpreter->ConvertStringToValue( rStr, nError, nCurFmtType); - if (nError) + if (nError != FormulaError::NONE) { pErrorInterpreter->SetError( nError); - return formula::CreateDoubleError( nError); + return CreateDoubleError( nError); } return fValue; } - return formula::CreateDoubleError( formula::errNoValue); + return CreateDoubleError( FormulaError::NoValue); } struct ElemEqualZero : public unary_function<double, double> @@ -244,7 +244,7 @@ public: bool ValidColRow( SCSIZE nC, SCSIZE nR) const; bool ValidColRowReplicated( SCSIZE & rC, SCSIZE & rR ) const; bool ValidColRowOrReplicated( SCSIZE & rC, SCSIZE & rR ) const; - void SetErrorAtInterpreter( sal_uInt16 nError ) const; + void SetErrorAtInterpreter( FormulaError nError ) const; void PutDouble(double fVal, SCSIZE nC, SCSIZE nR); void PutDouble( double fVal, SCSIZE nIndex); @@ -256,9 +256,9 @@ public: void PutEmpty(SCSIZE nC, SCSIZE nR); void PutEmptyPath(SCSIZE nC, SCSIZE nR); - void PutError( sal_uInt16 nErrorCode, SCSIZE nC, SCSIZE nR ); + void PutError( FormulaError nErrorCode, SCSIZE nC, SCSIZE nR ); void PutBoolean(bool bVal, SCSIZE nC, SCSIZE nR); - sal_uInt16 GetError( SCSIZE nC, SCSIZE nR) const; + FormulaError GetError( SCSIZE nC, SCSIZE nR) const; double GetDouble(SCSIZE nC, SCSIZE nR) const; double GetDouble( SCSIZE nIndex) const; double GetDoubleWithStringConversion(SCSIZE nC, SCSIZE nR) const; @@ -364,7 +364,7 @@ void ScMatrixImpl::Resize(SCSIZE nC, SCSIZE nR) else { // Invalid matrix size, allocate 1x1 matrix with error value. - maMat.resize(1, 1, formula::CreateDoubleError( formula::errMatrixSize)); + maMat.resize(1, 1, CreateDoubleError( FormulaError::MatrixSize)); maMatFlag.resize(1, 1); } } @@ -379,7 +379,7 @@ void ScMatrixImpl::Resize(SCSIZE nC, SCSIZE nR, double fVal) else { // Invalid matrix size, allocate 1x1 matrix with error value. - maMat.resize(1, 1, formula::CreateDoubleError( formula::errStackOverflow)); + maMat.resize(1, 1, CreateDoubleError( FormulaError::StackOverflow)); maMatFlag.resize(1, 1); } } @@ -437,7 +437,7 @@ bool ScMatrixImpl::ValidColRowOrReplicated( SCSIZE & rC, SCSIZE & rR ) const return ValidColRow( rC, rR) || ValidColRowReplicated( rC, rR); } -void ScMatrixImpl::SetErrorAtInterpreter( sal_uInt16 nError ) const +void ScMatrixImpl::SetErrorAtInterpreter( FormulaError nError ) const { if ( pErrorInterpreter ) pErrorInterpreter->SetError( nError); @@ -523,9 +523,9 @@ void ScMatrixImpl::PutEmptyPath(SCSIZE nC, SCSIZE nR) } } -void ScMatrixImpl::PutError( sal_uInt16 nErrorCode, SCSIZE nC, SCSIZE nR ) +void ScMatrixImpl::PutError( FormulaError nErrorCode, SCSIZE nC, SCSIZE nR ) { - maMat.set(nR, nC, formula::CreateDoubleError(nErrorCode)); + maMat.set(nR, nC, CreateDoubleError(nErrorCode)); } void ScMatrixImpl::PutBoolean(bool bVal, SCSIZE nC, SCSIZE nR) @@ -538,17 +538,17 @@ void ScMatrixImpl::PutBoolean(bool bVal, SCSIZE nC, SCSIZE nR) } } -sal_uInt16 ScMatrixImpl::GetError( SCSIZE nC, SCSIZE nR) const +FormulaError ScMatrixImpl::GetError( SCSIZE nC, SCSIZE nR) const { if (ValidColRowOrReplicated( nC, nR )) { double fVal = maMat.get_numeric(nR, nC); - return formula::GetDoubleErrorValue(fVal); + return GetDoubleErrorValue(fVal); } else { OSL_FAIL("ScMatrixImpl::GetError: dimension error"); - return formula::errNoValue; + return FormulaError::NoValue; } } @@ -559,8 +559,8 @@ double ScMatrixImpl::GetDouble(SCSIZE nC, SCSIZE nR) const double fVal = maMat.get_numeric(nR, nC); if ( pErrorInterpreter ) { - sal_uInt16 nError = formula::GetDoubleErrorValue(fVal); - if ( nError ) + FormulaError nError = GetDoubleErrorValue(fVal); + if ( nError != FormulaError::NONE ) SetErrorAtInterpreter( nError); } return fVal; @@ -568,7 +568,7 @@ double ScMatrixImpl::GetDouble(SCSIZE nC, SCSIZE nR) const else { OSL_FAIL("ScMatrixImpl::GetDouble: dimension error"); - return formula::CreateDoubleError( formula::errNoValue); + return CreateDoubleError( FormulaError::NoValue); } } @@ -606,7 +606,7 @@ svl::SharedString ScMatrixImpl::GetString(SCSIZE nC, SCSIZE nR) const default: OSL_FAIL("ScMatrixImpl::GetString: access error, no string"); } - SetErrorAtInterpreter(formula::GetDoubleErrorValue(fErr)); + SetErrorAtInterpreter(GetDoubleErrorValue(fErr)); } else { @@ -658,8 +658,8 @@ svl::SharedString ScMatrixImpl::GetString( SvNumberFormatter& rFormatter, SCSIZE ; } - sal_uInt16 nError = formula::GetDoubleErrorValue(fVal); - if (nError) + FormulaError nError = GetDoubleErrorValue(fVal); + if (nError != FormulaError::NONE) { SetErrorAtInterpreter( nError); return svl::SharedString( ScGlobal::GetErrorString( nError)); // string not interned @@ -1018,7 +1018,7 @@ double EvalMatrix(const MatrixImplType& rMat) mdds::mtm::element_t eType = rMat.get_type(aPos); if (eType != mdds::mtm::element_numeric && eType != mdds::mtm::element_boolean) // assuming a CompareMat this is an error - return formula::CreateDoubleError(formula::errIllegalArgument); + return CreateDoubleError(FormulaError::IllegalArgument); double fVal = rMat.get_numeric(aPos); if (!::rtl::math::isFinite(fVal)) @@ -1497,7 +1497,7 @@ inline double evaluate( double fVal, ScQueryOp eOp ) } OSL_TRACE( "evaluate: unhandled comparison operator: %d", (int)eOp); - return formula::CreateDoubleError( formula::errUnknownState); + return CreateDoubleError( FormulaError::UnknownState); } class CompareMatrixFunc : public std::unary_function<MatrixImplType::element_block_type, void> @@ -1695,7 +1695,7 @@ public: ToDoubleArray( size_t nSize, bool bEmptyAsZero ) : maArray(nSize, 0.0), miPos(maArray.begin()), mbEmptyAsZero(bEmptyAsZero) { - mfNaN = formula::CreateDoubleError( formula::errElementNaN); + mfNaN = CreateDoubleError( FormulaError::ElementNaN); } void operator() (const MatrixImplType::element_block_node_type& node) @@ -1766,7 +1766,7 @@ class MergeDoubleArrayFunc : public std::unary_function<MatrixImplType::element_ public: MergeDoubleArrayFunc(std::vector<double>& rArray) : mrArray(rArray), miPos(mrArray.begin()) { - mfNaN = formula::CreateDoubleError( formula::errElementNaN); + mfNaN = CreateDoubleError( FormulaError::ElementNaN); } void operator() (const MatrixImplType::element_block_node_type& node) @@ -1782,7 +1782,7 @@ public: numeric_element_block::const_iterator itEnd = numeric_element_block::end(*node.data); for (; it != itEnd; ++it, ++miPos) { - if (formula::GetDoubleErrorValue(*miPos) == formula::errElementNaN) + if (GetDoubleErrorValue(*miPos) == FormulaError::ElementNaN) continue; *miPos = op(*miPos, *it); @@ -1795,7 +1795,7 @@ public: boolean_element_block::const_iterator itEnd = boolean_element_block::end(*node.data); for (; it != itEnd; ++it, ++miPos) { - if (formula::GetDoubleErrorValue(*miPos) == formula::errElementNaN) + if (GetDoubleErrorValue(*miPos) == FormulaError::ElementNaN) continue; *miPos = op(*miPos, *it ? 1.0 : 0.0); @@ -1813,7 +1813,7 @@ public: // Empty element is equivalent of having a numeric value of 0.0. for (size_t i = 0; i < node.size; ++i, ++miPos) { - if (formula::GetDoubleErrorValue(*miPos) == formula::errElementNaN) + if (GetDoubleErrorValue(*miPos) == FormulaError::ElementNaN) continue; *miPos = op(*miPos, 0.0); @@ -2452,15 +2452,15 @@ void ScMatrixImpl::MatConcat(SCSIZE nMaxCol, SCSIZE nMaxRow, const ScMatrixRef& std::vector<OUString> aString(nMaxCol * nMaxRow); std::vector<bool> aValid(nMaxCol * nMaxRow, true); - std::vector<sal_uInt16> nErrors(nMaxCol * nMaxRow, 0); + std::vector<FormulaError> nErrors(nMaxCol * nMaxRow,FormulaError::NONE); size_t nRowOffset = 0; size_t nColOffset = 0; std::function<void(size_t, size_t, double)> aDoubleFunc = [&](size_t nRow, size_t nCol, double nVal) { - sal_uInt16 nErr = formula::GetDoubleErrorValue(nVal); - if (nErr) + FormulaError nErr = GetDoubleErrorValue(nVal); + if (nErr != FormulaError::NONE) { aValid[get_index(nMaxRow, nMaxCol, nRow, nCol, nRowOffset, nColOffset)] = false; nErrors[get_index(nMaxRow, nMaxCol, nRow, nCol, nRowOffset, nColOffset)] = nErr; @@ -2521,8 +2521,8 @@ void ScMatrixImpl::MatConcat(SCSIZE nMaxCol, SCSIZE nMaxRow, const ScMatrixRef& std::function<void(size_t, size_t, double)> aDoubleFunc2 = [&](size_t nRow, size_t nCol, double nVal) { - sal_uInt16 nErr = formula::GetDoubleErrorValue(nVal); - if (nErr) + FormulaError nErr = GetDoubleErrorValue(nVal); + if (nErr != FormulaError::NONE) { aValid[get_index(nMaxRow, nMaxCol, nRow, nCol, nRowOffset, nColOffset)] = false; nErrors[get_index(nMaxRow, nMaxCol, nRow, nCol, nRowOffset, nColOffset)] = nErr; @@ -2610,7 +2610,7 @@ void ScMatrixImpl::MatConcat(SCSIZE nMaxCol, SCSIZE nMaxRow, const ScMatrixRef& } else { - pos = maMat.set(pos, formula::CreateDoubleError(nErrors[nMaxRow * i + j])); + pos = maMat.set(pos, CreateDoubleError(nErrors[nMaxRow * i + j])); } pos = MatrixImplType::next_position(pos); } @@ -2654,7 +2654,7 @@ ScFullMatrix::ScFullMatrix( SCSIZE nC, SCSIZE nR) : pImpl.reset( new ScMatrixImpl( nC, nR)); else // Invalid matrix size, allocate 1x1 matrix with error value. - pImpl.reset( new ScMatrixImpl( 1,1, formula::CreateDoubleError( formula::errMatrixSize))); + pImpl.reset( new ScMatrixImpl( 1,1, CreateDoubleError( FormulaError::MatrixSize))); } ScFullMatrix::ScFullMatrix(SCSIZE nC, SCSIZE nR, double fInitVal) : @@ -2664,7 +2664,7 @@ ScFullMatrix::ScFullMatrix(SCSIZE nC, SCSIZE nR, double fInitVal) : pImpl.reset( new ScMatrixImpl( nC, nR, fInitVal)); else // Invalid matrix size, allocate 1x1 matrix with error value. - pImpl.reset( new ScMatrixImpl( 1,1, formula::CreateDoubleError( formula::errMatrixSize))); + pImpl.reset( new ScMatrixImpl( 1,1, CreateDoubleError( FormulaError::MatrixSize))); } ScFullMatrix::ScFullMatrix( size_t nC, size_t nR, const std::vector<double>& rInitVals ) : @@ -2674,7 +2674,7 @@ ScFullMatrix::ScFullMatrix( size_t nC, size_t nR, const std::vector<double>& rIn pImpl.reset( new ScMatrixImpl( nC, nR, rInitVals)); else // Invalid matrix size, allocate 1x1 matrix with error value. - pImpl.reset( new ScMatrixImpl( 1,1, formula::CreateDoubleError( formula::errMatrixSize))); + pImpl.reset( new ScMatrixImpl( 1,1, CreateDoubleError( FormulaError::MatrixSize))); } ScFullMatrix::~ScFullMatrix() @@ -2794,7 +2794,7 @@ void ScFullMatrix::PutEmptyPath(SCSIZE nC, SCSIZE nR) pImpl->PutEmptyPath(nC, nR); } -void ScFullMatrix::PutError( sal_uInt16 nErrorCode, SCSIZE nC, SCSIZE nR ) +void ScFullMatrix::PutError( FormulaError nErrorCode, SCSIZE nC, SCSIZE nR ) { pImpl->PutError(nErrorCode, nC, nR); } @@ -2804,7 +2804,7 @@ void ScFullMatrix::PutBoolean(bool bVal, SCSIZE nC, SCSIZE nR) pImpl->PutBoolean(bVal, nC, nR); } -sal_uInt16 ScFullMatrix::GetError( SCSIZE nC, SCSIZE nR) const +FormulaError ScFullMatrix::GetError( SCSIZE nC, SCSIZE nR) const { return pImpl->GetError(nC, nR); } @@ -3075,8 +3075,8 @@ struct COp<T, double> /** A template for operations where operands are supposed to be numeric. A non-numeric (string) operand leads to the configured conversion to number - method being called if in interpreter context and an errNoValue DoubleError - if conversion was not possible, else to an unconditional errNoValue + method being called if in interpreter context and an FormulaError::NoValue DoubleError + if conversion was not possible, else to an unconditional FormulaError::NoValue DoubleError. An empty operand evaluates to 0. XXX: semantically TEmptyRes and types other than number_value_type are @@ -3106,9 +3106,9 @@ public: { if (mpErrorInterpreter) { - sal_uInt16 nErr = mpErrorInterpreter->GetError(); - if (nErr) - mfVal = formula::CreateDoubleError( nErr); + FormulaError nErr = mpErrorInterpreter->GetError(); + if (nErr != FormulaError::NONE) + mfVal = CreateDoubleError( nErr); } } @@ -3618,7 +3618,7 @@ void ScVectorRefMatrix::PutEmptyPath(SCSIZE nC, SCSIZE nR) mpFullMatrix->PutEmptyPath(nC, nR); } -void ScVectorRefMatrix::PutError(sal_uInt16 nErrorCode, SCSIZE nC, SCSIZE nR) +void ScVectorRefMatrix::PutError(FormulaError nErrorCode, SCSIZE nC, SCSIZE nR) { ensureFullMatrix(); mpFullMatrix->PutError(nErrorCode, nC, nR); @@ -3666,7 +3666,7 @@ void ScVectorRefMatrix::PutEmptyPathVector(SCSIZE nCount, SCSIZE nC, SCSIZE nR) mpFullMatrix->PutEmptyPathVector(nCount, nC, nR); } -sal_uInt16 ScVectorRefMatrix::GetError(SCSIZE nC, SCSIZE nR) const +FormulaError ScVectorRefMatrix::GetError(SCSIZE nC, SCSIZE nR) const { const_cast<ScVectorRefMatrix*>(this)->ensureFullMatrix(); return mpFullMatrix->GetError(nC, nR); diff --git a/sc/source/core/tool/token.cxx b/sc/source/core/tool/token.cxx index ba91d2a0ad97..156b099f4500 100644 --- a/sc/source/core/tool/token.cxx +++ b/sc/source/core/tool/token.cxx @@ -294,7 +294,7 @@ void ScRawToken::SetDouble(double rVal) nValue = rVal; } -void ScRawToken::SetErrorConstant( sal_uInt16 nErr ) +void ScRawToken::SetErrorConstant( FormulaError nErr ) { eOp = ocPush; eType = svError; @@ -4736,8 +4736,8 @@ void appendTokenByType( sc::TokenStringContext& rCxt, OUStringBuffer& rBuf, cons } else { - sal_uInt16 nErr = pMat->GetError(nC, nR); - if (nErr) + FormulaError nErr = pMat->GetError(nC, nR); + if (nErr != FormulaError::NONE) rBuf.append(ScGlobal::GetErrorString(nErr)); else appendDouble(rCxt, rBuf, pMat->GetDouble(nC, nR)); @@ -4851,30 +4851,30 @@ void appendTokenByType( sc::TokenStringContext& rCxt, OUStringBuffer& rBuf, cons break; case svError: { - sal_uInt16 nErr = rToken.GetError(); + FormulaError nErr = rToken.GetError(); OpCode eOpErr; switch (nErr) { break; - case errDivisionByZero: + case FormulaError::DivisionByZero: eOpErr = ocErrDivZero; break; - case errNoValue: + case FormulaError::NoValue: eOpErr = ocErrValue; break; - case errNoRef: + case FormulaError::NoRef: eOpErr = ocErrRef; break; - case errNoName: + case FormulaError::NoName: eOpErr = ocErrName; break; - case errIllegalFPOperation: + case FormulaError::IllegalFPOperation: eOpErr = ocErrNum; break; - case NOTAVAILABLE: + case FormulaError::NotAvailable: eOpErr = ocErrNA; break; - case errNoCode: + case FormulaError::NoCode: default: eOpErr = ocErrNull; } diff --git a/sc/source/filter/dif/difexp.cxx b/sc/source/filter/dif/difexp.cxx index a68c0d236f39..cbdd8a8a4659 100644 --- a/sc/source/filter/dif/difexp.cxx +++ b/sc/source/filter/dif/difexp.cxx @@ -31,6 +31,7 @@ #include "cellvalue.hxx" #include <rtl/strbuf.hxx> #include <osl/diagnose.h> +#include <formula/errorcodes.hxx> void ScFormatFilterPluginImpl::ScExportDif( SvStream& rStream, ScDocument* pDoc, const ScAddress& rOutPos, const rtl_TextEncoding eNach ) @@ -168,7 +169,7 @@ void ScFormatFilterPluginImpl::ScExportDif( SvStream& rOut, ScDocument* pDoc, bWriteStringData = true; break; case CELLTYPE_FORMULA: - if (aCell.mpFormula->GetErrCode()) + if (aCell.mpFormula->GetErrCode() != FormulaError::NONE) aOS.appendAscii(pNumDataERROR); else if (aCell.mpFormula->IsValue()) { diff --git a/sc/source/filter/excel/excform.cxx b/sc/source/filter/excel/excform.cxx index 0b03feb10721..d911f185d2d4 100644 --- a/sc/source/filter/excel/excform.cxx +++ b/sc/source/filter/excel/excform.cxx @@ -1676,7 +1676,7 @@ void ExcelToSc::ExcRelToScRel( sal_uInt16 nRow, sal_uInt8 nCol, ScSingleRefData const ScTokenArray* ExcelToSc::GetBoolErr( XclBoolError eType ) { - sal_uInt16 nError; + FormulaError nError; aPool.Reset(); aStack.Reset(); @@ -1684,20 +1684,20 @@ const ScTokenArray* ExcelToSc::GetBoolErr( XclBoolError eType ) switch( eType ) { - case xlErrNull: eOc = ocStop; nError = formula::errNoCode; break; - case xlErrDiv0: eOc = ocStop; nError = formula::errDivisionByZero; break; - case xlErrValue: eOc = ocStop; nError = formula::errNoValue; break; - case xlErrRef: eOc = ocStop; nError = formula::errNoRef; break; - case xlErrName: eOc = ocStop; nError = formula::errNoName; break; - case xlErrNum: eOc = ocStop; nError = formula::errIllegalFPOperation; break; - case xlErrNA: eOc = ocNotAvail; nError = formula::NOTAVAILABLE; break; - case xlErrTrue: eOc = ocTrue; nError = 0; break; - case xlErrFalse: eOc = ocFalse; nError = 0; break; - case xlErrUnknown: eOc = ocStop; nError = formula::errUnknownState; break; + case xlErrNull: eOc = ocStop; nError = FormulaError::NoCode; break; + case xlErrDiv0: eOc = ocStop; nError = FormulaError::DivisionByZero; break; + case xlErrValue: eOc = ocStop; nError = FormulaError::NoValue; break; + case xlErrRef: eOc = ocStop; nError = FormulaError::NoRef; break; + case xlErrName: eOc = ocStop; nError = FormulaError::NoName; break; + case xlErrNum: eOc = ocStop; nError = FormulaError::IllegalFPOperation; break; + case xlErrNA: eOc = ocNotAvail; nError = FormulaError::NotAvailable; break; + case xlErrTrue: eOc = ocTrue; nError = FormulaError::NONE; break; + case xlErrFalse: eOc = ocFalse; nError = FormulaError::NONE; break; + case xlErrUnknown: eOc = ocStop; nError = FormulaError::UnknownState; break; default: OSL_FAIL( "ExcelToSc::GetBoolErr - wrong enum!" ); eOc = ocNoName; - nError = formula::errUnknownState; + nError = FormulaError::UnknownState; } aPool << eOc; @@ -1707,7 +1707,7 @@ const ScTokenArray* ExcelToSc::GetBoolErr( XclBoolError eType ) aPool >> aStack; const ScTokenArray* pErgebnis = aPool[ aStack.Get() ]; - if( nError ) + if( nError != FormulaError::NONE ) const_cast<ScTokenArray*>(pErgebnis)->SetCodeError( nError ); const_cast<ScTokenArray*>(pErgebnis)->SetExclusiveRecalcModeNormal(); @@ -1744,15 +1744,15 @@ const ScTokenArray* ExcelToSc::GetSharedFormula( const ScAddress& rRefPos ) cons void ExcelToSc::SetError( ScFormulaCell &rCell, const ConvErr eErr ) { - sal_uInt16 nInd; + FormulaError nInd; switch( eErr ) { - case ConvErrNi: nInd = formula::errUnknownToken; break; - case ConvErrNoMem: nInd = formula::errCodeOverflow; break; - case ConvErrExternal: nInd = formula::errNoName; break; - case ConvErrCount: nInd = formula::errCodeOverflow; break; - default: nInd = formula::errNoCode; // I had no better idea + case ConvErrNi: nInd = FormulaError::UnknownToken; break; + case ConvErrNoMem: nInd = FormulaError::CodeOverflow; break; + case ConvErrExternal: nInd = FormulaError::NoName; break; + case ConvErrCount: nInd = FormulaError::CodeOverflow; break; + default: nInd = FormulaError::NoCode; // I had no better idea } rCell.SetErrCode( nInd ); diff --git a/sc/source/filter/excel/xeformula.cxx b/sc/source/filter/excel/xeformula.cxx index 3be306e5b82e..b810279e19ca 100644 --- a/sc/source/filter/excel/xeformula.cxx +++ b/sc/source/filter/excel/xeformula.cxx @@ -492,8 +492,8 @@ XclTokenArrayRef XclExpFmlaCompImpl::CreateFormula( XclFormulaType eType, if( mxData->mbOk ) { XclExpScToken aTokData( GetNextToken() ); - sal_uInt16 nScError = rScTokArr.GetCodeError(); - if( (nScError != 0) && (!aTokData.Is() || (aTokData.GetOpCode() == ocStop)) ) + FormulaError nScError = rScTokArr.GetCodeError(); + if( (nScError != FormulaError::NONE) && (!aTokData.Is() || (aTokData.GetOpCode() == ocStop)) ) { // #i50253# convert simple ocStop token to error code formula (e.g. =#VALUE!) AppendErrorToken( XclTools::GetXclErrorCode( nScError ), aTokData.mnSpaces ); @@ -1286,13 +1286,14 @@ void XclExpFmlaCompImpl::ProcessMatrix( const XclExpScToken& rTokData ) ScMatrixValue nMatVal = pMatrix->Get( nScCol, nScRow ); if( ScMatrix::IsValueType( nMatVal.nType ) ) // value, boolean, or error { + FormulaError nErr; if( ScMatrix::IsBooleanType( nMatVal.nType ) ) { AppendExt( EXC_CACHEDVAL_BOOL ); AppendExt( static_cast< sal_uInt8 >( nMatVal.GetBoolean() ? 1 : 0 ) ); AppendExt( 0, 7 ); } - else if( sal_uInt16 nErr = nMatVal.GetError() ) + else if( (nErr = nMatVal.GetError()) != FormulaError::NONE ) { AppendExt( EXC_CACHEDVAL_ERROR ); AppendExt( XclTools::GetXclErrorCode( nErr ) ); diff --git a/sc/source/filter/excel/xehelper.cxx b/sc/source/filter/excel/xehelper.cxx index fa5a429a7b98..e0e8dfa6d3cf 100644 --- a/sc/source/filter/excel/xehelper.cxx +++ b/sc/source/filter/excel/xehelper.cxx @@ -1027,6 +1027,7 @@ void XclExpCachedMatrix::Save( XclExpStream& rStrm ) const { ScMatrixValue nMatVal = mrMatrix.Get( nCol, nRow ); + FormulaError nScError; if( SC_MATVAL_EMPTY == nMatVal.nType ) { rStrm.SetSliceSize( 9 ); @@ -1046,7 +1047,7 @@ void XclExpCachedMatrix::Save( XclExpStream& rStrm ) const rStrm << EXC_CACHEDVAL_BOOL << nBool; rStrm.WriteZeroBytes( 7 ); } - else if( sal_uInt16 nScError = nMatVal.GetError() ) + else if( (nScError = nMatVal.GetError()) != FormulaError::NONE ) { sal_Int8 nError ( XclTools::GetXclErrorCode( nScError ) ); rStrm.SetSliceSize( 9 ); diff --git a/sc/source/filter/excel/xelink.cxx b/sc/source/filter/excel/xelink.cxx index 3a8c0d21fdb0..8c7b1399a576 100644 --- a/sc/source/filter/excel/xelink.cxx +++ b/sc/source/filter/excel/xelink.cxx @@ -1185,7 +1185,7 @@ void XclExpCrn::WriteDouble( XclExpStream& rStrm, double fValue ) { if( ::rtl::math::isNan( fValue ) ) { - sal_uInt16 nScError = formula::GetDoubleErrorValue(fValue); + FormulaError nScError = GetDoubleErrorValue(fValue); WriteError( rStrm, XclTools::GetXclErrorCode( nScError ) ); } else diff --git a/sc/source/filter/excel/xestream.cxx b/sc/source/filter/excel/xestream.cxx index 7d08fb84ec70..adebb97ad352 100644 --- a/sc/source/filter/excel/xestream.cxx +++ b/sc/source/filter/excel/xestream.cxx @@ -639,7 +639,7 @@ void XclExpBiff8Encrypter::EncryptBytes( SvStream& rStrm, vector<sal_uInt8>& aBy mnOldPos = nStrmPos; } -static const char* lcl_GetErrorString( sal_uInt16 nScErrCode ) +static const char* lcl_GetErrorString( FormulaError nScErrCode ) { sal_uInt8 nXclErrCode = XclTools::GetXclErrorCode( nScErrCode ); switch( nXclErrCode ) diff --git a/sc/source/filter/excel/xetable.cxx b/sc/source/filter/excel/xetable.cxx index bed5e720b746..c5ab7de726cb 100644 --- a/sc/source/filter/excel/xetable.cxx +++ b/sc/source/filter/excel/xetable.cxx @@ -34,6 +34,7 @@ #include "xeescher.hxx" #include "xeextlst.hxx" #include "tokenarray.hxx" +#include <formula/errorcodes.hxx> #include <thread> #include <comphelper/threadpool.hxx> @@ -1045,8 +1046,8 @@ void XclExpFormulaCell::SaveXml( XclExpXmlStream& rStrm ) void XclExpFormulaCell::WriteContents( XclExpStream& rStrm ) { - sal_uInt16 nScErrCode = mrScFmlaCell.GetErrCode(); - if( nScErrCode ) + FormulaError nScErrCode = mrScFmlaCell.GetErrCode(); + if( nScErrCode != FormulaError::NONE ) { rStrm << EXC_FORMULA_RES_ERROR << sal_uInt8( 0 ) << XclTools::GetXclErrorCode( nScErrCode ) diff --git a/sc/source/filter/excel/xihelper.cxx b/sc/source/filter/excel/xihelper.cxx index f562714ee4d1..24fd6bb6cb87 100644 --- a/sc/source/filter/excel/xihelper.cxx +++ b/sc/source/filter/excel/xihelper.cxx @@ -812,9 +812,9 @@ XclImpCachedValue::~XclImpCachedValue() { } -sal_uInt16 XclImpCachedValue::GetScError() const +FormulaError XclImpCachedValue::GetScError() const { - return (mnType == EXC_CACHEDVAL_ERROR) ? XclTools::GetScErrorCode( mnBoolErr ) : 0; + return (mnType == EXC_CACHEDVAL_ERROR) ? XclTools::GetScErrorCode( mnBoolErr ) : FormulaError::NONE; } // Matrix Cached Values ============================================================== diff --git a/sc/source/filter/excel/xltools.cxx b/sc/source/filter/excel/xltools.cxx index a187ebab3e3e..1392eb5151e5 100644 --- a/sc/source/filter/excel/xltools.cxx +++ b/sc/source/filter/excel/xltools.cxx @@ -197,49 +197,50 @@ sal_uInt8 XclTools::GetXclOrientFromRot( sal_uInt16 nXclRot ) return EXC_ORIENT_NONE; } -sal_uInt8 XclTools::GetXclErrorCode( sal_uInt16 nScError ) +sal_uInt8 XclTools::GetXclErrorCode( FormulaError nScError ) { switch( nScError ) { - case formula::errIllegalArgument: return EXC_ERR_VALUE; - case formula::errIllegalFPOperation: return EXC_ERR_NUM; // maybe DIV/0 or NUM... - case formula::errDivisionByZero: return EXC_ERR_DIV0; - case formula::errIllegalParameter: return EXC_ERR_VALUE; - case formula::errPairExpected: return EXC_ERR_VALUE; - case formula::errOperatorExpected: return EXC_ERR_VALUE; - case formula::errVariableExpected: return EXC_ERR_VALUE; - case formula::errParameterExpected: return EXC_ERR_VALUE; - case formula::errNoValue: return EXC_ERR_VALUE; - case formula::errCircularReference: return EXC_ERR_VALUE; - case formula::errNoCode: return EXC_ERR_NULL; - case formula::errNoRef: return EXC_ERR_REF; - case formula::errNoName: return EXC_ERR_NAME; - case formula::errNoAddin: return EXC_ERR_NAME; - case formula::errNoMacro: return EXC_ERR_NAME; - case formula::NOTAVAILABLE: return EXC_ERR_NA; + case FormulaError::IllegalArgument: return EXC_ERR_VALUE; + case FormulaError::IllegalFPOperation: return EXC_ERR_NUM; // maybe DIV/0 or NUM... + case FormulaError::DivisionByZero: return EXC_ERR_DIV0; + case FormulaError::IllegalParameter: return EXC_ERR_VALUE; + case FormulaError::PairExpected: return EXC_ERR_VALUE; + case FormulaError::OperatorExpected: return EXC_ERR_VALUE; + case FormulaError::VariableExpected: return EXC_ERR_VALUE; + case FormulaError::ParameterExpected: return EXC_ERR_VALUE; + case FormulaError::NoValue: return EXC_ERR_VALUE; + case FormulaError::CircularReference: return EXC_ERR_VALUE; + case FormulaError::NoCode: return EXC_ERR_NULL; + case FormulaError::NoRef: return EXC_ERR_REF; + case FormulaError::NoName: return EXC_ERR_NAME; + case FormulaError::NoAddin: return EXC_ERR_NAME; + case FormulaError::NoMacro: return EXC_ERR_NAME; + case FormulaError::NotAvailable: return EXC_ERR_NA; + default: break; } return EXC_ERR_NA; } -sal_uInt16 XclTools::GetScErrorCode( sal_uInt8 nXclError ) +FormulaError XclTools::GetScErrorCode( sal_uInt8 nXclError ) { switch( nXclError ) { - case EXC_ERR_NULL: return formula::errNoCode; - case EXC_ERR_DIV0: return formula::errDivisionByZero; - case EXC_ERR_VALUE: return formula::errNoValue; - case EXC_ERR_REF: return formula::errNoRef; - case EXC_ERR_NAME: return formula::errNoName; - case EXC_ERR_NUM: return formula::errIllegalFPOperation; - case EXC_ERR_NA: return formula::NOTAVAILABLE; + case EXC_ERR_NULL: return FormulaError::NoCode; + case EXC_ERR_DIV0: return FormulaError::DivisionByZero; + case EXC_ERR_VALUE: return FormulaError::NoValue; + case EXC_ERR_REF: return FormulaError::NoRef; + case EXC_ERR_NAME: return FormulaError::NoName; + case EXC_ERR_NUM: return FormulaError::IllegalFPOperation; + case EXC_ERR_NA: return FormulaError::NotAvailable; default: OSL_FAIL( "XclTools::GetScErrorCode - unknown error code" ); } - return formula::NOTAVAILABLE; + return FormulaError::NotAvailable; } double XclTools::ErrorToDouble( sal_uInt8 nXclError ) { - return formula::CreateDoubleError(GetScErrorCode( nXclError )); + return CreateDoubleError(GetScErrorCode( nXclError )); } XclBoolError XclTools::ErrorToEnum( double& rfDblValue, bool bErrOrBool, sal_uInt8 nValue ) diff --git a/sc/source/filter/inc/scflt.hxx b/sc/source/filter/inc/scflt.hxx index 164fc56689c5..b315bfc32adb 100644 --- a/sc/source/filter/inc/scflt.hxx +++ b/sc/source/filter/inc/scflt.hxx @@ -602,7 +602,7 @@ public: class Sc10FontCollection : public ScCollection { protected: - sal_uLong nError; + sal_uLong nError; public: Sc10FontCollection( SvStream& rStream ); sal_uLong GetError() { return nError; } @@ -761,7 +761,7 @@ class Sc10Import Sc10NameCollection* pNameCollection; Sc10PatternCollection* pPatternCollection; Sc10DataBaseCollection* pDataBaseCollection; - sal_uLong nError; + sal_uLong nError; SCTAB nShowTab; ScViewOptions aSc30ViewOpt; ScfStreamProgressBar* pPrgrsBar; @@ -770,7 +770,7 @@ public: Sc10Import( SvStream& rStr, ScDocument* pDocument ); ~Sc10Import(); - sal_uLong Import(); + sal_uLong Import(); void LoadFileHeader(); void LoadFileInfo(); void LoadEditStateInfo(); diff --git a/sc/source/filter/inc/xihelper.hxx b/sc/source/filter/inc/xihelper.hxx index 0cd1583613a3..6677eeb4b718 100644 --- a/sc/source/filter/inc/xihelper.hxx +++ b/sc/source/filter/inc/xihelper.hxx @@ -321,7 +321,7 @@ public: /** Returns the cached Calc error code, if this value has Error type, else 0. */ inline sal_uInt8 GetXclError() const { return (mnType == EXC_CACHEDVAL_ERROR) ? mnBoolErr : EXC_ERR_NA; } /** Returns the cached Calc error code, if this value has Error type, else 0. */ - sal_uInt16 GetScError() const; + FormulaError GetScError() const; protected: typedef ::std::unique_ptr< const ScTokenArray > ScTokenArrayPtr; diff --git a/sc/source/filter/inc/xltools.hxx b/sc/source/filter/inc/xltools.hxx index 89d8531bf116..7ca6e2927f34 100644 --- a/sc/source/filter/inc/xltools.hxx +++ b/sc/source/filter/inc/xltools.hxx @@ -24,6 +24,7 @@ #include "ftools.hxx" class SfxObjectShell; +enum class FormulaError : sal_uInt16; // BIFF versions ============================================================== @@ -115,9 +116,9 @@ public: static sal_uInt8 GetXclOrientFromRot( sal_uInt16 nXclRot ); /** Converts a Calc error code to an Excel error code. */ - static sal_uInt8 GetXclErrorCode( sal_uInt16 nScError ); + static sal_uInt8 GetXclErrorCode( FormulaError nScError ); /** Converts an Excel error code to a Calc error code. */ - static sal_uInt16 GetScErrorCode( sal_uInt8 nXclError ); + static FormulaError GetScErrorCode( sal_uInt8 nXclError ); /** Converts the passed BIFF error to a double containing the respective Calc error code. */ static double ErrorToDouble( sal_uInt8 nXclError ); diff --git a/sc/source/filter/oox/defnamesbuffer.cxx b/sc/source/filter/oox/defnamesbuffer.cxx index fe41ed7d47ac..a3be8b775c33 100644 --- a/sc/source/filter/oox/defnamesbuffer.cxx +++ b/sc/source/filter/oox/defnamesbuffer.cxx @@ -331,7 +331,7 @@ std::unique_ptr<ScTokenArray> DefinedName::getScTokens() // Compile the tokens into RPN once to populate information into tokens // where necessary, e.g. for TableRef inner reference. RPN can be discarded // after, a resulting error must be reset. - sal_uInt16 nErr = pArray->GetCodeError(); + FormulaError nErr = pArray->GetCodeError(); aCompiler.CompileTokenArray(); pArray->DelRPN(); pArray->SetCodeError(nErr); diff --git a/sc/source/filter/starcalc/scflt.cxx b/sc/source/filter/starcalc/scflt.cxx index 77e54435ff9c..79ffdb99ac59 100644 --- a/sc/source/filter/starcalc/scflt.cxx +++ b/sc/source/filter/starcalc/scflt.cxx @@ -21,6 +21,7 @@ #include <editeng/eeitem.hxx> #include <com/sun/star/style/NumberingType.hpp> +#include <formula/errorcodes.hxx> #include <svx/algitem.hxx> #include <editeng/boxitem.hxx> #include <editeng/brushitem.hxx> @@ -443,7 +444,7 @@ Sc10NameData::Sc10NameData(SvStream& rStream) Sc10NameCollection::Sc10NameCollection(SvStream& rStream) : ScCollection (4, 4), - nError (0) + nError (0) { sal_uInt16 ID; rStream.ReadUInt16( ID ); diff --git a/sc/source/filter/xml/xmlexprt.cxx b/sc/source/filter/xml/xmlexprt.cxx index 235d7873ffb3..437df5d4ecda 100644 --- a/sc/source/filter/xml/xmlexprt.cxx +++ b/sc/source/filter/xml/xmlexprt.cxx @@ -97,6 +97,7 @@ #include <editeng/xmlcnitm.hxx> #include <editeng/flditem.hxx> #include <editeng/eeitem.hxx> +#include <formula/errorcodes.hxx> #include <xmloff/xmlerror.hxx> #include <xmloff/XMLEventExport.hxx> @@ -3144,7 +3145,7 @@ void ScXMLExport::WriteCell(ScMyCell& aCell, sal_Int32 nEqualCellCount) AddAttribute(sAttrFormula, GetNamespaceMap().GetQNameByKey(nNamespacePrefix, aFormula.copy(1, aFormula.getLength()-2), false)); } } - if (pFormulaCell->GetErrCode()) + if (pFormulaCell->GetErrCode() != FormulaError::NONE) { AddAttribute(sAttrValueType, XML_STRING); AddAttribute(sAttrStringValue, aCell.maBaseCell.getString(pDoc)); diff --git a/sc/source/filter/xml/xmlimprt.cxx b/sc/source/filter/xml/xmlimprt.cxx index ac0f89f73c19..55c49b33a513 100644 --- a/sc/source/filter/xml/xmlimprt.cxx +++ b/sc/source/filter/xml/xmlimprt.cxx @@ -43,6 +43,7 @@ #include <svl/zformat.hxx> #include <svl/languageoptions.hxx> #include <editeng/editstat.hxx> +#include <formula/errorcodes.hxx> #include "appluno.hxx" #include "xmlimprt.hxx" @@ -3412,7 +3413,7 @@ bool ScXMLImport::IsFormulaErrorConstant( const OUString& rStr ) const if (!mpComp) return false; - return mpComp->GetErrorConstant(rStr) > 0; + return mpComp->GetErrorConstant(rStr) > FormulaError::NONE; } ScEditEngineDefaulter* ScXMLImport::GetEditEngine() diff --git a/sc/source/ui/app/inputhdl.cxx b/sc/source/ui/app/inputhdl.cxx index 26b14aca19d1..964896d714a5 100644 --- a/sc/source/ui/app/inputhdl.cxx +++ b/sc/source/ui/app/inputhdl.cxx @@ -23,6 +23,7 @@ #include <sfx2/app.hxx> #include <editeng/acorrcfg.hxx> +#include <formula/errorcodes.hxx> #include <svx/algitem.hxx> #include <editeng/adjustitem.hxx> #include <editeng/brushitem.hxx> @@ -1434,8 +1435,8 @@ static OUString lcl_Calculate( const OUString& rFormula, ScDocument* pDoc, const bColRowName = false; } - sal_uInt16 nErrCode = pCalc->GetErrCode(); - if ( nErrCode != 0 ) + FormulaError nErrCode = pCalc->GetErrCode(); + if ( nErrCode != FormulaError::NONE ) return ScGlobal::GetErrorString(nErrCode); SvNumberFormatter& aFormatter = *(pDoc->GetFormatTable()); diff --git a/sc/source/ui/app/scmod.cxx b/sc/source/ui/app/scmod.cxx index 4a3395356084..8b0e101f45fb 100644 --- a/sc/source/ui/app/scmod.cxx +++ b/sc/source/ui/app/scmod.cxx @@ -1265,7 +1265,7 @@ void ScModule::ModifyOptions( const SfxItemSet& rOptSet ) // Re-compile cells with name error, and recalc if at least one cell // has been re-compiled. In the future we may want to find a way to // recalc only those that are affected. - if (pDoc->CompileErrorCells(formula::errNoName)) + if (pDoc->CompileErrorCells(FormulaError::NoName)) bCalcAll = true; } diff --git a/sc/source/ui/app/transobj.cxx b/sc/source/ui/app/transobj.cxx index 4a061f46d627..50f50536b33e 100644 --- a/sc/source/ui/app/transobj.cxx +++ b/sc/source/ui/app/transobj.cxx @@ -53,6 +53,7 @@ #include <editeng/paperinf.hxx> #include <editeng/sizeitem.hxx> +#include <formula/errorcodes.hxx> #include <svx/algitem.hxx> #include <svl/intitem.hxx> #include <svl/zforlist.hxx> @@ -816,9 +817,9 @@ void ScTransferObj::StripRefs( ScDocument* pDoc, SCCOL nCol = aIter.GetPos().Col() - nSubX; SCROW nRow = aIter.GetPos().Row() - nSubY; - sal_uInt16 nErrCode = pFCell->GetErrCode(); + FormulaError nErrCode = pFCell->GetErrCode(); ScAddress aPos(nCol, nRow, nDestTab); - if (nErrCode) + if (nErrCode != FormulaError::NONE) { if ( static_cast<const SvxHorJustifyItem*>(pDestDoc->GetAttr( nCol,nRow,nDestTab, ATTR_HOR_JUSTIFY))->GetValue() == diff --git a/sc/source/ui/condformat/condformatdlgentry.cxx b/sc/source/ui/condformat/condformatdlgentry.cxx index df5db9acefbf..0343b040253c 100644 --- a/sc/source/ui/condformat/condformatdlgentry.cxx +++ b/sc/source/ui/condformat/condformatdlgentry.cxx @@ -24,6 +24,7 @@ #include <vcl/msgbox.hxx> #include <vcl/settings.hxx> #include <formula/token.hxx> +#include <formula/errorcodes.hxx> #include "tokenarray.hxx" #include "stlpool.hxx" #include "tabvwsh.hxx" @@ -311,7 +312,7 @@ IMPL_LINK_TYPED(ScConditionFrmtEntry, OnEdChanged, Edit&, rEdit, void) std::unique_ptr<ScTokenArray> ta(aComp.CompileString(aFormula)); // Error, warn the user - if( ta->GetCodeError() || ( ta->GetLen() == 0 ) ) + if( ta->GetCodeError() != FormulaError::NONE || ( ta->GetLen() == 0 ) ) { rEdit.SetControlBackground(COL_LIGHTRED); maFtVal->SetText(ScGlobal::GetRscString(STR_VALID_DEFERROR)); diff --git a/sc/source/ui/docshell/docsh.cxx b/sc/source/ui/docshell/docsh.cxx index 823cf06f26c2..20d21be97639 100644 --- a/sc/source/ui/docshell/docsh.cxx +++ b/sc/source/ui/docshell/docsh.cxx @@ -24,6 +24,7 @@ #include "scitems.hxx" #include <editeng/justifyitem.hxx> #include <comphelper/classids.hxx> +#include <formula/errorcodes.hxx> #include <vcl/msgbox.hxx> #include <vcl/virdev.hxx> #include <vcl/waitobj.hxx> @@ -1993,13 +1994,13 @@ void ScDocShell::AsciiSave( SvStream& rStream, const ScImportOptions& rAsciiOpt break; case CELLTYPE_FORMULA : { - sal_uInt16 nErrCode; + FormulaError nErrCode; if ( bShowFormulas ) { pCell->mpFormula->GetFormula(aString); bString = true; } - else if ((nErrCode = pCell->mpFormula->GetErrCode()) != 0) + else if ((nErrCode = pCell->mpFormula->GetErrCode()) != FormulaError::NONE) { aString = ScGlobal::GetErrorString( nErrCode ); bString = true; diff --git a/sc/source/ui/docshell/externalrefmgr.cxx b/sc/source/ui/docshell/externalrefmgr.cxx index b34cb9d5ad52..8c496a0d36cb 100644 --- a/sc/source/ui/docshell/externalrefmgr.cxx +++ b/sc/source/ui/docshell/externalrefmgr.cxx @@ -140,10 +140,10 @@ struct UpdateFormulaCell : public unary_function<ScFormulaCell*, void> if (!pCode->HasExternalRef()) return; - if (pCode->GetCodeError()) + if (pCode->GetCodeError() != FormulaError::NONE) { // Clear the error code, or a cell with error won't get re-compiled. - pCode->SetCodeError(0); + pCode->SetCodeError(FormulaError::NONE); pCell->SetCompile(true); pCell->CompileTokenArray(); } @@ -883,9 +883,9 @@ void ScExternalRefCache::setCellRangeData(sal_uInt16 nFileId, const ScRange& rRa SAL_WARN("sc.ui","ScExternalRefCache::setCellRangeData - not a one element matrix"); else { - sal_uInt16 nErr = GetDoubleErrorValue( pMat->GetDouble(0,0)); - SAL_WARN("sc.ui","ScExternalRefCache::setCellRangeData - matrix error value is " << nErr << - (nErr == errMatrixSize ? ", ok" : ", not ok")); + FormulaError nErr = GetDoubleErrorValue( pMat->GetDouble(0,0)); + SAL_WARN("sc.ui","ScExternalRefCache::setCellRangeData - matrix error value is " << (int)nErr << + (nErr == FormulaError::MatrixSize ? ", ok" : ", not ok")); } } } @@ -1547,8 +1547,8 @@ static FormulaToken* convertToToken( ScDocument* pHostDoc, ScDocument* pSrcDoc, case CELLTYPE_FORMULA: { ScFormulaCell* pFCell = rCell.mpFormula; - sal_uInt16 nError = pFCell->GetErrCode(); - if (nError) + FormulaError nError = pFCell->GetErrCode(); + if (nError != FormulaError::NONE) return new FormulaErrorToken( nError); else if (pFCell->IsValue()) { @@ -1933,7 +1933,7 @@ ScExternalRefCache::TokenRef ScExternalRefManager::getSingleRefToken( if (!getSrcDocTable( *pSrcDoc, rTabName, nTab, nFileId)) { // specified table name doesn't exist in the source document. - ScExternalRefCache::TokenRef pToken(new FormulaErrorToken(errNoRef)); + ScExternalRefCache::TokenRef pToken(new FormulaErrorToken(FormulaError::NoRef)); return pToken; } @@ -1964,7 +1964,7 @@ ScExternalRefCache::TokenRef ScExternalRefManager::getSingleRefToken( if (!pSrcDoc) { // Source document not reachable. Throw a reference error. - pToken.reset(new FormulaErrorToken(errNoRef)); + pToken.reset(new FormulaErrorToken(FormulaError::NoRef)); return pToken; } @@ -1972,7 +1972,7 @@ ScExternalRefCache::TokenRef ScExternalRefManager::getSingleRefToken( if (!getSrcDocTable( *pSrcDoc, rTabName, nTab, nFileId)) { // specified table name doesn't exist in the source document. - pToken.reset(new FormulaErrorToken(errNoRef)); + pToken.reset(new FormulaErrorToken(FormulaError::NoRef)); return pToken; } @@ -2037,7 +2037,7 @@ ScExternalRefCache::TokenArrayRef ScExternalRefManager::getDoubleRefTokens( { // Source document is not reachable. Throw a reference error. pArray.reset(new ScTokenArray); - pArray->AddToken(FormulaErrorToken(errNoRef)); + pArray->AddToken(FormulaErrorToken(FormulaError::NoRef)); return pArray; } @@ -2263,7 +2263,7 @@ ScExternalRefCache::TokenRef ScExternalRefManager::getSingleRefTokenFromSrcDoc( if (!pToken.get()) { // Generate an error for unresolvable cells. - pToken.reset( new FormulaErrorToken( errNoValue)); + pToken.reset( new FormulaErrorToken( FormulaError::NoValue)); } // Get number format information. @@ -2285,7 +2285,7 @@ ScExternalRefCache::TokenArrayRef ScExternalRefManager::getDoubleRefTokensFromSr { // specified table name doesn't exist in the source document. pArray.reset(new ScTokenArray); - pArray->AddToken(FormulaErrorToken(errNoRef)); + pArray->AddToken(FormulaErrorToken(FormulaError::NoRef)); return pArray; } @@ -2867,12 +2867,12 @@ public: case sc::FormulaResultValue::Error: case sc::FormulaResultValue::Invalid: default: - pTok.reset(new FormulaErrorToken(errNoValue)); + pTok.reset(new FormulaErrorToken(FormulaError::NoValue)); } } break; default: - pTok.reset(new FormulaErrorToken(errNoValue)); + pTok.reset(new FormulaErrorToken(FormulaError::NoValue)); } if (pTok) diff --git a/sc/source/ui/formdlg/formula.cxx b/sc/source/ui/formdlg/formula.cxx index bf50ba5e2e7a..eb5ddf4acef6 100644 --- a/sc/source/ui/formdlg/formula.cxx +++ b/sc/source/ui/formdlg/formula.cxx @@ -31,6 +31,7 @@ #include <tools/urlobj.hxx> #include <formula/formulahelper.hxx> #include <formula/IFunctionDescription.hxx> +#include <formula/errorcodes.hxx> #include "tokenuno.hxx" #include "formula.hxx" @@ -331,8 +332,8 @@ bool ScFormulaDlg::calculateValue( const OUString& rStrExp, OUString& rStrResult bColRowName = false; } - sal_uInt16 nErrCode = pFCell->GetErrCode(); - if ( nErrCode == 0 || pFCell->IsMatrix() ) + FormulaError nErrCode = pFCell->GetErrCode(); + if ( nErrCode == FormulaError::NONE || pFCell->IsMatrix() ) { SvNumberFormatter& aFormatter = *(m_pDoc->GetFormatTable()); Color* pColor; diff --git a/sc/source/ui/inc/tabvwsh.hxx b/sc/source/ui/inc/tabvwsh.hxx index c82a0865ab35..dd05b4c8110d 100644 --- a/sc/source/ui/inc/tabvwsh.hxx +++ b/sc/source/ui/inc/tabvwsh.hxx @@ -20,6 +20,7 @@ #ifndef INCLUDED_SC_SOURCE_UI_INC_TABVWSH_HXX #define INCLUDED_SC_SOURCE_UI_INC_TABVWSH_HXX +#include <formula/errorcodes.hxx> #include <svx/fmshell.hxx> #include <svtools/htmlcfg.hxx> #include <sfx2/viewsh.hxx> @@ -359,7 +360,7 @@ public: void ExecuteCellFormatDlg( SfxRequest& rReq, const OString &rTabPage); - bool GetFunction( OUString& rFuncStr, sal_uInt16 nErrCode ); + bool GetFunction( OUString& rFuncStr, FormulaError nErrCode ); void StartSimpleRefDialog( const OUString& rTitle, const OUString& rInitVal, bool bCloseOnButtonUp, bool bSingleCell, bool bMultiSelection ); diff --git a/sc/source/ui/namedlg/namedefdlg.cxx b/sc/source/ui/namedlg/namedefdlg.cxx index c46f17e99817..7892d4977419 100644 --- a/sc/source/ui/namedlg/namedefdlg.cxx +++ b/sc/source/ui/namedlg/namedefdlg.cxx @@ -11,7 +11,7 @@ #include <vcl/msgbox.hxx> #include <vcl/settings.hxx> - +#include <formula/errorcodes.hxx> #include <sfx2/app.hxx> #include "document.hxx" @@ -122,7 +122,7 @@ bool ScNameDefDlg::IsFormulaValid() ScCompiler aComp( mpDoc, maCursorPos); aComp.SetGrammar( mpDoc->GetGrammar() ); ScTokenArray* pCode = aComp.CompileString(m_pEdRange->GetText()); - if (pCode->GetCodeError()) + if (pCode->GetCodeError() != FormulaError::NONE) { //TODO: info message delete pCode; @@ -233,7 +233,7 @@ void ScNameDefDlg::AddPushed() pNewEntry->AddType(nType); // aExpression valid? - if ( 0 == pNewEntry->GetErrCode() ) + if ( FormulaError::NONE == pNewEntry->GetErrCode() ) { if ( !pRangeName->insert( pNewEntry, false /*bReuseFreeIndex*/ ) ) pNewEntry = nullptr; diff --git a/sc/source/ui/namedlg/namedlg.cxx b/sc/source/ui/namedlg/namedlg.cxx index bc5539126b8d..23f207aa7aeb 100644 --- a/sc/source/ui/namedlg/namedlg.cxx +++ b/sc/source/ui/namedlg/namedlg.cxx @@ -34,7 +34,7 @@ #include <vcl/msgbox.hxx> #include <vcl/settings.hxx> - +#include <formula/errorcodes.hxx> #include <o3tl/make_unique.hxx> #include <map> @@ -299,7 +299,7 @@ bool ScNameDlg::IsFormulaValid() ScCompiler aComp( mpDoc, maCursorPos); aComp.SetGrammar( mpDoc->GetGrammar() ); ScTokenArray* pCode = aComp.CompileString(m_pEdAssign->GetText()); - if (pCode->GetCodeError()) + if (pCode->GetCodeError() != FormulaError::NONE) { m_pFtInfo->SetControlBackground(GetSettings().GetStyleSettings().GetHighlightColor()); delete pCode; diff --git a/sc/source/ui/unoobj/cellsuno.cxx b/sc/source/ui/unoobj/cellsuno.cxx index 2085ff4a7d61..33bc42ef80e2 100644 --- a/sc/source/ui/unoobj/cellsuno.cxx +++ b/sc/source/ui/unoobj/cellsuno.cxx @@ -1147,7 +1147,7 @@ static bool lcl_PutDataArray( ScDocShell& rDocShell, const ScRange& rRange, case uno::TypeClass_VOID: { // void = "no value" - rDoc.SetError( nDocCol, nDocRow, nTab, formula::NOTAVAILABLE ); + rDoc.SetError( nDocCol, nDocRow, nTab, FormulaError::NotAvailable ); } break; @@ -3645,7 +3645,7 @@ uno::Reference<sheet::XSheetCellRanges> SAL_CALL ScCellRangesBase::queryFormulaC { ScFormulaCell* pFCell = aIter.getFormulaCell(); bool bAdd = false; - if (pFCell->GetErrCode()) + if (pFCell->GetErrCode() != FormulaError::NONE) { if ( nResultFlags & sheet::FormulaResult::ERROR ) bAdd = true; @@ -6548,12 +6548,12 @@ sal_Int32 SAL_CALL ScCellObj::getError() throw(uno::RuntimeException, std::excep return 0; } - sal_uInt16 nError = 0; + FormulaError nError = FormulaError::NONE; ScRefCellValue aCell(pDocSh->GetDocument(), aCellPos); if (aCell.meType == CELLTYPE_FORMULA) nError = aCell.mpFormula->GetErrCode(); - return nError; + return (sal_Int32)nError; } // XFormulaTokens diff --git a/sc/source/ui/unoobj/chart2uno.cxx b/sc/source/ui/unoobj/chart2uno.cxx index 5dafe5654af8..2fce34a9c611 100644 --- a/sc/source/ui/unoobj/chart2uno.cxx +++ b/sc/source/ui/unoobj/chart2uno.cxx @@ -2593,8 +2593,8 @@ void ScChart2DataSequence::BuildDataCache() case CELLTYPE_FORMULA: { ScFormulaCell* pFCell = aCell.mpFormula; - sal_uInt16 nErr = pFCell->GetErrCode(); - if (nErr) + FormulaError nErr = pFCell->GetErrCode(); + if (nErr != FormulaError::NONE) break; if (pFCell->IsValue()) diff --git a/sc/source/ui/unoobj/funcuno.cxx b/sc/source/ui/unoobj/funcuno.cxx index 445b73d3cba1..afbe7098dfcb 100644 --- a/sc/source/ui/unoobj/funcuno.cxx +++ b/sc/source/ui/unoobj/funcuno.cxx @@ -616,8 +616,8 @@ uno::Any SAL_CALL ScFunctionAccess::callFunction( const OUString& aName, // if there is no matrix result const ScMatrix* pMat = (mbArray && pFormula) ? pFormula->GetMatrix() : nullptr; - sal_uInt16 nErrCode = pFormula ? pFormula->GetErrCode() : formula::errIllegalArgument; - if ( nErrCode == 0 ) + FormulaError nErrCode = pFormula ? pFormula->GetErrCode() : FormulaError::IllegalArgument; + if ( nErrCode == FormulaError::NONE ) { if ( pMat ) { @@ -636,7 +636,7 @@ uno::Any SAL_CALL ScFunctionAccess::callFunction( const OUString& aName, aRet <<= aStrVal; } } - else if ( nErrCode == formula::NOTAVAILABLE ) + else if ( nErrCode == FormulaError::NotAvailable ) { // #N/A: leave result empty, no exception } diff --git a/sc/source/ui/view/cellsh.cxx b/sc/source/ui/view/cellsh.cxx index cc1ff7533114..8907fc3a83e6 100644 --- a/sc/source/ui/view/cellsh.cxx +++ b/sc/source/ui/view/cellsh.cxx @@ -777,7 +777,7 @@ void ScCellShell::GetState(SfxItemSet &rSet) rSet.Put( SfxStringItem( nWhich, OUString("...") ) ); else { - sal_uInt16 nErrCode = 0; + FormulaError nErrCode = FormulaError::NONE; ScFormulaCell* pCell = pDoc->GetFormulaCell(ScAddress(nPosX, nPosY, nTab)); if (pCell) { @@ -803,7 +803,7 @@ void ScCellShell::GetState(SfxItemSet &rSet) case SID_STATUS_SUM: { OUString aFuncStr; - if ( pTabViewShell->GetFunction( aFuncStr, 0 ) ) + if ( pTabViewShell->GetFunction( aFuncStr, FormulaError::NONE ) ) rSet.Put( SfxStringItem( nWhich, aFuncStr ) ); } break; diff --git a/sc/source/ui/view/output2.cxx b/sc/source/ui/view/output2.cxx index 07a3a44546fc..c981c631c41a 100644 --- a/sc/source/ui/view/output2.cxx +++ b/sc/source/ui/view/output2.cxx @@ -597,7 +597,7 @@ void ScDrawStringsVars::SetTextToWidthOrHash( ScRefCellValue& rCell, long nWidth if (eType == CELLTYPE_FORMULA) { ScFormulaCell* pFCell = rCell.mpFormula; - if (pFCell->GetErrCode() != 0 || pOutput->mbShowFormulas) + if (pFCell->GetErrCode() != FormulaError::NONE || pOutput->mbShowFormulas) { SetHashText(); // If the error string doesn't fit, always use "###". Also for "display formulas" (#i116691#) return; diff --git a/sc/source/ui/view/tabvwsha.cxx b/sc/source/ui/view/tabvwsha.cxx index ef0d1ced1843..149b31098760 100644 --- a/sc/source/ui/view/tabvwsha.cxx +++ b/sc/source/ui/view/tabvwsha.cxx @@ -63,7 +63,7 @@ using namespace com::sun::star; -bool ScTabViewShell::GetFunction( OUString& rFuncStr, sal_uInt16 nErrCode ) +bool ScTabViewShell::GetFunction( OUString& rFuncStr, FormulaError nErrCode ) { OUString aStr; @@ -79,9 +79,9 @@ bool ScTabViewShell::GetFunction( OUString& rFuncStr, sal_uInt16 nErrCode ) ScSubTotalFunc eFunc = (ScSubTotalFunc)nFunc; if (bIgnoreError && (eFunc == SUBTOTAL_FUNC_CNT || eFunc == SUBTOTAL_FUNC_CNT2)) - nErrCode = 0; + nErrCode = FormulaError::NONE; - if (nErrCode) + if (nErrCode != FormulaError::NONE) { rFuncStr = ScGlobal::GetLongErrorString(nErrCode); return true; diff --git a/sc/source/ui/view/viewfunc.cxx b/sc/source/ui/view/viewfunc.cxx index 18f4ee1a836f..e43ef8aa896f 100644 --- a/sc/source/ui/view/viewfunc.cxx +++ b/sc/source/ui/view/viewfunc.cxx @@ -416,7 +416,7 @@ void ScViewFunc::EnterData( SCCOL nCol, SCROW nRow, SCTAB nTab, { // try to parse with first parser-correction pArr = aComp.CompileString( aComp.GetCorrectedFormula() ); } - if ( !pArr->GetCodeError() ) + if ( pArr->GetCodeError() == FormulaError::NONE ) { bAddEqual = true; aComp.CompileTokenArray(); @@ -466,8 +466,8 @@ void ScViewFunc::EnterData( SCCOL nCol, SCROW nRow, SCTAB nTab, // cells and the error be set explicitly, so that // via FormulaCell copy-ctor and Interpreter it will be, when possible, // ironed out again, too intelligent.. e.g.: =1)) - sal_uInt16 nError = pArr->GetCodeError(); - if ( !nError ) + FormulaError nError = pArr->GetCodeError(); + if ( nError == FormulaError::NONE ) { // update list of recent functions with all functions that // are not within parentheses @@ -510,7 +510,7 @@ void ScViewFunc::EnterData( SCCOL nCol, SCROW nRow, SCTAB nTab, sal_uLong nIndex = (sal_uLong) static_cast<const SfxUInt32Item*>( pDoc->GetAttr( nCol, nRow, i, ATTR_VALUE_FORMAT ))->GetValue(); if ( pFormatter->GetType( nIndex ) == css::util::NumberFormat::TEXT || - ( ( rString[0] == '+' || rString[0] == '-' ) && nError && rString == aFormula ) ) + ( ( rString[0] == '+' || rString[0] == '-' ) && nError != FormulaError::NONE && rString == aFormula ) ) { if ( pData ) { @@ -523,7 +523,7 @@ void ScViewFunc::EnterData( SCCOL nCol, SCROW nRow, SCTAB nTab, else { ScFormulaCell* pCell = new ScFormulaCell( aCell, *pDoc, aPos ); - if ( nError ) + if ( nError != FormulaError::NONE ) { pCell->GetCode()->DelRPN(); pCell->SetErrCode( nError ); @@ -2655,7 +2655,7 @@ bool ScViewFunc::InsertName( const OUString& rName, const OUString& rSymbol, nType |= ScRangeData::Type::Criteria; pNewEntry->AddType(nType); - if ( !pNewEntry->GetErrCode() ) // text valid? + if ( pNewEntry->GetErrCode() == FormulaError::NONE ) // text valid? { ScDocShellModificator aModificator( *pDocSh ); |