[Libreoffice-commits] core.git: 2 commits - sw/source
Libreoffice Gerrit user
logerrit at kemper.freedesktop.org
Wed Aug 22 06:27:47 UTC 2018
sw/source/core/fields/docufld.cxx | 4 ++--
sw/source/core/fields/textapi.cxx | 6 +++---
sw/source/core/inc/textapi.hxx | 2 +-
sw/source/core/text/porfld.cxx | 36 ++++++++++++++++++------------------
sw/source/core/text/porfld.hxx | 10 +++++-----
sw/source/core/text/porftn.hxx | 4 ++--
sw/source/core/text/pormulti.cxx | 8 +++-----
sw/source/core/text/txtfld.cxx | 27 ++++++++++++---------------
sw/source/core/text/txtftn.cxx | 4 ++--
sw/source/core/unocore/unofield.cxx | 6 +++---
10 files changed, 51 insertions(+), 56 deletions(-)
New commits:
commit ddfed109ebaa854582bc59750a1988af3f6ad3d6
Author: Noel Grandin <noel.grandin at collabora.co.uk>
AuthorDate: Mon Aug 20 15:54:33 2018 +0200
Commit: Noel Grandin <noel.grandin at collabora.co.uk>
CommitDate: Wed Aug 22 08:27:36 2018 +0200
loplugin:useuniqueptr in SwFieldPortion
Change-Id: I7b87652c86ff682760120f3992b33e27f4eaeaed
Reviewed-on: https://gerrit.libreoffice.org/59365
Tested-by: Jenkins
Reviewed-by: Noel Grandin <noel.grandin at collabora.co.uk>
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;
}
commit 9590c68852177056602342dd874b8818eeb57e82
Author: Noel Grandin <noel.grandin at collabora.co.uk>
AuthorDate: Mon Aug 20 15:02:00 2018 +0200
Commit: Noel Grandin <noel.grandin at collabora.co.uk>
CommitDate: Wed Aug 22 08:27:22 2018 +0200
loplugin:useuniqueptr in SwTextAPIObject
Change-Id: I697a8a119fa4ad0a6c50bc6e4a3bc8944435928a
Reviewed-on: https://gerrit.libreoffice.org/59364
Tested-by: Jenkins
Reviewed-by: Noel Grandin <noel.grandin at collabora.co.uk>
diff --git a/sw/source/core/fields/docufld.cxx b/sw/source/core/fields/docufld.cxx
index de055bb4cfa2..b5c8f083dc70 100644
--- a/sw/source/core/fields/docufld.cxx
+++ b/sw/source/core/fields/docufld.cxx
@@ -1849,8 +1849,8 @@ bool SwPostItField::QueryValue( uno::Any& rAny, sal_uInt16 nWhichId ) const
{
SwPostItFieldType* pGetType = static_cast<SwPostItFieldType*>(GetTyp());
SwDoc* pDoc = pGetType->GetDoc();
- SwTextAPIEditSource* pObj = new SwTextAPIEditSource( pDoc );
- const_cast <SwPostItField*> (this)->m_xTextObject = new SwTextAPIObject( pObj );
+ auto pObj = o3tl::make_unique<SwTextAPIEditSource>( pDoc );
+ const_cast <SwPostItField*> (this)->m_xTextObject = new SwTextAPIObject( std::move(pObj) );
}
if ( mpText )
diff --git a/sw/source/core/fields/textapi.cxx b/sw/source/core/fields/textapi.cxx
index 605b3d06e885..2b10349ba7c5 100644
--- a/sw/source/core/fields/textapi.cxx
+++ b/sw/source/core/fields/textapi.cxx
@@ -53,9 +53,9 @@ static const SvxItemPropertySet* ImplGetSvxTextPortionPropertySet()
return &aSvxTextPortionPropertySet;
}
-SwTextAPIObject::SwTextAPIObject( SwTextAPIEditSource* p )
-: SvxUnoText( p, ImplGetSvxTextPortionPropertySet(), uno::Reference < text::XText >() )
-, pSource(p)
+SwTextAPIObject::SwTextAPIObject( std::unique_ptr<SwTextAPIEditSource> p )
+: SvxUnoText( p.get(), ImplGetSvxTextPortionPropertySet(), uno::Reference < text::XText >() )
+, pSource(std::move(p))
{
}
diff --git a/sw/source/core/inc/textapi.hxx b/sw/source/core/inc/textapi.hxx
index 4c03c8dc62f3..e2d704556993 100644
--- a/sw/source/core/inc/textapi.hxx
+++ b/sw/source/core/inc/textapi.hxx
@@ -55,7 +55,7 @@ class SwTextAPIObject : public SvxUnoText
{
std::unique_ptr<SwTextAPIEditSource> pSource;
public:
- SwTextAPIObject( SwTextAPIEditSource* p);
+ SwTextAPIObject( std::unique_ptr<SwTextAPIEditSource> p);
virtual ~SwTextAPIObject() throw() override;
void DisposeEditSource() { pSource->Dispose(); }
std::unique_ptr<OutlinerParaObject> CreateText() { return pSource->CreateText(); }
diff --git a/sw/source/core/unocore/unofield.cxx b/sw/source/core/unocore/unofield.cxx
index 620143150e8a..03e0fedc064c 100644
--- a/sw/source/core/unocore/unofield.cxx
+++ b/sw/source/core/unocore/unofield.cxx
@@ -89,6 +89,7 @@
#include <svl/listener.hxx>
#include <svx/dataaccessdescriptor.hxx>
#include <o3tl/any.hxx>
+#include <o3tl/make_unique.hxx>
#include <osl/mutex.hxx>
#include <vcl/svapp.hxx>
#include <textapi.hxx>
@@ -2376,9 +2377,8 @@ uno::Any SAL_CALL SwXTextField::getPropertyValue(const OUString& rPropertyName)
{
if (!m_pImpl->m_xTextObject.is())
{
- SwTextAPIEditSource* pObj =
- new SwTextAPIEditSource(m_pImpl->m_pDoc);
- m_pImpl->m_xTextObject = new SwTextAPIObject( pObj );
+ m_pImpl->m_xTextObject
+ = new SwTextAPIObject( o3tl::make_unique<SwTextAPIEditSource>(m_pImpl->m_pDoc) );
}
uno::Reference<text::XText> xText(m_pImpl->m_xTextObject.get());
More information about the Libreoffice-commits
mailing list