summaryrefslogtreecommitdiff
path: root/include
diff options
context:
space:
mode:
authorEike Rathke <erack@redhat.com>2017-01-05 18:23:04 +0100
committerEike Rathke <erack@redhat.com>2017-01-06 00:47:43 +0000
commit049862c9dd426eef74e229aee619facb98c7e7da (patch)
treedbd5a1da79d9a0dd3b9ce38cd9e6ab3110e61399 /include
parenta34de7f0e4165db1a64be42044f9d5900d0d3da9 (diff)
check "#ERRxxx!" constants for accepted error values, tdf#105024 follow-up
Change-Id: I9a11695710baa2f4e022c8e07f01b962cfabe2e7 (cherry picked from commit 6b89bcf85a911d043c9d93e843be12e6f23adedd) Reviewed-on: https://gerrit.libreoffice.org/32763 Reviewed-by: Eike Rathke <erack@redhat.com> Tested-by: Eike Rathke <erack@redhat.com>
Diffstat (limited to 'include')
-rw-r--r--include/formula/errorcodes.hxx67
1 files changed, 67 insertions, 0 deletions
diff --git a/include/formula/errorcodes.hxx b/include/formula/errorcodes.hxx
index 329be0d3b24d..2af9b1112de7 100644
--- a/include/formula/errorcodes.hxx
+++ b/include/formula/errorcodes.hxx
@@ -119,6 +119,73 @@ inline FormulaError GetDoubleErrorValue( double fVal )
return (FormulaError)(nErr & 0x0000ffff);
}
+/** Error values that are accepted as detailed "#ERRxxx!" constants.
+
+ Used in FormulaCompiler::GetErrorConstant() to prevent users from inventing
+ arbitrary values that already have or later might get a significant meaning.
+ */
+inline bool isPublishedFormulaError( FormulaError nErr )
+{
+ // Every value has to be handled explicitly, do not add a default case to
+ // let the compiler complain if a value is missing.
+ switch (nErr)
+ {
+ case FormulaError::NONE:
+ return false;
+
+ case FormulaError::IllegalChar:
+ case FormulaError::IllegalArgument:
+ case FormulaError::IllegalFPOperation:
+ case FormulaError::IllegalParameter:
+ case FormulaError::IllegalJump:
+ case FormulaError::Separator:
+ case FormulaError::Pair:
+ case FormulaError::PairExpected:
+ case FormulaError::OperatorExpected:
+ case FormulaError::VariableExpected:
+ case FormulaError::ParameterExpected:
+ case FormulaError::CodeOverflow:
+ case FormulaError::StringOverflow:
+ case FormulaError::StackOverflow:
+ case FormulaError::UnknownState:
+ case FormulaError::UnknownVariable:
+ case FormulaError::UnknownOpCode:
+ case FormulaError::UnknownStackVariable:
+ case FormulaError::NoValue:
+ case FormulaError::UnknownToken:
+ case FormulaError::NoCode:
+ case FormulaError::CircularReference:
+ case FormulaError::NoConvergence:
+ case FormulaError::NoRef:
+ case FormulaError::NoName:
+ case FormulaError::DoubleRef:
+ return true;
+
+ case FormulaError::TrackFromCircRef:
+ case FormulaError::CellNoValue:
+ return false;
+
+ case FormulaError::NoAddin:
+ case FormulaError::NoMacro:
+ case FormulaError::DivisionByZero:
+ case FormulaError::NestedArray:
+ return true;
+
+ case FormulaError::NotNumericString:
+ case FormulaError::JumpMatHasResult:
+ case FormulaError::ElementNaN:
+ case FormulaError::RetryCircular:
+ return false;
+
+ case FormulaError::MatrixSize:
+ return true;
+
+ case FormulaError::NotAvailable:
+ return false;
+ }
+ return false;
+}
+
#endif // INCLUDED_FORMULA_ERRORCODES_HXX
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */