[Libreoffice-commits] core.git: sw/source
Noel Grandin (via logerrit)
logerrit at kemper.freedesktop.org
Thu Sep 23 07:20:18 UTC 2021
sw/source/core/doc/docfmt.cxx | 2
sw/source/core/inc/UndoAttribute.hxx | 6 +-
sw/source/core/inc/UndoCore.hxx | 2
sw/source/core/undo/unattr.cxx | 71 +++++++++++++++++++----------------
sw/source/core/undo/undobj1.cxx | 12 ++---
sw/source/core/undo/unsect.cxx | 49 ++++++++++++------------
6 files changed, 76 insertions(+), 66 deletions(-)
New commits:
commit 672dce81178dc1b4b6ad54f2b5d922ee806acf91
Author: Noel Grandin <noelgrandin at gmail.com>
AuthorDate: Wed Sep 22 20:47:14 2021 +0200
Commit: Noel Grandin <noel.grandin at collabora.co.uk>
CommitDate: Thu Sep 23 09:19:44 2021 +0200
no need to allocate these SfxItemSet on the heap
Change-Id: Iefa9cb88eaadb4535bbbe59a939b9773d81a438d
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/122487
Tested-by: Jenkins
Reviewed-by: Noel Grandin <noel.grandin at collabora.co.uk>
diff --git a/sw/source/core/doc/docfmt.cxx b/sw/source/core/doc/docfmt.cxx
index d2ccfaf81544..0f93a708c388 100644
--- a/sw/source/core/doc/docfmt.cxx
+++ b/sw/source/core/doc/docfmt.cxx
@@ -1898,7 +1898,7 @@ void SwDoc::ChgFormat(SwFormat & rFormat, const SfxItemSet & rSet)
}
GetIDocumentUndoRedo().AppendUndo(
- std::make_unique<SwUndoFormatAttr>(aOldSet, rFormat, /*bSaveDrawPt*/true));
+ std::make_unique<SwUndoFormatAttr>(std::move(aOldSet), rFormat, /*bSaveDrawPt*/true));
}
rFormat.SetFormatAttr(rSet);
diff --git a/sw/source/core/inc/UndoAttribute.hxx b/sw/source/core/inc/UndoAttribute.hxx
index c1387cbda734..6c866342434a 100644
--- a/sw/source/core/inc/UndoAttribute.hxx
+++ b/sw/source/core/inc/UndoAttribute.hxx
@@ -86,7 +86,7 @@ class SwUndoFormatAttr final : public SwUndo
{
friend class SwUndoDefaultAttr;
OUString m_sFormatName;
- std::unique_ptr<SfxItemSet> m_pOldSet; // old attributes
+ std::optional<SfxItemSet> m_oOldSet; // old attributes
sal_uLong m_nNodeIndex;
const sal_uInt16 m_nFormatWhich;
const bool m_bSaveDrawPt;
@@ -107,7 +107,7 @@ class SwUndoFormatAttr final : public SwUndo
public:
// register at the Format and save old attributes
// --> OD 2008-02-27 #refactorlists# - removed <rNewSet>
- SwUndoFormatAttr( const SfxItemSet& rOldSet,
+ SwUndoFormatAttr( SfxItemSet&& rOldSet,
SwFormat& rFormat,
bool bSaveDrawPt );
SwUndoFormatAttr( const SfxPoolItem& rItem,
@@ -196,7 +196,7 @@ public:
class SwUndoDefaultAttr final : public SwUndo
{
- std::unique_ptr<SfxItemSet> m_pOldSet; // the old attributes
+ std::optional<SfxItemSet> m_oOldSet; // the old attributes
std::unique_ptr<SvxTabStopItem> m_pTabStop;
public:
diff --git a/sw/source/core/inc/UndoCore.hxx b/sw/source/core/inc/UndoCore.hxx
index 62fcccd0231c..4f94a6b6cca0 100644
--- a/sw/source/core/inc/UndoCore.hxx
+++ b/sw/source/core/inc/UndoCore.hxx
@@ -190,7 +190,7 @@ class SwUndoSetFlyFormat final : public SwUndo, public SwClient
SwFrameFormat* m_pFrameFormat; // saved FlyFormat
const OUString m_DerivedFromFormatName;
const OUString m_NewFormatName;
- std::unique_ptr<SfxItemSet> m_pItemSet; // the re-/ set attributes
+ std::optional<SfxItemSet> m_oItemSet; // the re-/ set attributes
sal_uLong m_nOldNode, m_nNewNode;
sal_Int32 m_nOldContent, m_nNewContent;
RndStdIds m_nOldAnchorType, m_nNewAnchorType;
diff --git a/sw/source/core/undo/unattr.cxx b/sw/source/core/undo/unattr.cxx
index 3c3f05ac1895..09b7e44bc7b8 100644
--- a/sw/source/core/undo/unattr.cxx
+++ b/sw/source/core/undo/unattr.cxx
@@ -82,7 +82,7 @@ void SwUndoFormatAttrHelper::SwClientNotify(const SwModify&, const SfxHint& rHin
} else if(RES_ATTRSET_CHG == pOld->Which()) {
auto& rChgSet = *static_cast<const SwAttrSetChg*>(pOld)->GetChgSet();
if(!GetUndo())
- m_pUndo.reset(new SwUndoFormatAttr(rChgSet, m_rFormat, m_bSaveDrawPt));
+ m_pUndo.reset(new SwUndoFormatAttr(SfxItemSet(rChgSet), m_rFormat, m_bSaveDrawPt));
else {
SfxItemIter aIter(rChgSet);
for(auto pItem = aIter.GetCurItem(); pItem; pItem = aIter.NextItem())
@@ -91,13 +91,13 @@ void SwUndoFormatAttrHelper::SwClientNotify(const SwModify&, const SfxHint& rHin
}
}
-SwUndoFormatAttr::SwUndoFormatAttr( const SfxItemSet& rOldSet,
+SwUndoFormatAttr::SwUndoFormatAttr( SfxItemSet&& rOldSet,
SwFormat& rChgFormat,
bool bSaveDrawPt )
: SwUndo( SwUndoId::INSFMTATTR, rChgFormat.GetDoc() )
, m_sFormatName ( rChgFormat.GetName() )
// #i56253#
- , m_pOldSet( new SfxItemSet( rOldSet ) )
+ , m_oOldSet( std::move( rOldSet ) )
, m_nNodeIndex( 0 )
, m_nFormatWhich( rChgFormat.Which() )
, m_bSaveDrawPt( bSaveDrawPt )
@@ -111,23 +111,23 @@ SwUndoFormatAttr::SwUndoFormatAttr( const SfxPoolItem& rItem, SwFormat& rChgForm
bool bSaveDrawPt )
: SwUndo( SwUndoId::INSFMTATTR, rChgFormat.GetDoc() )
, m_sFormatName(rChgFormat.GetName())
- , m_pOldSet( rChgFormat.GetAttrSet().Clone( false ) )
+ , m_oOldSet( rChgFormat.GetAttrSet().CloneAsValue( false ) )
, m_nNodeIndex( 0 )
, m_nFormatWhich( rChgFormat.Which() )
, m_bSaveDrawPt( bSaveDrawPt )
{
assert(m_sFormatName.getLength());
- m_pOldSet->Put( rItem );
+ m_oOldSet->Put( rItem );
Init( rChgFormat );
}
void SwUndoFormatAttr::Init( const SwFormat & rFormat )
{
// tdf#126017 never save SwNodeIndex, it will go stale
- m_pOldSet->ClearItem(RES_CNTNT);
+ m_oOldSet->ClearItem(RES_CNTNT);
// treat change of anchor specially
- if ( SfxItemState::SET == m_pOldSet->GetItemState( RES_ANCHOR, false )) {
+ if ( SfxItemState::SET == m_oOldSet->GetItemState( RES_ANCHOR, false )) {
SaveFlyAnchor( &rFormat, m_bSaveDrawPt );
} else if ( RES_FRMFMT == m_nFormatWhich ) {
const SwDoc* pDoc = rFormat.GetDoc();
@@ -159,7 +159,7 @@ void SwUndoFormatAttr::UndoImpl(::sw::UndoRedoContext & rContext)
// OD 2004-10-26 #i35443#
// Important note: <Undo(..)> also called by <ReDo(..)>
- if (!m_pOldSet)
+ if (!m_oOldSet)
return;
SwFormat * pFormat = GetFormat(rContext.GetDoc());
@@ -170,7 +170,7 @@ void SwUndoFormatAttr::UndoImpl(::sw::UndoRedoContext & rContext)
// restored, all other attributes are also restored.
// Thus, keep track of its restoration
bool bAnchorAttrRestored( false );
- if ( SfxItemState::SET == m_pOldSet->GetItemState( RES_ANCHOR, false )) {
+ if ( SfxItemState::SET == m_oOldSet->GetItemState( RES_ANCHOR, false )) {
bAnchorAttrRestored = RestoreFlyAnchor(rContext);
if ( bAnchorAttrRestored ) {
// Anchor attribute successful restored.
@@ -179,19 +179,22 @@ void SwUndoFormatAttr::UndoImpl(::sw::UndoRedoContext & rContext)
} else {
// Anchor attribute not restored due to invalid anchor position.
// Thus, delete anchor attribute.
- m_pOldSet->ClearItem( RES_ANCHOR );
+ m_oOldSet->ClearItem( RES_ANCHOR );
}
}
if ( bAnchorAttrRestored ) return;
SwUndoFormatAttrHelper aTmp( *pFormat, m_bSaveDrawPt );
- pFormat->SetFormatAttr( *m_pOldSet );
+ pFormat->SetFormatAttr( *m_oOldSet );
if ( aTmp.GetUndo() ) {
// transfer ownership of helper object's old set
- m_pOldSet = std::move(aTmp.GetUndo()->m_pOldSet);
+ if (aTmp.GetUndo()->m_oOldSet)
+ m_oOldSet.emplace(std::move(*aTmp.GetUndo()->m_oOldSet));
+ else
+ m_oOldSet.reset();
} else {
- m_pOldSet->ClearItem();
+ m_oOldSet->ClearItem();
}
if ( RES_FLYFRMFMT == m_nFormatWhich || RES_DRAWFRMFMT == m_nFormatWhich ) {
@@ -266,7 +269,7 @@ void SwUndoFormatAttr::RedoImpl(::sw::UndoRedoContext & rContext)
void SwUndoFormatAttr::RepeatImpl(::sw::RepeatContext & rContext)
{
- if (!m_pOldSet)
+ if (!m_oOldSet)
return;
SwDoc & rDoc(rContext.GetDoc());
@@ -335,7 +338,7 @@ void SwUndoFormatAttr::PutAttr( const SfxPoolItem& rItem, const SwDoc& rDoc )
{
return; // tdf#126017 never save SwNodeIndex, it will go stale
}
- m_pOldSet->Put( rItem );
+ m_oOldSet->Put( rItem );
if ( RES_ANCHOR == rItem.Which() )
{
SwFormat * pFormat = GetFormat( rDoc );
@@ -351,12 +354,12 @@ void SwUndoFormatAttr::SaveFlyAnchor( const SwFormat * pFormat, bool bSvDrwPt )
Point aPt( static_cast<const SwFrameFormat*>(pFormat)->FindSdrObject()
->GetRelativePos() );
// store old value as attribute, to keep SwUndoFormatAttr small
- m_pOldSet->Put( SwFormatFrameSize( SwFrameSize::Variable, aPt.X(), aPt.Y() ) );
+ m_oOldSet->Put( SwFormatFrameSize( SwFrameSize::Variable, aPt.X(), aPt.Y() ) );
}
}
const SwFormatAnchor& rAnchor =
- m_pOldSet->Get( RES_ANCHOR, false );
+ m_oOldSet->Get( RES_ANCHOR, false );
if( !rAnchor.GetContentAnchor() )
return;
@@ -375,7 +378,7 @@ void SwUndoFormatAttr::SaveFlyAnchor( const SwFormat * pFormat, bool bSvDrwPt )
}
SwFormatAnchor aAnchor( rAnchor.GetAnchorId(), nContent );
- m_pOldSet->Put( aAnchor );
+ m_oOldSet->Put( aAnchor );
}
// #i35443# - Add return value, type <bool>.
@@ -387,7 +390,7 @@ bool SwUndoFormatAttr::RestoreFlyAnchor(::sw::UndoRedoContext & rContext)
SwDoc *const pDoc = & rContext.GetDoc();
SwFrameFormat* pFrameFormat = static_cast<SwFrameFormat*>( GetFormat( *pDoc ) );
const SwFormatAnchor& rAnchor =
- m_pOldSet->Get( RES_ANCHOR, false );
+ m_oOldSet->Get( RES_ANCHOR, false );
SwFormatAnchor aNewAnchor( rAnchor.GetAnchorId() );
if (RndStdIds::FLY_AT_PAGE != rAnchor.GetAnchorId()) {
@@ -420,10 +423,10 @@ bool SwUndoFormatAttr::RestoreFlyAnchor(::sw::UndoRedoContext & rContext)
if( pDoc->getIDocumentLayoutAccess().GetCurrentViewShell() ) {
if( RES_DRAWFRMFMT == pFrameFormat->Which() ) {
// get the old cached value
- const SwFormatFrameSize& rOldSize = m_pOldSet->Get( RES_FRM_SIZE );
+ const SwFormatFrameSize& rOldSize = m_oOldSet->Get( RES_FRM_SIZE );
aDrawSavePt.setX( rOldSize.GetWidth() );
aDrawSavePt.setY( rOldSize.GetHeight() );
- m_pOldSet->ClearItem( RES_FRM_SIZE );
+ m_oOldSet->ClearItem( RES_FRM_SIZE );
// write the current value into cache
aDrawOldPt = pFrameFormat->FindSdrObject()->GetRelativePos();
@@ -458,15 +461,18 @@ bool SwUndoFormatAttr::RestoreFlyAnchor(::sw::UndoRedoContext & rContext)
}
{
- m_pOldSet->Put( aNewAnchor );
+ m_oOldSet->Put( aNewAnchor );
SwUndoFormatAttrHelper aTmp( *pFrameFormat, m_bSaveDrawPt );
- pFrameFormat->SetFormatAttr( *m_pOldSet );
+ pFrameFormat->SetFormatAttr( *m_oOldSet );
if ( aTmp.GetUndo() ) {
m_nNodeIndex = aTmp.GetUndo()->m_nNodeIndex;
// transfer ownership of helper object's old set
- m_pOldSet = std::move(aTmp.GetUndo()->m_pOldSet);
+ if (aTmp.GetUndo()->m_oOldSet)
+ m_oOldSet.emplace(std::move(*aTmp.GetUndo()->m_oOldSet));
+ else
+ m_oOldSet.reset();
} else {
- m_pOldSet->ClearItem();
+ m_oOldSet->ClearItem();
}
}
@@ -477,7 +483,7 @@ bool SwUndoFormatAttr::RestoreFlyAnchor(::sw::UndoRedoContext & rContext)
// change of the Contact object by setting the anchor.
pFrameFormat->CallSwClientNotify(sw::RestoreFlyAnchorHint(aDrawSavePt));
// cache the old value again
- m_pOldSet->Put(SwFormatFrameSize(SwFrameSize::Variable, aDrawOldPt.X(), aDrawOldPt.Y()));
+ m_oOldSet->Put(SwFormatFrameSize(SwFrameSize::Variable, aDrawOldPt.X(), aDrawOldPt.Y()));
}
if (RndStdIds::FLY_AS_CHAR == aNewAnchor.GetAnchorId()) {
@@ -848,10 +854,10 @@ SwUndoDefaultAttr::SwUndoDefaultAttr( const SfxItemSet& rSet, const SwDoc& rDoc
// store separately, because it may change!
m_pTabStop.reset(&pItem->Clone()->StaticWhichCast(RES_PARATR_TABSTOP));
if ( 1 != rSet.Count() ) { // are there more attributes?
- m_pOldSet.reset( new SfxItemSet( rSet ) );
+ m_oOldSet.emplace( rSet );
}
} else {
- m_pOldSet.reset( new SfxItemSet( rSet ) );
+ m_oOldSet.emplace( rSet );
}
}
@@ -862,15 +868,16 @@ SwUndoDefaultAttr::~SwUndoDefaultAttr()
void SwUndoDefaultAttr::UndoImpl(::sw::UndoRedoContext & rContext)
{
SwDoc & rDoc = rContext.GetDoc();
- if (m_pOldSet)
+ if (m_oOldSet)
{
SwUndoFormatAttrHelper aTmp(
*rDoc.GetDfltTextFormatColl() );
- rDoc.SetDefault( *m_pOldSet );
- m_pOldSet.reset();
+ rDoc.SetDefault( *m_oOldSet );
+ m_oOldSet.reset();
if ( aTmp.GetUndo() ) {
// transfer ownership of helper object's old set
- m_pOldSet = std::move(aTmp.GetUndo()->m_pOldSet);
+ if (aTmp.GetUndo()->m_oOldSet)
+ m_oOldSet.emplace(std::move(*aTmp.GetUndo()->m_oOldSet));
}
}
if (m_pTabStop)
diff --git a/sw/source/core/undo/undobj1.cxx b/sw/source/core/undo/undobj1.cxx
index 54b031c8de59..87e6c00677cb 100644
--- a/sw/source/core/undo/undobj1.cxx
+++ b/sw/source/core/undo/undobj1.cxx
@@ -488,8 +488,8 @@ SwUndoSetFlyFormat::SwUndoSetFlyFormat( SwFrameFormat& rFlyFormat, const SwFrame
: SwUndo( SwUndoId::SETFLYFRMFMT, rFlyFormat.GetDoc() ), SwClient( &rFlyFormat ), m_pFrameFormat( &rFlyFormat ),
m_DerivedFromFormatName( rFlyFormat.IsDefault() ? "" : rFlyFormat.DerivedFrom()->GetName() ),
m_NewFormatName( rNewFrameFormat.GetName() ),
- m_pItemSet( new SfxItemSet( *rFlyFormat.GetAttrSet().GetPool(),
- rFlyFormat.GetAttrSet().GetRanges() )),
+ m_oItemSet( std::in_place, *rFlyFormat.GetAttrSet().GetPool(),
+ rFlyFormat.GetAttrSet().GetRanges() ),
m_nOldNode( 0 ), m_nNewNode( 0 ),
m_nOldContent( 0 ), m_nNewContent( 0 ),
m_nOldAnchorType( RndStdIds::FLY_AT_PARA ), m_nNewAnchorType( RndStdIds::FLY_AT_PARA ), m_bAnchorChanged( false )
@@ -571,11 +571,11 @@ void SwUndoSetFlyFormat::UndoImpl(::sw::UndoRedoContext & rContext)
if( m_pFrameFormat->DerivedFrom() != pDerivedFromFrameFormat)
m_pFrameFormat->SetDerivedFrom(pDerivedFromFrameFormat);
- SfxItemIter aIter( *m_pItemSet );
+ SfxItemIter aIter( *m_oItemSet );
for (const SfxPoolItem* pItem = aIter.GetCurItem(); pItem; pItem = aIter.NextItem())
{
if( IsInvalidItem( pItem ))
- m_pFrameFormat->ResetFormatAttr( m_pItemSet->GetWhichByPos(
+ m_pFrameFormat->ResetFormatAttr( m_oItemSet->GetWhichByPos(
aIter.GetCurPos() ));
else
m_pFrameFormat->SetFormatAttr( *pItem );
@@ -696,10 +696,10 @@ void SwUndoSetFlyFormat::PutAttr( sal_uInt16 nWhich, const SfxPoolItem* pItem )
}
}
else
- m_pItemSet->Put( *pItem );
+ m_oItemSet->Put( *pItem );
}
else
- m_pItemSet->InvalidateItem( nWhich );
+ m_oItemSet->InvalidateItem( nWhich );
}
void SwUndoSetFlyFormat::SwClientNotify(const SwModify&, const SfxHint& rHint)
diff --git a/sw/source/core/undo/unsect.cxx b/sw/source/core/undo/unsect.cxx
index b2f14d8a4b44..9cc907084436 100644
--- a/sw/source/core/undo/unsect.cxx
+++ b/sw/source/core/undo/unsect.cxx
@@ -47,12 +47,12 @@
/// class Calc needed for calculation of the hidden condition of a section.
#include <calc.hxx>
-static std::unique_ptr<SfxItemSet> lcl_GetAttrSet( const SwSection& rSect )
+static std::optional<SfxItemSet> lcl_GetAttrSet( const SwSection& rSect )
{
// save attributes of the format (columns, color, ...)
// Content and Protect items are not interesting since they are already
// stored in Section, thus delete them.
- std::unique_ptr<SfxItemSet> pAttr;
+ std::optional<SfxItemSet> oAttr;
if( rSect.GetFormat() )
{
sal_uInt16 nCnt = 1;
@@ -61,16 +61,16 @@ static std::unique_ptr<SfxItemSet> lcl_GetAttrSet( const SwSection& rSect )
if( nCnt < rSect.GetFormat()->GetAttrSet().Count() )
{
- pAttr.reset(new SfxItemSet( rSect.GetFormat()->GetAttrSet() ));
- pAttr->ClearItem( RES_PROTECT );
- pAttr->ClearItem( RES_CNTNT );
- if( !pAttr->Count() )
+ oAttr.emplace( rSect.GetFormat()->GetAttrSet() );
+ oAttr->ClearItem( RES_PROTECT );
+ oAttr->ClearItem( RES_CNTNT );
+ if( !oAttr->Count() )
{
- pAttr.reset();
+ oAttr.reset();
}
}
}
- return pAttr;
+ return oAttr;
}
SwUndoInsSection::SwUndoInsSection(
@@ -322,7 +322,7 @@ class SwUndoDelSection
private:
std::unique_ptr<SwSectionData> const m_pSectionData; /// section not TOX
std::unique_ptr<SwTOXBase> const m_pTOXBase; /// set iff section is TOX
- std::unique_ptr<SfxItemSet> const m_pAttrSet;
+ std::optional<SfxItemSet> const m_oAttrSet;
std::shared_ptr< ::sfx2::MetadatableUndo > const m_pMetadataUndo;
sal_uLong const m_nStartNode;
sal_uLong const m_nEndNode;
@@ -349,7 +349,7 @@ SwUndoDelSection::SwUndoDelSection(
, m_pTOXBase( dynamic_cast<const SwTOXBaseSection*>( &rSection) != nullptr
? new SwTOXBase(static_cast<SwTOXBaseSection const&>(rSection))
: nullptr )
- , m_pAttrSet( ::lcl_GetAttrSet(rSection) )
+ , m_oAttrSet( ::lcl_GetAttrSet(rSection) )
, m_pMetadataUndo( rSectionFormat.CreateUndo() )
, m_nStartNode( pIndex->GetIndex() )
, m_nEndNode( pIndex->GetNode().EndOfSectionIndex() )
@@ -364,16 +364,16 @@ void SwUndoDelSection::UndoImpl(::sw::UndoRedoContext & rContext)
{
// sw_redlinehide: this should work as-is; there will be another undo for the update
rDoc.InsertTableOf(m_nStartNode, m_nEndNode-2, *m_pTOXBase,
- m_pAttrSet.get());
+ m_oAttrSet ? &*m_oAttrSet : nullptr);
}
else
{
SwNodeIndex aStt( rDoc.GetNodes(), m_nStartNode );
SwNodeIndex aEnd( rDoc.GetNodes(), m_nEndNode-2 );
SwSectionFormat* pFormat = rDoc.MakeSectionFormat();
- if (m_pAttrSet)
+ if (m_oAttrSet)
{
- pFormat->SetFormatAttr( *m_pAttrSet );
+ pFormat->SetFormatAttr( *m_oAttrSet );
}
/// OD 04.10.2002 #102894#
@@ -428,7 +428,7 @@ class SwUndoUpdateSection
{
private:
std::unique_ptr<SwSectionData> m_pSectionData;
- std::unique_ptr<SfxItemSet> m_pAttrSet;
+ std::optional<SfxItemSet> m_oAttrSet;
sal_uLong const m_nStartNode;
bool const m_bOnlyAttrChanged;
@@ -454,7 +454,7 @@ SwUndoUpdateSection::SwUndoUpdateSection(
bool const bOnlyAttr)
: SwUndo( SwUndoId::CHGSECTION, &pIndex->GetNode().GetDoc() )
, m_pSectionData( new SwSectionData(rSection) )
- , m_pAttrSet( ::lcl_GetAttrSet(rSection) )
+ , m_oAttrSet( ::lcl_GetAttrSet(rSection) )
, m_nStartNode( pIndex->GetIndex() )
, m_bOnlyAttrChanged( bOnlyAttr )
{
@@ -470,19 +470,19 @@ void SwUndoUpdateSection::UndoImpl(::sw::UndoRedoContext & rContext)
SwSection& rNdSect = pSectNd->GetSection();
SwFormat* pFormat = rNdSect.GetFormat();
- std::unique_ptr<SfxItemSet> pCur = ::lcl_GetAttrSet( rNdSect );
- if (m_pAttrSet)
+ std::optional<SfxItemSet> oCur = ::lcl_GetAttrSet( rNdSect );
+ if (m_oAttrSet)
{
// The Content and Protect items must persist
const SfxPoolItem* pItem;
- m_pAttrSet->Put( pFormat->GetFormatAttr( RES_CNTNT ));
+ m_oAttrSet->Put( pFormat->GetFormatAttr( RES_CNTNT ));
if( SfxItemState::SET == pFormat->GetItemState( RES_PROTECT, true, &pItem ))
{
- m_pAttrSet->Put( *pItem );
+ m_oAttrSet->Put( *pItem );
}
- pFormat->DelDiffs( *m_pAttrSet );
- m_pAttrSet->ClearItem( RES_CNTNT );
- pFormat->SetFormatAttr( *m_pAttrSet );
+ pFormat->DelDiffs( *m_oAttrSet );
+ m_oAttrSet->ClearItem( RES_CNTNT );
+ pFormat->SetFormatAttr( *m_oAttrSet );
}
else
{
@@ -491,7 +491,10 @@ void SwUndoUpdateSection::UndoImpl(::sw::UndoRedoContext & rContext)
pFormat->ResetFormatAttr( RES_HEADER, RES_OPAQUE );
pFormat->ResetFormatAttr( RES_SURROUND, RES_FRMATR_END-1 );
}
- m_pAttrSet = std::move(pCur);
+ if (oCur)
+ m_oAttrSet.emplace(std::move(*oCur));
+ else
+ m_oAttrSet.reset();
if (m_bOnlyAttrChanged)
return;
More information about the Libreoffice-commits
mailing list