From d1e47b1428abf1732ab4d5e219b210760d4152e0 Mon Sep 17 00:00:00 2001 From: Noel Grandin Date: Mon, 22 May 2017 13:25:58 +0200 Subject: enhance useuniqueptr loplugin teach it to look for the following sequence in a destructor: delete m_pfoo; m_pfoo = nullptr; Change-Id: Icd6271a63a024e32b53cc9e599f8f59952160380 Reviewed-on: https://gerrit.libreoffice.org/37900 Tested-by: Jenkins Reviewed-by: Noel Grandin --- chart2/source/view/axes/VPolarAngleAxis.cxx | 6 ++---- chart2/source/view/axes/VPolarAxis.cxx | 4 +--- chart2/source/view/axes/VPolarAxis.hxx | 3 ++- chart2/source/view/axes/VPolarGrid.cxx | 6 ++---- chart2/source/view/axes/VPolarGrid.hxx | 3 ++- chart2/source/view/axes/VPolarRadiusAxis.cxx | 2 -- 6 files changed, 9 insertions(+), 15 deletions(-) (limited to 'chart2') diff --git a/chart2/source/view/axes/VPolarAngleAxis.cxx b/chart2/source/view/axes/VPolarAngleAxis.cxx index c5d6b62ded37..9186a4643c6b 100644 --- a/chart2/source/view/axes/VPolarAngleAxis.cxx +++ b/chart2/source/view/axes/VPolarAngleAxis.cxx @@ -44,8 +44,6 @@ VPolarAngleAxis::VPolarAngleAxis( const AxisProperties& rAxisProperties VPolarAngleAxis::~VPolarAngleAxis() { - delete m_pPosHelper; - m_pPosHelper = nullptr; } bool VPolarAngleAxis::createTextShapes_ForAngleAxis( @@ -118,7 +116,7 @@ bool VPolarAngleAxis::createTextShapes_ForAngleAxis( double fLogicAngle = pTickInfo->getUnscaledTickValue(); LabelAlignment eLabelAlignment(LABEL_ALIGN_CENTER); - PolarLabelPositionHelper aPolarLabelPositionHelper(m_pPosHelper,nDimensionCount,xTarget, pShapeFactory); + PolarLabelPositionHelper aPolarLabelPositionHelper(m_pPosHelper.get(), nDimensionCount, xTarget, pShapeFactory); sal_Int32 nScreenValueOffsetInRadiusDirection = m_aAxisLabelProperties.m_aMaximumSpaceForLabels.Height/15; awt::Point aAnchorScreenPosition2D( aPolarLabelPositionHelper.getLabelScreenPositionAndAlignmentForLogicValues( eLabelAlignment, fLogicAngle, fLogicRadius, fLogicZ, nScreenValueOffsetInRadiusDirection )); @@ -201,7 +199,7 @@ void VPolarAngleAxis::createShapes() //create axis main lines drawing::PointSequenceSequence aPoints(1); - VPolarGrid::createLinePointSequence_ForAngleAxis( aPoints, m_aAllTickInfos, m_aIncrement, m_aScale, m_pPosHelper, fLogicRadius, fLogicZ ); + VPolarGrid::createLinePointSequence_ForAngleAxis( aPoints, m_aAllTickInfos, m_aIncrement, m_aScale, m_pPosHelper.get(), fLogicRadius, fLogicZ ); uno::Reference< drawing::XShape > xShape = m_pShapeFactory->createLine2D( m_xGroupShape_Shapes, aPoints, &m_aAxisProperties.m_aLineProperties ); //because of this name this line will be used for marking the axis diff --git a/chart2/source/view/axes/VPolarAxis.cxx b/chart2/source/view/axes/VPolarAxis.cxx index c7783d8e087e..da53f99b527c 100644 --- a/chart2/source/view/axes/VPolarAxis.cxx +++ b/chart2/source/view/axes/VPolarAxis.cxx @@ -45,13 +45,11 @@ VPolarAxis::VPolarAxis( const AxisProperties& rAxisProperties , m_pPosHelper( new PolarPlottingPositionHelper() ) , m_aIncrements() { - PlotterBase::m_pPosHelper = m_pPosHelper; + PlotterBase::m_pPosHelper = m_pPosHelper.get(); } VPolarAxis::~VPolarAxis() { - delete m_pPosHelper; - m_pPosHelper = nullptr; } void VPolarAxis::setIncrements( const std::vector< ExplicitIncrementData >& rIncrements ) diff --git a/chart2/source/view/axes/VPolarAxis.hxx b/chart2/source/view/axes/VPolarAxis.hxx index 1ce1b3c94add..f1626f4b9474 100644 --- a/chart2/source/view/axes/VPolarAxis.hxx +++ b/chart2/source/view/axes/VPolarAxis.hxx @@ -20,6 +20,7 @@ #define INCLUDED_CHART2_SOURCE_VIEW_AXES_VPOLARAXIS_HXX #include "VAxisBase.hxx" +#include namespace chart { @@ -45,7 +46,7 @@ protected: , sal_Int32 nDimensionIndex, sal_Int32 nDimensionCount ); protected: //member - PolarPlottingPositionHelper* m_pPosHelper; + std::unique_ptr m_pPosHelper; std::vector< ExplicitIncrementData > m_aIncrements; }; diff --git a/chart2/source/view/axes/VPolarGrid.cxx b/chart2/source/view/axes/VPolarGrid.cxx index 6347900a167e..7ff9a9be2ffd 100644 --- a/chart2/source/view/axes/VPolarGrid.cxx +++ b/chart2/source/view/axes/VPolarGrid.cxx @@ -43,13 +43,11 @@ VPolarGrid::VPolarGrid( sal_Int32 nDimensionIndex, sal_Int32 nDimensionCount , m_pPosHelper( new PolarPlottingPositionHelper() ) , m_aIncrements() { - PlotterBase::m_pPosHelper = m_pPosHelper; + PlotterBase::m_pPosHelper = m_pPosHelper.get(); } VPolarGrid::~VPolarGrid() { - delete m_pPosHelper; - m_pPosHelper = nullptr; } void VPolarGrid::setIncrements( const std::vector< ExplicitIncrementData >& rIncrements ) @@ -207,7 +205,7 @@ void VPolarGrid::create2DRadiusGrid( const Reference< drawing::XShapes >& xLogic drawing::PointSequenceSequence aPoints(1); VPolarGrid::createLinePointSequence_ForAngleAxis( aPoints, rAngleTickInfos - , rAngleIncrement, rAngleScale, m_pPosHelper, fLogicRadius, fLogicZ ); + , rAngleIncrement, rAngleScale, m_pPosHelper.get(), fLogicRadius, fLogicZ ); if(aPoints[0].getLength()) appendPointSequence( aAllPoints, aPoints ); } diff --git a/chart2/source/view/axes/VPolarGrid.hxx b/chart2/source/view/axes/VPolarGrid.hxx index ab7326607ce7..f7c177071567 100644 --- a/chart2/source/view/axes/VPolarGrid.hxx +++ b/chart2/source/view/axes/VPolarGrid.hxx @@ -23,6 +23,7 @@ #include "Tickmarks.hxx" #include "VLineProperties.hxx" #include +#include namespace chart { @@ -54,7 +55,7 @@ public: private: //member css::uno::Sequence< css::uno::Reference< css::beans::XPropertySet > > m_aGridPropertiesList;//main grid, subgrid, subsubgrid etc - PolarPlottingPositionHelper* m_pPosHelper; + std::unique_ptr m_pPosHelper; std::vector< ExplicitIncrementData > m_aIncrements; void getAllTickInfos( sal_Int32 nDimensionIndex, TickInfoArraysType& rAllTickInfos ) const; diff --git a/chart2/source/view/axes/VPolarRadiusAxis.cxx b/chart2/source/view/axes/VPolarRadiusAxis.cxx index d05c2f4b7e72..ffc66d3e2842 100644 --- a/chart2/source/view/axes/VPolarRadiusAxis.cxx +++ b/chart2/source/view/axes/VPolarRadiusAxis.cxx @@ -48,8 +48,6 @@ VPolarRadiusAxis::VPolarRadiusAxis( const AxisProperties& rAxisProperties VPolarRadiusAxis::~VPolarRadiusAxis() { - delete m_pPosHelper; - m_pPosHelper = nullptr; } void VPolarRadiusAxis::setTransformationSceneToScreen( const drawing::HomogenMatrix& rMatrix) -- cgit