[Libreoffice-commits] core.git: sw/source
Libreoffice Gerrit user
logerrit at kemper.freedesktop.org
Wed Oct 24 09:42:03 UTC 2018
sw/source/uibase/inc/conttree.hxx | 4 +-
sw/source/uibase/utlui/content.cxx | 56 ++++++++++++++++++-------------------
2 files changed, 30 insertions(+), 30 deletions(-)
New commits:
commit 4b46826ec2219935ebcf86ed6e6db73910122e72
Author: Noel Grandin <noel.grandin at collabora.co.uk>
AuthorDate: Tue Oct 23 14:10:16 2018 +0200
Commit: Noel Grandin <noel.grandin at collabora.co.uk>
CommitDate: Wed Oct 24 11:41:38 2018 +0200
loplugin:useuniqueptr in SwContentTree
Change-Id: I4f42497023883450a00f8b50a7dd6d30ca1cbac4
Reviewed-on: https://gerrit.libreoffice.org/62265
Tested-by: Jenkins
Reviewed-by: Noel Grandin <noel.grandin at collabora.co.uk>
diff --git a/sw/source/uibase/inc/conttree.hxx b/sw/source/uibase/inc/conttree.hxx
index 186da31e64bf..3be6342ee7c7 100644
--- a/sw/source/uibase/inc/conttree.hxx
+++ b/sw/source/uibase/inc/conttree.hxx
@@ -76,8 +76,8 @@ class SwContentTree final
OUString const m_sSpace;
AutoTimer m_aUpdTimer;
- o3tl::enumarray<ContentTypeId,SwContentType*> m_aActiveContentArr;
- o3tl::enumarray<ContentTypeId,SwContentType*> m_aHiddenContentArr;
+ o3tl::enumarray<ContentTypeId,std::unique_ptr<SwContentType>> m_aActiveContentArr;
+ o3tl::enumarray<ContentTypeId,std::unique_ptr<SwContentType>> m_aHiddenContentArr;
OUString m_aContextStrings[CONTEXT_COUNT + 1];
OUString const m_sRemoveIdx;
OUString const m_sUpdateIdx;
diff --git a/sw/source/uibase/utlui/content.cxx b/sw/source/uibase/utlui/content.cxx
index ef15d5fee11e..2bb546138d60 100644
--- a/sw/source/uibase/utlui/content.cxx
+++ b/sw/source/uibase/utlui/content.cxx
@@ -1683,18 +1683,18 @@ void SwContentTree::Display( bool bActive )
{
for( ContentTypeId nCntType : o3tl::enumrange<ContentTypeId>() )
{
- SwContentType** ppContentT = bActive ?
- &m_aActiveContentArr[nCntType] :
- &m_aHiddenContentArr[nCntType];
- if(!*ppContentT)
- (*ppContentT) = new SwContentType(pShell, nCntType, m_nOutlineLevel );
+ std::unique_ptr<SwContentType>& rpContentT = bActive ?
+ m_aActiveContentArr[nCntType] :
+ m_aHiddenContentArr[nCntType];
+ if(!rpContentT)
+ rpContentT.reset(new SwContentType(pShell, nCntType, m_nOutlineLevel ));
- OUString sEntry = (*ppContentT)->GetName();
+ OUString sEntry = rpContentT->GetName();
SvTreeListEntry* pEntry;
Image aImage(GetBitmapForContentTypeId(nCntType));
- bool bChOnDemand = 0 != (*ppContentT)->GetMemberCount();
+ bool bChOnDemand = 0 != rpContentT->GetMemberCount();
pEntry = InsertEntry(sEntry, aImage, aImage,
- nullptr, bChOnDemand, TREELIST_APPEND, (*ppContentT));
+ nullptr, bChOnDemand, TREELIST_APPEND, rpContentT.get());
if(nCntType == m_nLastSelType)
pSelEntry = pEntry;
sal_Int32 nExpandOptions = (State::HIDDEN == m_eState)
@@ -1737,21 +1737,21 @@ void SwContentTree::Display( bool bActive )
}
else
{
- SwContentType** ppRootContentT = bActive ?
- &m_aActiveContentArr[m_nRootType] :
- &m_aHiddenContentArr[m_nRootType];
- if(!(*ppRootContentT))
- (*ppRootContentT) = new SwContentType(pShell, m_nRootType, m_nOutlineLevel );
+ std::unique_ptr<SwContentType>& rpRootContentT = bActive ?
+ m_aActiveContentArr[m_nRootType] :
+ m_aHiddenContentArr[m_nRootType];
+ if(!rpRootContentT)
+ rpRootContentT.reset(new SwContentType(pShell, m_nRootType, m_nOutlineLevel ));
Image aImage(GetBitmapForContentTypeId(m_nRootType));
SvTreeListEntry* pParent = InsertEntry(
- (*ppRootContentT)->GetName(), aImage, aImage,
- nullptr, false, TREELIST_APPEND, *ppRootContentT);
+ rpRootContentT->GetName(), aImage, aImage,
+ nullptr, false, TREELIST_APPEND, rpRootContentT.get());
if(m_nRootType != ContentTypeId::OUTLINE)
{
- for(size_t i = 0; i < (*ppRootContentT)->GetMemberCount(); ++i)
+ for(size_t i = 0; i < rpRootContentT->GetMemberCount(); ++i)
{
- const SwContent* pCnt = (*ppRootContentT)->GetMember(i);
+ const SwContent* pCnt = rpRootContentT->GetMember(i);
if(pCnt)
{
OUString sEntry = pCnt->GetName();
@@ -2051,7 +2051,7 @@ bool SwContentTree::HasContentChanged()
assert(dynamic_cast<SwContentType*>(static_cast<SwTypeNumber*>(pEntry->GetUserData())));
const ContentTypeId nType = static_cast<SwContentType*>(pEntry->GetUserData())->GetType();
bOutline = m_nRootType == ContentTypeId::OUTLINE;
- SwContentType* pArrType = m_aActiveContentArr[nType];
+ SwContentType* pArrType = m_aActiveContentArr[nType].get();
if(!pArrType)
bRepaint = true;
else
@@ -2130,7 +2130,7 @@ bool SwContentTree::HasContentChanged()
SwContentType* pTreeType = static_cast<SwContentType*>(pEntry->GetUserData());
const size_t nTreeCount = pTreeType->GetMemberCount();
const ContentTypeId nType = pTreeType->GetType();
- SwContentType* pArrType = m_aActiveContentArr[nType];
+ SwContentType* pArrType = m_aActiveContentArr[nType].get();
if(!pArrType)
bRepaint = true;
else
@@ -2269,7 +2269,7 @@ void SwContentTree::SetHiddenShell(SwWrtShell* pSh)
FindActiveTypeAndRemoveUserData();
for(ContentTypeId i : o3tl::enumrange<ContentTypeId>())
{
- DELETEZ(m_aHiddenContentArr[i]);
+ m_aHiddenContentArr[i].reset();
}
Display(false);
@@ -2306,7 +2306,7 @@ void SwContentTree::SetActiveShell(SwWrtShell* pSh)
FindActiveTypeAndRemoveUserData();
for(ContentTypeId i : o3tl::enumrange<ContentTypeId>())
{
- DELETEZ(m_aActiveContentArr[i]);
+ m_aActiveContentArr[i].reset();
}
Display(true);
}
@@ -2322,7 +2322,7 @@ void SwContentTree::SetConstantShell(SwWrtShell* pSh)
FindActiveTypeAndRemoveUserData();
for(ContentTypeId i : o3tl::enumrange<ContentTypeId>())
{
- DELETEZ(m_aActiveContentArr[i]);
+ m_aActiveContentArr[i].reset();
}
Display(true);
}
@@ -3133,13 +3133,13 @@ void SwContentTree::SetOutlineLevel(sal_uInt8 nSet)
{
m_nOutlineLevel = nSet;
m_pConfig->SetOutlineLevel( m_nOutlineLevel );
- SwContentType** ppContentT = (State::ACTIVE == m_eState)
- ? &m_aActiveContentArr[ContentTypeId::OUTLINE]
- : &m_aHiddenContentArr[ContentTypeId::OUTLINE];
- if(*ppContentT)
+ std::unique_ptr<SwContentType>& rpContentT = (State::ACTIVE == m_eState)
+ ? m_aActiveContentArr[ContentTypeId::OUTLINE]
+ : m_aHiddenContentArr[ContentTypeId::OUTLINE];
+ if(rpContentT)
{
- (*ppContentT)->SetOutlineLevel(m_nOutlineLevel);
- (*ppContentT)->Init();
+ rpContentT->SetOutlineLevel(m_nOutlineLevel);
+ rpContentT->Init();
}
Display(State::ACTIVE == m_eState);
}
More information about the Libreoffice-commits
mailing list