diff options
author | Noel Grandin <noelgrandin@gmail.com> | 2021-09-23 18:44:42 +0200 |
---|---|---|
committer | Noel Grandin <noel.grandin@collabora.co.uk> | 2021-09-24 08:39:10 +0200 |
commit | 044fa30a4c77013c87a7e2a6dd9022a2f6599778 (patch) | |
tree | b5ca9f2490a71288acf2dabec306e4a275044c6d /sw | |
parent | d21a1d999f8872f22a96ad7d1dc2f0e3b48421b5 (diff) |
no need to allocate this SfxItemSet on the heap
Change-Id: I973d6ef5d3ddcb1b3cd0506c59ee63411e80a4ec
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/122539
Tested-by: Jenkins
Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
Diffstat (limited to 'sw')
-rw-r--r-- | sw/source/core/txtnode/thints.cxx | 20 |
1 files changed, 10 insertions, 10 deletions
diff --git a/sw/source/core/txtnode/thints.cxx b/sw/source/core/txtnode/thints.cxx index 995d82606dab..2464bc9d6860 100644 --- a/sw/source/core/txtnode/thints.cxx +++ b/sw/source/core/txtnode/thints.cxx @@ -912,7 +912,7 @@ void SwpHints::BuildPortions( SwTextNode& rNode, SwTextAttr& rNewHint, // #i81764# This should not be applied for no length attributes!!! <-- if ( !bNoLengthAttribute && rNode.HasSwAttrSet() && pNewStyle->Count() ) { - std::unique_ptr<SfxItemSet> pNewSet; + std::optional<SfxItemSet> oNewSet; SfxItemIter aIter2( *pNewStyle ); const SfxPoolItem* pItem = aIter2.GetCurItem(); @@ -927,19 +927,19 @@ void SwpHints::BuildPortions( SwTextNode& rNode, SwTextAttr& rNewHint, // Do not clear item if the attribute is set in a character format: if ( !pCurrentCharFormat || nullptr == CharFormat::GetItem( *pCurrentCharFormat, pItem->Which() ) ) { - if ( !pNewSet ) - pNewSet = pNewStyle->Clone(); - pNewSet->ClearItem( pItem->Which() ); + if ( !oNewSet ) + oNewSet.emplace(pNewStyle->CloneAsValue()); + oNewSet->ClearItem( pItem->Which() ); } } } while ((pItem = aIter2.NextItem())); - if ( pNewSet ) + if ( oNewSet ) { bOptimizeAllowed = false; - if ( pNewSet->Count() ) - pNewStyle = rNode.getIDocumentStyleAccess().getAutomaticStyle( *pNewSet, IStyleAccess::AUTO_STYLE_CHAR ); + if ( oNewSet->Count() ) + pNewStyle = rNode.getIDocumentStyleAccess().getAutomaticStyle( *oNewSet, IStyleAccess::AUTO_STYLE_CHAR ); else pNewStyle.reset(); } @@ -1038,9 +1038,9 @@ SwTextAttr* MakeTextAttr( // If the attribute is an auto-style which refers to a pool that is // different from rDoc's pool, we have to correct this: const std::shared_ptr<SfxItemSet> pAutoStyle = static_cast<const SwFormatAutoFormat&>(rAttr).GetStyleHandle(); - std::unique_ptr<const SfxItemSet> pNewSet( - pAutoStyle->SfxItemSet::Clone( true, &rDoc.GetAttrPool() )); - SwTextAttr* pNew = MakeTextAttr( rDoc, *pNewSet, nStt, nEnd ); + SfxItemSet aNewSet = + pAutoStyle->SfxItemSet::CloneAsValue( true, &rDoc.GetAttrPool() ); + SwTextAttr* pNew = MakeTextAttr( rDoc, aNewSet, nStt, nEnd ); return pNew; } |