[Libreoffice-commits] core.git: Branch 'libreoffice-5-1' - chart2/source
David Tardon
dtardon at redhat.com
Wed May 18 19:30:57 UTC 2016
chart2/source/view/charttypes/BarChart.cxx | 9 +++++++--
chart2/source/view/charttypes/VSeriesPlotter.cxx | 11 +++++++++--
2 files changed, 16 insertions(+), 4 deletions(-)
New commits:
commit cb91beeb29ba27afe29b02711e942818017bab3c
Author: David Tardon <dtardon at redhat.com>
Date: Fri May 13 16:34:09 2016 +0200
tdf#35957 check for preconditions earlier
This cuts the number of calls of
chart::VSeriesPlotter::calculateYMinAndMaxForCategory from ~10 billion
to 1760 and load time from a minute to a second...
Change-Id: I8ec07d82aa0e915659ce4cbdf6cd1bdd381d6245
(cherry picked from commit 07794b4c221dceb06da4d4b3fd7e3678457663af)
Reviewed-on: https://gerrit.libreoffice.org/24977
Tested-by: Jenkins <ci at libreoffice.org>
Reviewed-by: Markus Mohrhard <markus.mohrhard at googlemail.com>
diff --git a/chart2/source/view/charttypes/BarChart.cxx b/chart2/source/view/charttypes/BarChart.cxx
index cd2019e..048fd0c 100644
--- a/chart2/source/view/charttypes/BarChart.cxx
+++ b/chart2/source/view/charttypes/BarChart.cxx
@@ -468,6 +468,10 @@ void BarChart::createShapes()
if( aLogicYSumMap.find(nAttachedAxisIndex)==aLogicYSumMap.end() )
aLogicYSumMap[nAttachedAxisIndex]=0.0;
+ const sal_Int32 nSlotPoints = aXSlotIter->getPointCount();
+ if( nPointIndex >= nSlotPoints )
+ continue;
+
double fMinimumY = 0.0, fMaximumY = 0.0;
aXSlotIter->calculateYMinAndMaxForCategory( nPointIndex
, isSeparateStackingForDifferentSigns( 1 ), fMinimumY, fMaximumY, nAttachedAxisIndex );
@@ -510,8 +514,9 @@ void BarChart::createShapes()
// get distance from base value to maximum and minimum
double fMinimumY = 0.0, fMaximumY = 0.0;
- aXSlotIter->calculateYMinAndMaxForCategory( nPointIndex
- , isSeparateStackingForDifferentSigns( 1 ), fMinimumY, fMaximumY, nAttachedAxisIndex );
+ if( nPointIndex < aXSlotIter->getPointCount())
+ aXSlotIter->calculateYMinAndMaxForCategory( nPointIndex
+ , isSeparateStackingForDifferentSigns( 1 ), fMinimumY, fMaximumY, nAttachedAxisIndex );
double fLogicPositiveYSum = 0.0;
if( !::rtl::math::isNan( fMaximumY ) )
diff --git a/chart2/source/view/charttypes/VSeriesPlotter.cxx b/chart2/source/view/charttypes/VSeriesPlotter.cxx
index 4ed9bdc..f8206ab 100644
--- a/chart2/source/view/charttypes/VSeriesPlotter.cxx
+++ b/chart2/source/view/charttypes/VSeriesPlotter.cxx
@@ -1847,11 +1847,13 @@ void VDataSeriesGroup::calculateYMinAndMaxForCategory( sal_Int32 nCategoryIndex
, bool bSeparateStackingForDifferentSigns
, double& rfMinimumY, double& rfMaximumY, sal_Int32 nAxisIndex )
{
+ assert(nCategoryIndex >= 0);
+ assert(nCategoryIndex < getPointCount());
+
::rtl::math::setInf(&rfMinimumY, false);
::rtl::math::setInf(&rfMaximumY, true);
- sal_Int32 nPointCount = getPointCount();//necessary to create m_aListOfCachedYValues
- if(nCategoryIndex<0 || nCategoryIndex>=nPointCount || m_aSeriesVector.empty())
+ if(m_aSeriesVector.empty())
return;
CachedYValues aCachedYValues = m_aListOfCachedYValues[nCategoryIndex][nAxisIndex];
@@ -1945,6 +1947,11 @@ void VDataSeriesGroup::calculateYMinAndMaxForCategoryRange(
//iterate through the given categories
if(nStartCategoryIndex<0)
nStartCategoryIndex=0;
+ const sal_Int32 nPointCount = getPointCount();//necessary to create m_aListOfCachedYValues
+ if(nPointCount <= 0)
+ return;
+ if (nEndCategoryIndex >= nPointCount)
+ nEndCategoryIndex = nPointCount - 1;
if(nEndCategoryIndex<0)
nEndCategoryIndex=0;
for( sal_Int32 nCatIndex = nStartCategoryIndex; nCatIndex <= nEndCategoryIndex; nCatIndex++ )
More information about the Libreoffice-commits
mailing list