diff options
-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 |