From dfb0c861e0d277f93482c58e607112b5e3baf5f5 Mon Sep 17 00:00:00 2001 From: Noel Grandin Date: Sun, 19 Sep 2021 20:54:42 +0200 Subject: 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 --- sw/source/core/unocore/unoobj.cxx | 36 +++++++++++++++++------------------- 1 file 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 pSet; - std::unique_ptr pSetParent; + std::optional oSet; + std::optional 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 )); + oSet.emplace( rPaM.GetDoc().GetAttrPool(), + svl::Items ); 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; } } -- cgit v1.2.3