diff options
author | Eike Rathke <erack@redhat.com> | 2016-06-30 11:30:53 +0200 |
---|---|---|
committer | Eike Rathke <erack@redhat.com> | 2016-06-30 12:58:15 +0200 |
commit | f8f655da5919858994dafb292429cf4d0298be4c (patch) | |
tree | 173483ffdaf3a0599c96857bf444b268e9b51a61 /sc | |
parent | 2087b8f2f66487f6e5940eb5fc318944a1865e31 (diff) |
return SAL_MAX_... instead of 0 for GetInt*()
Most places will use GetInt*() to obtain flags or enums in a range
0..somenumber and explicitly check for valid values, so returning MAX instead
of 0 will save us an extra comparison of nGlobalError and push/return.
Change-Id: I84c5d693d3642ea643308dc4650a391de2ebe82a
Diffstat (limited to 'sc')
-rw-r--r-- | sc/source/core/inc/interpre.hxx | 9 | ||||
-rw-r--r-- | sc/source/core/tool/interpr4.cxx | 8 |
2 files changed, 8 insertions, 9 deletions
diff --git a/sc/source/core/inc/interpre.hxx b/sc/source/core/inc/interpre.hxx index 6e95f02acffd..1c7baa5c2ac3 100644 --- a/sc/source/core/inc/interpre.hxx +++ b/sc/source/core/inc/interpre.hxx @@ -406,14 +406,13 @@ double GetDoubleFromMatrix(const ScMatrixRef& pMat); double GetDouble(); double GetDoubleWithDefault(double nDefault); bool IsMissing(); -/// if GetDouble() not within int32 limits sets nGlobalError and returns 0 +/** if GetDouble() not within int32 limits sets nGlobalError and returns SAL_MAX_INT32 */ sal_Int32 GetInt32(); -/** if GetDoubleWithDefault() not within int32 limits sets nGlobalError and - returns nDefault */ +/** if GetDoubleWithDefault() not within int32 limits sets nGlobalError and returns SAL_MAX_INT32 */ sal_Int32 GetInt32WithDefault( sal_Int32 nDefault ); -/// if GetDouble() not within int16 limits sets nGlobalError and returns 0 +/** if GetDouble() not within int16 limits sets nGlobalError and returns SAL_MAX_INT16 */ sal_Int16 GetInt16(); -/// if GetDouble() not within uint32 limits sets nGlobalError and returns 0 +/** if GetDouble() not within uint32 limits sets nGlobalError and returns SAL_MAX_UINT32 */ sal_uInt32 GetUInt32(); bool GetBool() { return GetDouble() != 0.0; } /// returns TRUE if double (or error, check nGlobalError), else FALSE diff --git a/sc/source/core/tool/interpr4.cxx b/sc/source/core/tool/interpr4.cxx index 29881d97b0fb..1421f87fcfb0 100644 --- a/sc/source/core/tool/interpr4.cxx +++ b/sc/source/core/tool/interpr4.cxx @@ -2099,7 +2099,7 @@ sal_Int32 ScInterpreter::GetInt32() if (fVal < SAL_MIN_INT32 || fVal > SAL_MAX_INT32) { SetError( errIllegalArgument); - return 0; + return SAL_MAX_INT32; } return static_cast<sal_Int32>(fVal); } @@ -2110,7 +2110,7 @@ sal_Int32 ScInterpreter::GetInt32WithDefault( sal_Int32 nDefault ) if (fVal < SAL_MIN_INT32 || fVal > SAL_MAX_INT32) { SetError( errIllegalArgument); - return nDefault; + return SAL_MAX_INT32; } return static_cast<sal_Int32>(fVal); } @@ -2121,7 +2121,7 @@ sal_Int16 ScInterpreter::GetInt16() if (fVal < SAL_MIN_INT16 || fVal > SAL_MAX_INT16) { SetError( errIllegalArgument); - return 0; + return SAL_MAX_INT16; } return static_cast<sal_Int16>(fVal); } @@ -2132,7 +2132,7 @@ sal_uInt32 ScInterpreter::GetUInt32() if (fVal < 0.0 || fVal > SAL_MAX_UINT32) { SetError( errIllegalArgument); - return 0; + return SAL_MAX_UINT32; } return static_cast<sal_uInt32>(fVal); } |