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

loplugin:useuniqueptr in SvxRTFItemStackType

Change-Id: I1677915d91fb151997d4bef18473f33ab2f09648
Reviewed-on: https://gerrit.libreoffice.org/49173Tested-by: 's avatarJenkins <ci@libreoffice.org>
Reviewed-by: 's avatarNoel Grandin <noel.grandin@collabora.co.uk>
üst 76643b20
...@@ -945,9 +945,9 @@ SvxRTFItemStackType::SvxRTFItemStackType( ...@@ -945,9 +945,9 @@ SvxRTFItemStackType::SvxRTFItemStackType(
, m_pChildList( nullptr ) , m_pChildList( nullptr )
, nStyleNo( 0 ) , nStyleNo( 0 )
{ {
pSttNd = rPos.MakeNodeIdx(); pSttNd.reset( rPos.MakeNodeIdx() );
nSttCnt = rPos.GetCntIdx(); nSttCnt = rPos.GetCntIdx();
pEndNd = pSttNd; pEndNd = pSttNd.get();
nEndCnt = nSttCnt; nEndCnt = nSttCnt;
} }
...@@ -959,9 +959,9 @@ SvxRTFItemStackType::SvxRTFItemStackType( ...@@ -959,9 +959,9 @@ SvxRTFItemStackType::SvxRTFItemStackType(
, m_pChildList( nullptr ) , m_pChildList( nullptr )
, nStyleNo( rCpy.nStyleNo ) , nStyleNo( rCpy.nStyleNo )
{ {
pSttNd = rPos.MakeNodeIdx(); pSttNd.reset( rPos.MakeNodeIdx() );
nSttCnt = rPos.GetCntIdx(); nSttCnt = rPos.GetCntIdx();
pEndNd = pSttNd; pEndNd = pSttNd.get();
nEndCnt = nSttCnt; nEndCnt = nSttCnt;
aAttrSet.SetParent( &rCpy.aAttrSet ); aAttrSet.SetParent( &rCpy.aAttrSet );
...@@ -971,26 +971,23 @@ SvxRTFItemStackType::SvxRTFItemStackType( ...@@ -971,26 +971,23 @@ SvxRTFItemStackType::SvxRTFItemStackType(
SvxRTFItemStackType::~SvxRTFItemStackType() SvxRTFItemStackType::~SvxRTFItemStackType()
{ {
delete m_pChildList; if( pSttNd.get() != pEndNd )
if( pSttNd != pEndNd )
delete pEndNd; delete pEndNd;
delete pSttNd;
} }
void SvxRTFItemStackType::Add(std::unique_ptr<SvxRTFItemStackType> pIns) void SvxRTFItemStackType::Add(std::unique_ptr<SvxRTFItemStackType> pIns)
{ {
if (!m_pChildList) if (!m_pChildList)
m_pChildList = new SvxRTFItemStackList; m_pChildList.reset( new SvxRTFItemStackList );
m_pChildList->push_back(std::move(pIns)); m_pChildList->push_back(std::move(pIns));
} }
void SvxRTFItemStackType::SetStartPos( const EditPosition& rPos ) void SvxRTFItemStackType::SetStartPos( const EditPosition& rPos )
{ {
if (pSttNd != pEndNd) if (pSttNd.get() != pEndNd)
delete pEndNd; delete pEndNd;
delete pSttNd; pSttNd.reset(rPos.MakeNodeIdx() );
pSttNd = rPos.MakeNodeIdx(); pEndNd = pSttNd.get();
pEndNd = pSttNd;
nSttCnt = rPos.GetCntIdx(); nSttCnt = rPos.GetCntIdx();
} }
...@@ -1074,8 +1071,7 @@ void SvxRTFItemStackType::Compress( const SvxRTFParser& rParser ) ...@@ -1074,8 +1071,7 @@ void SvxRTFItemStackType::Compress( const SvxRTFParser& rParser )
} }
if (m_pChildList->empty()) if (m_pChildList->empty())
{ {
delete m_pChildList; m_pChildList.reset();
m_pChildList = nullptr;
} }
} }
void SvxRTFItemStackType::SetRTFDefaults( const SfxItemSet& rDefaults ) void SvxRTFItemStackType::SetRTFDefaults( const SfxItemSet& rDefaults )
......
...@@ -312,9 +312,10 @@ class EDITENG_DLLPUBLIC SvxRTFItemStackType ...@@ -312,9 +312,10 @@ class EDITENG_DLLPUBLIC SvxRTFItemStackType
friend class SvxRTFParser; friend class SvxRTFParser;
SfxItemSet aAttrSet; SfxItemSet aAttrSet;
EditNodeIdx *pSttNd, *pEndNd; std::unique_ptr<EditNodeIdx> pSttNd;
EditNodeIdx *pEndNd;
sal_Int32 nSttCnt, nEndCnt; sal_Int32 nSttCnt, nEndCnt;
SvxRTFItemStackList* m_pChildList; std::unique_ptr<SvxRTFItemStackList> m_pChildList;
sal_uInt16 nStyleNo; sal_uInt16 nStyleNo;
SvxRTFItemStackType(SvxRTFItemStackType const&) = delete; SvxRTFItemStackType(SvxRTFItemStackType const&) = delete;
......
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