From 2fa4b37e8d6d516e9ac9190ee45456534611c3e7 Mon Sep 17 00:00:00 2001 From: Laurent Balland-Poirier Date: Sat, 2 Jan 2016 15:02:00 +0100 Subject: tdf#96807 Reset min/max of auto scale Y minimum for auto scale was accidentaly set to 0. This avoided correct calculation of Y auto log scale (tdf#96807) But also set linear Y auto scale from 0 (tdf#85690) This fix detects if both min and max are equal to 0, and reset them (+-inf) Change-Id: Ifaf306831f3b5a18a86483c88e807f478b447c77 Reviewed-on: https://gerrit.libreoffice.org/21055 Reviewed-by: jan iversen Tested-by: jan iversen Tested-by: Jenkins (cherry picked from commit 5553d6a9314fd778b9a124d8a2c7e9dd1d7a58a3) Reviewed-on: https://gerrit.libreoffice.org/21278 Reviewed-by: Christian Lohmaier (cherry picked from commit 98982ca06a87e8b63204b0acda2105c66ae57440) Reviewed-on: https://gerrit.libreoffice.org/21459 Reviewed-by: Chris Sherlock --- chart2/source/view/axes/ScaleAutomatism.cxx | 14 ++++++++++++-- chart2/source/view/inc/ScaleAutomatism.hxx | 1 + 2 files changed, 13 insertions(+), 2 deletions(-) diff --git a/chart2/source/view/axes/ScaleAutomatism.cxx b/chart2/source/view/axes/ScaleAutomatism.cxx index f58bde445981..61df0aff8689 100644 --- a/chart2/source/view/axes/ScaleAutomatism.cxx +++ b/chart2/source/view/axes/ScaleAutomatism.cxx @@ -99,8 +99,7 @@ ScaleAutomatism::ScaleAutomatism( const ScaleData& rSourceScale, const Date& rNu , m_nTimeResolution(::com::sun::star::chart::TimeUnit::DAY) , m_aNullDate(rNullDate) { - ::rtl::math::setNan( &m_fValueMinimum ); - ::rtl::math::setNan( &m_fValueMaximum ); + resetValueRange(); double fExplicitOrigin = 0.0; if( m_aSourceScale.Origin >>= fExplicitOrigin ) @@ -110,8 +109,19 @@ ScaleAutomatism::~ScaleAutomatism() { } +void ScaleAutomatism::resetValueRange( ) +{ + ::rtl::math::setNan( &m_fValueMinimum ); + ::rtl::math::setNan( &m_fValueMaximum ); +} + void ScaleAutomatism::expandValueRange( double fMinimum, double fMaximum ) { + // if m_fValueMinimum and m_fValueMaximum == 0, it means that they were not determined. + // m_fValueMinimum == 0 makes impossible to determine real minimum, + // so they need to be reseted tdf#96807 + if( (m_fValueMinimum == 0.0) && (m_fValueMaximum == 0.0) ) + resetValueRange(); if( (fMinimum < m_fValueMinimum) || ::rtl::math::isNan( m_fValueMinimum ) ) m_fValueMinimum = fMinimum; if( (fMaximum > m_fValueMaximum) || ::rtl::math::isNan( m_fValueMaximum ) ) diff --git a/chart2/source/view/inc/ScaleAutomatism.hxx b/chart2/source/view/inc/ScaleAutomatism.hxx index 17370fb4a5da..513cf7d6c456 100644 --- a/chart2/source/view/inc/ScaleAutomatism.hxx +++ b/chart2/source/view/inc/ScaleAutomatism.hxx @@ -53,6 +53,7 @@ public: * undefined (that is empty `uno::Any` objects). */ void expandValueRange( double fMinimum, double fMaximum ); + void resetValueRange(); /** Sets additional auto scaling options. @param bExpandBorderToIncrementRhythm If true, expands automatic -- cgit v1.2.3