[Libreoffice-commits] core.git: sc/source

Winfried Donkers winfrieddonkers at libreoffice.org
Thu Oct 13 18:58:29 UTC 2016


 sc/source/core/tool/interpr8.cxx |   37 +++++++++++++------------------------
 1 file changed, 13 insertions(+), 24 deletions(-)

New commits:
commit ad707a3dafd020949cfd94098dc51c69466dafb8
Author: Winfried Donkers <winfrieddonkers at libreoffice.org>
Date:   Tue Sep 20 08:04:50 2016 +0200

    tdf#94635 follow up; correct handling of double x-values in case of
    
    month intervals.
    
    Change-Id: I310d8d127d6b9ca571200ba8974a980430d69eb7
    Reviewed-on: https://gerrit.libreoffice.org/29076
    Tested-by: Jenkins <ci at libreoffice.org>
    Reviewed-by: Eike Rathke <erack at redhat.com>

diff --git a/sc/source/core/tool/interpr8.cxx b/sc/source/core/tool/interpr8.cxx
index 894c623..5f98f26 100644
--- a/sc/source/core/tool/interpr8.cxx
+++ b/sc/source/core/tool/interpr8.cxx
@@ -221,16 +221,14 @@ bool ScETSForecastCalculation::PreprocessDataRange( const ScMatrixRef& rMatX, co
     mfStepSize = ::std::numeric_limits<double>::max();
     if ( mnMonthDay )
     {
-        aDate = aNullDate + static_cast< long >( maRange[ 0 ].X );
-        maRange[ 0 ].X = aDate.GetYear() * 12 + aDate.GetMonth();
-    }
-    for ( SCSIZE i = 1; i < mnCount; i++ )
-    {
-        if ( mnMonthDay )
+        for ( SCSIZE i = 0; i < mnCount; i++ )
         {
             aDate = aNullDate + static_cast< long >( maRange[ i ].X );
             maRange[ i ].X = aDate.GetYear() * 12 + aDate.GetMonth();
         }
+    }
+    for ( SCSIZE i = 1; i < mnCount; i++ )
+    {
         double fStep = maRange[ i ].X - maRange[ i - 1 ].X;
         if ( fStep == 0.0 )
         {
@@ -245,15 +243,20 @@ bool ScETSForecastCalculation::PreprocessDataRange( const ScMatrixRef& rMatX, co
             switch ( nAggregation )
             {
                 case 1 : // AVERAGE (default)
+                         while ( maRange[ i ].X == maRange[ i - 1 ].X  && i < mnCount )
+                         {
+                             maRange.erase( maRange.begin() + i );
+                             --mnCount;
+                         }
+                         break;
                 case 7 : // SUM
                          while ( maRange[ i ].X == maRange[ i - 1 ].X  && i < mnCount )
                          {
                              fTmp += maRange[ i ].Y;
-                             nCounter++;
                              maRange.erase( maRange.begin() + i );
                              --mnCount;
                          }
-                         maRange[ i - 1 ].Y = ( nAggregation == 1 ? fTmp / nCounter : fTmp );
+                         maRange[ i - 1 ].Y = fTmp;
                          break;
 
                 case 2 : // COUNT
@@ -310,22 +313,11 @@ bool ScETSForecastCalculation::PreprocessDataRange( const ScMatrixRef& rMatX, co
                          break;
             }
             if ( i < mnCount - 1 )
-            {
-                i++;
-                if ( mnMonthDay )
-                {
-                    Date aDate1 = aNullDate + static_cast< long >( maRange[ i ].X );
-                    fStep = 12 * ( aDate1.GetYear() - aDate.GetYear() ) +
-                            ( aDate1.GetMonth() - aDate.GetMonth() );
-                    aDate = aDate1;
-                }
-                else
-                    fStep = maRange[ i ].X - maRange[ i - 1 ].X;
-            }
+                fStep = maRange[ i ].X - maRange[ i - 1 ].X;
             else
                fStep = mfStepSize;
         }
-        if ( fStep < mfStepSize )
+        if ( fStep > 0 && fStep < mfStepSize )
             mfStepSize = fStep;
     }
 
@@ -972,9 +964,6 @@ bool ScETSForecastCalculation::GetStatisticValue( const ScMatrixRef& rTypeMat, c
 
 bool ScETSForecastCalculation::GetSamplesInPeriod( double& rVal )
 {
-    if ( !initCalc() )
-        return false;
-
     rVal = mnSmplInPrd;
     return true;
 }


More information about the Libreoffice-commits mailing list