summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorWinfried Donkers <winfrieddonkers@libreoffice.org>2015-09-15 09:39:25 +0200
committerEike Rathke <erack@redhat.com>2015-09-15 15:14:47 +0000
commit75bde904d5b4f756037889f2b2ddee3e34dd81b8 (patch)
tree865a42c00fa6918fd705586460296b2c998dea38
parentd8f78d624b779244f5953fd32960c4f487e320d3 (diff)
tdf#94079 allow empty array for holiday sequence
in Calc functions NETWORKDAYS and WORKDAY.INTL Change-Id: I2d42ab956e4ab9f2187a0c6bc3c64c9306ca892a Reviewed-on: https://gerrit.libreoffice.org/18559 Tested-by: Jenkins <ci@libreoffice.org> Reviewed-by: Eike Rathke <erack@redhat.com> Tested-by: Eike Rathke <erack@redhat.com>
-rw-r--r--sc/source/core/inc/interpre.hxx2
-rw-r--r--sc/source/core/tool/interpr2.cxx4
-rw-r--r--sc/source/core/tool/interpr3.cxx16
-rw-r--r--sc/source/core/tool/interpr5.cxx6
4 files changed, 16 insertions, 12 deletions
diff --git a/sc/source/core/inc/interpre.hxx b/sc/source/core/inc/interpre.hxx
index 7367ea7489b9..f11182a60657 100644
--- a/sc/source/core/inc/interpre.hxx
+++ b/sc/source/core/inc/interpre.hxx
@@ -821,7 +821,7 @@ double GetMedian( ::std::vector<double> & rArray );
double GetPercentile( ::std::vector<double> & rArray, double fPercentile );
double GetPercentileExclusive( ::std::vector<double> & rArray, double fPercentile );
void GetNumberSequenceArray( sal_uInt8 nParamCount, ::std::vector<double>& rArray, bool bConvertTextInArray );
-void GetSortArray( sal_uInt8 nParamCount, ::std::vector<double>& rSortArray, ::std::vector<long>* pIndexOrder, bool bConvertTextInArray );
+void GetSortArray( sal_uInt8 nParamCount, ::std::vector<double>& rSortArray, ::std::vector<long>* pIndexOrder, bool bConvertTextInArray, bool bAllowEmptyArray );
static void QuickSort(::std::vector<double>& rSortArray, ::std::vector<long>* pIndexOrder = NULL);
void ScModalValue();
void ScModalValue_Multi();
diff --git a/sc/source/core/tool/interpr2.cxx b/sc/source/core/tool/interpr2.cxx
index 059678281e35..a1cce0f4822c 100644
--- a/sc/source/core/tool/interpr2.cxx
+++ b/sc/source/core/tool/interpr2.cxx
@@ -277,7 +277,7 @@ sal_uInt16 ScInterpreter::GetWeekendAndHolidayMasks(
if ( nParamCount >= 3 )
{
- GetSortArray( 1, rSortArray, NULL, false );
+ GetSortArray( 1, rSortArray, NULL, false, true );
size_t nMax = rSortArray.size();
for ( size_t i = 0; i < nMax; i++ )
rSortArray.at( i ) = ::rtl::math::approxFloor( rSortArray.at( i ) ) + nNullDate;
@@ -294,7 +294,7 @@ sal_uInt16 ScInterpreter::GetWeekendAndHolidayMasks_MS(
OUString aWeekendDays;
if ( nParamCount == 4 )
{
- GetSortArray( 1, rSortArray, NULL, true );
+ GetSortArray( 1, rSortArray, NULL, true, true );
size_t nMax = rSortArray.size();
for ( size_t i = 0; i < nMax; i++ )
rSortArray.at( i ) = ::rtl::math::approxFloor( rSortArray.at( i ) ) + nNullDate;
diff --git a/sc/source/core/tool/interpr3.cxx b/sc/source/core/tool/interpr3.cxx
index 3fad7e760859..6d27e3b1b978 100644
--- a/sc/source/core/tool/interpr3.cxx
+++ b/sc/source/core/tool/interpr3.cxx
@@ -3463,7 +3463,7 @@ void ScInterpreter::ScModalValue()
if ( !MustHaveParamCountMin( nParamCount, 1 ) )
return;
vector<double> aSortArray;
- GetSortArray( nParamCount, aSortArray, NULL, false );
+ GetSortArray( nParamCount, aSortArray, NULL, false, false );
SCSIZE nSize = aSortArray.size();
if (aSortArray.empty() || nSize == 0 || nGlobalError)
PushNoValue();
@@ -3549,7 +3549,7 @@ void ScInterpreter::ScPercentrank( bool bInclusive )
double fSignificance = ( nParamCount == 3 ? ::rtl::math::approxFloor( GetDouble() ) : 3.0 );
double fNum = GetDouble();
vector<double> aSortArray;
- GetSortArray( 1, aSortArray, NULL, false );
+ GetSortArray( 1, aSortArray, NULL, false, false );
SCSIZE nSize = aSortArray.size();
if ( aSortArray.empty() || nSize == 0 || nGlobalError )
PushNoValue();
@@ -3642,7 +3642,7 @@ void ScInterpreter::ScTrimMean()
return;
}
vector<double> aSortArray;
- GetSortArray( 1, aSortArray, NULL, false );
+ GetSortArray( 1, aSortArray, NULL, false, false );
SCSIZE nSize = aSortArray.size();
if (aSortArray.empty() || nSize == 0 || nGlobalError)
PushNoValue();
@@ -3781,13 +3781,17 @@ void ScInterpreter::GetNumberSequenceArray( sal_uInt8 nParamCount, vector<double
PopError();
}
-void ScInterpreter::GetSortArray( sal_uInt8 nParamCount, vector<double>& rSortArray, vector<long>* pIndexOrder, bool bConvertTextInArray )
+void ScInterpreter::GetSortArray( sal_uInt8 nParamCount, vector<double>& rSortArray, vector<long>* pIndexOrder, bool bConvertTextInArray, bool bAllowEmptyArray )
{
GetNumberSequenceArray( nParamCount, rSortArray, bConvertTextInArray );
if (rSortArray.size() > MAX_ANZ_DOUBLE_FOR_SORT)
SetError( errStackOverflow);
- else if (rSortArray.empty())
+ else if ( rSortArray.empty() )
+ {
+ if ( bAllowEmptyArray )
+ return;
SetError( errNoValue);
+ }
if (nGlobalError == 0)
QuickSort( rSortArray, pIndexOrder);
@@ -3883,7 +3887,7 @@ void ScInterpreter::ScRank( bool bAverage )
bAscending = false;
vector<double> aSortArray;
- GetSortArray( 1, aSortArray, NULL, false );
+ GetSortArray( 1, aSortArray, NULL, false, false );
double fVal = GetDouble();
SCSIZE nSize = aSortArray.size();
if ( aSortArray.empty() || nSize == 0 || nGlobalError )
diff --git a/sc/source/core/tool/interpr5.cxx b/sc/source/core/tool/interpr5.cxx
index 6861e93f9969..8cb115cdef7d 100644
--- a/sc/source/core/tool/interpr5.cxx
+++ b/sc/source/core/tool/interpr5.cxx
@@ -837,7 +837,7 @@ void ScInterpreter::ScModalValue_Multi()
if ( !MustHaveParamCountMin( nParamCount, 1 ) )
return;
vector<double> aSortArray;
- GetSortArray( nParamCount, aSortArray, NULL, false );
+ GetSortArray( nParamCount, aSortArray, NULL, false, false );
SCSIZE nSize = aSortArray.size();
if ( aSortArray.empty() || nSize == 0 || nGlobalError )
PushNoValue();
@@ -1804,7 +1804,7 @@ void ScInterpreter::ScFrequency()
vector<double> aBinArray;
vector<long> aBinIndexOrder;
- GetSortArray( 1, aBinArray, &aBinIndexOrder, false );
+ GetSortArray( 1, aBinArray, &aBinIndexOrder, false, false );
SCSIZE nBinSize = aBinArray.size();
if (nGlobalError)
{
@@ -1813,7 +1813,7 @@ void ScInterpreter::ScFrequency()
}
vector<double> aDataArray;
- GetSortArray( 1, aDataArray, NULL, false );
+ GetSortArray( 1, aDataArray, NULL, false, false );
SCSIZE nDataSize = aDataArray.size();
if (aDataArray.empty() || nGlobalError)