sc/source/core/inc/interpre.hxx | 1 + sc/source/core/tool/interpr2.cxx | 15 +-------------- sc/source/core/tool/interpr4.cxx | 5 +++++ 3 files changed, 7 insertions(+), 14 deletions(-)
New commits: commit 1acf329e7f0501549e8882952ecffc43abc41521 Author: Mike Kaganski <mike.kagan...@collabora.com> AuthorDate: Wed Feb 5 11:49:10 2025 +0500 Commit: Mike Kaganski <mike.kagan...@collabora.com> CommitDate: Sat Feb 15 14:13:21 2025 +0100 Introduce GetInt16WithDefault, and use in ScGetWeekOfYear to simplify Change-Id: I29b91222d653d28e1d6cb853d815d7bea2c8bedd Reviewed-on: https://gerrit.libreoffice.org/c/core/+/181699 Reviewed-by: Mike Kaganski <mike.kagan...@collabora.com> Tested-by: Jenkins diff --git a/sc/source/core/inc/interpre.hxx b/sc/source/core/inc/interpre.hxx index 8173b6742720..11394bede166 100644 --- a/sc/source/core/inc/interpre.hxx +++ b/sc/source/core/inc/interpre.hxx @@ -498,6 +498,7 @@ private: sal_Int32 GetFloor32(); /** if GetDouble() not within int16 limits sets nGlobalError and returns SAL_MAX_INT16 */ sal_Int16 GetInt16(); + sal_Int16 GetInt16WithDefault(sal_Int16 nDefault); /** if GetDouble() not within uint32 limits sets nGlobalError and returns SAL_MAX_UINT32 */ sal_uInt32 GetUInt32(); bool GetBool() { return GetDouble() != 0.0; } diff --git a/sc/source/core/tool/interpr2.cxx b/sc/source/core/tool/interpr2.cxx index 8aa2883b4027..85e4cec75c21 100644 --- a/sc/source/core/tool/interpr2.cxx +++ b/sc/source/core/tool/interpr2.cxx @@ -253,20 +253,7 @@ void ScInterpreter::ScGetWeekOfYear() if ( !MustHaveParamCount( nParamCount, 1, 2 ) ) return; - sal_Int16 nFlag; - if (nParamCount == 1) - { - nFlag = 1; - } - else if (GetRawStackType() == svMissing) - { - nFlag = 1; - Pop(); - } - else - { - nFlag = GetInt16(); - } + sal_Int16 nFlag = (nParamCount == 1) ? 1 : GetInt16WithDefault(1); Date aDate = mrContext.NFGetNullDate(); aDate.AddDays( GetFloor32()); diff --git a/sc/source/core/tool/interpr4.cxx b/sc/source/core/tool/interpr4.cxx index 814fe288d5bc..f5a399bd8bca 100644 --- a/sc/source/core/tool/interpr4.cxx +++ b/sc/source/core/tool/interpr4.cxx @@ -2258,6 +2258,11 @@ sal_Int16 ScInterpreter::GetInt16() return double_to<sal_Int16>(GetDouble()); } +sal_Int16 ScInterpreter::GetInt16WithDefault(sal_Int16 nDefault) +{ + return double_to<sal_Int16>(GetDoubleWithDefault(nDefault)); +} + sal_uInt32 ScInterpreter::GetUInt32() { return double_to<sal_uInt32>(GetDouble());