diff options
author | Noel Grandin <noel.grandin@collabora.co.uk> | 2018-03-20 09:26:34 +0200 |
---|---|---|
committer | Noel Grandin <noel.grandin@collabora.co.uk> | 2018-03-22 07:34:46 +0100 |
commit | 2074a7a42d5865ce2915a0e3c16535d5105c6e71 (patch) | |
tree | 42e56c77cad6eae9c6cac4377f0fa3c9f9c6dfbd /sw | |
parent | a9c78d7849b62fde34ec79c50063fba550c05e70 (diff) |
loplugin:useuniqueptr in SwDefTOXBase_Impl
Change-Id: I114cbf54420d8fb017e1ec5530d40413d8c34ed4
Reviewed-on: https://gerrit.libreoffice.org/51666
Tested-by: Jenkins <ci@libreoffice.org>
Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
Diffstat (limited to 'sw')
-rw-r--r-- | sw/source/core/doc/doctxm.cxx | 11 | ||||
-rw-r--r-- | sw/source/core/inc/doctxm.hxx | 40 |
2 files changed, 15 insertions, 36 deletions
diff --git a/sw/source/core/doc/doctxm.cxx b/sw/source/core/doc/doctxm.cxx index 621f540c0e00..64310da59d4c 100644 --- a/sw/source/core/doc/doctxm.cxx +++ b/sw/source/core/doc/doctxm.cxx @@ -449,7 +449,7 @@ const SwAttrSet& SwDoc::GetTOXBaseAttrSet(const SwTOXBase& rTOXBase) const SwTOXBase* SwDoc::GetDefaultTOXBase( TOXTypes eTyp, bool bCreate ) { - SwTOXBase** prBase = nullptr; + std::unique_ptr<SwTOXBase>* prBase = nullptr; switch(eTyp) { case TOX_CONTENT: prBase = &mpDefTOXBases->pContBase; break; @@ -468,14 +468,14 @@ const SwTOXBase* SwDoc::GetDefaultTOXBase( TOXTypes eTyp, bool bCreate ) { SwForm aForm(eTyp); const SwTOXType* pType = GetTOXType(eTyp, 0); - (*prBase) = new SwTOXBase(pType, aForm, SwTOXElement::NONE, pType->GetTypeName()); + prBase->reset(new SwTOXBase(pType, aForm, SwTOXElement::NONE, pType->GetTypeName())); } - return (*prBase); + return prBase->get(); } void SwDoc::SetDefaultTOXBase(const SwTOXBase& rBase) { - SwTOXBase** prBase = nullptr; + std::unique_ptr<SwTOXBase>* prBase = nullptr; switch(rBase.GetType()) { case TOX_CONTENT: prBase = &mpDefTOXBases->pContBase; break; @@ -490,8 +490,7 @@ void SwDoc::SetDefaultTOXBase(const SwTOXBase& rBase) } if (!prBase) return; - delete *prBase; - (*prBase) = new SwTOXBase(rBase); + prBase->reset(new SwTOXBase(rBase)); } /// Delete table of contents diff --git a/sw/source/core/inc/doctxm.hxx b/sw/source/core/inc/doctxm.hxx index 1e7fc131fbae..39826f2eb8ec 100644 --- a/sw/source/core/inc/doctxm.hxx +++ b/sw/source/core/inc/doctxm.hxx @@ -85,38 +85,18 @@ public: struct SwDefTOXBase_Impl { - SwTOXBase* pContBase; - SwTOXBase* pIdxBase; - SwTOXBase* pUserBase; - SwTOXBase* pTableBase; - SwTOXBase* pObjBase; - SwTOXBase* pIllBase; - SwTOXBase* pAuthBase; - SwTOXBase* pBiblioBase; - - SwDefTOXBase_Impl() : - pContBase(nullptr), - pIdxBase(nullptr), - pUserBase(nullptr), - pTableBase(nullptr), - pObjBase(nullptr), - pIllBase(nullptr), - pAuthBase(nullptr), - pBiblioBase(nullptr) + std::unique_ptr<SwTOXBase> pContBase; + std::unique_ptr<SwTOXBase> pIdxBase; + std::unique_ptr<SwTOXBase> pUserBase; + std::unique_ptr<SwTOXBase> pTableBase; + std::unique_ptr<SwTOXBase> pObjBase; + std::unique_ptr<SwTOXBase> pIllBase; + std::unique_ptr<SwTOXBase> pAuthBase; + std::unique_ptr<SwTOXBase> pBiblioBase; + + SwDefTOXBase_Impl() { } - ~SwDefTOXBase_Impl() - { - delete pContBase; - delete pIdxBase; - delete pUserBase; - delete pTableBase; - delete pObjBase; - delete pIllBase; - delete pAuthBase; - delete pBiblioBase; - } - }; #endif |