diff options
author | Noel Grandin <noel.grandin@collabora.co.uk> | 2021-05-27 20:47:06 +0200 |
---|---|---|
committer | Noel Grandin <noel.grandin@collabora.co.uk> | 2021-05-28 12:18:03 +0200 |
commit | 83fb7db6911aa77d713f3da0391b680e55563181 (patch) | |
tree | e54ce90695acf14f3a77ea4b2680997c22e55ae8 /sfx2 | |
parent | fbfb57635b602b50cb22465047ae5bcdbef3dd0a (diff) |
no need to allocate these SfxItemSet on the heap
use std::optional where the code needs to control the lifetime of the
object explicitly
Change-Id: Ia550ce051360f68911abc68c945a97d62a637b06
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/116291
Tested-by: Jenkins
Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
Diffstat (limited to 'sfx2')
-rw-r--r-- | sfx2/source/control/unoctitm.cxx | 4 | ||||
-rw-r--r-- | sfx2/source/doc/sfxbasemodel.cxx | 10 |
2 files changed, 7 insertions, 7 deletions
diff --git a/sfx2/source/control/unoctitm.cxx b/sfx2/source/control/unoctitm.cxx index a7e4346c0d48..6228266abeb6 100644 --- a/sfx2/source/control/unoctitm.cxx +++ b/sfx2/source/control/unoctitm.cxx @@ -730,12 +730,12 @@ void SfxDispatchController_Impl::dispatch( const css::util::URL& aURL, } eMapUnit = GetCoreMetric( pShell->GetPool(), GetId() ); - std::unique_ptr<SfxAllItemSet> xSet(new SfxAllItemSet(pShell->GetPool())); + std::optional<SfxAllItemSet> xSet(pShell->GetPool()); TransformParameters(GetId(), lNewArgs, *xSet, pSlot); if (xSet->Count()) { // execute with arguments - call directly - pItem = pDispatcher->Execute(GetId(), nCall, xSet.get(), &aInternalSet, nModifier); + pItem = pDispatcher->Execute(GetId(), nCall, &*xSet, &aInternalSet, nModifier); if ( pItem != nullptr ) { if (const SfxBoolItem* pBoolItem = dynamic_cast<const SfxBoolItem*>(pItem)) diff --git a/sfx2/source/doc/sfxbasemodel.cxx b/sfx2/source/doc/sfxbasemodel.cxx index 0af671f6ae0a..5ef7e7829da5 100644 --- a/sfx2/source/doc/sfxbasemodel.cxx +++ b/sfx2/source/doc/sfxbasemodel.cxx @@ -1617,7 +1617,7 @@ void SAL_CALL SfxBaseModel::storeSelf( const Sequence< beans::PropertyValue > [](const beans::PropertyValue& rProp) { return rProp.Name != "CheckIn"; }); } - std::unique_ptr<SfxAllItemSet> pParams(new SfxAllItemSet( SfxGetpApp()->GetPool() )); + std::optional<SfxAllItemSet> pParams(SfxGetpApp()->GetPool() ); TransformParameters( nSlotId, aArgs, *pParams ); SfxGetpApp()->NotifyEvent( SfxEventHint( SfxEventHintId::SaveDoc, GlobalEventConfig::GetEventName(GlobalEventId::SAVEDOC), m_pData->m_pObjectShell.get() ) ); @@ -1639,7 +1639,7 @@ void SAL_CALL SfxBaseModel::storeSelf( const Sequence< beans::PropertyValue > } else { - bRet = m_pData->m_pObjectShell->Save_Impl( pParams.get() ); + bRet = m_pData->m_pObjectShell->Save_Impl( &*pParams ); } } else @@ -1648,9 +1648,9 @@ void SAL_CALL SfxBaseModel::storeSelf( const Sequence< beans::PropertyValue > m_pData->m_pObjectShell->GetMedium( )->SetInCheckIn( nSlotId == SID_CHECKIN ); if (bOnMainThread) bRet = vcl::solarthread::syncExecute( - [this, &pParams] { return m_pData->m_pObjectShell->Save_Impl(pParams.get()); }); + [this, &pParams] { return m_pData->m_pObjectShell->Save_Impl(&*pParams); }); else - bRet = m_pData->m_pObjectShell->Save_Impl(pParams.get()); + bRet = m_pData->m_pObjectShell->Save_Impl(&*pParams); m_pData->m_pObjectShell->GetMedium( )->SetInCheckIn( nSlotId != SID_CHECKIN ); } @@ -3056,7 +3056,7 @@ void SfxBaseModel::impl_store( const OUString& sURL SfxGetpApp()->NotifyEvent( SfxEventHint( bSaveTo ? SfxEventHintId::SaveToDoc : SfxEventHintId::SaveAsDoc, GlobalEventConfig::GetEventName( bSaveTo ? GlobalEventId::SAVETODOC : GlobalEventId::SAVEASDOC ), m_pData->m_pObjectShell.get() ) ); - std::unique_ptr<SfxAllItemSet> pItemSet(new SfxAllItemSet(SfxGetpApp()->GetPool())); + std::optional<SfxAllItemSet> pItemSet(SfxGetpApp()->GetPool()); pItemSet->Put(SfxStringItem(SID_FILE_NAME, sURL)); if ( bSaveTo ) pItemSet->Put(SfxBoolItem(SID_SAVETO, true)); |