diff options
author | Noel Grandin <noel.grandin@collabora.co.uk> | 2017-01-11 13:31:26 +0200 |
---|---|---|
committer | Noel Grandin <noel.grandin@collabora.co.uk> | 2017-01-16 06:10:10 +0000 |
commit | 570d8dab6d6754ab8020cbe6624020dff7b8b624 (patch) | |
tree | 44272338a72fc70ca2228917f93a53be95b118a3 /chart2/source | |
parent | 0611017c1df3c98684fbb904c1ab5ec7f68074d8 (diff) |
new loplugin: useuniqueptr: chart2
Change-Id: Ic029ed28fd6de8cf4ee204585c1c6e0c8a4b67ff
Reviewed-on: https://gerrit.libreoffice.org/32960
Tested-by: Jenkins <ci@libreoffice.org>
Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
Diffstat (limited to 'chart2/source')
16 files changed, 46 insertions, 48 deletions
diff --git a/chart2/source/controller/accessibility/AccessibleChartView.cxx b/chart2/source/controller/accessibility/AccessibleChartView.cxx index 0cce8bd4b88b..fac65a65c301 100644 --- a/chart2/source/controller/accessibility/AccessibleChartView.cxx +++ b/chart2/source/controller/accessibility/AccessibleChartView.cxx @@ -63,7 +63,6 @@ AccessibleChartView::AccessibleChartView(SdrView* pView ) : AccessibleChartView::~AccessibleChartView() { - delete m_pViewForwarder; } awt::Rectangle AccessibleChartView::GetWindowPosSize() const @@ -324,12 +323,8 @@ void SAL_CALL AccessibleChartView::initialize( const Sequence< Any >& rArguments aAccInfo.m_spObjectHierarchy = m_spObjectHierarchy; aAccInfo.m_pSdrView = m_pSdrView; VclPtr<vcl::Window> pWindow = VCLUnoHelper::GetWindow( m_xWindow ); - if ( m_pViewForwarder ) - { - delete m_pViewForwarder; - } - m_pViewForwarder = new AccessibleViewForwarder( this, pWindow ); - aAccInfo.m_pViewForwarder = m_pViewForwarder; + m_pViewForwarder.reset( new AccessibleViewForwarder( this, pWindow ) ); + aAccInfo.m_pViewForwarder = m_pViewForwarder.get(); // broadcasts an INVALIDATE_ALL_CHILDREN event globally SetInfo( aAccInfo ); } diff --git a/chart2/source/controller/accessibility/AccessibleTextHelper.cxx b/chart2/source/controller/accessibility/AccessibleTextHelper.cxx index d7d4fdd5ae9b..367c098c73b9 100644 --- a/chart2/source/controller/accessibility/AccessibleTextHelper.cxx +++ b/chart2/source/controller/accessibility/AccessibleTextHelper.cxx @@ -53,7 +53,6 @@ AccessibleTextHelper::AccessibleTextHelper( AccessibleTextHelper::~AccessibleTextHelper() { - delete m_pTextHelper; } // ____ XInitialization ____ @@ -79,7 +78,7 @@ void SAL_CALL AccessibleTextHelper::initialize( const Sequence< uno::Any >& aArg SolarMutexGuard aSolarGuard; - delete m_pTextHelper; + m_pTextHelper.reset(); VclPtr<vcl::Window> pWindow( VCLUnoHelper::GetWindow( xWindow )); if( pWindow ) @@ -90,7 +89,7 @@ void SAL_CALL AccessibleTextHelper::initialize( const Sequence< uno::Any >& aArg SdrObject * pTextObj = m_pDrawViewWrapper->getNamedSdrObject( aCID ); if( pTextObj ) { - m_pTextHelper = new ::accessibility::AccessibleTextHelper(o3tl::make_unique<SvxTextEditSource>(*pTextObj, nullptr, *pView, *pWindow)); + m_pTextHelper.reset( new ::accessibility::AccessibleTextHelper(o3tl::make_unique<SvxTextEditSource>(*pTextObj, nullptr, *pView, *pWindow)) ); m_pTextHelper->SetEventSource( xEventSource ); } } diff --git a/chart2/source/controller/drawinglayer/ViewElementListProvider.cxx b/chart2/source/controller/drawinglayer/ViewElementListProvider.cxx index bebf04e8db03..d79a53cf89e4 100644 --- a/chart2/source/controller/drawinglayer/ViewElementListProvider.cxx +++ b/chart2/source/controller/drawinglayer/ViewElementListProvider.cxx @@ -52,9 +52,14 @@ ViewElementListProvider::ViewElementListProvider( DrawModelWrapper* pDrawModelWr { } +ViewElementListProvider::ViewElementListProvider( ViewElementListProvider&& rOther ) +{ + m_pDrawModelWrapper = rOther.m_pDrawModelWrapper; + m_pFontList = std::move(rOther.m_pFontList); +} + ViewElementListProvider::~ViewElementListProvider() { - delete m_pFontList; } XColorListRef ViewElementListProvider::GetColorTable() const @@ -191,10 +196,10 @@ FontList* ViewElementListProvider::getFontList() const { OutputDevice* pRefDev = m_pDrawModelWrapper ? m_pDrawModelWrapper->getReferenceDevice() : nullptr; OutputDevice* pDefaultOut = Application::GetDefaultDevice(); - m_pFontList = new FontList( pRefDev ? pRefDev : pDefaultOut - , pRefDev ? pDefaultOut : nullptr); + m_pFontList.reset( new FontList( pRefDev ? pRefDev : pDefaultOut + , pRefDev ? pDefaultOut : nullptr) ); } - return m_pFontList; + return m_pFontList.get(); } } //namespace chart diff --git a/chart2/source/controller/inc/AccessibleChartView.hxx b/chart2/source/controller/inc/AccessibleChartView.hxx index 8f37db11a1da..a82fc8bd64f0 100644 --- a/chart2/source/controller/inc/AccessibleChartView.hxx +++ b/chart2/source/controller/inc/AccessibleChartView.hxx @@ -122,7 +122,7 @@ private: // members std::shared_ptr< ObjectHierarchy > m_spObjectHierarchy; AccessibleUniqueId m_aCurrentSelectionOID; SdrView* m_pSdrView; - ::accessibility::IAccessibleViewForwarder* m_pViewForwarder; + std::unique_ptr<::accessibility::IAccessibleViewForwarder> m_pViewForwarder; }; } //namespace chart diff --git a/chart2/source/controller/inc/AccessibleTextHelper.hxx b/chart2/source/controller/inc/AccessibleTextHelper.hxx index 43d22b8b3e3b..27744de6d085 100644 --- a/chart2/source/controller/inc/AccessibleTextHelper.hxx +++ b/chart2/source/controller/inc/AccessibleTextHelper.hxx @@ -95,8 +95,8 @@ public: css::uno::RuntimeException, std::exception) override; private: - ::accessibility::AccessibleTextHelper * m_pTextHelper; - DrawViewWrapper * m_pDrawViewWrapper; + std::unique_ptr<::accessibility::AccessibleTextHelper> m_pTextHelper; + DrawViewWrapper * m_pDrawViewWrapper; }; } // namespace chart diff --git a/chart2/source/controller/inc/ViewElementListProvider.hxx b/chart2/source/controller/inc/ViewElementListProvider.hxx index f3e65a838e16..5fa359e83705 100644 --- a/chart2/source/controller/inc/ViewElementListProvider.hxx +++ b/chart2/source/controller/inc/ViewElementListProvider.hxx @@ -33,6 +33,7 @@ class ViewElementListProvider final { public: ViewElementListProvider( DrawModelWrapper* pDrawModelWrapper ); + ViewElementListProvider( ViewElementListProvider&& ); ~ViewElementListProvider(); XColorListRef GetColorTable() const; @@ -51,8 +52,8 @@ public: //SfxPrinter* getPrinter(); private: - DrawModelWrapper* m_pDrawModelWrapper; - mutable FontList* m_pFontList; + DrawModelWrapper* m_pDrawModelWrapper; + mutable std::unique_ptr<FontList> m_pFontList; }; } //namespace chart diff --git a/chart2/source/view/axes/Tickmarks_Equidistant.cxx b/chart2/source/view/axes/Tickmarks_Equidistant.cxx index e4fe9e4741ec..e09ce607416f 100644 --- a/chart2/source/view/axes/Tickmarks_Equidistant.cxx +++ b/chart2/source/view/axes/Tickmarks_Equidistant.cxx @@ -77,7 +77,7 @@ EquidistantTickFactory::EquidistantTickFactory( { //@todo: make sure that the scale is valid for the scaling - m_pfCurrentValues = new double[getTickDepth()]; + m_pfCurrentValues.reset( new double[getTickDepth()] ); if( m_rScale.Scaling.is() ) { @@ -128,7 +128,6 @@ EquidistantTickFactory::EquidistantTickFactory( EquidistantTickFactory::~EquidistantTickFactory() { - delete[] m_pfCurrentValues; } sal_Int32 EquidistantTickFactory::getTickDepth() const diff --git a/chart2/source/view/axes/Tickmarks_Equidistant.hxx b/chart2/source/view/axes/Tickmarks_Equidistant.hxx index 1e8474457fb9..6859020b0167 100644 --- a/chart2/source/view/axes/Tickmarks_Equidistant.hxx +++ b/chart2/source/view/axes/Tickmarks_Equidistant.hxx @@ -123,7 +123,8 @@ private: //member double m_fScaledVisibleMin; double m_fScaledVisibleMax; - double* m_pfCurrentValues; + std::unique_ptr<double[]> + m_pfCurrentValues; //major-tick positions that may lay outside the visible range but complete partly visible intervals at the borders double m_fOuterMajorTickBorderMin; double m_fOuterMajorTickBorderMax; diff --git a/chart2/source/view/charttypes/AreaChart.cxx b/chart2/source/view/charttypes/AreaChart.cxx index 6ee585c4581e..088994157655 100644 --- a/chart2/source/view/charttypes/AreaChart.cxx +++ b/chart2/source/view/charttypes/AreaChart.cxx @@ -70,8 +70,8 @@ AreaChart::AreaChart( const uno::Reference<XChartType>& xChartTypeModel m_pMainPosHelper->AllowShiftXAxisPos(true); m_pMainPosHelper->AllowShiftZAxisPos(true); - PlotterBase::m_pPosHelper = m_pMainPosHelper; - VSeriesPlotter::m_pMainPosHelper = m_pMainPosHelper; + PlotterBase::m_pPosHelper = m_pMainPosHelper.get(); + VSeriesPlotter::m_pMainPosHelper = m_pMainPosHelper.get(); try { @@ -92,7 +92,6 @@ AreaChart::AreaChart( const uno::Reference<XChartType>& xChartTypeModel AreaChart::~AreaChart() { - delete m_pMainPosHelper; } double AreaChart::getMaximumX() @@ -555,7 +554,7 @@ void AreaChart::impl_createSeriesShapes() sal_Int32 nAttachedAxisIndex = (*aSeriesIter)->getAttachedAxisIndex(); PlottingPositionHelper* pPosHelper = &(this->getPlottingPositionHelper( nAttachedAxisIndex )); if(!pPosHelper) - pPosHelper = m_pMainPosHelper; + pPosHelper = m_pMainPosHelper.get(); PlotterBase::m_pPosHelper = pPosHelper; createRegressionCurvesShapes( **aSeriesIter, m_xErrorBarTarget, m_xRegressionCurveEquationTarget, @@ -702,7 +701,7 @@ void AreaChart::createShapes() PlottingPositionHelper* pPosHelper = &(this->getPlottingPositionHelper( nAttachedAxisIndex )); if(!pPosHelper) - pPosHelper = m_pMainPosHelper; + pPosHelper = m_pMainPosHelper.get(); PlotterBase::m_pPosHelper = pPosHelper; double fAdd = pSeries->getYValue( nIndex ); @@ -740,7 +739,7 @@ void AreaChart::createShapes() sal_Int32 nAttachedAxisIndex = (*aSeriesIter)->getAttachedAxisIndex(); PlottingPositionHelper* pPosHelper = &(this->getPlottingPositionHelper( nAttachedAxisIndex )); if(!pPosHelper) - pPosHelper = m_pMainPosHelper; + pPosHelper = m_pMainPosHelper.get(); PlotterBase::m_pPosHelper = pPosHelper; if(m_nDimension==3) diff --git a/chart2/source/view/charttypes/AreaChart.hxx b/chart2/source/view/charttypes/AreaChart.hxx index b4f00ef82483..b26e0b0d4c8c 100644 --- a/chart2/source/view/charttypes/AreaChart.hxx +++ b/chart2/source/view/charttypes/AreaChart.hxx @@ -65,7 +65,8 @@ private: //methods , css::drawing::PolyPolygonShape3D &aPoly ); private: //member - PlottingPositionHelper* m_pMainPosHelper; + std::unique_ptr<PlottingPositionHelper> + m_pMainPosHelper; bool m_bArea;//false -> line or symbol only bool m_bLine; diff --git a/chart2/source/view/charttypes/BarChart.cxx b/chart2/source/view/charttypes/BarChart.cxx index a082d21b121a..261cf4f6847b 100644 --- a/chart2/source/view/charttypes/BarChart.cxx +++ b/chart2/source/view/charttypes/BarChart.cxx @@ -44,8 +44,8 @@ BarChart::BarChart( const uno::Reference<XChartType>& xChartTypeModel : VSeriesPlotter( xChartTypeModel, nDimensionCount ) , m_pMainPosHelper( new BarPositionHelper() ) { - PlotterBase::m_pPosHelper = m_pMainPosHelper; - VSeriesPlotter::m_pMainPosHelper = m_pMainPosHelper; + PlotterBase::m_pPosHelper = m_pMainPosHelper.get(); + VSeriesPlotter::m_pMainPosHelper = m_pMainPosHelper.get(); try { @@ -63,7 +63,6 @@ BarChart::BarChart( const uno::Reference<XChartType>& xChartTypeModel BarChart::~BarChart() { - delete m_pMainPosHelper; } PlottingPositionHelper& BarChart::getPlottingPositionHelper( sal_Int32 nAxisIndex ) const @@ -494,14 +493,14 @@ void BarChart::createShapes() for( aXSlotIter = aZSlotIter->begin(); aXSlotIter != aXSlotEnd; ++aXSlotIter, fSlotX+=1.0 ) { sal_Int32 nAttachedAxisIndex = 0; - BarPositionHelper* pPosHelper = m_pMainPosHelper; + BarPositionHelper* pPosHelper = m_pMainPosHelper.get(); if( aXSlotIter != aXSlotEnd ) { nAttachedAxisIndex = aXSlotIter->getAttachedAxisIndexForFirstSeries(); //2ND_AXIS_IN_BARS so far one can assume to have the same plotter for each z slot pPosHelper = dynamic_cast<BarPositionHelper*>(&( this->getPlottingPositionHelper( nAttachedAxisIndex ) ) ); if(!pPosHelper) - pPosHelper = m_pMainPosHelper; + pPosHelper = m_pMainPosHelper.get(); } PlotterBase::m_pPosHelper = pPosHelper; @@ -870,14 +869,14 @@ void BarChart::createShapes() ::std::vector< VDataSeriesGroup >::iterator aXSlotIter = aZSlotIter->begin(); const ::std::vector< VDataSeriesGroup >::const_iterator aXSlotEnd = aZSlotIter->end(); - BarPositionHelper* pPosHelper = m_pMainPosHelper; + BarPositionHelper* pPosHelper = m_pMainPosHelper.get(); if( aXSlotIter != aXSlotEnd ) { sal_Int32 nAttachedAxisIndex = aXSlotIter->getAttachedAxisIndexForFirstSeries(); //2ND_AXIS_IN_BARS so far one can assume to have the same plotter for each z slot pPosHelper = dynamic_cast<BarPositionHelper*>(&( this->getPlottingPositionHelper( nAttachedAxisIndex ) ) ); if(!pPosHelper) - pPosHelper = m_pMainPosHelper; + pPosHelper = m_pMainPosHelper.get(); } PlotterBase::m_pPosHelper = pPosHelper; diff --git a/chart2/source/view/charttypes/BarChart.hxx b/chart2/source/view/charttypes/BarChart.hxx index 706e257d91a8..199c034fc136 100644 --- a/chart2/source/view/charttypes/BarChart.hxx +++ b/chart2/source/view/charttypes/BarChart.hxx @@ -62,7 +62,7 @@ private: //methods void adaptOverlapAndGapwidthForGroupBarsPerAxis(); private: //member - BarPositionHelper* m_pMainPosHelper; + std::unique_ptr<BarPositionHelper> m_pMainPosHelper; css::uno::Sequence< sal_Int32 > m_aOverlapSequence; css::uno::Sequence< sal_Int32 > m_aGapwidthSequence; }; diff --git a/chart2/source/view/charttypes/CandleStickChart.cxx b/chart2/source/view/charttypes/CandleStickChart.cxx index cabe1af2a88b..439ed56ea1ce 100644 --- a/chart2/source/view/charttypes/CandleStickChart.cxx +++ b/chart2/source/view/charttypes/CandleStickChart.cxx @@ -42,13 +42,12 @@ CandleStickChart::CandleStickChart( const uno::Reference<XChartType>& xChartType : VSeriesPlotter( xChartTypeModel, nDimensionCount ) , m_pMainPosHelper( new BarPositionHelper() ) { - PlotterBase::m_pPosHelper = m_pMainPosHelper; - VSeriesPlotter::m_pMainPosHelper = m_pMainPosHelper; + PlotterBase::m_pPosHelper = m_pMainPosHelper.get(); + VSeriesPlotter::m_pMainPosHelper = m_pMainPosHelper.get(); } CandleStickChart::~CandleStickChart() { - delete m_pMainPosHelper; } // MinimumAndMaximumSupplier @@ -148,14 +147,14 @@ void CandleStickChart::createShapes() const ::std::vector< VDataSeriesGroup >::const_iterator aXSlotEnd = aZSlotIter->end(); sal_Int32 nAttachedAxisIndex = 0; - BarPositionHelper* pPosHelper = m_pMainPosHelper; + BarPositionHelper* pPosHelper = m_pMainPosHelper.get(); if( aXSlotIter != aXSlotEnd ) { nAttachedAxisIndex = aXSlotIter->getAttachedAxisIndexForFirstSeries(); //2ND_AXIS_IN_BARS so far one can assume to have the same plotter for each z slot pPosHelper = dynamic_cast<BarPositionHelper*>(&( this->getPlottingPositionHelper( nAttachedAxisIndex ) ) ); if(!pPosHelper) - pPosHelper = m_pMainPosHelper; + pPosHelper = m_pMainPosHelper.get(); } PlotterBase::m_pPosHelper = pPosHelper; diff --git a/chart2/source/view/charttypes/CandleStickChart.hxx b/chart2/source/view/charttypes/CandleStickChart.hxx index 3142e1bdd47e..d74be2a49ed9 100644 --- a/chart2/source/view/charttypes/CandleStickChart.hxx +++ b/chart2/source/view/charttypes/CandleStickChart.hxx @@ -47,7 +47,7 @@ public: virtual LegendSymbolStyle getLegendSymbolStyle() override; private: //member - BarPositionHelper* m_pMainPosHelper; + std::unique_ptr<BarPositionHelper> m_pMainPosHelper; }; } //namespace chart #endif diff --git a/chart2/source/view/charttypes/PieChart.cxx b/chart2/source/view/charttypes/PieChart.cxx index 50c3bd070a68..0e4e26db1d8d 100644 --- a/chart2/source/view/charttypes/PieChart.cxx +++ b/chart2/source/view/charttypes/PieChart.cxx @@ -172,8 +172,8 @@ PieChart::PieChart( const uno::Reference<XChartType>& xChartTypeModel { ::rtl::math::setNan(&m_fMaxOffset); - PlotterBase::m_pPosHelper = m_pPosHelper; - VSeriesPlotter::m_pMainPosHelper = m_pPosHelper; + PlotterBase::m_pPosHelper = m_pPosHelper.get(); + VSeriesPlotter::m_pMainPosHelper = m_pPosHelper.get(); m_pPosHelper->m_fRadiusOffset = 0.0; m_pPosHelper->m_fRingDistance = 0.0; @@ -196,7 +196,6 @@ PieChart::PieChart( const uno::Reference<XChartType>& xChartTypeModel PieChart::~PieChart() { - delete m_pPosHelper; } void PieChart::setScales( const std::vector< ExplicitScaleData >& rScales, bool /* bSwapXAndYAxis */ ) @@ -310,7 +309,7 @@ void PieChart::createTextLabelShape( ///the scene position of the label anchor point is calculated (see notes for ///`PolarLabelPositionHelper::getLabelScreenPositionAndAlignmentForUnitCircleValues`), ///and immediately transformed into the screen position. - PolarLabelPositionHelper aPolarPosHelper(m_pPosHelper,m_nDimension,m_xLogicTarget,m_pShapeFactory); + PolarLabelPositionHelper aPolarPosHelper(m_pPosHelper.get(),m_nDimension,m_xLogicTarget,m_pShapeFactory); awt::Point aScreenPosition2D( aPolarPosHelper.getLabelScreenPositionAndAlignmentForUnitCircleValues(eAlignment, nLabelPlacement , rParam.mfUnitCircleStartAngleDegree, rParam.mfUnitCircleWidthAngleDegree diff --git a/chart2/source/view/charttypes/PieChart.hxx b/chart2/source/view/charttypes/PieChart.hxx index 7e5f0243dae3..6ec5356a6eeb 100644 --- a/chart2/source/view/charttypes/PieChart.hxx +++ b/chart2/source/view/charttypes/PieChart.hxx @@ -110,7 +110,8 @@ struct PieLabelInfo; void performLabelBestFit(ShapeParam& rShapeParam, PieLabelInfo& rPieLabelInfo); private: //member - PiePositionHelper* m_pPosHelper; + std::unique_ptr<PiePositionHelper> + m_pPosHelper; bool m_bUseRings; bool m_bSizeExcludesLabelsAndExplodedSegments; |