summaryrefslogtreecommitdiff
path: root/sw
diff options
context:
space:
mode:
authorNoel Grandin <noel.grandin@collabora.co.uk>2018-08-20 15:54:33 +0200
committerNoel Grandin <noel.grandin@collabora.co.uk>2018-08-22 08:27:36 +0200
commitddfed109ebaa854582bc59750a1988af3f6ad3d6 (patch)
tree43b1c53a27afab60300232e73e9321adef342c87 /sw
parent9590c68852177056602342dd874b8818eeb57e82 (diff)
loplugin:useuniqueptr in SwFieldPortion
Change-Id: I7b87652c86ff682760120f3992b33e27f4eaeaed Reviewed-on: https://gerrit.libreoffice.org/59365 Tested-by: Jenkins Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
Diffstat (limited to 'sw')
-rw-r--r--sw/source/core/text/porfld.cxx36
-rw-r--r--sw/source/core/text/porfld.hxx10
-rw-r--r--sw/source/core/text/porftn.hxx4
-rw-r--r--sw/source/core/text/pormulti.cxx8
-rw-r--r--sw/source/core/text/txtfld.cxx27
-rw-r--r--sw/source/core/text/txtftn.cxx4
6 files changed, 42 insertions, 47 deletions
diff --git a/sw/source/core/text/porfld.cxx b/sw/source/core/text/porfld.cxx
index d76a1d94c053..818a15d8e26f 100644
--- a/sw/source/core/text/porfld.cxx
+++ b/sw/source/core/text/porfld.cxx
@@ -52,14 +52,14 @@ SwLinePortion *SwFieldPortion::Compress()
SwFieldPortion *SwFieldPortion::Clone( const OUString &rExpand ) const
{
- SwFont *pNewFnt = m_pFont.get();
- if( nullptr != pNewFnt )
+ std::unique_ptr<SwFont> pNewFnt;
+ if( m_pFont )
{
- pNewFnt = new SwFont( *m_pFont );
+ pNewFnt.reset(new SwFont( *m_pFont ));
}
// #i107143#
// pass placeholder property to created <SwFieldPortion> instance.
- SwFieldPortion* pClone = new SwFieldPortion( rExpand, pNewFnt, m_bPlaceHolder );
+ SwFieldPortion* pClone = new SwFieldPortion( rExpand, std::move(pNewFnt), m_bPlaceHolder );
pClone->SetNextOffset( m_nNextOffset );
pClone->m_bNoLength = m_bNoLength;
return pClone;
@@ -73,8 +73,8 @@ void SwFieldPortion::TakeNextOffset( const SwFieldPortion* pField )
m_bFollow = true;
}
-SwFieldPortion::SwFieldPortion( const OUString &rExpand, SwFont *pFont, bool bPlaceHold )
- : m_aExpand(rExpand), m_pFont(pFont), m_nNextOffset(0), m_nNextScriptChg(COMPLETE_STRING), m_nViewWidth(0)
+SwFieldPortion::SwFieldPortion( const OUString &rExpand, std::unique_ptr<SwFont> pFont, bool bPlaceHold )
+ : m_aExpand(rExpand), m_pFont(std::move(pFont)), m_nNextOffset(0), m_nNextScriptChg(COMPLETE_STRING), m_nViewWidth(0)
, m_bFollow( false ), m_bLeft( false), m_bHide( false)
, m_bCenter (false), m_bHasFollow( false )
, m_bAnimated( false), m_bNoPaint( false)
@@ -473,10 +473,10 @@ SwPosSize SwFieldPortion::GetTextSize( const SwTextSizeInfo &rInf ) const
SwFieldPortion *SwHiddenPortion::Clone(const OUString &rExpand ) const
{
- SwFont *pNewFnt = m_pFont.get();
- if( nullptr != pNewFnt )
- pNewFnt = new SwFont( *m_pFont );
- return new SwHiddenPortion( rExpand, pNewFnt );
+ std::unique_ptr<SwFont> pNewFnt;
+ if( m_pFont )
+ pNewFnt.reset(new SwFont( *m_pFont ));
+ return new SwHiddenPortion( rExpand, std::move(pNewFnt) );
}
void SwHiddenPortion::Paint( const SwTextPaintInfo &rInf ) const
@@ -496,12 +496,12 @@ bool SwHiddenPortion::GetExpText( const SwTextSizeInfo &rInf, OUString &rText )
}
SwNumberPortion::SwNumberPortion( const OUString &rExpand,
- SwFont *pFont,
+ std::unique_ptr<SwFont> pFont,
const bool bLft,
const bool bCntr,
const sal_uInt16 nMinDst,
const bool bLabelAlignmentPosAndSpaceModeActive )
- : SwFieldPortion( rExpand, pFont ),
+ : SwFieldPortion( rExpand, std::move(pFont) ),
nFixWidth(0),
nMinDist( nMinDst ),
mbLabelAlignmentPosAndSpaceModeActive( bLabelAlignmentPosAndSpaceModeActive )
@@ -519,11 +519,11 @@ TextFrameIndex SwNumberPortion::GetCursorOfst(const sal_uInt16) const
SwFieldPortion *SwNumberPortion::Clone( const OUString &rExpand ) const
{
- SwFont *pNewFnt = m_pFont.get();
- if( nullptr != pNewFnt )
- pNewFnt = new SwFont( *m_pFont );
+ std::unique_ptr<SwFont> pNewFnt;
+ if( m_pFont )
+ pNewFnt.reset(new SwFont( *m_pFont ));
- return new SwNumberPortion( rExpand, pNewFnt, IsLeft(), IsCenter(),
+ return new SwNumberPortion( rExpand, std::move(pNewFnt), IsLeft(), IsCenter(),
nMinDist, mbLabelAlignmentPosAndSpaceModeActive );
}
@@ -739,13 +739,13 @@ void SwNumberPortion::Paint( const SwTextPaintInfo &rInf ) const
SwBulletPortion::SwBulletPortion( const sal_Unicode cBullet,
const OUString& rBulletFollowedBy,
- SwFont *pFont,
+ std::unique_ptr<SwFont> pFont,
const bool bLft,
const bool bCntr,
const sal_uInt16 nMinDst,
const bool bLabelAlignmentPosAndSpaceModeActive )
: SwNumberPortion( OUStringLiteral1(cBullet) + rBulletFollowedBy,
- pFont, bLft, bCntr, nMinDst,
+ std::move(pFont), bLft, bCntr, nMinDst,
bLabelAlignmentPosAndSpaceModeActive )
{
SetWhichPor( POR_BULLET );
diff --git a/sw/source/core/text/porfld.hxx b/sw/source/core/text/porfld.hxx
index a0476bbb58f2..d014ec9a0bce 100644
--- a/sw/source/core/text/porfld.hxx
+++ b/sw/source/core/text/porfld.hxx
@@ -53,7 +53,7 @@ protected:
public:
SwFieldPortion( const SwFieldPortion& rField );
- SwFieldPortion( const OUString &rExpand, SwFont *pFnt = nullptr, bool bPlaceHolder = false );
+ SwFieldPortion( const OUString &rExpand, std::unique_ptr<SwFont> pFnt = nullptr, bool bPlaceHolder = false );
virtual ~SwFieldPortion() override;
sal_uInt16 m_nAttrFieldType;
@@ -107,8 +107,8 @@ public:
class SwHiddenPortion : public SwFieldPortion
{
public:
- SwHiddenPortion( const OUString &rExpand, SwFont *pFntL = nullptr )
- : SwFieldPortion( rExpand, pFntL )
+ SwHiddenPortion( const OUString &rExpand, std::unique_ptr<SwFont> pFntL = nullptr )
+ : SwFieldPortion( rExpand, std::move(pFntL) )
{ SetLen(TextFrameIndex(1)); SetWhichPor( POR_HIDDEN ); }
virtual void Paint( const SwTextPaintInfo &rInf ) const override;
virtual bool GetExpText( const SwTextSizeInfo &rInf, OUString &rText ) const override;
@@ -126,7 +126,7 @@ protected:
public:
SwNumberPortion( const OUString &rExpand,
- SwFont *pFnt,
+ std::unique_ptr<SwFont> pFnt,
const bool bLeft,
const bool bCenter,
const sal_uInt16 nMinDst,
@@ -145,7 +145,7 @@ class SwBulletPortion : public SwNumberPortion
public:
SwBulletPortion( const sal_Unicode cCh,
const OUString& rBulletFollowedBy,
- SwFont *pFnt,
+ std::unique_ptr<SwFont> pFnt,
const bool bLeft,
const bool bCenter,
const sal_uInt16 nMinDst,
diff --git a/sw/source/core/text/porftn.hxx b/sw/source/core/text/porftn.hxx
index bb0b625ce28e..7b0ae819dbe0 100644
--- a/sw/source/core/text/porftn.hxx
+++ b/sw/source/core/text/porftn.hxx
@@ -50,8 +50,8 @@ public:
class SwFootnoteNumPortion : public SwNumberPortion
{
public:
- SwFootnoteNumPortion( const OUString &rExpand, SwFont *pFntL )
- : SwNumberPortion( rExpand, pFntL, true, false, 0, false )
+ SwFootnoteNumPortion( const OUString &rExpand, std::unique_ptr<SwFont> pFntL )
+ : SwNumberPortion( rExpand, std::move(pFntL), true, false, 0, false )
{ SetWhichPor( POR_FTNNUM ); }
};
diff --git a/sw/source/core/text/pormulti.cxx b/sw/source/core/text/pormulti.cxx
index 78423e440a6f..700d3e0817db 100644
--- a/sw/source/core/text/pormulti.cxx
+++ b/sw/source/core/text/pormulti.cxx
@@ -585,21 +585,19 @@ SwRubyPortion::SwRubyPortion( const SwMultiCreator& rCreate, const SwFont& rFnt,
const SwCharFormat *const pFormat =
static_txtattr_cast<SwTextRuby const*>(rCreate.pAttr)->GetCharFormat();
- SwFont *pRubyFont;
+ std::unique_ptr<SwFont> pRubyFont;
if( pFormat )
{
const SwAttrSet& rSet = pFormat->GetAttrSet();
- pRubyFont = new SwFont( rFnt );
+ pRubyFont.reset(new SwFont( rFnt ));
pRubyFont->SetDiffFnt( &rSet, &rIDocumentSettingAccess );
// we do not allow a vertical font for the ruby text
pRubyFont->SetVertical( rFnt.GetOrientation() , OnRight() );
}
- else
- pRubyFont = nullptr;
OUString aStr = rRuby.GetText().copy( sal_Int32(nOffs) );
- SwFieldPortion *pField = new SwFieldPortion( aStr, pRubyFont );
+ SwFieldPortion *pField = new SwFieldPortion( aStr, std::move(pRubyFont) );
pField->SetNextOffset( nOffs );
pField->SetFollow( true );
diff --git a/sw/source/core/text/txtfld.cxx b/sw/source/core/text/txtfld.cxx
index 9ba37a923740..e66b7ed2c884 100644
--- a/sw/source/core/text/txtfld.cxx
+++ b/sw/source/core/text/txtfld.cxx
@@ -275,18 +275,16 @@ SwExpandPortion *SwTextFormatter::NewFieldPortion( SwTextFormatInfo &rInf,
if( bNewFlyPor )
{
- SwFont *pTmpFnt = nullptr;
+ std::unique_ptr<SwFont> pTmpFnt;
if( !bName )
{
- pTmpFnt = new SwFont( *m_pFont );
+ pTmpFnt.reset(new SwFont( *m_pFont ));
pTmpFnt->SetDiffFnt(&pChFormat->GetAttrSet(), &m_pFrame->GetDoc().getIDocumentSettingAccess());
}
- {
- OUString const aStr( bName
- ? pField->GetFieldName()
- : pField->ExpandField(bInClipboard) );
- pRet = new SwFieldPortion(aStr, pTmpFnt, bPlaceHolder);
- }
+ OUString const aStr( bName
+ ? pField->GetFieldName()
+ : pField->ExpandField(bInClipboard) );
+ pRet = new SwFieldPortion(aStr, std::move(pTmpFnt), bPlaceHolder);
}
return pRet;
@@ -516,7 +514,6 @@ SwNumberPortion *SwTextFormatter::NewNumberPortion( SwTextFormatInfo &rInf ) con
// The SwFont is created dynamically and passed in the ctor,
// as the CharFormat only returns an SV-Font.
// In the dtor of SwNumberPortion, the SwFont is deleted.
- SwFont *pNumFnt = nullptr;
const SwAttrSet* pFormat = rNumFormat.GetCharFormat() ?
&rNumFormat.GetCharFormat()->GetAttrSet() :
nullptr;
@@ -527,7 +524,7 @@ SwNumberPortion *SwTextFormatter::NewNumberPortion( SwTextFormatInfo &rInf ) con
const vcl::Font *pFormatFnt = rNumFormat.GetBulletFont();
// Build a new bullet font basing on the current paragraph font:
- pNumFnt = new SwFont( &rInf.GetCharAttr(), pIDSA );
+ std::unique_ptr<SwFont> pNumFnt(new SwFont( &rInf.GetCharAttr(), pIDSA ));
// #i53199#
if ( !pIDSA->get(DocumentSettingId::DO_NOT_RESET_PARA_ATTRS_FOR_NUM_FONT) )
@@ -552,7 +549,7 @@ SwNumberPortion *SwTextFormatter::NewNumberPortion( SwTextFormatInfo &rInf ) con
if( pFormat )
pNumFnt->SetDiffFnt( pFormat, pIDSA );
- checkApplyParagraphMarkFormatToNumbering( pNumFnt, rInf, pIDSA );
+ checkApplyParagraphMarkFormatToNumbering( pNumFnt.get(), rInf, pIDSA );
if ( pFormatFnt )
{
@@ -571,7 +568,7 @@ SwNumberPortion *SwTextFormatter::NewNumberPortion( SwTextFormatInfo &rInf ) con
// --> OD 2008-01-23 #newlistelevelattrs#
pRet = new SwBulletPortion( rNumFormat.GetBulletChar(),
pTextNd->GetLabelFollowedBy(),
- pNumFnt,
+ std::move(pNumFnt),
bLeft, bCenter, nMinDist,
bLabelAlignmentPosAndSpaceModeActive );
}
@@ -591,7 +588,7 @@ SwNumberPortion *SwTextFormatter::NewNumberPortion( SwTextFormatInfo &rInf ) con
{
// Build a new numbering font basing on the current paragraph font:
- pNumFnt = new SwFont( &rInf.GetCharAttr(), pIDSA );
+ std::unique_ptr<SwFont> pNumFnt(new SwFont( &rInf.GetCharAttr(), pIDSA ));
// #i53199#
if ( !pIDSA->get(DocumentSettingId::DO_NOT_RESET_PARA_ATTRS_FOR_NUM_FONT) )
@@ -608,12 +605,12 @@ SwNumberPortion *SwTextFormatter::NewNumberPortion( SwTextFormatInfo &rInf ) con
if( pFormat )
pNumFnt->SetDiffFnt( pFormat, pIDSA );
- checkApplyParagraphMarkFormatToNumbering( pNumFnt, rInf, pIDSA );
+ checkApplyParagraphMarkFormatToNumbering( pNumFnt.get(), rInf, pIDSA );
// we do not allow a vertical font
pNumFnt->SetVertical( pNumFnt->GetOrientation(), m_pFrame->IsVertical() );
- pRet = new SwNumberPortion( aText, pNumFnt,
+ pRet = new SwNumberPortion( aText, std::move(pNumFnt),
bLeft, bCenter, nMinDist,
bLabelAlignmentPosAndSpaceModeActive );
}
diff --git a/sw/source/core/text/txtftn.cxx b/sw/source/core/text/txtftn.cxx
index e07aac8691d9..07ce11d2765f 100644
--- a/sw/source/core/text/txtftn.cxx
+++ b/sw/source/core/text/txtftn.cxx
@@ -929,7 +929,7 @@ SwNumberPortion *SwTextFormatter::NewFootnoteNumPortion( SwTextFormatInfo const
const SwAttrSet* pParSet = &rInf.GetCharAttr();
const IDocumentSettingAccess* pIDSA = &pDoc->getIDocumentSettingAccess();
- SwFont *pNumFnt = new SwFont( pParSet, pIDSA );
+ std::unique_ptr<SwFont> pNumFnt(new SwFont( pParSet, pIDSA ));
// #i37142#
// Underline style of paragraph font should not be considered
@@ -949,7 +949,7 @@ SwNumberPortion *SwTextFormatter::NewFootnoteNumPortion( SwTextFormatInfo const
pNumFnt->SetDiffFnt(&rSet, pIDSA );
pNumFnt->SetVertical( pNumFnt->GetOrientation(), m_pFrame->IsVertical() );
- SwFootnoteNumPortion* pNewPor = new SwFootnoteNumPortion( aFootnoteText, pNumFnt );
+ SwFootnoteNumPortion* pNewPor = new SwFootnoteNumPortion( aFootnoteText, std::move(pNumFnt) );
pNewPor->SetLeft( !m_pFrame->IsRightToLeft() );
return pNewPor;
}