loplugin:useuniqueptr in TEParaPortions

Change-Id: I530c432176ea6bd338387d2f8855f9f477e8ca75
Reviewed-on: https://gerrit.libreoffice.org/49093
Tested-by: Jenkins <ci@libreoffice.org>
Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
This commit is contained in:
Noel Grandin
2018-01-29 09:00:05 +02:00
parent 904263cdd0
commit 056ee671e2
4 changed files with 3 additions and 9 deletions

View File

@@ -212,15 +212,15 @@ public:
class TEParaPortions class TEParaPortions
{ {
private: private:
std::vector<TEParaPortion*> mvData; std::vector<std::unique_ptr<TEParaPortion>> mvData;
public: public:
TEParaPortions() : mvData() {} TEParaPortions() : mvData() {}
~TEParaPortions(); ~TEParaPortions();
sal_uInt32 Count() const { return static_cast<sal_uInt32>(mvData.size()); } sal_uInt32 Count() const { return static_cast<sal_uInt32>(mvData.size()); }
TEParaPortion* GetObject( sal_uInt32 nIndex ) { return mvData[nIndex]; } TEParaPortion* GetObject( sal_uInt32 nIndex ) { return mvData[nIndex].get(); }
void Insert( TEParaPortion* pObject, sal_uInt32 nPos ) { mvData.insert( mvData.begin()+nPos, pObject ); } void Insert( TEParaPortion* pObject, sal_uInt32 nPos ) { mvData.emplace( mvData.begin()+nPos, pObject ); }
void Remove( sal_uInt32 nPos ) { mvData.erase( mvData.begin()+nPos ); } void Remove( sal_uInt32 nPos ) { mvData.erase( mvData.begin()+nPos ); }
}; };

View File

@@ -267,8 +267,6 @@ void TEParaPortion::CorrectValuesBehindLastFormattedLine( sal_uInt16 nLastFormat
TEParaPortions::~TEParaPortions() TEParaPortions::~TEParaPortions()
{ {
for (auto const& elem : mvData)
delete elem;
} }
IdleFormatter::IdleFormatter() IdleFormatter::IdleFormatter()

View File

@@ -523,7 +523,6 @@ TextPaM TextEngine::ImpConnectParagraphs( sal_uInt32 nLeft, sal_uInt32 nRight )
pLeftPortion->MarkSelectionInvalid( aPaM.GetIndex() ); pLeftPortion->MarkSelectionInvalid( aPaM.GetIndex() );
mpTEParaPortions->Remove( nRight ); mpTEParaPortions->Remove( nRight );
delete pRightPortion;
// the right Node is deleted by EditDoc::ConnectParagraphs() // the right Node is deleted by EditDoc::ConnectParagraphs()
return aPaM; return aPaM;
@@ -601,7 +600,6 @@ TextPaM TextEngine::ImpDeleteText( const TextSelection& rSel )
void TextEngine::ImpRemoveParagraph( sal_uInt32 nPara ) void TextEngine::ImpRemoveParagraph( sal_uInt32 nPara )
{ {
TextNode* pNode = mpDoc->GetNodes()[ nPara ]; TextNode* pNode = mpDoc->GetNodes()[ nPara ];
std::unique_ptr<TEParaPortion> xPortion(mpTEParaPortions->GetObject( nPara ));
// the Node is handled by Undo and is deleted if appropriate // the Node is handled by Undo and is deleted if appropriate
mpDoc->GetNodes().erase( mpDoc->GetNodes().begin() + nPara ); mpDoc->GetNodes().erase( mpDoc->GetNodes().begin() + nPara );
@@ -611,7 +609,6 @@ void TextEngine::ImpRemoveParagraph( sal_uInt32 nPara )
delete pNode; delete pNode;
mpTEParaPortions->Remove( nPara ); mpTEParaPortions->Remove( nPara );
xPortion.reset();
ImpParagraphRemoved( nPara ); ImpParagraphRemoved( nPara );
} }

View File

@@ -165,7 +165,6 @@ void TextUndoDelPara::Redo()
// pNode is not valid anymore in case an Undo joined paragraphs // pNode is not valid anymore in case an Undo joined paragraphs
mpNode = GetDoc()->GetNodes()[ mnPara ]; mpNode = GetDoc()->GetNodes()[ mnPara ];
delete GetTEParaPortions()->GetObject( mnPara );
GetTEParaPortions()->Remove( mnPara ); GetTEParaPortions()->Remove( mnPara );
// do not delete Node because of Undo! // do not delete Node because of Undo!