summaryrefslogtreecommitdiff
path: root/sc
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:47:23 +0000
commit04ef6cf59052010cb6103e260dff6367b634acd8 (patch)
treed3ece1ecdd760c96c778ae79306b40f1e9c1ea9c /sc
parent3b7ebeb5e7bbbfde0467f043171ab454340eaa0c (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> (cherry picked from commit 75bde904d5b4f756037889f2b2ddee3e34dd81b8) Reviewed-on: https://gerrit.libreoffice.org/18595
Diffstat (limited to 'sc')
-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 f804052c3bbf..efa11d1147ed 100644
--- a/sc/source/core/inc/interpre.hxx
+++ b/sc/source/core/inc/interpre.hxx
@@ -823,7 +823,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 9df3a901f977..84a5bff3d6bc 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 47ac91e2e35b..066394d7180c 100644
--- a/sc/source/core/tool/interpr3.cxx
+++ b/sc/source/core/tool/interpr3.cxx
@@ -3465,7 +3465,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();
@@ -3551,7 +3551,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();
@@ -3644,7 +3644,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();
@@ -3783,13 +3783,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);
@@ -3885,7 +3889,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 c0606a9ef51d..6616c2db0aea 100644
--- a/sc/source/core/tool/interpr5.cxx
+++ b/sc/source/core/tool/interpr5.cxx
@@ -834,7 +834,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();
@@ -1801,7 +1801,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)
{
@@ -1810,7 +1810,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)