summaryrefslogtreecommitdiff
path: root/sw
diff options
context:
space:
mode:
authorNoel Grandin <noel.grandin@collabora.co.uk>2018-04-11 09:56:41 +0200
committerNoel Grandin <noel.grandin@collabora.co.uk>2018-04-11 14:08:27 +0200
commite5246409cc384cd2ba321620e92250f7ddf153af (patch)
treeeae4b87b9df1918bc69e081d87449a34ef483a99 /sw
parent1c0e591accda7669bec9ccfc23977ce3f7386930 (diff)
return std::unique_ptr from SfxItemSet::Clone
Change-Id: Ie747b5c8ff0b82b9f8d268f9a60dbde41b5f022b Reviewed-on: https://gerrit.libreoffice.org/52712 Tested-by: Jenkins <ci@libreoffice.org> Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
Diffstat (limited to 'sw')
-rw-r--r--sw/inc/swatrset.hxx2
-rw-r--r--sw/qa/extras/uiwriter/uiwriter.cxx2
-rw-r--r--sw/source/core/attr/swatrset.cxx11
-rw-r--r--sw/source/core/doc/doclay.cxx8
-rw-r--r--sw/source/core/text/txtfld.cxx4
-rw-r--r--sw/source/core/txtnode/thints.cxx4
-rw-r--r--sw/source/core/txtnode/txtedt.cxx3
-rw-r--r--sw/source/core/unocore/unoobj.cxx4
-rw-r--r--sw/source/uibase/uno/SwXDocumentSettings.cxx2
9 files changed, 19 insertions, 21 deletions
diff --git a/sw/inc/swatrset.hxx b/sw/inc/swatrset.hxx
index 7392b33f09b5..18e6ad0e8585 100644
--- a/sw/inc/swatrset.hxx
+++ b/sw/inc/swatrset.hxx
@@ -172,7 +172,7 @@ public:
SwAttrSet( SwAttrPool&, const sal_uInt16* nWhichPairTable );
SwAttrSet( const SwAttrSet& );
- virtual SfxItemSet* Clone(bool bItems = true, SfxItemPool *pToPool = nullptr) const override;
+ virtual std::unique_ptr<SfxItemSet> Clone(bool bItems = true, SfxItemPool *pToPool = nullptr) const override;
bool Put_BC( const SfxPoolItem& rAttr, SwAttrSet* pOld, SwAttrSet* pNew );
bool Put_BC( const SfxItemSet& rSet, SwAttrSet* pOld, SwAttrSet* pNew );
diff --git a/sw/qa/extras/uiwriter/uiwriter.cxx b/sw/qa/extras/uiwriter/uiwriter.cxx
index 20e559088dd6..c06da717c749 100644
--- a/sw/qa/extras/uiwriter/uiwriter.cxx
+++ b/sw/qa/extras/uiwriter/uiwriter.cxx
@@ -1981,7 +1981,7 @@ void SwUiWriterTest::testTdf79236()
//Getting some paragraph style
SwTextFormatColl* pTextFormat = pDoc->FindTextFormatCollByName("Text Body");
const SwAttrSet& rAttrSet = pTextFormat->GetAttrSet();
- SfxItemSet* pNewSet = rAttrSet.Clone();
+ std::unique_ptr<SfxItemSet> pNewSet = rAttrSet.Clone();
sal_uInt16 initialCount = pNewSet->Count();
SvxAdjustItem AdjustItem = rAttrSet.GetAdjust();
SvxAdjust initialAdjust = AdjustItem.GetAdjust();
diff --git a/sw/source/core/attr/swatrset.cxx b/sw/source/core/attr/swatrset.cxx
index 91c4cd7b0a15..bd0e3c5e92bb 100644
--- a/sw/source/core/attr/swatrset.cxx
+++ b/sw/source/core/attr/swatrset.cxx
@@ -148,17 +148,17 @@ SwAttrSet::SwAttrSet( const SwAttrSet& rSet )
{
}
-SfxItemSet* SwAttrSet::Clone( bool bItems, SfxItemPool *pToPool ) const
+std::unique_ptr<SfxItemSet> SwAttrSet::Clone( bool bItems, SfxItemPool *pToPool ) const
{
if ( pToPool && pToPool != GetPool() )
{
SwAttrPool* pAttrPool = dynamic_cast< SwAttrPool* >(pToPool);
- SfxItemSet* pTmpSet = nullptr;
+ std::unique_ptr<SfxItemSet> pTmpSet;
if ( !pAttrPool )
pTmpSet = SfxItemSet::Clone( bItems, pToPool );
else
{
- pTmpSet = new SwAttrSet( *pAttrPool, GetRanges() );
+ pTmpSet.reset(new SwAttrSet( *pAttrPool, GetRanges() ));
if ( bItems )
{
SfxWhichIter aIter(*pTmpSet);
@@ -175,9 +175,10 @@ SfxItemSet* SwAttrSet::Clone( bool bItems, SfxItemPool *pToPool ) const
return pTmpSet;
}
else
- return bItems
+ return std::unique_ptr<SfxItemSet>(
+ bItems
? new SwAttrSet( *this )
- : new SwAttrSet( *GetPool(), GetRanges() );
+ : new SwAttrSet( *GetPool(), GetRanges() ));
}
bool SwAttrSet::Put_BC( const SfxPoolItem& rAttr,
diff --git a/sw/source/core/doc/doclay.cxx b/sw/source/core/doc/doclay.cxx
index 4430547b343b..58e44dc5346d 100644
--- a/sw/source/core/doc/doclay.cxx
+++ b/sw/source/core/doc/doclay.cxx
@@ -735,7 +735,7 @@ lcl_InsertLabel(SwDoc & rDoc, SwTextFormatColls *const pTextFormatCollTable,
/* #i6447#: Only the selected items are copied from the old
format. */
- SfxItemSet* pNewSet = pNewFormat->GetAttrSet().Clone();
+ std::unique_ptr<SfxItemSet> pNewSet = pNewFormat->GetAttrSet().Clone();
// Copy only the set attributes.
// The others should apply from the Templates.
@@ -868,7 +868,7 @@ lcl_InsertLabel(SwDoc & rDoc, SwTextFormatColls *const pTextFormatCollTable,
else
pOldFormat->SetFormatAttr( *pNewSet );
- delete pNewSet;
+ pNewSet.reset();
// Have only the FlyFrames created.
// We leave this to established methods (especially for InCntFlys).
@@ -1054,7 +1054,7 @@ lcl_InsertDrawLabel( SwDoc & rDoc, SwTextFormatColls *const pTextFormatCollTable
// The TextAttribute needs to be destroyed.
// Unfortunately, this also destroys the Format next to the Frames.
// To avoid this, we disconnect the attribute from the Format.
- SfxItemSet* pNewSet = pOldFormat->GetAttrSet().Clone( false );
+ std::unique_ptr<SfxItemSet> pNewSet = pOldFormat->GetAttrSet().Clone( false );
// Protect the Frame's size and position
if ( rSdrObj.IsMoveProtect() || rSdrObj.IsResizeProtect() )
@@ -1174,7 +1174,7 @@ lcl_InsertDrawLabel( SwDoc & rDoc, SwTextFormatColls *const pTextFormatCollTable
else
pOldFormat->SetFormatAttr( *pNewSet );
- delete pNewSet;
+ pNewSet.reset();
// Have only the FlyFrames created.
// We leave this to established methods (especially for InCntFlys).
diff --git a/sw/source/core/text/txtfld.cxx b/sw/source/core/text/txtfld.cxx
index 7e958cd7be8c..559216676999 100644
--- a/sw/source/core/text/txtfld.cxx
+++ b/sw/source/core/text/txtfld.cxx
@@ -422,10 +422,10 @@ static void checkApplyParagraphMarkFormatToNumbering( SwFont* pNumFnt, SwTextFor
std::shared_ptr<SfxItemSet> pSet(hint->GetAutoFormat().GetStyleHandle());
// Check each item and in case it should be ignored, then clear it.
- std::shared_ptr<SfxItemSet> pCleanedSet;
+ std::unique_ptr<SfxItemSet> pCleanedSet;
if (pSet.get())
{
- pCleanedSet.reset(pSet->Clone());
+ pCleanedSet = pSet->Clone();
SfxItemIter aIter(*pSet);
const SfxPoolItem* pItem = aIter.GetCurItem();
diff --git a/sw/source/core/txtnode/thints.cxx b/sw/source/core/txtnode/thints.cxx
index d7b70e8a297d..2db0657c3fe1 100644
--- a/sw/source/core/txtnode/thints.cxx
+++ b/sw/source/core/txtnode/thints.cxx
@@ -880,7 +880,7 @@ void SwpHints::BuildPortions( SwTextNode& rNode, SwTextAttr& rNewHint,
// #i81764# This should not be applied for no length attributes!!! <--
if ( !bNoLengthAttribute && rNode.HasSwAttrSet() && pNewStyle->Count() )
{
- SfxItemSet* pNewSet = nullptr;
+ std::unique_ptr<SfxItemSet> pNewSet;
SfxItemIter aIter2( *pNewStyle );
const SfxPoolItem* pItem = aIter2.GetCurItem();
@@ -910,8 +910,6 @@ void SwpHints::BuildPortions( SwTextNode& rNode, SwTextAttr& rNewHint,
pNewStyle = rNode.getIDocumentStyleAccess().getAutomaticStyle( *pNewSet, IStyleAccess::AUTO_STYLE_CHAR );
else
pNewStyle.reset();
-
- delete pNewSet;
}
}
diff --git a/sw/source/core/txtnode/txtedt.cxx b/sw/source/core/txtnode/txtedt.cxx
index 1ca1123f3724..8fae25735fcb 100644
--- a/sw/source/core/txtnode/txtedt.cxx
+++ b/sw/source/core/txtnode/txtedt.cxx
@@ -328,7 +328,7 @@ static bool lcl_HaveCommonAttributes( IStyleAccess& rStyleAccess,
{
bool bRet = false;
- SfxItemSet* pNewSet = nullptr;
+ std::unique_ptr<SfxItemSet> pNewSet;
if ( !pSet1 )
{
@@ -363,7 +363,6 @@ static bool lcl_HaveCommonAttributes( IStyleAccess& rStyleAccess,
{
if ( pNewSet->Count() )
pStyleHandle = rStyleAccess.getAutomaticStyle( *pNewSet, IStyleAccess::AUTO_STYLE_CHAR );
- delete pNewSet;
bRet = true;
}
diff --git a/sw/source/core/unocore/unoobj.cxx b/sw/source/core/unocore/unoobj.cxx
index 18047a1ca874..6c6d2c35f846 100644
--- a/sw/source/core/unocore/unoobj.cxx
+++ b/sw/source/core/unocore/unoobj.cxx
@@ -1940,9 +1940,9 @@ SwUnoCursorHelper::GetPropertyStates(
//try again to find out if a value has been inherited
if( beans::PropertyState_DIRECT_VALUE == pStates[i] )
{
- if (!pSetParent.get())
+ if (!pSetParent)
{
- pSetParent.reset( pSet->Clone( false ) );
+ pSetParent = pSet->Clone( false );
// #i63870#
SwUnoCursorHelper::GetCursorAttr(
rPaM, *pSetParent, true, false );
diff --git a/sw/source/uibase/uno/SwXDocumentSettings.cxx b/sw/source/uibase/uno/SwXDocumentSettings.cxx
index 132fddc777de..f665bfefc0b0 100644
--- a/sw/source/uibase/uno/SwXDocumentSettings.cxx
+++ b/sw/source/uibase/uno/SwXDocumentSettings.cxx
@@ -398,7 +398,7 @@ void SwXDocumentSettings::_setSingleValue( const comphelper::PropertyInfo & rInf
SfxPrinter* pPrinter = mpDoc->getIDocumentDeviceAccess().getPrinter( true );
if ( pPrinter->GetName() != sPrinterName )
{
- VclPtrInstance<SfxPrinter> pNewPrinter( std::unique_ptr<SfxItemSet>(pPrinter->GetOptions().Clone()), sPrinterName );
+ VclPtrInstance<SfxPrinter> pNewPrinter( pPrinter->GetOptions().Clone(), sPrinterName );
assert (! pNewPrinter->isDisposed() );
if( pNewPrinter->IsKnown() )
{