diff options
author | Noel Grandin <noel.grandin@collabora.co.uk> | 2018-06-04 16:19:16 +0200 |
---|---|---|
committer | Noel Grandin <noel.grandin@collabora.co.uk> | 2018-06-11 08:26:56 +0200 |
commit | 0c195667cf9408c489913b7591d16505fc237741 (patch) | |
tree | 1aabe1f103829e00830243a91c1867e1004bc104 /chart2 | |
parent | daa93e62f76a86c66ebaa7e915e1f6fc71ea02e2 (diff) |
loplugin:useuniqueptr in VDataSeriesGroup
Change-Id: Ic2425c3b4068b3ec8ce6ba9f48311c7d2ab6e933
Reviewed-on: https://gerrit.libreoffice.org/55525
Tested-by: Jenkins <ci@libreoffice.org>
Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
Diffstat (limited to 'chart2')
-rw-r--r-- | chart2/source/view/charttypes/AreaChart.cxx | 27 | ||||
-rw-r--r-- | chart2/source/view/charttypes/AreaChart.hxx | 2 | ||||
-rw-r--r-- | chart2/source/view/charttypes/BarChart.cxx | 16 | ||||
-rw-r--r-- | chart2/source/view/charttypes/BarChart.hxx | 2 | ||||
-rw-r--r-- | chart2/source/view/charttypes/BubbleChart.cxx | 10 | ||||
-rw-r--r-- | chart2/source/view/charttypes/CandleStickChart.cxx | 8 | ||||
-rw-r--r-- | chart2/source/view/charttypes/CandleStickChart.hxx | 2 | ||||
-rw-r--r-- | chart2/source/view/charttypes/NetChart.cxx | 24 | ||||
-rw-r--r-- | chart2/source/view/charttypes/PieChart.cxx | 12 | ||||
-rw-r--r-- | chart2/source/view/charttypes/PieChart.hxx | 2 | ||||
-rw-r--r-- | chart2/source/view/charttypes/VSeriesPlotter.cxx | 69 | ||||
-rw-r--r-- | chart2/source/view/inc/VSeriesPlotter.hxx | 9 | ||||
-rw-r--r-- | chart2/source/view/main/ChartView.cxx | 4 |
13 files changed, 95 insertions, 92 deletions
diff --git a/chart2/source/view/charttypes/AreaChart.cxx b/chart2/source/view/charttypes/AreaChart.cxx index 22d952b8eeff..7ecf7e9ebeeb 100644 --- a/chart2/source/view/charttypes/AreaChart.cxx +++ b/chart2/source/view/charttypes/AreaChart.cxx @@ -144,7 +144,7 @@ drawing::Direction3D AreaChart::getPreferredDiagramAspectRatio() const return aRet; } -void AreaChart::addSeries( VDataSeries* pSeries, sal_Int32 zSlot, sal_Int32 xSlot, sal_Int32 ySlot ) +void AreaChart::addSeries( std::unique_ptr<VDataSeries> pSeries, sal_Int32 zSlot, sal_Int32 xSlot, sal_Int32 ySlot ) { if( m_bArea && pSeries ) { @@ -160,7 +160,7 @@ void AreaChart::addSeries( VDataSeries* pSeries, sal_Int32 zSlot, sal_Int32 xSlo xSlot=0; ySlot=0; } - VSeriesPlotter::addSeries( pSeries, zSlot, xSlot, ySlot ); + VSeriesPlotter::addSeries( std::move(pSeries), zSlot, xSlot, ySlot ); } void lcl_removeDuplicatePoints( drawing::PolyPolygonShape3D& rPolyPoly, PlottingPositionHelper& rPosHelper ) @@ -540,7 +540,7 @@ void AreaChart::impl_createSeriesShapes() drawing::PolyPolygonShape3D* pSeriesPoly = nullptr; //iterate through all series - for( VDataSeries* pSeries : rXSlot.m_aSeriesVector ) + for( std::unique_ptr<VDataSeries> const & pSeries : rXSlot.m_aSeriesVector ) { sal_Int32 nAttachedAxisIndex = pSeries->getAttachedAxisIndex(); PlottingPositionHelper* pPosHelper = &(getPlottingPositionHelper( nAttachedAxisIndex )); @@ -554,12 +554,12 @@ void AreaChart::impl_createSeriesShapes() pSeriesPoly = &pSeries->m_aPolyPolygonShape3D; if( m_bArea ) { - if( !impl_createArea( pSeries, pSeriesPoly, aPreviousSeriesPolyMap[nAttachedAxisIndex], pPosHelper ) ) + if( !impl_createArea( pSeries.get(), pSeriesPoly, aPreviousSeriesPolyMap[nAttachedAxisIndex], pPosHelper ) ) continue; } if( m_bLine ) { - if( !impl_createLine( pSeries, pSeriesPoly, pPosHelper ) ) + if( !impl_createLine( pSeries.get(), pSeriesPoly, pPosHelper ) ) continue; } aPreviousSeriesPolyMap[nAttachedAxisIndex] = pSeriesPoly; @@ -586,13 +586,12 @@ void lcl_reorderSeries( std::vector< std::vector< VDataSeriesGroup > >& rZSlots std::vector< VDataSeriesGroup >::reverse_iterator aXIt( aZIt->rbegin() ); std::vector< VDataSeriesGroup >::reverse_iterator aXEnd( aZIt->rend() ); for( ; aXIt != aXEnd; ++aXIt ) - aXSlot.push_back(*aXIt); + aXSlot.push_back(std::move(*aXIt)); - aRet.push_back(aXSlot); + aRet.push_back(std::move(aXSlot)); } - rZSlots.clear(); - rZSlots = aRet; + rZSlots = std::move(aRet); } }//anonymous namespace @@ -664,7 +663,7 @@ void AreaChart::createShapes() //iterate through all x slots in this category to get 100percent sum for( auto const& rXSlot : rZSlot ) { - for( VDataSeries* pSeries : rXSlot.m_aSeriesVector ) + for( std::unique_ptr<VDataSeries> const & pSeries : rXSlot.m_aSeriesVector ) { if(!pSeries) continue; @@ -701,12 +700,12 @@ void AreaChart::createShapes() { std::vector<std::map< sal_Int32, double > > aLogicYForNextSeriesMapByX(nEndIndex); //one for each different nAttachedAxisIndex //iterate through all series - for( VDataSeries* pSeries : rXSlot.m_aSeriesVector ) + for( std::unique_ptr<VDataSeries> const & pSeries : rXSlot.m_aSeriesVector ) { if(!pSeries) continue; - uno::Reference< drawing::XShapes > xSeriesGroupShape_Shapes = getSeriesGroupShapeFrontChild(pSeries, m_xSeriesTarget); + uno::Reference< drawing::XShapes > xSeriesGroupShape_Shapes = getSeriesGroupShapeFrontChild(pSeries.get(), m_xSeriesTarget); sal_Int32 nAttachedAxisIndex = pSeries->getAttachedAxisIndex(); PlottingPositionHelper* pPosHelper = &(getPlottingPositionHelper( nAttachedAxisIndex )); @@ -789,7 +788,7 @@ void AreaChart::createShapes() drawing::Position3D aScenePosition( pPosHelper->transformLogicToScene( fLogicX,fLogicY,fLogicZ, false ) ); //better performance for big data - FormerPoint aFormerPoint( aSeriesFormerPointMap[pSeries] ); + FormerPoint aFormerPoint( aSeriesFormerPointMap[pSeries.get()] ); pPosHelper->setCoordinateSystemResolution( m_aCoordinateSystemResolution ); if( !pSeries->isAttributedDataPoint(nIndex) && @@ -800,7 +799,7 @@ void AreaChart::createShapes() m_bPointsWereSkipped = true; continue; } - aSeriesFormerPointMap[pSeries] = FormerPoint(aScaledLogicPosition.PositionX, aScaledLogicPosition.PositionY, aScaledLogicPosition.PositionZ); + aSeriesFormerPointMap[pSeries.get()] = FormerPoint(aScaledLogicPosition.PositionX, aScaledLogicPosition.PositionY, aScaledLogicPosition.PositionZ); //store point information for series polygon //for area and/or line (symbols only do not need this) diff --git a/chart2/source/view/charttypes/AreaChart.hxx b/chart2/source/view/charttypes/AreaChart.hxx index 119e0a51d5b6..6c8bdba51c09 100644 --- a/chart2/source/view/charttypes/AreaChart.hxx +++ b/chart2/source/view/charttypes/AreaChart.hxx @@ -40,7 +40,7 @@ public: virtual ~AreaChart() override; virtual void createShapes() override; - virtual void addSeries( VDataSeries* pSeries, sal_Int32 zSlot, sal_Int32 xSlot, sal_Int32 ySlot ) override; + virtual void addSeries( std::unique_ptr<VDataSeries> pSeries, sal_Int32 zSlot, sal_Int32 xSlot, sal_Int32 ySlot ) override; virtual css::drawing::Direction3D getPreferredDiagramAspectRatio() const override; diff --git a/chart2/source/view/charttypes/BarChart.cxx b/chart2/source/view/charttypes/BarChart.cxx index ec9940cf6b04..146373edd0b2 100644 --- a/chart2/source/view/charttypes/BarChart.cxx +++ b/chart2/source/view/charttypes/BarChart.cxx @@ -361,7 +361,7 @@ bool lcl_hasGeometry3DVariableWidth( sal_Int32 nGeometry3D ) } }// end anonymous namespace -void BarChart::addSeries( VDataSeries* pSeries, sal_Int32 zSlot, sal_Int32 xSlot, sal_Int32 ySlot ) +void BarChart::addSeries( std::unique_ptr<VDataSeries> pSeries, sal_Int32 zSlot, sal_Int32 xSlot, sal_Int32 ySlot ) { if( !pSeries ) return; @@ -378,7 +378,7 @@ void BarChart::addSeries( VDataSeries* pSeries, sal_Int32 zSlot, sal_Int32 xSlot if(zSlot>=static_cast<sal_Int32>(m_aZSlots.size())) m_aZSlots.resize(zSlot+1); } - VSeriesPlotter::addSeries( pSeries, zSlot, xSlot, ySlot ); + VSeriesPlotter::addSeries( std::move(pSeries), zSlot, xSlot, ySlot ); } //better performance for big data @@ -601,7 +601,7 @@ void BarChart::createShapes() double fNegativeLogicYForNextSeries = fBaseValue; //iterate through all series in this x slot - for( VDataSeries* pSeries : rXSlot.m_aSeriesVector ) + for( std::unique_ptr<VDataSeries> const & pSeries : rXSlot.m_aSeriesVector ) { if(!pSeries) continue; @@ -629,7 +629,7 @@ void BarChart::createShapes() bDrawConnectionLinesInited = true; } - uno::Reference<drawing::XShapes> xSeriesGroupShape_Shapes(getSeriesGroupShape(pSeries, xSeriesTarget)); + uno::Reference<drawing::XShapes> xSeriesGroupShape_Shapes(getSeriesGroupShape(pSeries.get(), xSeriesTarget)); uno::Reference<drawing::XShape> xSeriesGroupShape(xSeriesGroupShape_Shapes, uno::UNO_QUERY); // Suspend setting rects dirty for the duration of this call aShapeSet.insert(xSeriesGroupShape); @@ -749,7 +749,7 @@ void BarChart::createShapes() } //better performance for big data - FormerBarPoint aFormerPoint( aSeriesFormerPointMap[pSeries] ); + FormerBarPoint aFormerPoint( aSeriesFormerPointMap[pSeries.get()] ); pPosHelper->setCoordinateSystemResolution( m_aCoordinateSystemResolution ); if( !pSeries->isAttributedDataPoint(nPointIndex) && @@ -764,7 +764,7 @@ void BarChart::createShapes() m_bPointsWereSkipped = true; continue; } - aSeriesFormerPointMap[pSeries] = FormerBarPoint(fLogicX,fUpperYValue,fLowerYValue,fLogicZ); + aSeriesFormerPointMap[pSeries.get()] = FormerBarPoint(fLogicX,fUpperYValue,fLowerYValue,fLogicZ); if( bDrawConnectionLines ) { @@ -930,7 +930,7 @@ void BarChart::createShapes() for( auto const& rXSlot : rZSlot ) { //iterate through all series in this x slot - for( VDataSeries* pSeries : rXSlot.m_aSeriesVector ) + for( std::unique_ptr<VDataSeries> const & pSeries : rXSlot.m_aSeriesVector ) { if(!pSeries) continue; @@ -948,7 +948,7 @@ void BarChart::createShapes() pPosHelper->transformScaledLogicToScene( aPoly ); uno::Reference< drawing::XShapes > xSeriesGroupShape_Shapes( - getSeriesGroupShape(pSeries, xSeriesTarget) ); + getSeriesGroupShape(pSeries.get(), xSeriesTarget) ); uno::Reference< drawing::XShape > xShape( m_pShapeFactory->createLine2D( xSeriesGroupShape_Shapes, PolyToPointSequence( aPoly ) ) ); setMappedProperties( xShape, pSeries->getPropertiesOfSeries() diff --git a/chart2/source/view/charttypes/BarChart.hxx b/chart2/source/view/charttypes/BarChart.hxx index c35c7321e8a0..ed4457affb71 100644 --- a/chart2/source/view/charttypes/BarChart.hxx +++ b/chart2/source/view/charttypes/BarChart.hxx @@ -38,7 +38,7 @@ public: virtual ~BarChart() override; virtual void createShapes() override; - virtual void addSeries( VDataSeries* pSeries, sal_Int32 zSlot, sal_Int32 xSlot, sal_Int32 ySlot ) override; + virtual void addSeries( std::unique_ptr<VDataSeries> pSeries, sal_Int32 zSlot, sal_Int32 xSlot, sal_Int32 ySlot ) override; virtual css::drawing::Direction3D getPreferredDiagramAspectRatio() const override; diff --git a/chart2/source/view/charttypes/BubbleChart.cxx b/chart2/source/view/charttypes/BubbleChart.cxx index ffd37cc57097..8036f9e9aa42 100644 --- a/chart2/source/view/charttypes/BubbleChart.cxx +++ b/chart2/source/view/charttypes/BubbleChart.cxx @@ -74,7 +74,7 @@ void BubbleChart::calculateMaximumLogicBubbleSize() { for( auto const& rXSlot : rZSlot ) { - for( VDataSeries* pSeries : rXSlot.m_aSeriesVector ) + for( std::unique_ptr<VDataSeries> const & pSeries : rXSlot.m_aSeriesVector ) { if(!pSeries) continue; @@ -205,7 +205,7 @@ void BubbleChart::createShapes() for( auto const& rXSlot : rZSlot ) { //iterate through all series - for( VDataSeries* pSeries : rXSlot.m_aSeriesVector ) + for( std::unique_ptr<VDataSeries> const & pSeries : rXSlot.m_aSeriesVector ) { if(!pSeries) continue; @@ -213,7 +213,7 @@ void BubbleChart::createShapes() bool bHasFillColorMapping = pSeries->hasPropertyMapping("FillColor"); bool bHasBorderColorMapping = pSeries->hasPropertyMapping("LineColor"); - uno::Reference< drawing::XShapes > xSeriesGroupShape_Shapes = getSeriesGroupShape(pSeries, xSeriesTarget); + uno::Reference< drawing::XShapes > xSeriesGroupShape_Shapes = getSeriesGroupShape(pSeries.get(), xSeriesTarget); sal_Int32 nAttachedAxisIndex = pSeries->getAttachedAxisIndex(); PlottingPositionHelper* pPosHelper = &(getPlottingPositionHelper( nAttachedAxisIndex )); @@ -246,7 +246,7 @@ void BubbleChart::createShapes() drawing::Position3D aScenePosition( pPosHelper->transformLogicToScene( fLogicX,fLogicY,fLogicZ, false ) ); //better performance for big data - FormerPoint aFormerPoint( aSeriesFormerPointMap[pSeries] ); + FormerPoint aFormerPoint( aSeriesFormerPointMap[pSeries.get()] ); pPosHelper->setCoordinateSystemResolution( m_aCoordinateSystemResolution ); if( !pSeries->isAttributedDataPoint(nIndex) && @@ -257,7 +257,7 @@ void BubbleChart::createShapes() m_bPointsWereSkipped = true; continue; } - aSeriesFormerPointMap[pSeries] = FormerPoint(aScaledLogicPosition.PositionX, aScaledLogicPosition.PositionY, aScaledLogicPosition.PositionZ); + aSeriesFormerPointMap[pSeries.get()] = FormerPoint(aScaledLogicPosition.PositionX, aScaledLogicPosition.PositionY, aScaledLogicPosition.PositionZ); //create a single datapoint if point is visible if( !bIsVisible ) diff --git a/chart2/source/view/charttypes/CandleStickChart.cxx b/chart2/source/view/charttypes/CandleStickChart.cxx index 3b8bfd338a1d..201aeafc928a 100644 --- a/chart2/source/view/charttypes/CandleStickChart.cxx +++ b/chart2/source/view/charttypes/CandleStickChart.cxx @@ -67,10 +67,10 @@ drawing::Direction3D CandleStickChart::getPreferredDiagramAspectRatio() const return drawing::Direction3D(-1,-1,-1); } -void CandleStickChart::addSeries( VDataSeries* pSeries, sal_Int32 /* zSlot */, sal_Int32 xSlot, sal_Int32 ySlot ) +void CandleStickChart::addSeries( std::unique_ptr<VDataSeries> pSeries, sal_Int32 /* zSlot */, sal_Int32 xSlot, sal_Int32 ySlot ) { //ignore y stacking for candle stick chart - VSeriesPlotter::addSeries( pSeries, 0, xSlot, ySlot ); + VSeriesPlotter::addSeries( std::move(pSeries), 0, xSlot, ySlot ); } void CandleStickChart::createShapes() @@ -159,7 +159,7 @@ void CandleStickChart::createShapes() for( auto const& rXSlot : rZSlot ) { //iterate through all series in this x slot - for( VDataSeries* const pSeries : rXSlot.m_aSeriesVector ) + for( std::unique_ptr<VDataSeries> const & pSeries : rXSlot.m_aSeriesVector ) { //collect data point information (logic coordinates, style ): double fUnscaledX = pSeries->getXValue( nIndex ); @@ -213,7 +213,7 @@ void CandleStickChart::createShapes() uno::Reference< drawing::XShapes > xPointGroupShape_Shapes(nullptr); { OUString aPointCID = ObjectIdentifier::createPointCID( pSeries->getPointCID_Stub(), nIndex ); - uno::Reference< drawing::XShapes > xSeriesGroupShape_Shapes( getSeriesGroupShape(pSeries, xSeriesTarget) ); + uno::Reference< drawing::XShapes > xSeriesGroupShape_Shapes( getSeriesGroupShape(pSeries.get(), xSeriesTarget) ); xPointGroupShape_Shapes = createGroupShape(xSeriesGroupShape_Shapes,aPointCID); } diff --git a/chart2/source/view/charttypes/CandleStickChart.hxx b/chart2/source/view/charttypes/CandleStickChart.hxx index af19e2d1e0ba..2d289131827a 100644 --- a/chart2/source/view/charttypes/CandleStickChart.hxx +++ b/chart2/source/view/charttypes/CandleStickChart.hxx @@ -38,7 +38,7 @@ public: virtual ~CandleStickChart() override; virtual void createShapes() override; - virtual void addSeries( VDataSeries* pSeries, sal_Int32 zSlot, sal_Int32 xSlot, sal_Int32 ySlot ) override; + virtual void addSeries( std::unique_ptr<VDataSeries> pSeries, sal_Int32 zSlot, sal_Int32 xSlot, sal_Int32 ySlot ) override; virtual css::drawing::Direction3D getPreferredDiagramAspectRatio() const override; diff --git a/chart2/source/view/charttypes/NetChart.cxx b/chart2/source/view/charttypes/NetChart.cxx index cbecb881b759..d4fe9c4eeb08 100644 --- a/chart2/source/view/charttypes/NetChart.cxx +++ b/chart2/source/view/charttypes/NetChart.cxx @@ -253,7 +253,7 @@ void NetChart::impl_createSeriesShapes() drawing::PolyPolygonShape3D* pSeriesPoly = nullptr; //iterate through all series - for( VDataSeries* pSeries : rXSlot.m_aSeriesVector ) + for( std::unique_ptr<VDataSeries> const & pSeries : rXSlot.m_aSeriesVector ) { sal_Int32 nAttachedAxisIndex = pSeries->getAttachedAxisIndex(); PlottingPositionHelper* pPosHelper = &(getPlottingPositionHelper( nAttachedAxisIndex )); @@ -264,12 +264,12 @@ void NetChart::impl_createSeriesShapes() pSeriesPoly = &pSeries->m_aPolyPolygonShape3D; if( m_bArea ) { - if( !impl_createArea( pSeries, pSeriesPoly, aPreviousSeriesPolyMap[nAttachedAxisIndex], pPosHelper ) ) + if( !impl_createArea( pSeries.get(), pSeriesPoly, aPreviousSeriesPolyMap[nAttachedAxisIndex], pPosHelper ) ) continue; } if( m_bLine ) { - if( !impl_createLine( pSeries, pSeriesPoly, pPosHelper ) ) + if( !impl_createLine( pSeries.get(), pSeriesPoly, pPosHelper ) ) continue; } aPreviousSeriesPolyMap[nAttachedAxisIndex] = pSeriesPoly; @@ -291,18 +291,16 @@ void lcl_reorderSeries( std::vector< std::vector< VDataSeriesGroup > >& rZSlots for( ; aZIt != aZEnd; ++aZIt ) { std::vector< VDataSeriesGroup > aXSlot; - aXSlot.reserve( aZIt->size() ); std::vector< VDataSeriesGroup >::reverse_iterator aXIt( aZIt->rbegin() ); std::vector< VDataSeriesGroup >::reverse_iterator aXEnd( aZIt->rend() ); for( ; aXIt != aXEnd; ++aXIt ) - aXSlot.push_back(*aXIt); + aXSlot.push_back(std::move(*aXIt)); - aRet.push_back(aXSlot); + aRet.push_back(std::move(aXSlot)); } - rZSlots.clear(); - rZSlots = aRet; + rZSlots = std::move(aRet); } }//anonymous namespace @@ -372,7 +370,7 @@ void NetChart::createShapes() //iterate through all x slots in this category to get 100percent sum for( auto const& rXSlot : rZSlot ) { - for( VDataSeries* pSeries : rXSlot.m_aSeriesVector ) + for( std::unique_ptr<VDataSeries> const & pSeries : rXSlot.m_aSeriesVector ) { if(!pSeries) continue; @@ -404,7 +402,7 @@ void NetChart::createShapes() { std::map< sal_Int32, double > aLogicYForNextSeriesMap;//one for each different nAttachedAxisIndex //iterate through all series - for( VDataSeries* pSeries : rXSlot.m_aSeriesVector ) + for( std::unique_ptr<VDataSeries> const & pSeries : rXSlot.m_aSeriesVector ) { if(!pSeries) continue; @@ -415,7 +413,7 @@ void NetChart::createShapes() if( m_bArea && (rXSlot.m_aSeriesVector.size() == 1) && (nIndex >= pSeries->getTotalPointCount()) ) continue; - uno::Reference< drawing::XShapes > xSeriesGroupShape_Shapes = getSeriesGroupShapeFrontChild(pSeries, m_xSeriesTarget); + uno::Reference< drawing::XShapes > xSeriesGroupShape_Shapes = getSeriesGroupShapeFrontChild(pSeries.get(), m_xSeriesTarget); sal_Int32 nAttachedAxisIndex = pSeries->getAttachedAxisIndex(); PlottingPositionHelper* pPosHelper = &(getPlottingPositionHelper( nAttachedAxisIndex )); @@ -497,7 +495,7 @@ void NetChart::createShapes() drawing::Position3D aScenePosition( pPosHelper->transformLogicToScene( fLogicX,fLogicY,fLogicZ, false ) ); //better performance for big data - FormerPoint aFormerPoint( aSeriesFormerPointMap[pSeries] ); + FormerPoint aFormerPoint( aSeriesFormerPointMap[pSeries.get()] ); pPosHelper->setCoordinateSystemResolution( m_aCoordinateSystemResolution ); if( !pSeries->isAttributedDataPoint(nIndex) && @@ -508,7 +506,7 @@ void NetChart::createShapes() m_bPointsWereSkipped = true; continue; } - aSeriesFormerPointMap[pSeries] = FormerPoint(aScaledLogicPosition.PositionX, aScaledLogicPosition.PositionY, aScaledLogicPosition.PositionZ); + aSeriesFormerPointMap[pSeries.get()] = FormerPoint(aScaledLogicPosition.PositionX, aScaledLogicPosition.PositionY, aScaledLogicPosition.PositionZ); //store point information for series polygon //for area and/or line (symbols only do not need this) diff --git a/chart2/source/view/charttypes/PieChart.cxx b/chart2/source/view/charttypes/PieChart.cxx index 7c24f5e0c4a3..ec234ac26be2 100644 --- a/chart2/source/view/charttypes/PieChart.cxx +++ b/chart2/source/view/charttypes/PieChart.cxx @@ -383,9 +383,9 @@ void PieChart::createTextLabelShape( m_aLabelInfoList.push_back(aPieLabelInfo); } -void PieChart::addSeries( VDataSeries* pSeries, sal_Int32 /* zSlot */, sal_Int32 /* xSlot */, sal_Int32 /* ySlot */ ) +void PieChart::addSeries( std::unique_ptr<VDataSeries> pSeries, sal_Int32 /* zSlot */, sal_Int32 /* xSlot */, sal_Int32 /* ySlot */ ) { - VSeriesPlotter::addSeries( pSeries, 0, -1, 0 ); + VSeriesPlotter::addSeries( std::move(pSeries), 0, -1, 0 ); } double PieChart::getMinimumX() @@ -404,11 +404,11 @@ double PieChart::getMaxOffset() if( m_aZSlots.front().empty() ) return m_fMaxOffset; - const std::vector< VDataSeries* >& rSeriesList( m_aZSlots.front().front().m_aSeriesVector ); + const std::vector< std::unique_ptr<VDataSeries> >& rSeriesList( m_aZSlots.front().front().m_aSeriesVector ); if(rSeriesList.empty()) return m_fMaxOffset; - VDataSeries* pSeries = rSeriesList.front(); + VDataSeries* pSeries = rSeriesList.front().get(); uno::Reference< beans::XPropertySet > xSeriesProp( pSeries->getPropertiesOfSeries() ); if( !xSeriesProp.is() ) return m_fMaxOffset; @@ -562,10 +562,10 @@ void PieChart::createShapes() { ShapeParam aParam; - std::vector< VDataSeries* >* pSeriesList = &(aXSlotIter->m_aSeriesVector); + std::vector< std::unique_ptr<VDataSeries> >* pSeriesList = &(aXSlotIter->m_aSeriesVector); if(pSeriesList->empty())//there should be only one series in each x slot continue; - VDataSeries* pSeries = pSeriesList->front(); + VDataSeries* pSeries = pSeriesList->front().get(); if(!pSeries) continue; diff --git a/chart2/source/view/charttypes/PieChart.hxx b/chart2/source/view/charttypes/PieChart.hxx index 0b97eb1090df..e7c3e4b19a7d 100644 --- a/chart2/source/view/charttypes/PieChart.hxx +++ b/chart2/source/view/charttypes/PieChart.hxx @@ -46,7 +46,7 @@ public: virtual void rearrangeLabelToAvoidOverlapIfRequested( const css::awt::Size& rPageSize ) override; virtual void setScales( const std::vector< ExplicitScaleData >& rScales, bool bSwapXAndYAxis ) override; - virtual void addSeries( VDataSeries* pSeries, sal_Int32 zSlot, sal_Int32 xSlot, sal_Int32 ySlot ) override; + virtual void addSeries( std::unique_ptr<VDataSeries> pSeries, sal_Int32 zSlot, sal_Int32 xSlot, sal_Int32 ySlot ) override; virtual css::drawing::Direction3D getPreferredDiagramAspectRatio() const override; virtual bool shouldSnapRectToUsedArea() override; diff --git a/chart2/source/view/charttypes/VSeriesPlotter.cxx b/chart2/source/view/charttypes/VSeriesPlotter.cxx index 011381e4db94..92ede0fb1a2d 100644 --- a/chart2/source/view/charttypes/VSeriesPlotter.cxx +++ b/chart2/source/view/charttypes/VSeriesPlotter.cxx @@ -106,12 +106,21 @@ VDataSeriesGroup::CachedYValues::CachedYValues() { } -VDataSeriesGroup::VDataSeriesGroup( VDataSeries* pSeries ) - : m_aSeriesVector(1,pSeries) +VDataSeriesGroup::VDataSeriesGroup( std::unique_ptr<VDataSeries> pSeries ) + : m_aSeriesVector(1) , m_bMaxPointCountDirty(true) , m_nMaxPointCount(0) , m_aListOfCachedYValues() { + m_aSeriesVector[0] = std::move(pSeries); +} + +VDataSeriesGroup::VDataSeriesGroup( VDataSeriesGroup&& other ) + : m_aSeriesVector( std::move(other.m_aSeriesVector) ) + , m_bMaxPointCountDirty( other.m_bMaxPointCountDirty ) + , m_nMaxPointCount( std::move(other.m_nMaxPointCount) ) + , m_aListOfCachedYValues( std::move(other.m_aListOfCachedYValues) ) +{ } VDataSeriesGroup::~VDataSeriesGroup() @@ -121,16 +130,12 @@ VDataSeriesGroup::~VDataSeriesGroup() void VDataSeriesGroup::deleteSeries() { //delete all data series help objects: - for (VDataSeries* pSeries : m_aSeriesVector) - { - delete pSeries; - } m_aSeriesVector.clear(); } -void VDataSeriesGroup::addSeries( VDataSeries* pSeries ) +void VDataSeriesGroup::addSeries( std::unique_ptr<VDataSeries> pSeries ) { - m_aSeriesVector.push_back(pSeries); + m_aSeriesVector.push_back(std::move(pSeries)); m_bMaxPointCountDirty=true; } @@ -179,7 +184,7 @@ VSeriesPlotter::~VSeriesPlotter() m_aSecondaryValueScales.clear(); } -void VSeriesPlotter::addSeries( VDataSeries* pSeries, sal_Int32 zSlot, sal_Int32 xSlot, sal_Int32 ySlot ) +void VSeriesPlotter::addSeries( std::unique_ptr<VDataSeries> pSeries, sal_Int32 zSlot, sal_Int32 xSlot, sal_Int32 ySlot ) { //take ownership of pSeries @@ -204,8 +209,8 @@ void VSeriesPlotter::addSeries( VDataSeries* pSeries, sal_Int32 zSlot, sal_Int32 { //new z slot std::vector< VDataSeriesGroup > aZSlot; - aZSlot.emplace_back(pSeries ); - m_aZSlots.push_back( aZSlot ); + aZSlot.emplace_back( std::move(pSeries) ); + m_aZSlots.push_back( std::move(aZSlot) ); } else { @@ -215,7 +220,7 @@ void VSeriesPlotter::addSeries( VDataSeries* pSeries, sal_Int32 zSlot, sal_Int32 if(xSlot<0 || xSlot>=static_cast<sal_Int32>(rXSlots.size())) { //append the series to already existing x series - rXSlots.emplace_back(pSeries ); + rXSlots.emplace_back( std::move(pSeries) ); } else { @@ -234,7 +239,7 @@ void VSeriesPlotter::addSeries( VDataSeries* pSeries, sal_Int32 zSlot, sal_Int32 else if( ySlot == -1 || ySlot >= nYSlotCount) { //append the series to already existing y series - rYSlots.addSeries(pSeries); + rYSlots.addSeries( std::move(pSeries) ); } else { @@ -270,7 +275,7 @@ void VSeriesPlotter::releaseShapes() for (VDataSeriesGroup const & rGroup : rGroupVector) { //iterate through all series in this x slot - for (VDataSeries* pSeries : rGroup.m_aSeriesVector) + for (std::unique_ptr<VDataSeries> const & pSeries : rGroup.m_aSeriesVector) { pSeries->releaseShapes(); } @@ -1700,7 +1705,7 @@ sal_Int32 VDataSeriesGroup::getPointCount() const sal_Int32 nRet = 0; - for (VDataSeries* pSeries : m_aSeriesVector) + for (std::unique_ptr<VDataSeries> const & pSeries : m_aSeriesVector) { sal_Int32 nPointCount = pSeries->getTotalPointCount(); if( nPointCount>nRet ) @@ -1729,7 +1734,7 @@ void VDataSeriesGroup::getMinimumAndMaximiumX( double& rfMinimum, double& rfMaxi ::rtl::math::setInf(&rfMinimum, false); ::rtl::math::setInf(&rfMaximum, true); - for (VDataSeries* pSeries : m_aSeriesVector) + for (std::unique_ptr<VDataSeries> const & pSeries : m_aSeriesVector) { sal_Int32 nPointCount = pSeries->getTotalPointCount(); for(sal_Int32 nN=0;nN<nPointCount;nN++) @@ -1893,7 +1898,7 @@ void VDataSeriesGroup::getMinimumAndMaximiumYInContinuousXRange( return; PerXMinMaxCalculator aRangeCalc; - for (const VDataSeries* pSeries : m_aSeriesVector) + for (const std::unique_ptr<VDataSeries> & pSeries : m_aSeriesVector) { if (!pSeries) continue; @@ -1954,7 +1959,7 @@ void VDataSeriesGroup::calculateYMinAndMaxForCategory( sal_Int32 nCategoryIndex if( bSeparateStackingForDifferentSigns ) { - for (const VDataSeries* pSeries: m_aSeriesVector) + for (const std::unique_ptr<VDataSeries> & pSeries: m_aSeriesVector) { if( nAxisIndex != pSeries->getAttachedAxisIndex() ) continue; @@ -1982,7 +1987,7 @@ void VDataSeriesGroup::calculateYMinAndMaxForCategory( sal_Int32 nCategoryIndex } else { - for (const VDataSeries* pSeries: m_aSeriesVector) + for (const std::unique_ptr<VDataSeries> & pSeries: m_aSeriesVector) { if( nAxisIndex != pSeries->getAttachedAxisIndex() ) continue; @@ -2102,7 +2107,7 @@ VDataSeries* VSeriesPlotter::getFirstSeries() const { if (!rGroup[0].m_aSeriesVector.empty()) { - VDataSeries* pSeries = rGroup[0].m_aSeriesVector[0]; + VDataSeries* pSeries = rGroup[0].m_aSeriesVector[0].get(); if (pSeries) return pSeries; } @@ -2136,10 +2141,10 @@ uno::Sequence< OUString > VSeriesPlotter::getSeriesNames() const { if (!rGroup.empty()) { - VDataSeriesGroup aSeriesGroup(rGroup[0]); - if (!aSeriesGroup.m_aSeriesVector.empty()) + VDataSeriesGroup const & rSeriesGroup(rGroup[0]); + if (!rSeriesGroup.m_aSeriesVector.empty()) { - VDataSeries* pSeries = aSeriesGroup.m_aSeriesVector[0]; + VDataSeries const * pSeries = rSeriesGroup.m_aSeriesVector[0].get(); uno::Reference< XDataSeries > xSeries( pSeries ? pSeries->getModel() : nullptr ); if( xSeries.is() ) { @@ -2158,14 +2163,14 @@ void VSeriesPlotter::setPageReferenceSize( const css::awt::Size & rPageRefSize ) // set reference size also at all data series - std::vector<VDataSeriesGroup> aSeriesGroups(FlattenVector(m_aZSlots)); - for (VDataSeriesGroup const & rGroup : aSeriesGroups) - { - for (VDataSeries* pSeries : rGroup.m_aSeriesVector) + for (auto const & outer : m_aZSlots) + for (VDataSeriesGroup const & rGroup : outer) { - pSeries->setPageReferenceSize(m_aPageReferenceSize); + for (std::unique_ptr<VDataSeries> const & pSeries : rGroup.m_aSeriesVector) + { + pSeries->setPageReferenceSize(m_aPageReferenceSize); + } } - } } //better performance for big data @@ -2206,7 +2211,7 @@ std::vector< ViewLegendEntry > VSeriesPlotter::createLegendEntries( { for (VDataSeriesGroup const & rGroup : rGroupVector) { - for (VDataSeries* pSeries : rGroup.m_aSeriesVector) + for (std::unique_ptr<VDataSeries> const & pSeries : rGroup.m_aSeriesVector) { if (!pSeries) continue; @@ -2256,8 +2261,8 @@ std::vector<VDataSeries*> VSeriesPlotter::getAllSeries() { for(VDataSeriesGroup const & rGroup : rXSlot) { - std::vector<VDataSeries*> aSeriesList = rGroup.m_aSeriesVector; - aAllSeries.insert(aAllSeries.end(), aSeriesList.begin(), aSeriesList.end()); + for (std::unique_ptr<VDataSeries> const & p : rGroup.m_aSeriesVector) + aAllSeries.push_back(p.get()); } } return aAllSeries; diff --git a/chart2/source/view/inc/VSeriesPlotter.hxx b/chart2/source/view/inc/VSeriesPlotter.hxx index afe4fb9bdcea..e1eac757381e 100644 --- a/chart2/source/view/inc/VSeriesPlotter.hxx +++ b/chart2/source/view/inc/VSeriesPlotter.hxx @@ -83,10 +83,11 @@ class VDataSeriesGroup final { public: VDataSeriesGroup() = delete; - VDataSeriesGroup( VDataSeries* pSeries ); + VDataSeriesGroup( std::unique_ptr<VDataSeries> pSeries ); + VDataSeriesGroup( VDataSeriesGroup&& ); ~VDataSeriesGroup(); - void addSeries( VDataSeries* pSeries );//takes ownership of pSeries + void addSeries( std::unique_ptr<VDataSeries> pSeries );//takes ownership of pSeries sal_Int32 getSeriesCount() const; void deleteSeries(); @@ -103,7 +104,7 @@ public: , bool bSeparateStackingForDifferentSigns , double& rfMinimumY, double& rfMaximumY, sal_Int32 nAxisIndex ); - std::vector< VDataSeries* > m_aSeriesVector; + std::vector< std::unique_ptr<VDataSeries> > m_aSeriesVector; private: //cached values @@ -144,7 +145,7 @@ public: * ySlot == already occupied : insert at given y and x position * ySlot > occupied : stack on top at given x position */ - virtual void addSeries( VDataSeries* pSeries, sal_Int32 zSlot, sal_Int32 xSlot, sal_Int32 ySlot ); + virtual void addSeries( std::unique_ptr<VDataSeries> pSeries, sal_Int32 zSlot, sal_Int32 xSlot, sal_Int32 ySlot ); /** a value <= 0 for a directions means that this direction can be stretched arbitrary */ diff --git a/chart2/source/view/main/ChartView.cxx b/chart2/source/view/main/ChartView.cxx index 259b58ce7779..247d385fb689 100644 --- a/chart2/source/view/main/ChartView.cxx +++ b/chart2/source/view/main/ChartView.cxx @@ -564,7 +564,7 @@ void SeriesPlotterContainer::initializeCooSysAndSeriesPlotter( if( !bIncludeHiddenCells && !DataSeriesHelper::hasUnhiddenData(xDataSeries) ) continue; - VDataSeries* pSeries = new VDataSeries( xDataSeries ); + std::unique_ptr<VDataSeries> pSeries(new VDataSeries( xDataSeries )); pSeries->setGlobalSeriesIndex(nGlobalSeriesIndex); nGlobalSeriesIndex++; @@ -613,7 +613,7 @@ void SeriesPlotterContainer::initializeCooSysAndSeriesPlotter( // UNO enums have one additional auto-generated case break; } - pPlotter->addSeries( pSeries, zSlot, xSlot, ySlot ); + pPlotter->addSeries( std::move(pSeries), zSlot, xSlot, ySlot ); } } } |