From 9625db65446711044e364443b5afbdbb09283055 Mon Sep 17 00:00:00 2001 From: Noel Grandin Date: Wed, 16 Feb 2022 15:38:19 +0200 Subject: simplify some vector construction Change-Id: I0bd131066f5d70fb1dc1c4f851d4d6059994a6f8 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/130002 Tested-by: Jenkins Reviewed-by: Noel Grandin --- chart2/source/view/charttypes/BarChart.cxx | 20 ++++++++++---------- chart2/source/view/charttypes/CandleStickChart.cxx | 8 ++++---- chart2/source/view/charttypes/VSeriesPlotter.cxx | 5 +---- 3 files changed, 15 insertions(+), 18 deletions(-) (limited to 'chart2/source/view/charttypes') diff --git a/chart2/source/view/charttypes/BarChart.cxx b/chart2/source/view/charttypes/BarChart.cxx index c09548e5f17e..817a29fd06ec 100644 --- a/chart2/source/view/charttypes/BarChart.cxx +++ b/chart2/source/view/charttypes/BarChart.cxx @@ -900,18 +900,18 @@ void BarChart::doXSlot( } else //m_nDimension!=3 { - // performance improvement: alloc the sequence before the rendering - // otherwise we have 2 realloc calls - std::vector> aPoly; - aPoly.resize(1); drawing::Position3D aLeftUpperPoint( fLogicX-fLogicBarWidth/2.0,fUpperYValue,fLogicZ ); drawing::Position3D aRightUpperPoint( fLogicX+fLogicBarWidth/2.0,fUpperYValue,fLogicZ ); - - AddPointToPoly( aPoly, drawing::Position3D( fLogicX-fLogicBarWidth/2.0,fLowerYValue,fLogicZ) ); - AddPointToPoly( aPoly, drawing::Position3D( fLogicX+fLogicBarWidth/2.0,fLowerYValue,fLogicZ) ); - AddPointToPoly( aPoly, aRightUpperPoint ); - AddPointToPoly( aPoly, aLeftUpperPoint ); - AddPointToPoly( aPoly, drawing::Position3D( fLogicX-fLogicBarWidth/2.0,fLowerYValue,fLogicZ) ); + std::vector> aPoly + { + { // inner vector + drawing::Position3D( fLogicX-fLogicBarWidth/2.0,fLowerYValue,fLogicZ), + drawing::Position3D( fLogicX+fLogicBarWidth/2.0,fLowerYValue,fLogicZ), + aRightUpperPoint, + aLeftUpperPoint, + drawing::Position3D( fLogicX-fLogicBarWidth/2.0,fLowerYValue,fLogicZ) + } + }; pPosHelper->transformScaledLogicToScene( aPoly ); xShape = ShapeFactory::createArea2D( xSeriesGroupShape_Shapes, aPoly ); PropertyMapper::setMappedProperties( *xShape, xDataPointProperties, PropertyMapper::getPropertyNameMapForFilledSeriesProperties() ); diff --git a/chart2/source/view/charttypes/CandleStickChart.cxx b/chart2/source/view/charttypes/CandleStickChart.cxx index f1b11492ee60..5c8497a5d4b2 100644 --- a/chart2/source/view/charttypes/CandleStickChart.cxx +++ b/chart2/source/view/charttypes/CandleStickChart.cxx @@ -216,10 +216,10 @@ void CandleStickChart::createShapes() //create min-max line if( isValidPosition(aPosMiddleMinimum) && isValidPosition(aPosMiddleMaximum) ) { - std::vector> aPoly; - sal_Int32 nLineIndex =0; - AddPointToPoly( aPoly, aPosMiddleMinimum, nLineIndex); - AddPointToPoly( aPoly, aPosMiddleMaximum, nLineIndex); + std::vector> aPoly + { + { aPosMiddleMinimum, aPosMiddleMaximum } + }; rtl::Reference xShape = ShapeFactory::createLine2D( xPointGroupShape_Shapes, aPoly); diff --git a/chart2/source/view/charttypes/VSeriesPlotter.cxx b/chart2/source/view/charttypes/VSeriesPlotter.cxx index e2a4d07cd3c7..50bff922f861 100644 --- a/chart2/source/view/charttypes/VSeriesPlotter.cxx +++ b/chart2/source/view/charttypes/VSeriesPlotter.cxx @@ -1091,10 +1091,7 @@ void VSeriesPlotter::addErrorBorder( ,const rtl::Reference& rTarget ,const uno::Reference< beans::XPropertySet >& rErrorBorderProp ) { - std::vector> aPoly; - sal_Int32 nSequenceIndex = 0; - AddPointToPoly( aPoly, rPos0, nSequenceIndex ); - AddPointToPoly( aPoly, rPos1, nSequenceIndex ); + std::vector> aPoly { { rPos0, rPos1} }; rtl::Reference xShape = ShapeFactory::createLine2D( rTarget, aPoly ); PropertyMapper::setMappedProperties( *xShape, rErrorBorderProp, -- cgit