summaryrefslogtreecommitdiff
path: root/sc
diff options
context:
space:
mode:
authorEike Rathke <erack@redhat.com>2016-06-30 10:54:16 +0200
committerEike Rathke <erack@redhat.com>2016-06-30 12:58:15 +0200
commit2087b8f2f66487f6e5940eb5fc318944a1865e31 (patch)
treed693e3263154679b3b1ec6b44d800fde9e13202b /sc
parent75c364e426eb34ba1be2ac71f768fd3969e85226 (diff)
introduce ScInterpreter::GetInt32WithDefault()
Change-Id: Ic3a5c65e4846a4582461564f572be83897b1d12d
Diffstat (limited to 'sc')
-rw-r--r--sc/source/core/inc/interpre.hxx3
-rw-r--r--sc/source/core/tool/interpr4.cxx11
2 files changed, 14 insertions, 0 deletions
diff --git a/sc/source/core/inc/interpre.hxx b/sc/source/core/inc/interpre.hxx
index 5ac28bc7d6be..6e95f02acffd 100644
--- a/sc/source/core/inc/interpre.hxx
+++ b/sc/source/core/inc/interpre.hxx
@@ -408,6 +408,9 @@ double GetDoubleWithDefault(double nDefault);
bool IsMissing();
/// if GetDouble() not within int32 limits sets nGlobalError and returns 0
sal_Int32 GetInt32();
+/** if GetDoubleWithDefault() not within int32 limits sets nGlobalError and
+ returns nDefault */
+sal_Int32 GetInt32WithDefault( sal_Int32 nDefault );
/// if GetDouble() not within int16 limits sets nGlobalError and returns 0
sal_Int16 GetInt16();
/// if GetDouble() not within uint32 limits sets nGlobalError and returns 0
diff --git a/sc/source/core/tool/interpr4.cxx b/sc/source/core/tool/interpr4.cxx
index 8ac56098ffdd..29881d97b0fb 100644
--- a/sc/source/core/tool/interpr4.cxx
+++ b/sc/source/core/tool/interpr4.cxx
@@ -2104,6 +2104,17 @@ sal_Int32 ScInterpreter::GetInt32()
return static_cast<sal_Int32>(fVal);
}
+sal_Int32 ScInterpreter::GetInt32WithDefault( sal_Int32 nDefault )
+{
+ double fVal = rtl::math::approxFloor( GetDoubleWithDefault( nDefault));
+ if (fVal < SAL_MIN_INT32 || fVal > SAL_MAX_INT32)
+ {
+ SetError( errIllegalArgument);
+ return nDefault;
+ }
+ return static_cast<sal_Int32>(fVal);
+}
+
sal_Int16 ScInterpreter::GetInt16()
{
double fVal = rtl::math::approxFloor( GetDouble());