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 04ef6cf59052010cb6103e260dff6367b634acd8
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>
    (cherry picked from commit 75bde904d5b4f756037889f2b2ddee3e34dd81b8)
    Reviewed-on: https://gerrit.libreoffice.org/18595

diff --git a/sc/source/core/inc/interpre.hxx b/sc/source/core/inc/interpre.hxx
index f804052..efa11d1 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 9df3a90..84a5bff 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 47ac91e..066394d 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 c0606a9..6616c2d 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)
_______________________________________________
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/libreoffice-commits

Reply via email to