sc/qa/unit/data/contentCSV/statistical-functions.csv | 6 +++--- sc/qa/unit/data/ods/functions.ods |binary sc/source/core/tool/interpr3.cxx | 8 ++++++-- 3 files changed, 9 insertions(+), 5 deletions(-)
New commits: commit 74d39f5cff324d76092268418028bd882d8a4d60 Author: Eike Rathke <er...@redhat.com> AuthorDate: Thu Apr 6 14:41:39 2023 +0200 Commit: Eike Rathke <er...@redhat.com> CommitDate: Thu Apr 6 16:58:12 2023 +0200 Resolves: tdf#154627 RANK() query value not in data must return error For all RANK(), RANK.EQ(), RANK.AVG(). Also, use #N/A NotAvailable instead of #VALUE! NoValue. This made it necessary to adapt sc/qa/unit/data/ods/functions.ods and result check that had a totally senseless query value with arbitrary results. Change-Id: If835b5ed49caf16a813b4ea897e1d7dd1aa02954 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/150067 Reviewed-by: Eike Rathke <er...@redhat.com> Tested-by: Jenkins diff --git a/sc/qa/unit/data/contentCSV/statistical-functions.csv b/sc/qa/unit/data/contentCSV/statistical-functions.csv index 2e3c45cdb4a3..b9dbe2f2fbd9 100644 --- a/sc/qa/unit/data/contentCSV/statistical-functions.csv +++ b/sc/qa/unit/data/contentCSV/statistical-functions.csv @@ -117,9 +117,9 @@ 1 -0.1225598712 -0.1363480926 -2 -9 -2 +10 +11 +10 0.5,0.1 121,216 120 diff --git a/sc/qa/unit/data/ods/functions.ods b/sc/qa/unit/data/ods/functions.ods index 04c6e6ed1274..1ef3a7217b34 100644 Binary files a/sc/qa/unit/data/ods/functions.ods and b/sc/qa/unit/data/ods/functions.ods differ diff --git a/sc/source/core/tool/interpr3.cxx b/sc/source/core/tool/interpr3.cxx index 0153ee612e1c..88b32b44af1e 100644 --- a/sc/source/core/tool/interpr3.cxx +++ b/sc/source/core/tool/interpr3.cxx @@ -4254,7 +4254,7 @@ void ScInterpreter::ScRank( bool bAverage ) else { if ( fVal < aSortArray[ 0 ] || fVal > aSortArray[ nSize - 1 ] ) - PushNoValue(); + PushError( FormulaError::NotAvailable); else { double fLastPos = 0; @@ -4279,7 +4279,11 @@ void ScInterpreter::ScRank( bool bAverage ) } if ( !bFinished ) fLastPos = i; - if ( !bAverage ) + if (fFirstPos <= 0) + { + PushError( FormulaError::NotAvailable); + } + else if ( !bAverage ) { if ( bAscending ) PushDouble( fFirstPos );