summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNoel Grandin <noel.grandin@collabora.co.uk>2022-01-11 11:20:45 +0200
committerNoel Grandin <noel.grandin@collabora.co.uk>2022-01-11 13:59:43 +0100
commit5b7a32ac6e39d2c5991ee2fbdcf7d40556747578 (patch)
treeb70f922ed78b96373f2970f3d552fcc8918d9135
parenta67b622ce51b4a8d0d36a62e4749f4ed0f17cfd2 (diff)
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.grandin@collabora.co.uk>
-rw-r--r--chart2/source/view/axes/DateScaling.cxx55
1 files changed, 27 insertions, 28 deletions
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;