diff options
author | Noel Grandin <noel.grandin@collabora.co.uk> | 2018-08-13 16:15:53 +0200 |
---|---|---|
committer | Noel Grandin <noel.grandin@collabora.co.uk> | 2018-08-15 08:41:25 +0200 |
commit | 6536083617f5043752f047fff7a8641873a69d4c (patch) | |
tree | 0e259d6718c3532c7c372d74d3ac20036345b067 /chart2 | |
parent | 0b6f2f3ff47b6f1455d213bee4b257542e527976 (diff) |
pass PlottingPositionHelper around by std::unique_ptr
Change-Id: I2bcfeb1e670bc75f093a05e7d5bfb0be09235052
Reviewed-on: https://gerrit.libreoffice.org/59023
Tested-by: Jenkins
Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
Diffstat (limited to 'chart2')
-rw-r--r-- | chart2/source/view/charttypes/BarPositionHelper.cxx | 6 | ||||
-rw-r--r-- | chart2/source/view/charttypes/BarPositionHelper.hxx | 2 | ||||
-rw-r--r-- | chart2/source/view/charttypes/VSeriesPlotter.cxx | 11 | ||||
-rw-r--r-- | chart2/source/view/inc/PlottingPositionHelper.hxx | 6 | ||||
-rw-r--r-- | chart2/source/view/inc/VSeriesPlotter.hxx | 2 | ||||
-rw-r--r-- | chart2/source/view/main/PlottingPositionHelper.cxx | 15 |
6 files changed, 18 insertions, 24 deletions
diff --git a/chart2/source/view/charttypes/BarPositionHelper.cxx b/chart2/source/view/charttypes/BarPositionHelper.cxx index cd5e215fcb0d..45565989f9d7 100644 --- a/chart2/source/view/charttypes/BarPositionHelper.cxx +++ b/chart2/source/view/charttypes/BarPositionHelper.cxx @@ -22,6 +22,7 @@ #include <ViewDefines.hxx> #include <CommonConverters.hxx> #include <DateHelper.hxx> +#include <o3tl/make_unique.hxx> #include <com/sun/star/chart/TimeUnit.hpp> namespace chart @@ -46,10 +47,9 @@ BarPositionHelper::~BarPositionHelper() { } -PlottingPositionHelper* BarPositionHelper::clone() const +std::unique_ptr<PlottingPositionHelper> BarPositionHelper::clone() const { - BarPositionHelper* pRet = new BarPositionHelper(*this); - return pRet; + return o3tl::make_unique<BarPositionHelper>(*this); } void BarPositionHelper::updateSeriesCount( double fSeriesCount ) diff --git a/chart2/source/view/charttypes/BarPositionHelper.hxx b/chart2/source/view/charttypes/BarPositionHelper.hxx index 59f22d3bedde..e63fa883708e 100644 --- a/chart2/source/view/charttypes/BarPositionHelper.hxx +++ b/chart2/source/view/charttypes/BarPositionHelper.hxx @@ -33,7 +33,7 @@ public: BarPositionHelper( const BarPositionHelper& rSource ); virtual ~BarPositionHelper() override; - virtual PlottingPositionHelper* clone() const override; + virtual std::unique_ptr<PlottingPositionHelper> clone() const override; void updateSeriesCount( double fSeriesCount ); /*only enter the size of x stacked series*/ diff --git a/chart2/source/view/charttypes/VSeriesPlotter.cxx b/chart2/source/view/charttypes/VSeriesPlotter.cxx index ce592dcc89eb..b2af514f763c 100644 --- a/chart2/source/view/charttypes/VSeriesPlotter.cxx +++ b/chart2/source/view/charttypes/VSeriesPlotter.cxx @@ -175,11 +175,6 @@ VSeriesPlotter::~VSeriesPlotter() } m_aZSlots.clear(); - for (auto const& elem : m_aSecondaryPosHelperMap) - { - PlottingPositionHelper* pPosHelper = elem.second; - delete pPosHelper; - } m_aSecondaryPosHelperMap.clear(); m_aSecondaryValueScales.clear(); @@ -2077,15 +2072,15 @@ PlottingPositionHelper& VSeriesPlotter::getPlottingPositionHelper( sal_Int32 nAx tSecondaryPosHelperMap::const_iterator aPosIt = m_aSecondaryPosHelperMap.find( nAxisIndex ); if( aPosIt != m_aSecondaryPosHelperMap.end() ) { - pRet = aPosIt->second; + pRet = aPosIt->second.get(); } else if (m_pPosHelper) { tSecondaryValueScales::const_iterator aScaleIt = m_aSecondaryValueScales.find( nAxisIndex ); if( aScaleIt != m_aSecondaryValueScales.end() ) { - pRet = m_pPosHelper->createSecondaryPosHelper( aScaleIt->second ); - m_aSecondaryPosHelperMap[nAxisIndex] = pRet; + m_aSecondaryPosHelperMap[nAxisIndex] = m_pPosHelper->createSecondaryPosHelper( aScaleIt->second ); + pRet = m_aSecondaryPosHelperMap[nAxisIndex].get(); } } } diff --git a/chart2/source/view/inc/PlottingPositionHelper.hxx b/chart2/source/view/inc/PlottingPositionHelper.hxx index b5e54d3cc06d..bf70d7f9c28a 100644 --- a/chart2/source/view/inc/PlottingPositionHelper.hxx +++ b/chart2/source/view/inc/PlottingPositionHelper.hxx @@ -46,8 +46,8 @@ public: PlottingPositionHelper( const PlottingPositionHelper& rSource ); virtual ~PlottingPositionHelper(); - virtual PlottingPositionHelper* clone() const; - PlottingPositionHelper* createSecondaryPosHelper( const ExplicitScaleData& rSecondaryScale ); + virtual std::unique_ptr<PlottingPositionHelper> clone() const; + std::unique_ptr<PlottingPositionHelper> createSecondaryPosHelper( const ExplicitScaleData& rSecondaryScale ); virtual void setTransformationSceneToScreen( const css::drawing::HomogenMatrix& rMatrix); @@ -143,7 +143,7 @@ public: PolarPlottingPositionHelper( const PolarPlottingPositionHelper& rSource ); virtual ~PolarPlottingPositionHelper() override; - virtual PlottingPositionHelper* clone() const override; + virtual std::unique_ptr<PlottingPositionHelper> clone() const override; virtual void setTransformationSceneToScreen( const css::drawing::HomogenMatrix& rMatrix) override; virtual void setScales( const std::vector< ExplicitScaleData >& rScales, bool bSwapXAndYAxis ) override; diff --git a/chart2/source/view/inc/VSeriesPlotter.hxx b/chart2/source/view/inc/VSeriesPlotter.hxx index e1eac757381e..e181c7590a71 100644 --- a/chart2/source/view/inc/VSeriesPlotter.hxx +++ b/chart2/source/view/inc/VSeriesPlotter.hxx @@ -424,7 +424,7 @@ private: typedef std::map< sal_Int32 , ExplicitScaleData > tSecondaryValueScales; tSecondaryValueScales m_aSecondaryValueScales; - typedef std::map< sal_Int32 , PlottingPositionHelper* > tSecondaryPosHelperMap; + typedef std::map< sal_Int32 , std::unique_ptr<PlottingPositionHelper> > tSecondaryPosHelperMap; mutable tSecondaryPosHelperMap m_aSecondaryPosHelperMap; css::awt::Size m_aPageReferenceSize; }; diff --git a/chart2/source/view/main/PlottingPositionHelper.cxx b/chart2/source/view/main/PlottingPositionHelper.cxx index 0af1fe3d35fc..6c05d96b233a 100644 --- a/chart2/source/view/main/PlottingPositionHelper.cxx +++ b/chart2/source/view/main/PlottingPositionHelper.cxx @@ -33,6 +33,7 @@ #include <com/sun/star/drawing/Position3D.hpp> #include <com/sun/star/drawing/XShapes.hpp> +#include <o3tl/make_unique.hxx> #include <rtl/math.hxx> #include <tools/helpers.hxx> @@ -81,15 +82,14 @@ PlottingPositionHelper::~PlottingPositionHelper() } -PlottingPositionHelper* PlottingPositionHelper::clone() const +std::unique_ptr<PlottingPositionHelper> PlottingPositionHelper::clone() const { - PlottingPositionHelper* pRet = new PlottingPositionHelper(*this); - return pRet; + return o3tl::make_unique<PlottingPositionHelper>(*this); } -PlottingPositionHelper* PlottingPositionHelper::createSecondaryPosHelper( const ExplicitScaleData& rSecondaryScale ) +std::unique_ptr<PlottingPositionHelper> PlottingPositionHelper::createSecondaryPosHelper( const ExplicitScaleData& rSecondaryScale ) { - PlottingPositionHelper* pRet = clone(); + auto pRet = clone(); pRet->m_aScales[1]=rSecondaryScale; return pRet; } @@ -338,10 +338,9 @@ PolarPlottingPositionHelper::~PolarPlottingPositionHelper() { } -PlottingPositionHelper* PolarPlottingPositionHelper::clone() const +std::unique_ptr<PlottingPositionHelper> PolarPlottingPositionHelper::clone() const { - PolarPlottingPositionHelper* pRet = new PolarPlottingPositionHelper(*this); - return pRet; + return o3tl::make_unique<PolarPlottingPositionHelper>(*this); } void PolarPlottingPositionHelper::setTransformationSceneToScreen( const drawing::HomogenMatrix& rMatrix) |