chart2/source/view/axes/DateScaling.cxx |   55 +++++++++++++++-----------------
 1 file changed, 27 insertions(+), 28 deletions(-)

New commits:
commit 5b7a32ac6e39d2c5991ee2fbdcf7d40556747578
Author:     Noel Grandin <noel.gran...@collabora.co.uk>
AuthorDate: Tue Jan 11 11:20:45 2022 +0200
Commit:     Noel Grandin <noel.gran...@collabora.co.uk>
CommitDate: Tue Jan 11 13:59:43 2022 +0100

    skip unnecessary in DateScaling::doScaling
    
    when the timeunit is DAY, we don't need to do the AddDays thing
    
    Change-Id: Ie06c50dbb8b315e604f19e341bcdd88c75481a90
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/128282
    Tested-by: Jenkins
    Reviewed-by: Noel Grandin <noel.gran...@collabora.co.uk>

diff --git a/chart2/source/view/axes/DateScaling.cxx 
b/chart2/source/view/axes/DateScaling.cxx
index 6f352c486517..15cb59635d69 100644
--- a/chart2/source/view/axes/DateScaling.cxx
+++ b/chart2/source/view/axes/DateScaling.cxx
@@ -58,36 +58,35 @@ double SAL_CALL DateScaling::doScaling( double value )
     double fResult(value);
     if( std::isnan( value ) || std::isinf( value ) )
         return std::numeric_limits<double>::quiet_NaN();
-    else
+    switch( m_nTimeUnit )
     {
-        Date aDate(m_aNullDate);
-        aDate.AddDays(::rtl::math::approxFloor(value));
-        switch( m_nTimeUnit )
+        case DAY:
+            fResult = value;
+            if(m_bShifted)
+                fResult+=0.5;
+            break;
+        case YEAR:
+        case MONTH:
+        default:
         {
-            case DAY:
-                fResult = value;
-                if(m_bShifted)
-                    fResult+=0.5;
-                break;
-            case YEAR:
-            case MONTH:
-            default:
-                fResult = aDate.GetYear();
-                fResult *= lcl_fNumberOfMonths;//assuming equal count of 
months in each year
-                fResult += aDate.GetMonth();
-
-                double fDayOfMonth = aDate.GetDay();
-                fDayOfMonth -= 1.0;
-                double fDaysInMonth = aDate.GetDaysInMonth();
-                fResult += fDayOfMonth/fDaysInMonth;
-                if(m_bShifted)
-                {
-                    if( m_nTimeUnit==YEAR )
-                        fResult += 0.5*lcl_fNumberOfMonths;
-                    else
-                        fResult += 0.5;
-                }
-                break;
+            Date aDate(m_aNullDate);
+            aDate.AddDays(::rtl::math::approxFloor(value));
+            fResult = aDate.GetYear();
+            fResult *= lcl_fNumberOfMonths;//assuming equal count of months in 
each year
+            fResult += aDate.GetMonth();
+
+            double fDayOfMonth = aDate.GetDay();
+            fDayOfMonth -= 1.0;
+            double fDaysInMonth = aDate.GetDaysInMonth();
+            fResult += fDayOfMonth/fDaysInMonth;
+            if(m_bShifted)
+            {
+                if( m_nTimeUnit==YEAR )
+                    fResult += 0.5*lcl_fNumberOfMonths;
+                else
+                    fResult += 0.5;
+            }
+            break;
         }
     }
     return fResult;

Reply via email to