diff options
24 files changed, 46 insertions, 40 deletions
diff --git a/include/svl/itemset.hxx b/include/svl/itemset.hxx index 41771f106c48..f3470098d42f 100644 --- a/include/svl/itemset.hxx +++ b/include/svl/itemset.hxx @@ -61,8 +61,14 @@ public: const SfxPoolItemHolder& operator=(const SfxPoolItemHolder&); bool operator==(const SfxPoolItemHolder &) const; + SfxItemPool& getPool() const { assert(!isDeleted() && "Destructed instance used (!)"); return *m_pPool; } const SfxPoolItem* getItem() const { assert(!isDeleted() && "Destructed instance used (!)"); return m_pItem; } + + bool operator!() const { return nullptr == m_pItem; } + explicit operator bool() const { return nullptr != m_pItem; } + bool is() const { return nullptr != m_pItem; } + sal_uInt16 Which() const { if(nullptr != m_pItem) return m_pItem->Which(); return 0; } }; diff --git a/sc/source/ui/dbgui/PivotLayoutDialog.cxx b/sc/source/ui/dbgui/PivotLayoutDialog.cxx index de1f6b3b6f8e..51b0eda00b2f 100644 --- a/sc/source/ui/dbgui/PivotLayoutDialog.cxx +++ b/sc/source/ui/dbgui/PivotLayoutDialog.cxx @@ -487,7 +487,7 @@ void ScPivotLayoutDialog::ApplyChanges() const SfxPoolItemHolder aResult(pDispatcher->ExecuteList(SID_PIVOT_TABLE, nCallMode, { &aPivotItem })); - if (nullptr != aResult.getItem()) + if (aResult) { // existing pivot table might have moved to a new range or a new sheet if ( pOldDPObj != nullptr ) diff --git a/sc/source/ui/view/viewfun2.cxx b/sc/source/ui/view/viewfun2.cxx index 224bb722e0dd..5cb800fe8ce1 100644 --- a/sc/source/ui/view/viewfun2.cxx +++ b/sc/source/ui/view/viewfun2.cxx @@ -2885,7 +2885,8 @@ void ScViewFunc::MoveTable( const SfxPoolItemHolder aResult(GetViewData().GetDispatcher().ExecuteList( SID_OPENDOC, SfxCallMode::API|SfxCallMode::SYNCHRON, { &aItem, &aTarget })); - if (nullptr != aResult.getItem()) + + if (aResult) { if ( auto pObjectItem = dynamic_cast<const SfxObjectItem*>(aResult.getItem()) ) pDestShell = dynamic_cast<ScDocShell*>( pObjectItem->GetShell() ); diff --git a/sc/source/ui/view/viewfun4.cxx b/sc/source/ui/view/viewfun4.cxx index d75541b30234..48ac1a97cf02 100644 --- a/sc/source/ui/view/viewfun4.cxx +++ b/sc/source/ui/view/viewfun4.cxx @@ -590,7 +590,7 @@ bool ScViewFunc::PasteFile( const Point& rPos, const OUString& rFile, bool bLink const SfxPoolItemHolder aResult(GetViewData().GetDispatcher().ExecuteList( SID_INSERT_AVMEDIA, SfxCallMode::SYNCHRON, { &aMediaURLItem })); - return (nullptr != aResult.getItem()); + return aResult.is(); } #endif @@ -621,7 +621,7 @@ bool ScViewFunc::PasteFile( const Point& rPos, const OUString& rFile, bool bLink const SfxPoolItemHolder aResult(rDispatcher.ExecuteList(SID_OPENDOC, SfxCallMode::ASYNCHRON, { &aFileNameItem, &aFilterItem, &aTargetItem})); - return (nullptr != aResult.getItem()); + return aResult.is(); } } diff --git a/sd/source/ui/app/sdmod1.cxx b/sd/source/ui/app/sdmod1.cxx index 0d9e82f27802..d6fc5c406efb 100644 --- a/sd/source/ui/app/sdmod1.cxx +++ b/sd/source/ui/app/sdmod1.cxx @@ -323,7 +323,7 @@ void SdModule::GetState(SfxItemSet& rItemSet) if (rItemSet.GetItemState(SID_OPENDOC) != SfxItemState::UNKNOWN) { const SfxPoolItemHolder aItem(SfxGetpApp()->GetSlotState(SID_OPENDOC, SfxGetpApp()->GetInterface())); - if (nullptr != aItem.getItem()) + if (aItem) rItemSet.Put(*aItem.getItem()); } @@ -331,7 +331,7 @@ void SdModule::GetState(SfxItemSet& rItemSet) if (rItemSet.GetItemState(SID_OPENHYPERLINK) != SfxItemState::UNKNOWN) { const SfxPoolItemHolder aItem(SfxGetpApp()->GetSlotState(SID_OPENHYPERLINK, SfxGetpApp()->GetInterface())); - if (nullptr != aItem.getItem()) + if (aItem) rItemSet.Put(*aItem.getItem()); } diff --git a/sd/source/ui/unoidl/unomodule.cxx b/sd/source/ui/unoidl/unomodule.cxx index 5ee3cab40d7e..65642ece9c04 100644 --- a/sd/source/ui/unoidl/unomodule.cxx +++ b/sd/source/ui/unoidl/unomodule.cxx @@ -49,7 +49,7 @@ void SAL_CALL SdUnoModule::dispatchWithNotification( const util::URL& aURL, cons { SfxRequest aReq( pSlot, aArgs, SfxCallMode::SYNCHRON, SD_MOD()->GetPool() ); const SfxPoolItemHolder aResult(SD_MOD()->ExecuteSlot(aReq)); - if (nullptr != aResult.getItem()) + if (aResult) aState = frame::DispatchResultState::SUCCESS; else aState = frame::DispatchResultState::FAILURE; diff --git a/sfx2/source/appl/appopen.cxx b/sfx2/source/appl/appopen.cxx index 4e1b06e52268..b19e0a36fa63 100644 --- a/sfx2/source/appl/appopen.cxx +++ b/sfx2/source/appl/appopen.cxx @@ -534,7 +534,7 @@ void SfxApplication::NewDocExec_Impl( SfxRequest& rReq ) else { SfxCallMode eMode = SfxCallMode::SYNCHRON; - SfxPoolItemHolder aRet; + SfxPoolItemHolder aResult; SfxStringItem aReferer( SID_REFERER, "private:user" ); SfxStringItem aTarget( SID_TARGETNAME, "_default" ); if ( !aTemplateFileName.isEmpty() ) @@ -544,18 +544,18 @@ void SfxApplication::NewDocExec_Impl( SfxRequest& rReq ) SfxStringItem aName( SID_FILE_NAME, aObj.GetMainURL( INetURLObject::DecodeMechanism::NONE ) ); SfxStringItem aTemplName( SID_TEMPLATE_NAME, aTemplateName ); SfxStringItem aTemplRegionName( SID_TEMPLATE_REGIONNAME, aTemplateRegion ); - aRet = GetDispatcher_Impl()->ExecuteList(SID_OPENDOC, eMode, + aResult = GetDispatcher_Impl()->ExecuteList(SID_OPENDOC, eMode, {&aName, &aTarget, &aReferer, &aTemplName, &aTemplRegionName}); } else { SfxStringItem aName( SID_FILE_NAME, "private:factory" ); - aRet = GetDispatcher_Impl()->ExecuteList(SID_OPENDOC, eMode, + aResult = GetDispatcher_Impl()->ExecuteList(SID_OPENDOC, eMode, { &aName, &aTarget, &aReferer } ); } - if ( nullptr != aRet.getItem() ) - rReq.SetReturnValue( *aRet.getItem() ); + if (aResult) + rReq.SetReturnValue( *aResult.getItem() ); } } diff --git a/sfx2/source/control/bindings.cxx b/sfx2/source/control/bindings.cxx index 47ddda28136f..40e44ff8b5a3 100644 --- a/sfx2/source/control/bindings.cxx +++ b/sfx2/source/control/bindings.cxx @@ -869,7 +869,7 @@ bool SfxBindings::Execute( sal_uInt16 nId, const SfxPoolItem** ppItems, SfxCallM return false; const SfxPoolItemHolder aRet(Execute_Impl(nId, ppItems, 0, nCallMode, nullptr)); - return (nullptr != aRet.getItem()); + return aRet.is(); } SfxPoolItemHolder SfxBindings::Execute_Impl( sal_uInt16 nId, const SfxPoolItem** ppItems, sal_uInt16 nModi, SfxCallMode nCallMode, @@ -963,7 +963,7 @@ SfxPoolItemHolder SfxBindings::Execute_Impl( sal_uInt16 nId, const SfxPoolItem** const SfxPoolItemHolder& rRetval(aReq.GetReturnValue()); - if (nullptr == rRetval.getItem()) + if (!rRetval) return SfxPoolItemHolder(rPool, new SfxVoidItem( nId ), true); return rRetval; @@ -1596,10 +1596,10 @@ SfxItemState SfxBindings::QueryState( sal_uInt16 nSlot, std::unique_ptr<SfxPoolI if (SfxItemState::SET == eState) { DBG_ASSERT( aResult.getItem(), "SfxItemState::SET but no item!" ); - if ( nullptr != aResult.getItem() ) + if (aResult) rpState.reset(aResult.getItem()->Clone()); } - else if (SfxItemState::DEFAULT == eState && nullptr != aResult.getItem()) + else if (SfxItemState::DEFAULT == eState && aResult) { rpState.reset(aResult.getItem()->Clone()); } diff --git a/sfx2/source/control/dispatch.cxx b/sfx2/source/control/dispatch.cxx index fe7271677fbf..31540b89a3ea 100644 --- a/sfx2/source/control/dispatch.cxx +++ b/sfx2/source/control/dispatch.cxx @@ -1977,7 +1977,7 @@ SfxItemState SfxDispatcher::QueryState( sal_uInt16 nSlot, SfxPoolItemHolder& rSt if ( GetShellAndSlot_Impl( nSlot, &pShell, &pSlot, false, true ) ) { rState = pShell->GetSlotState(nSlot); - if ( nullptr == rState.getItem() ) + if (!rState) return SfxItemState::DISABLED; else return SfxItemState::DEFAULT; @@ -1993,7 +1993,7 @@ SfxItemState SfxDispatcher::QueryState( sal_uInt16 nSID, css::uno::Any& rAny ) if ( GetShellAndSlot_Impl( nSID, &pShell, &pSlot, false, true ) ) { SfxPoolItemHolder aItem(pShell->GetSlotState(nSID)); - if (nullptr == aItem.getItem()) + if (!aItem) return SfxItemState::DISABLED; else { diff --git a/sfx2/source/control/request.cxx b/sfx2/source/control/request.cxx index c838ddfdfc77..c44ebef2eb55 100644 --- a/sfx2/source/control/request.cxx +++ b/sfx2/source/control/request.cxx @@ -418,7 +418,7 @@ void SfxRequest::RemoveItem( sal_uInt16 nID ) void SfxRequest::SetReturnValue(const SfxPoolItem &rItem) { - DBG_ASSERT(nullptr == pImpl->aRetVal.getItem(), "Set Return value multiple times?"); + DBG_ASSERT(!pImpl, "Set Return value multiple times?"); DBG_ASSERT(nullptr != pImpl->pPool, "Missing SfxItemPool (!)"); if (nullptr != pImpl->pPool) pImpl->aRetVal = SfxPoolItemHolder(*pImpl->pPool, &rItem); diff --git a/sfx2/source/control/unoctitm.cxx b/sfx2/source/control/unoctitm.cxx index c37544b2ecbd..d9eb3ea78745 100644 --- a/sfx2/source/control/unoctitm.cxx +++ b/sfx2/source/control/unoctitm.cxx @@ -666,7 +666,7 @@ void SfxDispatchController_Impl::dispatch( const css::util::URL& aURL, { // execute with arguments - call directly aItem = pDispatcher->Execute(GetId(), nCall, &*xSet, &aInternalSet, nModifier); - if (nullptr != aItem.getItem()) + if (aItem) { if (const SfxBoolItem* pBoolItem = dynamic_cast<const SfxBoolItem*>(aItem.getItem())) bSuccess = pBoolItem->GetValue(); @@ -687,7 +687,7 @@ void SfxDispatchController_Impl::dispatch( const css::util::URL& aURL, aReq.SetInternalArgs_Impl(aInternalSet); pDispatcher->GetBindings()->Execute_Impl( aReq, pSlot, pShell ); aItem = aReq.GetReturnValue(); - bSuccess = aReq.IsDone() || nullptr != aItem.getItem(); + bSuccess = aReq.IsDone() || aItem; } } else @@ -719,7 +719,7 @@ void SfxDispatchController_Impl::dispatch( const css::util::URL& aURL, } } - bSuccess = (nullptr != aItem.getItem()); + bSuccess = aItem.is(); } } @@ -733,7 +733,7 @@ void SfxDispatchController_Impl::dispatch( const css::util::URL& aURL, aEvent.State = css::frame::DispatchResultState::FAILURE; aEvent.Source = static_cast<css::frame::XDispatch*>(pDispatch); - if ( bSuccess && nullptr != aItem.getItem() && !aItem.getItem()->isVoidItem() ) + if ( bSuccess && aItem && !aItem.getItem()->isVoidItem() ) { sal_uInt16 nSubId( 0 ); if ( eMapUnit == MapUnit::MapTwip ) diff --git a/sfx2/source/dialog/mgetempl.cxx b/sfx2/source/dialog/mgetempl.cxx index a9b62452591e..977c5e8a93dd 100644 --- a/sfx2/source/dialog/mgetempl.cxx +++ b/sfx2/source/dialog/mgetempl.cxx @@ -373,8 +373,7 @@ bool SfxManageStyleSheetPage::Execute_Impl( nId, SfxCallMode::SYNCHRON | SfxCallMode::RECORD, pItems )); - return nullptr != aResult.getItem(); - + return aResult.is(); } IMPL_LINK(SfxManageStyleSheetPage, GetFocusHdl, weld::Widget&, rControl, void) diff --git a/sfx2/source/dialog/templdlg.cxx b/sfx2/source/dialog/templdlg.cxx index 1a55cb24c7fa..197e55b40bfb 100644 --- a/sfx2/source/dialog/templdlg.cxx +++ b/sfx2/source/dialog/templdlg.cxx @@ -519,7 +519,7 @@ bool SfxCommonTemplateDialog_Impl::Execute_Impl( // Dialog can be destroyed while in Execute() because started // subdialogs are not modal to it (#i97888#). - if ( nullptr == aResult.getItem() || aDeleted ) + if (!aResult || aDeleted ) return false; if ((nId == SID_STYLE_NEW || SID_STYLE_EDIT == nId) diff --git a/sfx2/source/doc/objserv.cxx b/sfx2/source/doc/objserv.cxx index 8340e4808fb8..5de217fd6a6d 100644 --- a/sfx2/source/doc/objserv.cxx +++ b/sfx2/source/doc/objserv.cxx @@ -667,7 +667,7 @@ void SfxObjectShell::ExecFile_Impl(SfxRequest &rReq) SfxDocumentInfoItem aDocInfoItem( aURL, getDocProperties(), aCmisProperties, IsUseUserData(), IsUseThumbnailSave() ); const SfxPoolItemHolder aSlotState(GetSlotState(SID_DOCTEMPLATE)); - if (nullptr == aSlotState.getItem()) + if (!aSlotState) // templates not supported aDocInfoItem.SetTemplate(false); diff --git a/sfx2/source/doc/objxtor.cxx b/sfx2/source/doc/objxtor.cxx index 11b38ced10a0..03a12f68ab8f 100644 --- a/sfx2/source/doc/objxtor.cxx +++ b/sfx2/source/doc/objxtor.cxx @@ -589,7 +589,7 @@ bool SfxObjectShell::PrepareClose aPoolItem = pFrame->GetBindings().ExecuteSynchron( SID_SAVEDOC, ppArgs ); } - if ( nullptr == aPoolItem.getItem() || aPoolItem.getItem()->isVoidItem() ) + if (!aPoolItem || aPoolItem.getItem()->isVoidItem() ) return false; if ( auto pBoolItem = dynamic_cast< const SfxBoolItem *>( aPoolItem.getItem() ) ) if ( !pBoolItem->GetValue() ) diff --git a/sfx2/source/view/frmload.cxx b/sfx2/source/view/frmload.cxx index 7f58a397ccd3..1fb671132afc 100644 --- a/sfx2/source/view/frmload.cxx +++ b/sfx2/source/view/frmload.cxx @@ -303,7 +303,7 @@ OUString SfxFrameLoader_Impl::impl_askForFilter_nothrow( const Reference< XInter bool lcl_getDispatchResult(const SfxPoolItemHolder& rResult) { - if (nullptr == rResult.getItem()) + if (!rResult) return false; // default must be set to true, because some return values diff --git a/sfx2/source/view/viewfrm.cxx b/sfx2/source/view/viewfrm.cxx index e82a4b0ed3d2..4530bdef2091 100644 --- a/sfx2/source/view/viewfrm.cxx +++ b/sfx2/source/view/viewfrm.cxx @@ -1012,7 +1012,7 @@ void SfxViewFrame::ExecHistory_Impl( SfxRequest &rReq ) { // The SW has its own undo in the View const SfxPoolItemHolder& rResult(GetViewShell()->ExecuteSlot(rReq)); - if (nullptr != rResult.getItem()) + if (rResult) bOK = static_cast<const SfxBoolItem*>(rResult.getItem())->GetValue(); } @@ -2969,7 +2969,7 @@ void SfxViewFrame::AddDispatchMacroToBasic_Impl( const OUString& sMacro ) aReq.AppendItem( SfxBoolItem(SID_RECORDMACRO,true) ); const SfxPoolItemHolder& rResult(SfxGetpApp()->ExecuteSlot(aReq)); OUString aScriptURL; - if (nullptr != rResult.getItem()) + if (rResult) aScriptURL = static_cast<const SfxStringItem*>(rResult.getItem())->GetValue(); if ( !aScriptURL.isEmpty() ) { diff --git a/sw/source/ui/fldui/fldtdlg.cxx b/sw/source/ui/fldui/fldtdlg.cxx index 8c20586167e7..5691935136e3 100644 --- a/sw/source/ui/fldui/fldtdlg.cxx +++ b/sw/source/ui/fldui/fldtdlg.cxx @@ -116,7 +116,7 @@ void SwFieldDlg::Close() const SfxPoolItemHolder aResult(m_pBindings->GetDispatcher()-> Execute(m_bDataBaseMode ? FN_INSERT_FIELD_DATA_ONLY : FN_INSERT_FIELD, SfxCallMode::SYNCHRON|SfxCallMode::RECORD)); - if (nullptr == aResult.getItem()) + if (!aResult) { // If Execute action did fail for whatever reason, this means that request // to close did fail or wasn't delivered to SwTextShell::ExecField(). diff --git a/sw/source/uibase/misc/redlndlg.cxx b/sw/source/uibase/misc/redlndlg.cxx index 0461276140e5..84fc6520546f 100644 --- a/sw/source/uibase/misc/redlndlg.cxx +++ b/sw/source/uibase/misc/redlndlg.cxx @@ -1158,7 +1158,7 @@ IMPL_LINK_NOARG(SwRedlineAcceptDlg, UndoHdl, SvxTPView*, void) pView->GetViewFrame().GetDispatcher()-> Execute(SID_UNDO, SfxCallMode::SYNCHRON); const SfxPoolItemHolder aResult(pView->GetSlotState(SID_UNDO)); - m_pTPView->EnableUndo(nullptr != aResult.getItem()); + m_pTPView->EnableUndo(aResult.is()); } Activate(); diff --git a/sw/source/uibase/shells/annotsh.cxx b/sw/source/uibase/shells/annotsh.cxx index 5c9ed82b4114..d3a2735068a6 100644 --- a/sw/source/uibase/shells/annotsh.cxx +++ b/sw/source/uibase/shells/annotsh.cxx @@ -801,7 +801,7 @@ void SwAnnotationShell::GetState(SfxItemSet& rSet) case SID_AUTOSPELL_CHECK: { const SfxPoolItemHolder aResult(m_rView.GetSlotState(nWhich)); - if (nullptr != aResult.getItem()) + if (aResult) rSet.Put(SfxBoolItem(nWhich, static_cast<const SfxBoolItem*>(aResult.getItem())->GetValue())); else rSet.DisableItem( nWhich ); diff --git a/sw/source/uibase/shells/drwtxtex.cxx b/sw/source/uibase/shells/drwtxtex.cxx index 4d8dd6304e92..63bdd8dbf1c4 100644 --- a/sw/source/uibase/shells/drwtxtex.cxx +++ b/sw/source/uibase/shells/drwtxtex.cxx @@ -1001,7 +1001,7 @@ void SwDrawTextShell::GetDrawTextCtrlState(SfxItemSet& rSet) case SID_AUTOSPELL_CHECK: { const SfxPoolItemHolder aResult(m_rView.GetSlotState(nWhich)); - if (nullptr != aResult.getItem()) + if (aResult) rSet.Put(SfxBoolItem(nWhich, static_cast<const SfxBoolItem*>(aResult.getItem())->GetValue())); else rSet.DisableItem( nWhich ); diff --git a/sw/source/uibase/uiview/viewstat.cxx b/sw/source/uibase/uiview/viewstat.cxx index 3c624274f4c5..2bcb6844ac16 100644 --- a/sw/source/uibase/uiview/viewstat.cxx +++ b/sw/source/uibase/uiview/viewstat.cxx @@ -263,7 +263,7 @@ void SwView::GetState(SfxItemSet &rSet) SelectShell(); const SfxPoolItemHolder aResult(m_pShell->GetSlotState(SID_UNDO)); - if(nullptr != aResult.getItem()) + if(aResult) rSet.Put(*aResult.getItem()); else rSet.DisableItem(nWhich); @@ -573,7 +573,7 @@ void SwView::GetState(SfxItemSet &rSet) SfxPoolItemHolder aResult; if(nAlias) GetViewFrame().GetDispatcher()->QueryState(nAlias, aResult); - if(nullptr != aResult.getItem()) + if(aResult) { if (!(m_nSelectionType & SelectionType::DrawObject)) { diff --git a/sw/source/uibase/uno/unomodule.cxx b/sw/source/uibase/uno/unomodule.cxx index 478502c4fe5d..f35ebe417b87 100644 --- a/sw/source/uibase/uno/unomodule.cxx +++ b/sw/source/uibase/uno/unomodule.cxx @@ -69,7 +69,7 @@ void SAL_CALL SwUnoModule::dispatchWithNotification( const util::URL& aURL, cons aReq.SetInternalArgs_Impl(aInternalSet); const SfxPoolItemHolder& rResult(SW_MOD()->ExecuteSlot(aReq)); - if (nullptr != rResult.getItem()) + if (rResult) aState = frame::DispatchResultState::SUCCESS; else aState = frame::DispatchResultState::FAILURE; diff --git a/sw/source/uibase/uno/unotxvw.cxx b/sw/source/uibase/uno/unotxvw.cxx index 43f2c7a62c82..a859e4ec5657 100644 --- a/sw/source/uibase/uno/unotxvw.cxx +++ b/sw/source/uibase/uno/unotxvw.cxx @@ -1231,7 +1231,7 @@ sal_Bool SwXTextViewCursor::screenDown() SfxRequest aReq(FN_PAGEDOWN, SfxCallMode::SLOT, m_pView->GetPool()); m_pView->Execute(aReq); const SfxPoolItemHolder& rResult(aReq.GetReturnValue()); - bRet = nullptr != rResult.getItem() && static_cast<const SfxBoolItem*>(rResult.getItem())->GetValue(); + bRet = rResult && static_cast<const SfxBoolItem*>(rResult.getItem())->GetValue(); return bRet; } @@ -1246,7 +1246,7 @@ sal_Bool SwXTextViewCursor::screenUp() SfxRequest aReq(FN_PAGEUP, SfxCallMode::SLOT, m_pView->GetPool()); m_pView->Execute(aReq); const SfxPoolItemHolder& rResult(aReq.GetReturnValue()); - bRet = nullptr != rResult.getItem() && static_cast<const SfxBoolItem*>(rResult.getItem())->GetValue(); + bRet = rResult && static_cast<const SfxBoolItem*>(rResult.getItem())->GetValue(); return bRet; } |