diff options
author | Noel Grandin <noel.grandin@collabora.co.uk> | 2018-09-28 11:24:04 +0200 |
---|---|---|
committer | Noel Grandin <noel.grandin@collabora.co.uk> | 2018-10-01 09:08:41 +0200 |
commit | bb8207ed0a900e1e45c5d3f91f82d28d5c88bc43 (patch) | |
tree | c3041299a7680945ff2314d39fde19c1a670a4bc /scaddins | |
parent | 7384e53bbc5163534ae898b7295b4efe51c8acde (diff) |
loplugin:useuniqueptr in scaddins::ConvertDataLinear
Change-Id: I071e7b072ea6b96a527ccbac91e122f0253eb448
Reviewed-on: https://gerrit.libreoffice.org/61117
Tested-by: Jenkins
Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
Diffstat (limited to 'scaddins')
-rw-r--r-- | scaddins/source/analysis/analysishelper.cxx | 14 | ||||
-rw-r--r-- | scaddins/source/analysis/analysishelper.hxx | 3 |
2 files changed, 8 insertions, 9 deletions
diff --git a/scaddins/source/analysis/analysishelper.cxx b/scaddins/source/analysis/analysishelper.cxx index 20bd97273fc3..a6b8e7df568c 100644 --- a/scaddins/source/analysis/analysishelper.cxx +++ b/scaddins/source/analysis/analysishelper.cxx @@ -2298,10 +2298,10 @@ double ConvertDataLinear::ConvertFromBase( double f, sal_Int16 n ) const ConvertDataList::ConvertDataList() { -#define NEWD(str,unit,cl) maVector.push_back(new ConvertData(str,unit,cl)) -#define NEWDP(str,unit,cl) maVector.push_back(new ConvertData(str,unit,cl,true)) -#define NEWL(str,unit,offs,cl) maVector.push_back(new ConvertDataLinear(str,unit,offs,cl)) -#define NEWLP(str,unit,offs,cl) maVector.push_back(new ConvertDataLinear(str,unit,offs,cl,true)) +#define NEWD(str,unit,cl) maVector.emplace_back(new ConvertData(str,unit,cl)) +#define NEWDP(str,unit,cl) maVector.emplace_back(new ConvertData(str,unit,cl,true)) +#define NEWL(str,unit,offs,cl) maVector.emplace_back(new ConvertDataLinear(str,unit,offs,cl)) +#define NEWLP(str,unit,offs,cl) maVector.emplace_back(new ConvertDataLinear(str,unit,offs,cl,true)) // *** are extra and not standard Excel Analysis Addin! @@ -2481,8 +2481,6 @@ ConvertDataList::ConvertDataList() ConvertDataList::~ConvertDataList() { - for( std::vector<ConvertData*>::const_iterator it = maVector.begin(); it != maVector.end(); ++it ) - delete *it; } @@ -2495,10 +2493,10 @@ double ConvertDataList::Convert( double fVal, const OUString& rFrom, const OUStr sal_Int16 nLevelFrom = 0; sal_Int16 nLevelTo = 0; - std::vector<ConvertData*>::iterator it = maVector.begin(); + auto it = maVector.begin(); while( it != maVector.end() && ( bSearchFrom || bSearchTo ) ) { - ConvertData* p = *it; + ConvertData* p = it->get(); if( bSearchFrom ) { sal_Int16 n = p->GetMatchingLevel( rFrom ); diff --git a/scaddins/source/analysis/analysishelper.hxx b/scaddins/source/analysis/analysishelper.hxx index 85dc1eb65ccb..f0eaac926dfb 100644 --- a/scaddins/source/analysis/analysishelper.hxx +++ b/scaddins/source/analysis/analysishelper.hxx @@ -34,6 +34,7 @@ #include "analysisdefs.hxx" +#include <memory> #include <vector> @@ -576,7 +577,7 @@ public: class ConvertDataList { private: - std::vector<ConvertData*> maVector; + std::vector<std::unique_ptr<ConvertData>> maVector; public: ConvertDataList(); ~ConvertDataList(); |