sc/source/core/inc/interpre.hxx | 2 +- sc/source/core/tool/interpr2.cxx | 4 ++-- sc/source/core/tool/interpr3.cxx | 16 ++++++++++------ sc/source/core/tool/interpr5.cxx | 6 +++--- 4 files changed, 16 insertions(+), 12 deletions(-)
New commits: commit 75bde904d5b4f756037889f2b2ddee3e34dd81b8 Author: Winfried Donkers <winfrieddonk...@libreoffice.org> Date: Tue Sep 15 09:39:25 2015 +0200 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 <c...@libreoffice.org> Reviewed-by: Eike Rathke <er...@redhat.com> Tested-by: Eike Rathke <er...@redhat.com> diff --git a/sc/source/core/inc/interpre.hxx b/sc/source/core/inc/interpre.hxx index 7367ea7..f11182a 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 0596782..a1cce0f 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 3fad7e7..6d27e3b 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 6861e93..8cb115c 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) _______________________________________________ Libreoffice-commits mailing list libreoffice-comm...@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/libreoffice-commits