summaryrefslogtreecommitdiff
path: root/sw
diff options
context:
space:
mode:
authorNoel Grandin <noel.grandin@collabora.co.uk>2018-07-04 10:51:01 +0200
committerNoel Grandin <noel.grandin@collabora.co.uk>2018-07-10 08:31:10 +0200
commit6b8a1a6fa77f910a2537958799bbdbac96e0bb57 (patch)
tree78755aa3e3aee4829d02b9f9e7b8e776da82bad3 /sw
parent208f91edea145fd76ffd67f238079f11c4142082 (diff)
loplugin:useuniqueptr in SwDropPortion
Change-Id: I42381af772d545206fc7facb0b893f7a1c8625bf Reviewed-on: https://gerrit.libreoffice.org/57200 Tested-by: Jenkins Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
Diffstat (limited to 'sw')
-rw-r--r--sw/source/core/text/pordrop.hxx6
-rw-r--r--sw/source/core/text/txtdrop.cxx18
2 files changed, 12 insertions, 12 deletions
diff --git a/sw/source/core/text/pordrop.hxx b/sw/source/core/text/pordrop.hxx
index 7d2293d17648..648ed03f4c38 100644
--- a/sw/source/core/text/pordrop.hxx
+++ b/sw/source/core/text/pordrop.hxx
@@ -61,7 +61,7 @@ public:
class SwDropPortion : public SwTextPortion
{
friend class SwDropCapCache;
- SwDropPortionPart* pPart; // due to script/attribute changes
+ std::unique_ptr<SwDropPortionPart> pPart; // due to script/attribute changes
sal_uInt16 nLines; // Line count
sal_uInt16 nDropHeight; // Height
sal_uInt16 nDropDescent; // Distance to the next line
@@ -91,8 +91,8 @@ public:
sal_uInt16 GetDropDescent() const { return nDropDescent; }
sal_uInt16 GetDropLeft() const { return Width() + nFix; }
- SwDropPortionPart* GetPart() const { return pPart; }
- void SetPart( SwDropPortionPart* pNew ) { pPart = pNew; }
+ SwDropPortionPart* GetPart() const { return pPart.get(); }
+ void SetPart( std::unique_ptr<SwDropPortionPart> pNew ) { pPart = std::move(pNew); }
void SetY( short nNew ) { nY = nNew; }
diff --git a/sw/source/core/text/txtdrop.cxx b/sw/source/core/text/txtdrop.cxx
index 6ced927d91cb..53558c50b230 100644
--- a/sw/source/core/text/txtdrop.cxx
+++ b/sw/source/core/text/txtdrop.cxx
@@ -117,7 +117,7 @@ SwDropPortion::SwDropPortion( const sal_uInt16 nLineCnt,
SwDropPortion::~SwDropPortion()
{
- delete pPart;
+ pPart.reset();
if( pBlink )
pBlink->Delete( this );
}
@@ -635,15 +635,16 @@ SwDropPortion *SwTextFormatter::NewDropPortion( SwTextFormatInfo &rInf )
if ( nNextChg > nPorLen )
nNextChg = nPorLen;
- SwDropPortionPart* pPart =
- new SwDropPortionPart( *pTmpFnt, nNextChg - nTmpIdx );
+ std::unique_ptr<SwDropPortionPart> pPart(
+ new SwDropPortionPart( *pTmpFnt, nNextChg - nTmpIdx ) );
+ auto pPartTemp = pPart.get();
if ( ! pCurrPart )
- pDropPor->SetPart( pPart );
+ pDropPor->SetPart( std::move(pPart) );
else
- pCurrPart->SetFollow( std::unique_ptr<SwDropPortionPart>(pPart) );
+ pCurrPart->SetFollow( std::move(pPart) );
- pCurrPart = pPart;
+ pCurrPart = pPartTemp;
}
SetPaintDrop( true );
@@ -1008,7 +1009,7 @@ bool SwDropPortion::Format( SwTextFormatInfo &rInf )
const long nOldX = rInf.X();
{
SwDropSave aSave( rInf );
- SwDropPortionPart* pCurrPart = pPart;
+ SwDropPortionPart* pCurrPart = pPart.get();
while ( pCurrPart )
{
@@ -1057,8 +1058,7 @@ bool SwDropPortion::Format( SwTextFormatInfo &rInf )
// And now for another round
nDropHeight = nLines = 0;
- delete pPart;
- pPart = nullptr;
+ pPart.reset();
// Meanwhile use normal formatting
bFull = SwTextPortion::Format( rInf );