diff options
Diffstat (limited to 'sfx2')
-rw-r--r-- | sfx2/source/appl/appopen.cxx | 7 | ||||
-rw-r--r-- | sfx2/source/control/bindings.cxx | 8 |
2 files changed, 6 insertions, 9 deletions
diff --git a/sfx2/source/appl/appopen.cxx b/sfx2/source/appl/appopen.cxx index 1c16308dbd4e..c54b3e58580b 100644 --- a/sfx2/source/appl/appopen.cxx +++ b/sfx2/source/appl/appopen.cxx @@ -942,11 +942,11 @@ void SfxApplication::OpenDocExec_Impl( SfxRequest& rReq ) pTargetFrame = &SfxViewFrame::Current()->GetFrame(); // check if caller has set a callback - const SfxLinkItem* pLinkItem = rReq.GetArg<SfxLinkItem>(SID_DONELINK); + std::unique_ptr<SfxLinkItem> pLinkItem; // remove from Itemset, because it confuses the parameter transformation - if ( pLinkItem ) - pLinkItem = static_cast<SfxLinkItem*>( pLinkItem->Clone() ); + if (auto pParamLinkItem = rReq.GetArg<SfxLinkItem>(SID_DONELINK)) + pLinkItem.reset( static_cast<SfxLinkItem*>( pParamLinkItem->Clone() ) ); rReq.RemoveItem( SID_DONELINK ); @@ -1111,7 +1111,6 @@ void SfxApplication::OpenDocExec_Impl( SfxRequest& rReq ) { pLinkItem->GetValue().Call(pRetValue); } - delete pLinkItem; } } diff --git a/sfx2/source/control/bindings.cxx b/sfx2/source/control/bindings.cxx index 2b2409be3369..29d49129f076 100644 --- a/sfx2/source/control/bindings.cxx +++ b/sfx2/source/control/bindings.cxx @@ -1018,20 +1018,18 @@ void SfxBindings::Execute_Impl( SfxRequest& aReq, const SfxSlot* pSlot, SfxShell { // we can toggle Bools bool bOldValue = pOldBoolItem->GetValue(); - SfxBoolItem *pNewItem = static_cast<SfxBoolItem*>(pOldItem->Clone()); + std::unique_ptr<SfxBoolItem> pNewItem(static_cast<SfxBoolItem*>(pOldItem->Clone())); pNewItem->SetValue( !bOldValue ); aReq.AppendItem( *pNewItem ); - delete pNewItem; } else if ( dynamic_cast< const SfxEnumItemInterface *>( pOldItem ) != nullptr && static_cast<const SfxEnumItemInterface *>(pOldItem)->HasBoolValue()) { // and Enums with Bool-Interface - SfxEnumItemInterface *pNewItem = - static_cast<SfxEnumItemInterface*>(pOldItem->Clone()); + std::unique_ptr<SfxEnumItemInterface> pNewItem( + static_cast<SfxEnumItemInterface*>(pOldItem->Clone())); pNewItem->SetBoolValue(!static_cast<const SfxEnumItemInterface *>(pOldItem)->GetBoolValue()); aReq.AppendItem( *pNewItem ); - delete pNewItem; } else { OSL_FAIL( "Toggle only for Enums and Bools allowed" ); |