diff options
author | Noel Grandin <noel.grandin@collabora.co.uk> | 2021-07-01 11:01:40 +0200 |
---|---|---|
committer | Noel Grandin <noel.grandin@collabora.co.uk> | 2021-07-02 15:34:38 +0200 |
commit | 2024780f9e169a6c1d167e494d37f46f7640dc97 (patch) | |
tree | 2488052807d613f63f6afe9a624d8f8fddda674b /editeng | |
parent | d656191ec308d4280b93c7169372e543a255d108 (diff) |
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 <noel.grandin@collabora.co.uk>
Diffstat (limited to 'editeng')
-rw-r--r-- | editeng/source/uno/unotext.cxx | 29 |
1 files changed, 14 insertions, 15 deletions
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<SfxItemSet> pOldAttrSet; - std::unique_ptr<SfxItemSet> pNewAttrSet; + std::optional<SfxItemSet> pOldAttrSet; + std::optional<SfxItemSet> pNewAttrSet; - std::unique_ptr<SfxItemSet> pOldParaSet; - std::unique_ptr<SfxItemSet> pNewParaSet; + std::optional<SfxItemSet> pOldParaSet; + std::optional<SfxItemSet> 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<SfxItemSet> pSet; + std::optional<SfxItemSet> 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); } |