summaryrefslogtreecommitdiff
path: root/sw/source/core/txtnode/thints.cxx
diff options
context:
space:
mode:
authorNoel Grandin <noel.grandin@collabora.co.uk>2022-02-18 10:56:56 +0200
committerNoel Grandin <noel.grandin@collabora.co.uk>2022-02-18 11:53:27 +0100
commitfe2ec505786bacc6f3baca3292367903644ac99b (patch)
tree34c79dbc66f0fef4142d6675891ea1b15a54ec3a /sw/source/core/txtnode/thints.cxx
parent657095c9d26147e290e7944db875b9555b33dd1a (diff)
improve the SfxItemSet::CloneAsValue check
to prevent object slicing. Which reveals a problems with commit 044fa30a4c77013c87a7e2a6dd9022a2f6599778 Author: Noel Grandin <noelgrandin@gmail.com> Date: Thu Sep 23 18:44:42 2021 +0200 no need to allocate this SfxItemSet on the heap and commit 044fa30a4c77013c87a7e2a6dd9022a2f6599778 Author: Noel Grandin <noelgrandin@gmail.com> Date: Thu Sep 23 18:44:42 2021 +0200 no need to allocate this SfxItemSet on the heap so revert the problematic bits of those commits Change-Id: I5eeba1d5bdb91f4e539850516f2b1c11e69ff2c1 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/130127 Tested-by: Jenkins Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
Diffstat (limited to 'sw/source/core/txtnode/thints.cxx')
-rw-r--r--sw/source/core/txtnode/thints.cxx20
1 files changed, 10 insertions, 10 deletions
diff --git a/sw/source/core/txtnode/thints.cxx b/sw/source/core/txtnode/thints.cxx
index 45e5e2f099f4..a6d72708c2f6 100644
--- a/sw/source/core/txtnode/thints.cxx
+++ b/sw/source/core/txtnode/thints.cxx
@@ -914,7 +914,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::optional<SfxItemSet> oNewSet;
+ std::unique_ptr<SfxItemSet> pNewSet;
SfxItemIter aIter2( *pNewStyle );
const SfxPoolItem* pItem = aIter2.GetCurItem();
@@ -929,19 +929,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 ( !oNewSet )
- oNewSet.emplace(pNewStyle->CloneAsValue());
- oNewSet->ClearItem( pItem->Which() );
+ if ( !pNewSet )
+ pNewSet = pNewStyle->Clone();
+ pNewSet->ClearItem( pItem->Which() );
}
}
}
while ((pItem = aIter2.NextItem()));
- if ( oNewSet )
+ if ( pNewSet )
{
bOptimizeAllowed = false;
- if ( oNewSet->Count() )
- pNewStyle = rNode.getIDocumentStyleAccess().getAutomaticStyle( *oNewSet, IStyleAccess::AUTO_STYLE_CHAR );
+ if ( pNewSet->Count() )
+ pNewStyle = rNode.getIDocumentStyleAccess().getAutomaticStyle( *pNewSet, IStyleAccess::AUTO_STYLE_CHAR );
else
pNewStyle.reset();
}
@@ -1039,9 +1039,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();
- SfxItemSet aNewSet =
- pAutoStyle->SfxItemSet::CloneAsValue( true, &rDoc.GetAttrPool() );
- SwTextAttr* pNew = MakeTextAttr( rDoc, aNewSet, nStt, nEnd );
+ std::unique_ptr<const SfxItemSet> pNewSet(
+ pAutoStyle->SfxItemSet::Clone( true, &rDoc.GetAttrPool() ));
+ SwTextAttr* pNew = MakeTextAttr( rDoc, *pNewSet, nStt, nEnd );
return pNew;
}