From 2024780f9e169a6c1d167e494d37f46f7640dc97 Mon Sep 17 00:00:00 2001 From: Noel Grandin Date: Thu, 1 Jul 2021 11:01:40 +0200 Subject: can allocate these SfxItemSet on the stack Change-Id: I85a749429a3a14aca5c6eaeaa5da37b25eb9f730 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/118283 Tested-by: Jenkins Reviewed-by: Noel Grandin --- editeng/source/uno/unotext.cxx | 29 ++++++++++++++--------------- 1 file changed, 14 insertions(+), 15 deletions(-) (limited to 'editeng') diff --git a/editeng/source/uno/unotext.cxx b/editeng/source/uno/unotext.cxx index cae30b9eaa99..cf9ea10a601e 100644 --- a/editeng/source/uno/unotext.cxx +++ b/editeng/source/uno/unotext.cxx @@ -770,11 +770,11 @@ void SvxUnoTextRangeBase::_setPropertyValues( const uno::Sequence< OUString >& a nEndPara = aSel.nEndPara; } - std::unique_ptr pOldAttrSet; - std::unique_ptr pNewAttrSet; + std::optional pOldAttrSet; + std::optional pNewAttrSet; - std::unique_ptr pOldParaSet; - std::unique_ptr pNewParaSet; + std::optional pOldParaSet; + std::optional pNewParaSet; for( ; nCount; nCount--, pPropertyNames++, pValues++ ) { @@ -786,11 +786,10 @@ void SvxUnoTextRangeBase::_setPropertyValues( const uno::Sequence< OUString >& a if( (nPara == -1) && !bParaAttrib ) { - if( nullptr == pNewAttrSet ) + if( !pNewAttrSet ) { - const SfxItemSet aSet( pForwarder->GetAttribs( aSel ) ); - pOldAttrSet.reset(new SfxItemSet( aSet )); - pNewAttrSet.reset(new SfxItemSet( *pOldAttrSet->GetPool(), pOldAttrSet->GetRanges() )); + pOldAttrSet.emplace( pForwarder->GetAttribs( aSel ) ); + pNewAttrSet.emplace( *pOldAttrSet->GetPool(), pOldAttrSet->GetRanges() ); } setPropertyValue( pMap, *pValues, GetSelection(), *pOldAttrSet, *pNewAttrSet ); @@ -806,11 +805,11 @@ void SvxUnoTextRangeBase::_setPropertyValues( const uno::Sequence< OUString >& a } else { - if( nullptr == pNewParaSet ) + if( !pNewParaSet ) { const SfxItemSet & rSet = pForwarder->GetParaAttribs( nTempPara ); - pOldParaSet.reset(new SfxItemSet( rSet )); - pNewParaSet.reset(new SfxItemSet( *pOldParaSet->GetPool(), pOldParaSet->GetRanges() )); + pOldParaSet.emplace( rSet ); + pNewParaSet.emplace( *pOldParaSet->GetPool(), pOldParaSet->GetRanges() ); } setPropertyValue( pMap, *pValues, GetSelection(), *pOldParaSet, *pNewParaSet ); @@ -1037,23 +1036,23 @@ uno::Sequence< beans::PropertyState > SvxUnoTextRangeBase::_getPropertyStates(co SvxTextForwarder* pForwarder = mpEditSource ? mpEditSource->GetTextForwarder() : nullptr; if( pForwarder ) { - std::unique_ptr pSet; + std::optional pSet; if( nPara != -1 ) { - pSet.reset(new SfxItemSet( pForwarder->GetParaAttribs( nPara ) )); + pSet.emplace( pForwarder->GetParaAttribs( nPara ) ); } else { ESelection aSel( GetSelection() ); CheckSelection( aSel, pForwarder ); - pSet.reset(new SfxItemSet( pForwarder->GetAttribs( aSel, EditEngineAttribs::OnlyHard ) )); + pSet.emplace( pForwarder->GetAttribs( aSel, EditEngineAttribs::OnlyHard ) ); } beans::PropertyState* pState = aRet.getArray(); for( const OUString& rName : PropertyName ) { const SfxItemPropertyMapEntry* pMap = mpPropSet->getPropertyMapEntry( rName ); - if( !_getOnePropertyStates(pSet.get(), pMap, *pState++) ) + if( !_getOnePropertyStates(&*pSet, pMap, *pState++) ) { throw beans::UnknownPropertyException(rName); } -- cgit