From 38733c7daab85793a8d88c58808f8e35d3d25887 Mon Sep 17 00:00:00 2001 From: Noel Grandin Date: Tue, 3 Jul 2018 09:36:24 +0200 Subject: [PATCH] loplugin:useuniqueptr in ScSimpleEditSourceHelper Change-Id: Iebe62753d9e6f83f985e4c55fb938d5861613898 Reviewed-on: https://gerrit.libreoffice.org/56903 Tested-by: Jenkins Reviewed-by: Noel Grandin --- compilerplugins/clang/useuniqueptr.cxx | 3 +++ sc/inc/textuno.hxx | 10 +++++----- sc/source/ui/unoobj/textuno.cxx | 12 ++++++------ 3 files changed, 14 insertions(+), 11 deletions(-) diff --git a/compilerplugins/clang/useuniqueptr.cxx b/compilerplugins/clang/useuniqueptr.cxx index d4262c1a33ee..7a3722b785f8 100644 --- a/compilerplugins/clang/useuniqueptr.cxx +++ b/compilerplugins/clang/useuniqueptr.cxx @@ -68,6 +68,9 @@ public: // SwRedlineData::pNext and pExtraData have complex handling if (fn == SRCDIR "/sw/source/core/doc/docredln.cxx") return; + // ScTempDocSource::pTempDoc + if (fn == SRCDIR "/sc/source/ui/unoobj/funcuno.cxx") + return; TraverseDecl(compiler.getASTContext().getTranslationUnitDecl()); } diff --git a/sc/inc/textuno.hxx b/sc/inc/textuno.hxx index bb90c82f85f4..f8ae5f60bff8 100644 --- a/sc/inc/textuno.hxx +++ b/sc/inc/textuno.hxx @@ -293,16 +293,16 @@ public: class ScSimpleEditSourceHelper { - ScEditEngineDefaulter* pEditEngine; - SvxEditEngineForwarder* pForwarder; - ScSimpleEditSource* pOriginalSource; + std::unique_ptr pEditEngine; + std::unique_ptr pForwarder; + std::unique_ptr pOriginalSource; public: ScSimpleEditSourceHelper(); ~ScSimpleEditSourceHelper(); - ScSimpleEditSource* GetOriginalSource() const { return pOriginalSource; } - ScEditEngineDefaulter* GetEditEngine() const { return pEditEngine; } + ScSimpleEditSource* GetOriginalSource() const { return pOriginalSource.get(); } + ScEditEngineDefaulter* GetEditEngine() const { return pEditEngine.get(); } }; class ScEditEngineTextObj : public ScSimpleEditSourceHelper, public SvxUnoText diff --git a/sc/source/ui/unoobj/textuno.cxx b/sc/source/ui/unoobj/textuno.cxx index 7d92fd868a67..6642e3af57a8 100644 --- a/sc/source/ui/unoobj/textuno.cxx +++ b/sc/source/ui/unoobj/textuno.cxx @@ -822,18 +822,18 @@ ScSimpleEditSourceHelper::ScSimpleEditSourceHelper() pEnginePool->SetDefaultMetric( MapUnit::Map100thMM ); pEnginePool->FreezeIdRanges(); - pEditEngine = new ScFieldEditEngine(nullptr, pEnginePool, nullptr, true); // TRUE: become owner of pool - pForwarder = new SvxEditEngineForwarder( *pEditEngine ); - pOriginalSource = new ScSimpleEditSource( pForwarder ); + pEditEngine.reset( new ScFieldEditEngine(nullptr, pEnginePool, nullptr, true) ); // TRUE: become owner of pool + pForwarder.reset( new SvxEditEngineForwarder( *pEditEngine ) ); + pOriginalSource.reset( new ScSimpleEditSource( pForwarder.get() ) ); } ScSimpleEditSourceHelper::~ScSimpleEditSourceHelper() { SolarMutexGuard aGuard; // needed for EditEngine dtor - delete pOriginalSource; - delete pForwarder; - delete pEditEngine; + pOriginalSource.reset(); + pForwarder.reset(); + pEditEngine.reset(); } ScEditEngineTextObj::ScEditEngineTextObj() :