Kaydet (Commit) 4b46826e authored tarafından Noel Grandin's avatar Noel Grandin

loplugin:useuniqueptr in SwContentTree

Change-Id: I4f42497023883450a00f8b50a7dd6d30ca1cbac4
Reviewed-on: https://gerrit.libreoffice.org/62265
Tested-by: Jenkins
Reviewed-by: 's avatarNoel Grandin <noel.grandin@collabora.co.uk>
üst 808ba7c1
...@@ -76,8 +76,8 @@ class SwContentTree final ...@@ -76,8 +76,8 @@ class SwContentTree final
OUString const m_sSpace; OUString const m_sSpace;
AutoTimer m_aUpdTimer; AutoTimer m_aUpdTimer;
o3tl::enumarray<ContentTypeId,SwContentType*> m_aActiveContentArr; o3tl::enumarray<ContentTypeId,std::unique_ptr<SwContentType>> m_aActiveContentArr;
o3tl::enumarray<ContentTypeId,SwContentType*> m_aHiddenContentArr; o3tl::enumarray<ContentTypeId,std::unique_ptr<SwContentType>> m_aHiddenContentArr;
OUString m_aContextStrings[CONTEXT_COUNT + 1]; OUString m_aContextStrings[CONTEXT_COUNT + 1];
OUString const m_sRemoveIdx; OUString const m_sRemoveIdx;
OUString const m_sUpdateIdx; OUString const m_sUpdateIdx;
......
...@@ -1683,18 +1683,18 @@ void SwContentTree::Display( bool bActive ) ...@@ -1683,18 +1683,18 @@ void SwContentTree::Display( bool bActive )
{ {
for( ContentTypeId nCntType : o3tl::enumrange<ContentTypeId>() ) for( ContentTypeId nCntType : o3tl::enumrange<ContentTypeId>() )
{ {
SwContentType** ppContentT = bActive ? std::unique_ptr<SwContentType>& rpContentT = bActive ?
&m_aActiveContentArr[nCntType] : m_aActiveContentArr[nCntType] :
&m_aHiddenContentArr[nCntType]; m_aHiddenContentArr[nCntType];
if(!*ppContentT) if(!rpContentT)
(*ppContentT) = new SwContentType(pShell, nCntType, m_nOutlineLevel ); rpContentT.reset(new SwContentType(pShell, nCntType, m_nOutlineLevel ));
OUString sEntry = (*ppContentT)->GetName(); OUString sEntry = rpContentT->GetName();
SvTreeListEntry* pEntry; SvTreeListEntry* pEntry;
Image aImage(GetBitmapForContentTypeId(nCntType)); Image aImage(GetBitmapForContentTypeId(nCntType));
bool bChOnDemand = 0 != (*ppContentT)->GetMemberCount(); bool bChOnDemand = 0 != rpContentT->GetMemberCount();
pEntry = InsertEntry(sEntry, aImage, aImage, pEntry = InsertEntry(sEntry, aImage, aImage,
nullptr, bChOnDemand, TREELIST_APPEND, (*ppContentT)); nullptr, bChOnDemand, TREELIST_APPEND, rpContentT.get());
if(nCntType == m_nLastSelType) if(nCntType == m_nLastSelType)
pSelEntry = pEntry; pSelEntry = pEntry;
sal_Int32 nExpandOptions = (State::HIDDEN == m_eState) sal_Int32 nExpandOptions = (State::HIDDEN == m_eState)
...@@ -1737,21 +1737,21 @@ void SwContentTree::Display( bool bActive ) ...@@ -1737,21 +1737,21 @@ void SwContentTree::Display( bool bActive )
} }
else else
{ {
SwContentType** ppRootContentT = bActive ? std::unique_ptr<SwContentType>& rpRootContentT = bActive ?
&m_aActiveContentArr[m_nRootType] : m_aActiveContentArr[m_nRootType] :
&m_aHiddenContentArr[m_nRootType]; m_aHiddenContentArr[m_nRootType];
if(!(*ppRootContentT)) if(!rpRootContentT)
(*ppRootContentT) = new SwContentType(pShell, m_nRootType, m_nOutlineLevel ); rpRootContentT.reset(new SwContentType(pShell, m_nRootType, m_nOutlineLevel ));
Image aImage(GetBitmapForContentTypeId(m_nRootType)); Image aImage(GetBitmapForContentTypeId(m_nRootType));
SvTreeListEntry* pParent = InsertEntry( SvTreeListEntry* pParent = InsertEntry(
(*ppRootContentT)->GetName(), aImage, aImage, rpRootContentT->GetName(), aImage, aImage,
nullptr, false, TREELIST_APPEND, *ppRootContentT); nullptr, false, TREELIST_APPEND, rpRootContentT.get());
if(m_nRootType != ContentTypeId::OUTLINE) 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) if(pCnt)
{ {
OUString sEntry = pCnt->GetName(); OUString sEntry = pCnt->GetName();
...@@ -2051,7 +2051,7 @@ bool SwContentTree::HasContentChanged() ...@@ -2051,7 +2051,7 @@ bool SwContentTree::HasContentChanged()
assert(dynamic_cast<SwContentType*>(static_cast<SwTypeNumber*>(pEntry->GetUserData()))); assert(dynamic_cast<SwContentType*>(static_cast<SwTypeNumber*>(pEntry->GetUserData())));
const ContentTypeId nType = static_cast<SwContentType*>(pEntry->GetUserData())->GetType(); const ContentTypeId nType = static_cast<SwContentType*>(pEntry->GetUserData())->GetType();
bOutline = m_nRootType == ContentTypeId::OUTLINE; bOutline = m_nRootType == ContentTypeId::OUTLINE;
SwContentType* pArrType = m_aActiveContentArr[nType]; SwContentType* pArrType = m_aActiveContentArr[nType].get();
if(!pArrType) if(!pArrType)
bRepaint = true; bRepaint = true;
else else
...@@ -2130,7 +2130,7 @@ bool SwContentTree::HasContentChanged() ...@@ -2130,7 +2130,7 @@ bool SwContentTree::HasContentChanged()
SwContentType* pTreeType = static_cast<SwContentType*>(pEntry->GetUserData()); SwContentType* pTreeType = static_cast<SwContentType*>(pEntry->GetUserData());
const size_t nTreeCount = pTreeType->GetMemberCount(); const size_t nTreeCount = pTreeType->GetMemberCount();
const ContentTypeId nType = pTreeType->GetType(); const ContentTypeId nType = pTreeType->GetType();
SwContentType* pArrType = m_aActiveContentArr[nType]; SwContentType* pArrType = m_aActiveContentArr[nType].get();
if(!pArrType) if(!pArrType)
bRepaint = true; bRepaint = true;
else else
...@@ -2269,7 +2269,7 @@ void SwContentTree::SetHiddenShell(SwWrtShell* pSh) ...@@ -2269,7 +2269,7 @@ void SwContentTree::SetHiddenShell(SwWrtShell* pSh)
FindActiveTypeAndRemoveUserData(); FindActiveTypeAndRemoveUserData();
for(ContentTypeId i : o3tl::enumrange<ContentTypeId>()) for(ContentTypeId i : o3tl::enumrange<ContentTypeId>())
{ {
DELETEZ(m_aHiddenContentArr[i]); m_aHiddenContentArr[i].reset();
} }
Display(false); Display(false);
...@@ -2306,7 +2306,7 @@ void SwContentTree::SetActiveShell(SwWrtShell* pSh) ...@@ -2306,7 +2306,7 @@ void SwContentTree::SetActiveShell(SwWrtShell* pSh)
FindActiveTypeAndRemoveUserData(); FindActiveTypeAndRemoveUserData();
for(ContentTypeId i : o3tl::enumrange<ContentTypeId>()) for(ContentTypeId i : o3tl::enumrange<ContentTypeId>())
{ {
DELETEZ(m_aActiveContentArr[i]); m_aActiveContentArr[i].reset();
} }
Display(true); Display(true);
} }
...@@ -2322,7 +2322,7 @@ void SwContentTree::SetConstantShell(SwWrtShell* pSh) ...@@ -2322,7 +2322,7 @@ void SwContentTree::SetConstantShell(SwWrtShell* pSh)
FindActiveTypeAndRemoveUserData(); FindActiveTypeAndRemoveUserData();
for(ContentTypeId i : o3tl::enumrange<ContentTypeId>()) for(ContentTypeId i : o3tl::enumrange<ContentTypeId>())
{ {
DELETEZ(m_aActiveContentArr[i]); m_aActiveContentArr[i].reset();
} }
Display(true); Display(true);
} }
...@@ -3133,13 +3133,13 @@ void SwContentTree::SetOutlineLevel(sal_uInt8 nSet) ...@@ -3133,13 +3133,13 @@ void SwContentTree::SetOutlineLevel(sal_uInt8 nSet)
{ {
m_nOutlineLevel = nSet; m_nOutlineLevel = nSet;
m_pConfig->SetOutlineLevel( m_nOutlineLevel ); m_pConfig->SetOutlineLevel( m_nOutlineLevel );
SwContentType** ppContentT = (State::ACTIVE == m_eState) std::unique_ptr<SwContentType>& rpContentT = (State::ACTIVE == m_eState)
? &m_aActiveContentArr[ContentTypeId::OUTLINE] ? m_aActiveContentArr[ContentTypeId::OUTLINE]
: &m_aHiddenContentArr[ContentTypeId::OUTLINE]; : m_aHiddenContentArr[ContentTypeId::OUTLINE];
if(*ppContentT) if(rpContentT)
{ {
(*ppContentT)->SetOutlineLevel(m_nOutlineLevel); rpContentT->SetOutlineLevel(m_nOutlineLevel);
(*ppContentT)->Init(); rpContentT->Init();
} }
Display(State::ACTIVE == m_eState); Display(State::ACTIVE == m_eState);
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment