sw/inc/swatrset.hxx                        |    1 
 sw/source/core/attr/swatrset.cxx           |    8 ++
 sw/source/core/doc/doclay.cxx              |  114 +++++++++++++----------------
 sw/source/core/model/ThemeColorChanger.cxx |   40 +++++-----
 sw/source/ui/dialog/uiregionsw.cxx         |   18 ++--
 5 files changed, 93 insertions(+), 88 deletions(-)

New commits:
commit 8eb53f735eba218b6911e7aa5a805972dfb54809
Author:     Noel Grandin <noel.gran...@collabora.co.uk>
AuthorDate: Wed Sep 27 16:47:13 2023 +0200
Commit:     Noel Grandin <noel.gran...@collabora.co.uk>
CommitDate: Wed Sep 27 19:13:04 2023 +0200

    reduce allocation when cloning SwAttrSet
    
    Change-Id: Ic37355cd2a6091576426c48ff694023e24ae6342
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/157334
    Tested-by: Jenkins
    Reviewed-by: Noel Grandin <noel.gran...@collabora.co.uk>

diff --git a/sw/inc/swatrset.hxx b/sw/inc/swatrset.hxx
index 64841ade79c9..667121f35327 100644
--- a/sw/inc/swatrset.hxx
+++ b/sw/inc/swatrset.hxx
@@ -183,6 +183,7 @@ public:
     SwAttrSet( const SwAttrSet& );
 
     virtual std::unique_ptr<SfxItemSet> Clone(bool bItems = true, SfxItemPool 
*pToPool = nullptr) const override;
+    SwAttrSet CloneAsValue(bool bItems = true) const;
 
     bool Put_BC( const SfxPoolItem& rAttr, SwAttrSet* pOld, SwAttrSet* pNew );
     bool Put_BC( const SfxItemSet& rSet, SwAttrSet* pOld, SwAttrSet* pNew );
diff --git a/sw/source/core/attr/swatrset.cxx b/sw/source/core/attr/swatrset.cxx
index 7821f9db366d..6d778c1cb6b2 100644
--- a/sw/source/core/attr/swatrset.cxx
+++ b/sw/source/core/attr/swatrset.cxx
@@ -222,6 +222,14 @@ std::unique_ptr<SfxItemSet> SwAttrSet::Clone( bool bItems, 
SfxItemPool *pToPool
                 : new SwAttrSet( *GetPool(), GetRanges() ));
 }
 
+SwAttrSet SwAttrSet::CloneAsValue( bool bItems ) const
+{
+    if (bItems)
+        return *this;
+    else
+        return SwAttrSet( *GetPool(), GetRanges() );
+}
+
 bool SwAttrSet::Put_BC( const SfxPoolItem& rAttr,
                        SwAttrSet* pOld, SwAttrSet* pNew )
 {
diff --git a/sw/source/core/doc/doclay.cxx b/sw/source/core/doc/doclay.cxx
index b6398ee8ce7f..c9881b848d29 100644
--- a/sw/source/core/doc/doclay.cxx
+++ b/sw/source/core/doc/doclay.cxx
@@ -741,19 +741,19 @@ lcl_InsertLabel(SwDoc & rDoc, SwTextFormatColls *const 
pTextFormatCollTable,
 
                 /* #i6447#: Only the selected items are copied from the old
                    format. */
-                std::unique_ptr<SfxItemSet> pNewSet = 
pNewFormat->GetAttrSet().Clone();
+                SwAttrSet aNewSet = pNewFormat->GetAttrSet().CloneAsValue();
 
                 // Copy only the set attributes.
                 // The others should apply from the Templates.
-                lcl_CpyAttr( *pNewSet, pOldFormat->GetAttrSet(), RES_PRINT );
-                lcl_CpyAttr( *pNewSet, pOldFormat->GetAttrSet(), RES_OPAQUE );
-                lcl_CpyAttr( *pNewSet, pOldFormat->GetAttrSet(), RES_PROTECT );
-                lcl_CpyAttr( *pNewSet, pOldFormat->GetAttrSet(), RES_SURROUND 
);
-                lcl_CpyAttr( *pNewSet, pOldFormat->GetAttrSet(), 
RES_VERT_ORIENT );
-                lcl_CpyAttr( *pNewSet, pOldFormat->GetAttrSet(), 
RES_HORI_ORIENT );
-                lcl_CpyAttr( *pNewSet, pOldFormat->GetAttrSet(), RES_LR_SPACE 
);
-                lcl_CpyAttr( *pNewSet, pOldFormat->GetAttrSet(), RES_UL_SPACE 
);
-                lcl_CpyAttr( *pNewSet, pOldFormat->GetAttrSet(), 
RES_BACKGROUND );
+                lcl_CpyAttr( aNewSet, pOldFormat->GetAttrSet(), RES_PRINT );
+                lcl_CpyAttr( aNewSet, pOldFormat->GetAttrSet(), RES_OPAQUE );
+                lcl_CpyAttr( aNewSet, pOldFormat->GetAttrSet(), RES_PROTECT );
+                lcl_CpyAttr( aNewSet, pOldFormat->GetAttrSet(), RES_SURROUND );
+                lcl_CpyAttr( aNewSet, pOldFormat->GetAttrSet(), 
RES_VERT_ORIENT );
+                lcl_CpyAttr( aNewSet, pOldFormat->GetAttrSet(), 
RES_HORI_ORIENT );
+                lcl_CpyAttr( aNewSet, pOldFormat->GetAttrSet(), RES_LR_SPACE );
+                lcl_CpyAttr( aNewSet, pOldFormat->GetAttrSet(), RES_UL_SPACE );
+                lcl_CpyAttr( aNewSet, pOldFormat->GetAttrSet(), RES_BACKGROUND 
);
                 if( bCpyBrd )
                 {
                     // If there's no BoxItem at graphic, but the new Format 
has one, then set the
@@ -761,40 +761,40 @@ lcl_InsertLabel(SwDoc & rDoc, SwTextFormatColls *const 
pTextFormatCollTable,
                     const SfxPoolItem *pItem;
                     if( SfxItemState::SET == pOldFormat->GetAttrSet().
                             GetItemState( RES_BOX, true, &pItem ))
-                        pNewSet->Put( *pItem );
+                        aNewSet.Put( *pItem );
                     else if( SfxItemState::SET == pNewFormat->GetAttrSet().
                             GetItemState( RES_BOX ))
-                        pNewSet->Put( *GetDfltAttr( RES_BOX ) );
+                        aNewSet.Put( *GetDfltAttr( RES_BOX ) );
 
                     if( SfxItemState::SET == pOldFormat->GetAttrSet().
                             GetItemState( RES_SHADOW, true, &pItem ))
-                        pNewSet->Put( *pItem );
+                        aNewSet.Put( *pItem );
                     else if( SfxItemState::SET == pNewFormat->GetAttrSet().
                             GetItemState( RES_SHADOW ))
-                        pNewSet->Put( *GetDfltAttr( RES_SHADOW ) );
+                        aNewSet.Put( *GetDfltAttr( RES_SHADOW ) );
                 }
                 else
                 {
                     // Hard-set the attributes, because they could come from 
the Template
                     // and then size calculations could not be correct anymore.
-                    pNewSet->Put( SvxBoxItem(RES_BOX) );
-                    pNewSet->Put( SvxShadowItem(RES_SHADOW) );
+                    aNewSet.Put( SvxBoxItem(RES_BOX) );
+                    aNewSet.Put( SvxShadowItem(RES_SHADOW) );
                 }
 
                 // Always transfer the anchor, which is a hard attribute 
anyways.
-                pNewSet->Put( pOldFormat->GetAnchor() );
+                aNewSet.Put( pOldFormat->GetAnchor() );
 
                 // The new one should be changeable in its height.
                 std::unique_ptr<SwFormatFrameSize> 
aFrameSize(pOldFormat->GetFrameSize().Clone());
                 aFrameSize->SetHeightSizeType( SwFrameSize::Minimum );
-                pNewSet->Put( std::move(aFrameSize) );
+                aNewSet.Put( std::move(aFrameSize) );
 
                 SwStartNode* pSttNd = rDoc.GetNodes().MakeTextSection(
                             rDoc.GetNodes().GetEndOfAutotext(),
                             SwFlyStartNode, pColl );
-                pNewSet->Put( SwFormatContent( pSttNd ));
+                aNewSet.Put( SwFormatContent( pSttNd ));
 
-                pNewFormat->SetFormatAttr( *pNewSet );
+                pNewFormat->SetFormatAttr( aNewSet );
 
                 // InContents need to be treated in a special way:
                 // The TextAttribute needs to be destroyed.
@@ -824,14 +824,14 @@ lcl_InsertLabel(SwDoc & rDoc, SwTextFormatColls *const 
pTextFormatCollTable,
                 // The old one should not have a flow and it should be 
adjusted to above and
                 // middle.
                 // Also, the width should be 100% and it should also adjust 
the height, if changed.
-                pNewSet->ClearItem();
+                aNewSet.ClearItem();
 
-                pNewSet->Put( SwFormatSurround( css::text::WrapTextMode_NONE ) 
);
-                pNewSet->Put( SvxOpaqueItem( RES_OPAQUE, true ) );
+                aNewSet.Put( SwFormatSurround( css::text::WrapTextMode_NONE ) 
);
+                aNewSet.Put( SvxOpaqueItem( RES_OPAQUE, true ) );
 
                 sal_Int16 eVert = bBefore ? text::VertOrientation::BOTTOM : 
text::VertOrientation::TOP;
-                pNewSet->Put( SwFormatVertOrient( 0, eVert ) );
-                pNewSet->Put( SwFormatHoriOrient( 0, 
text::HoriOrientation::CENTER ) );
+                aNewSet.Put( SwFormatVertOrient( 0, eVert ) );
+                aNewSet.Put( SwFormatHoriOrient( 0, 
text::HoriOrientation::CENTER ) );
 
                 aFrameSize.reset(pOldFormat->GetFrameSize().Clone());
 
@@ -848,17 +848,17 @@ lcl_InsertLabel(SwDoc & rDoc, SwTextFormatColls *const 
pTextFormatCollTable,
                 }
                 aFrameSize->SetWidthPercent(isMath ? 0 : 100);
                 aFrameSize->SetHeightPercent(SwFormatFrameSize::SYNCED);
-                pNewSet->Put( std::move(aFrameSize) );
+                aNewSet.Put( std::move(aFrameSize) );
 
                 // Hard-set the attributes, because they could come from the 
Template
                 // and then size calculations could not be correct anymore.
                 if( bCpyBrd )
                 {
-                    pNewSet->Put( SvxBoxItem(RES_BOX) );
-                    pNewSet->Put( SvxShadowItem(RES_SHADOW) );
+                    aNewSet.Put( SvxBoxItem(RES_BOX) );
+                    aNewSet.Put( SvxShadowItem(RES_SHADOW) );
                 }
-                pNewSet->Put( SvxLRSpaceItem(RES_LR_SPACE) );
-                pNewSet->Put( SvxULSpaceItem(RES_UL_SPACE) );
+                aNewSet.Put( SvxLRSpaceItem(RES_LR_SPACE) );
+                aNewSet.Put( SvxULSpaceItem(RES_UL_SPACE) );
 
                 // The old one is paragraph-bound to the paragraph in the new 
one.
                 SwFormatAnchor aAnch( RndStdIds::FLY_AT_PARA );
@@ -866,14 +866,12 @@ lcl_InsertLabel(SwDoc & rDoc, SwTextFormatColls *const 
pTextFormatCollTable,
                 pNew = aAnchIdx.GetNode().GetTextNode();
                 SwPosition aPos( aAnchIdx );
                 aAnch.SetAnchor( &aPos );
-                pNewSet->Put( aAnch );
+                aNewSet.Put( aAnch );
 
                 if( pUndo )
-                    pUndo->SetFlys( *pOldFormat, *pNewSet, *pNewFormat );
+                    pUndo->SetFlys( *pOldFormat, aNewSet, *pNewFormat );
                 else
-                    pOldFormat->SetFormatAttr( *pNewSet );
-
-                pNewSet.reset();
+                    pOldFormat->SetFormatAttr( aNewSet );
 
                 // Have only the FlyFrames created.
                 // We leave this to established methods (especially for 
InCntFlys).
@@ -1059,7 +1057,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.
-    std::unique_ptr<SfxItemSet> pNewSet = pOldFormat->GetAttrSet().Clone( 
false );
+    SwAttrSet aNewSet = pOldFormat->GetAttrSet().CloneAsValue( false );
 
     // Protect the Frame's size and position
     if ( rSdrObj.IsMoveProtect() || rSdrObj.IsResizeProtect() )
@@ -1068,11 +1066,11 @@ lcl_InsertDrawLabel( SwDoc & rDoc, SwTextFormatColls 
*const pTextFormatCollTable
         aProtect.SetContentProtect( false );
         aProtect.SetPosProtect( rSdrObj.IsMoveProtect() );
         aProtect.SetSizeProtect( rSdrObj.IsResizeProtect() );
-        pNewSet->Put( aProtect );
+        aNewSet.Put( aProtect );
     }
 
     // Take over the text wrap
-    lcl_CpyAttr( *pNewSet, pOldFormat->GetAttrSet(), RES_SURROUND );
+    lcl_CpyAttr( aNewSet, pOldFormat->GetAttrSet(), RES_SURROUND );
 
     // Send the frame to the back, if needed.
     // Consider the 'invisible' hell layer.
@@ -1081,25 +1079,25 @@ lcl_InsertDrawLabel( SwDoc & rDoc, SwTextFormatColls 
*const pTextFormatCollTable
     {
         SvxOpaqueItem aOpaque( RES_OPAQUE );
         aOpaque.SetValue( true );
-        pNewSet->Put( aOpaque );
+        aNewSet.Put( aOpaque );
     }
 
     // Take over position
     // #i26791# - use directly drawing object's positioning attributes
-    pNewSet->Put( pOldFormat->GetHoriOrient() );
-    pNewSet->Put( pOldFormat->GetVertOrient() );
+    aNewSet.Put( pOldFormat->GetHoriOrient() );
+    aNewSet.Put( pOldFormat->GetVertOrient() );
 
-    pNewSet->Put( pOldFormat->GetAnchor() );
+    aNewSet.Put( pOldFormat->GetAnchor() );
 
     // The new one should be variable in its height!
     Size aSz( rSdrObj.GetCurrentBoundRect().GetSize() );
     SwFormatFrameSize aFrameSize( SwFrameSize::Minimum, aSz.Width(), 
aSz.Height() );
-    pNewSet->Put( aFrameSize );
+    aNewSet.Put( aFrameSize );
 
     // Apply the margin to the new Frame.
     // Don't set a border, use the one from the Template.
-    pNewSet->Put( pOldFormat->GetLRSpace() );
-    pNewSet->Put( pOldFormat->GetULSpace() );
+    aNewSet.Put( pOldFormat->GetLRSpace() );
+    aNewSet.Put( pOldFormat->GetULSpace() );
 
     SwStartNode* pSttNd =
         rDoc.GetNodes().MakeTextSection(
@@ -1111,13 +1109,13 @@ lcl_InsertDrawLabel( SwDoc & rDoc, SwTextFormatColls 
*const pTextFormatCollTable
 
     // Set border and shadow to default if the template contains any.
     if( SfxItemState::SET == pNewFormat->GetAttrSet().GetItemState( RES_BOX ))
-        pNewSet->Put( *GetDfltAttr( RES_BOX ) );
+        aNewSet.Put( *GetDfltAttr( RES_BOX ) );
 
     if( SfxItemState::SET == pNewFormat->GetAttrSet().GetItemState(RES_SHADOW))
-        pNewSet->Put( *GetDfltAttr( RES_SHADOW ) );
+        aNewSet.Put( *GetDfltAttr( RES_SHADOW ) );
 
     pNewFormat->SetFormatAttr( SwFormatContent( pSttNd ));
-    pNewFormat->SetFormatAttr( *pNewSet );
+    pNewFormat->SetFormatAttr( aNewSet );
 
     const SwFormatAnchor& rAnchor = pNewFormat->GetAnchor();
     if ( RndStdIds::FLY_AS_CHAR == rAnchor.GetAnchorId() )
@@ -1142,9 +1140,9 @@ lcl_InsertDrawLabel( SwDoc & rDoc, SwTextFormatColls 
*const pTextFormatCollTable
 
     // The old one should not have a flow
     // and it should be adjusted to above and middle.
-    pNewSet->ClearItem();
+    aNewSet.ClearItem();
 
-    pNewSet->Put( SwFormatSurround( css::text::WrapTextMode_NONE ) );
+    aNewSet.Put( SwFormatSurround( css::text::WrapTextMode_NONE ) );
     if (nLayerId == rDoc.getIDocumentDrawModelAccess().GetHellId())
     {
     // Consider drawing objects in the 'invisible' hell layer
@@ -1154,12 +1152,12 @@ lcl_InsertDrawLabel( SwDoc & rDoc, SwTextFormatColls 
*const pTextFormatCollTable
     {
         rSdrObj.SetLayer( 
rDoc.getIDocumentDrawModelAccess().GetInvisibleHeavenId() );
     }
-    pNewSet->Put( SvxLRSpaceItem( RES_LR_SPACE ) );
-    pNewSet->Put( SvxULSpaceItem( RES_UL_SPACE ) );
+    aNewSet.Put( SvxLRSpaceItem( RES_LR_SPACE ) );
+    aNewSet.Put( SvxULSpaceItem( RES_UL_SPACE ) );
 
     // #i26791# - set position of the drawing object, which is labeled.
-    pNewSet->Put( SwFormatVertOrient( 0, text::VertOrientation::TOP, 
text::RelOrientation::FRAME ) );
-    pNewSet->Put( SwFormatHoriOrient( 0, text::HoriOrientation::CENTER, 
text::RelOrientation::FRAME ) );
+    aNewSet.Put( SwFormatVertOrient( 0, text::VertOrientation::TOP, 
text::RelOrientation::FRAME ) );
+    aNewSet.Put( SwFormatHoriOrient( 0, text::HoriOrientation::CENTER, 
text::RelOrientation::FRAME ) );
 
     // The old one is paragraph-bound to the new one's paragraph.
     SwFormatAnchor aAnch( RndStdIds::FLY_AT_PARA );
@@ -1167,18 +1165,16 @@ lcl_InsertDrawLabel( SwDoc & rDoc, SwTextFormatColls 
*const pTextFormatCollTable
     pNew = aAnchIdx.GetNode().GetTextNode();
     SwPosition aPos( aAnchIdx );
     aAnch.SetAnchor( &aPos );
-    pNewSet->Put( aAnch );
+    aNewSet.Put( aAnch );
 
     if( pUndo )
     {
-        pUndo->SetFlys( *pOldFormat, *pNewSet, *pNewFormat );
+        pUndo->SetFlys( *pOldFormat, aNewSet, *pNewFormat );
         // #i26791# - position no longer needed
         pUndo->SetDrawObj( nLayerId );
     }
     else
-        pOldFormat->SetFormatAttr( *pNewSet );
-
-    pNewSet.reset();
+        pOldFormat->SetFormatAttr( aNewSet );
 
     // Have only the FlyFrames created.
     // We leave this to established methods (especially for InCntFlys).
diff --git a/sw/source/core/model/ThemeColorChanger.cxx 
b/sw/source/core/model/ThemeColorChanger.cxx
index a14f8d872cf4..8cbc0b971066 100644
--- a/sw/source/core/model/ThemeColorChanger.cxx
+++ b/sw/source/core/model/ThemeColorChanger.cxx
@@ -353,15 +353,15 @@ void 
ThemeColorChanger::apply(std::shared_ptr<model::ColorSet> const& pColorSet)
         auto& rPageDesc = pDocument->GetPageDesc(nIndex);
         SwFrameFormat& rPageFormat = rPageDesc.GetMaster();
         const SwAttrSet& rAttrSet = rPageFormat.GetAttrSet();
-        std::unique_ptr<SfxItemSet> pNewSet = rAttrSet.Clone();
+        SwAttrSet aNewSet = rAttrSet.CloneAsValue();
 
         bool bChanged = false;
-        bChanged = bChanged || changeBackground(rAttrSet, *pNewSet, 
*pColorSet);
-        bChanged = bChanged || changeBox(rAttrSet, *pNewSet, *pColorSet);
+        bChanged = bChanged || changeBackground(rAttrSet, aNewSet, *pColorSet);
+        bChanged = bChanged || changeBox(rAttrSet, aNewSet, *pColorSet);
 
         if (bChanged)
         {
-            rPageFormat.SetFormatAttr(*pNewSet);
+            rPageFormat.SetFormatAttr(aNewSet);
             pDocument->ChgPageDesc(nIndex, rPageDesc);
         }
     }
@@ -377,14 +377,14 @@ void 
ThemeColorChanger::apply(std::shared_ptr<model::ColorSet> const& pColorSet)
         if (pFrameFormat)
         {
             const SwAttrSet& rAttrSet = pFrameFormat->GetAttrSet();
-            std::unique_ptr<SfxItemSet> pNewSet = rAttrSet.Clone();
+            SwAttrSet aNewSet = rAttrSet.CloneAsValue();
 
             bool bChanged = false;
-            bChanged = changeBackground(rAttrSet, *pNewSet, *pColorSet) || 
bChanged;
-            bChanged = changeBox(rAttrSet, *pNewSet, *pColorSet) || bChanged;
+            bChanged = changeBackground(rAttrSet, aNewSet, *pColorSet) || 
bChanged;
+            bChanged = changeBox(rAttrSet, aNewSet, *pColorSet) || bChanged;
 
             if (bChanged)
-                pDocument->ChgFormat(*pFrameFormat, *pNewSet);
+                pDocument->ChgFormat(*pFrameFormat, aNewSet);
         }
         pStyle = static_cast<SwDocStyleSheet*>(pPool->Next());
     }
@@ -397,18 +397,18 @@ void 
ThemeColorChanger::apply(std::shared_ptr<model::ColorSet> const& pColorSet)
         if (pTextFormatCollection)
         {
             const SwAttrSet& rAttrSet = pTextFormatCollection->GetAttrSet();
-            std::unique_ptr<SfxItemSet> pNewSet = rAttrSet.Clone();
+            SwAttrSet aNewSet = rAttrSet.CloneAsValue();
 
             bool bChanged = false;
-            bChanged = changeColor(rAttrSet, *pNewSet, *pColorSet) || bChanged;
-            bChanged = changeOverlineColor(rAttrSet, *pNewSet, *pColorSet) || 
bChanged;
-            bChanged = changeUnderlineColor(rAttrSet, *pNewSet, *pColorSet) || 
bChanged;
-            bChanged = changeBox(rAttrSet, *pNewSet, *pColorSet) || bChanged;
-            bChanged = changeBackground(rAttrSet, *pNewSet, *pColorSet) || 
bChanged;
+            bChanged = changeColor(rAttrSet, aNewSet, *pColorSet) || bChanged;
+            bChanged = changeOverlineColor(rAttrSet, aNewSet, *pColorSet) || 
bChanged;
+            bChanged = changeUnderlineColor(rAttrSet, aNewSet, *pColorSet) || 
bChanged;
+            bChanged = changeBox(rAttrSet, aNewSet, *pColorSet) || bChanged;
+            bChanged = changeBackground(rAttrSet, aNewSet, *pColorSet) || 
bChanged;
 
             if (bChanged)
             {
-                pDocument->ChgFormat(*pTextFormatCollection, *pNewSet);
+                pDocument->ChgFormat(*pTextFormatCollection, aNewSet);
                 
pPool->Broadcast(SfxStyleSheetHint(SfxHintId::StyleSheetModified, *pStyle));
             }
         }
@@ -423,14 +423,14 @@ void 
ThemeColorChanger::apply(std::shared_ptr<model::ColorSet> const& pColorSet)
         if (pCharFormat)
         {
             const SwAttrSet& rAttrSet = pCharFormat->GetAttrSet();
-            std::unique_ptr<SfxItemSet> pNewSet = rAttrSet.Clone();
+            SwAttrSet aNewSet = rAttrSet.CloneAsValue();
 
             bool bChanged = false;
-            bChanged = changeColor(rAttrSet, *pNewSet, *pColorSet) || bChanged;
-            bChanged = changeOverlineColor(rAttrSet, *pNewSet, *pColorSet) || 
bChanged;
-            bChanged = changeUnderlineColor(rAttrSet, *pNewSet, *pColorSet) || 
bChanged;
+            bChanged = changeColor(rAttrSet, aNewSet, *pColorSet) || bChanged;
+            bChanged = changeOverlineColor(rAttrSet, aNewSet, *pColorSet) || 
bChanged;
+            bChanged = changeUnderlineColor(rAttrSet, aNewSet, *pColorSet) || 
bChanged;
             if (bChanged)
-                pDocument->ChgFormat(*pCharFormat, *pNewSet);
+                pDocument->ChgFormat(*pCharFormat, aNewSet);
         }
         pStyle = static_cast<SwDocStyleSheet*>(pPool->Next());
     }
diff --git a/sw/source/ui/dialog/uiregionsw.cxx 
b/sw/source/ui/dialog/uiregionsw.cxx
index 14145a1ed35f..f55b2194bdc2 100644
--- a/sw/source/ui/dialog/uiregionsw.cxx
+++ b/sw/source/ui/dialog/uiregionsw.cxx
@@ -778,31 +778,31 @@ IMPL_LINK_NOARG(SwEditRegionDlg, OkHdl, weld::Button&, 
void)
             size_t nNewPos = rDocFormats.GetPos(pFormat);
             if ( SIZE_MAX != nNewPos )
             {
-                std::unique_ptr<SfxItemSet> pSet(pFormat->GetAttrSet().Clone( 
false ));
+                SwAttrSet aSet(pFormat->GetAttrSet().CloneAsValue( false ));
                 if( pFormat->GetCol() != pRepr->GetCol() )
-                    pSet->Put( pRepr->GetCol() );
+                    aSet.Put( pRepr->GetCol() );
 
                 std::unique_ptr<SvxBrushItem> 
aBrush(pFormat->makeBackgroundBrushItem(false));
                 if( pRepr->GetBackground() && *aBrush != 
*pRepr->GetBackground() )
-                    pSet->Put( *pRepr->GetBackground() );
+                    aSet.Put( *pRepr->GetBackground() );
 
                 if( pFormat->GetFootnoteAtTextEnd(false) != 
pRepr->GetFootnoteNtAtEnd() )
-                    pSet->Put( pRepr->GetFootnoteNtAtEnd() );
+                    aSet.Put( pRepr->GetFootnoteNtAtEnd() );
 
                 if( pFormat->GetEndAtTextEnd(false) != pRepr->GetEndNtAtEnd() )
-                    pSet->Put( pRepr->GetEndNtAtEnd() );
+                    aSet.Put( pRepr->GetEndNtAtEnd() );
 
                 if( pFormat->GetBalancedColumns() != pRepr->GetBalance() )
-                    pSet->Put( pRepr->GetBalance() );
+                    aSet.Put( pRepr->GetBalance() );
 
                 if( pFormat->GetFrameDir() != *pRepr->GetFrameDir() )
-                    pSet->Put( *pRepr->GetFrameDir() );
+                    aSet.Put( *pRepr->GetFrameDir() );
 
                 if( pFormat->GetLRSpace() != *pRepr->GetLRSpace())
-                    pSet->Put( *pRepr->GetLRSpace());
+                    aSet.Put( *pRepr->GetLRSpace());
 
                 m_rSh.UpdateSection( nNewPos, pRepr->GetSectionData(),
-                                   pSet->Count() ? pSet.get() : nullptr );
+                                   aSet.Count() ? &aSet : nullptr );
             }
         } while (m_xTree->iter_next(*xIter));
     }

Reply via email to