diff options
author | Noel Grandin <noelgrandin@gmail.com> | 2021-09-19 20:54:42 +0200 |
---|---|---|
committer | Noel Grandin <noel.grandin@collabora.co.uk> | 2021-09-20 08:56:18 +0200 |
commit | dfb0c861e0d277f93482c58e607112b5e3baf5f5 (patch) | |
tree | 5f24fc0624bd1de30516279a0ca91e5bd7590a3f | |
parent | a64e503b77679d60997a2b6c69b7f1cd37aba5e9 (diff) |
no need to allocate these SfxItemSet on the heap
Change-Id: Ia7be6c4e04f5558ed0dd53aa0df4feea1b1c556e
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/122329
Tested-by: Jenkins
Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
-rw-r--r-- | sw/source/core/unocore/unoobj.cxx | 36 |
1 files changed, 17 insertions, 19 deletions
diff --git a/sw/source/core/unocore/unoobj.cxx b/sw/source/core/unocore/unoobj.cxx index 86439e0dc3a2..b7c6cab3d7ed 100644 --- a/sw/source/core/unocore/unoobj.cxx +++ b/sw/source/core/unocore/unoobj.cxx @@ -1845,8 +1845,8 @@ SwUnoCursorHelper::GetPropertyStates( uno::Sequence< beans::PropertyState > aRet(rPropertyNames.getLength()); beans::PropertyState* pStates = aRet.getArray(); const SfxItemPropertyMap &rMap = rPropSet.getPropertyMap(); - std::unique_ptr<SfxItemSet> pSet; - std::unique_ptr<SfxItemSet> pSetParent; + std::optional<SfxItemSet> oSet; + std::optional<SfxItemSet> oSetParent; for (sal_Int32 i = 0, nEnd = rPropertyNames.getLength(); i < nEnd; i++) { @@ -1891,50 +1891,48 @@ SwUnoCursorHelper::GetPropertyStates( } else { - if (!pSet) + if (!oSet) { switch ( eCaller ) { case SW_PROPERTY_STATE_CALLER_SWX_TEXT_PORTION_TOLERANT: case SW_PROPERTY_STATE_CALLER_SWX_TEXT_PORTION: - pSet.reset( - new SfxItemSet( rPaM.GetDoc().GetAttrPool(), - svl::Items<RES_CHRATR_BEGIN, RES_TXTATR_END> )); + oSet.emplace( rPaM.GetDoc().GetAttrPool(), + svl::Items<RES_CHRATR_BEGIN, RES_TXTATR_END> ); break; case SW_PROPERTY_STATE_CALLER_SINGLE_VALUE_ONLY: - pSet.reset( - new SfxItemSet( rPaM.GetDoc().GetAttrPool(), - pEntry->nWID, pEntry->nWID )); + oSet.emplace( rPaM.GetDoc().GetAttrPool(), + pEntry->nWID, pEntry->nWID ); break; default: - pSet.reset( new SfxItemSet( + oSet.emplace( rPaM.GetDoc().GetAttrPool(), svl::Items< RES_CHRATR_BEGIN, RES_FRMATR_END - 1, RES_UNKNOWNATR_CONTAINER, - RES_UNKNOWNATR_CONTAINER>)); + RES_UNKNOWNATR_CONTAINER>); } // #i63870# - SwUnoCursorHelper::GetCursorAttr( rPaM, *pSet ); + SwUnoCursorHelper::GetCursorAttr( rPaM, *oSet ); } - pStates[i] = ( pSet->Count() ) - ? rPropSet.getPropertyState( *pEntry, *pSet ) + pStates[i] = ( oSet->Count() ) + ? rPropSet.getPropertyState( *pEntry, *oSet ) : beans::PropertyState_DEFAULT_VALUE; //try again to find out if a value has been inherited if( beans::PropertyState_DIRECT_VALUE == pStates[i] ) { - if (!pSetParent) + if (!oSetParent) { - pSetParent = pSet->Clone( false ); + oSetParent.emplace(oSet->CloneAsValue( false )); // #i63870# SwUnoCursorHelper::GetCursorAttr( - rPaM, *pSetParent, true, false ); + rPaM, *oSetParent, true, false ); } - pStates[i] = ( pSetParent->Count() ) - ? rPropSet.getPropertyState( *pEntry, *pSetParent ) + pStates[i] = ( oSetParent->Count() ) + ? rPropSet.getPropertyState( *pEntry, *oSetParent ) : beans::PropertyState_DEFAULT_VALUE; } } |