[Libreoffice-commits] core.git: Branch 'libreoffice-6-1' - chart2/source

Libreoffice Gerrit user logerrit at kemper.freedesktop.org
Mon Dec 3 10:24:51 UTC 2018


 chart2/source/view/axes/DateHelper.cxx           |    3 +++
 chart2/source/view/charttypes/AreaChart.cxx      |    5 +++++
 chart2/source/view/charttypes/VSeriesPlotter.cxx |    7 +++++++
 3 files changed, 15 insertions(+)

New commits:
commit 0a906dc78b575d696d402fb81900700e6e8e761e
Author:     Markus Mohrhard <markus.mohrhard at googlemail.com>
AuthorDate: Thu Nov 29 19:11:58 2018 +0100
Commit:     Caolán McNamara <caolanm at redhat.com>
CommitDate: Mon Dec 3 11:24:29 2018 +0100

    tdf#42915, NaN in a date axis can destroy the whole chart
    
    The NaN value forces the scaling of the axis to be based on years
    and introduces gaps in the rendering.
    
    Change-Id: I78219be289d76edb53b5672209e1c031ab62def9
    Reviewed-on: https://gerrit.libreoffice.org/64267
    Tested-by: Jenkins
    Reviewed-by: Markus Mohrhard <markus.mohrhard at googlemail.com>
    
    related tdf#42915, pass NaN through date transformation
    
    Many places in chart2 use NaN to mean no available value. Not propagating
    NaN through the helper disables all this functionality.
    
    Change-Id: I37f966007b5b7cc16778c5c6903710fbd144631b
    Reviewed-on: https://gerrit.libreoffice.org/64266
    Tested-by: Jenkins
    Reviewed-by: Markus Mohrhard <markus.mohrhard at googlemail.com>
    Reviewed-on: https://gerrit.libreoffice.org/64304
    (cherry picked from commit 55c5382591305a872b961d54571e3c823728ccb2)
    Reviewed-on: https://gerrit.libreoffice.org/64310
    Reviewed-by: Caolán McNamara <caolanm at redhat.com>
    Tested-by: Caolán McNamara <caolanm at redhat.com>

diff --git a/chart2/source/view/axes/DateHelper.cxx b/chart2/source/view/axes/DateHelper.cxx
index 046760436acd..dfe772e45f66 100644
--- a/chart2/source/view/axes/DateHelper.cxx
+++ b/chart2/source/view/axes/DateHelper.cxx
@@ -69,6 +69,9 @@ bool DateHelper::IsLessThanOneYearAway( const Date& rD1, const Date& rD2 )
 
 double DateHelper::RasterizeDateValue( double fValue, const Date& rNullDate, long TimeResolution )
 {
+    if (rtl::math::isNan(fValue))
+        return fValue;
+
     Date aDate(rNullDate); aDate.AddDays(::rtl::math::approxFloor(fValue));
     switch(TimeResolution)
     {
diff --git a/chart2/source/view/charttypes/AreaChart.cxx b/chart2/source/view/charttypes/AreaChart.cxx
index 2a8d773244e0..186cad53fe73 100644
--- a/chart2/source/view/charttypes/AreaChart.cxx
+++ b/chart2/source/view/charttypes/AreaChart.cxx
@@ -728,7 +728,12 @@ void AreaChart::createShapes()
                     //collect data point information (logic coordinates, style ):
                     double fLogicX = pSeries->getXValue(nIndex);
                     if (bDateCategory)
+                    {
+                        if (rtl::math::isNan(fLogicX))
+                            continue;
+
                         fLogicX = DateHelper::RasterizeDateValue( fLogicX, m_aNullDate, m_nTimeResolution );
+                    }
                     double fLogicY = pSeries->getYValue(nIndex);
 
                     if( m_nDimension==3 && m_bArea && rXSlot.m_aSeriesVector.size()!=1 )
diff --git a/chart2/source/view/charttypes/VSeriesPlotter.cxx b/chart2/source/view/charttypes/VSeriesPlotter.cxx
index ea7d5555c8be..78bc3037d36c 100644
--- a/chart2/source/view/charttypes/VSeriesPlotter.cxx
+++ b/chart2/source/view/charttypes/VSeriesPlotter.cxx
@@ -1460,10 +1460,17 @@ long VSeriesPlotter::calculateTimeResolutionOnXAxis()
         if( !rDateCategories.empty() )
         {
             std::vector< double >::const_iterator aIt = rDateCategories.begin(), aEnd = rDateCategories.end();
+            while (rtl::math::isNan(*aIt) && aIt != aEnd)
+            {
+                ++aIt;
+            }
             Date aPrevious(aNullDate); aPrevious.AddDays(rtl::math::approxFloor(*aIt));
             ++aIt;
             for(;aIt!=aEnd;++aIt)
             {
+                if (rtl::math::isNan(*aIt))
+                    continue;
+
                 Date aCurrent(aNullDate); aCurrent.AddDays(rtl::math::approxFloor(*aIt));
                 if( nRet == css::chart::TimeUnit::YEAR )
                 {


More information about the Libreoffice-commits mailing list