sfx2/source/control/dispatch.cxx | 62 ++++++++++++++++++--------------------- 1 file changed, 29 insertions(+), 33 deletions(-)
New commits: commit 56398dbeb68634e6bf0fe836cb122219104794c9 Author: Mike Kaganski <mike.kagan...@collabora.com> AuthorDate: Tue Jun 17 18:01:30 2025 +0500 Commit: Miklos Vajna <vmik...@collabora.com> CommitDate: Thu Jun 19 13:05:28 2025 +0200 Flatten SfxDispatcher::FindServer_ The repeated checks of pSlot can be replaces by one initial check. Change-Id: I8183e3cf6feea5dcd15c7c47bce6f701aaf69d7b Reviewed-on: https://gerrit.libreoffice.org/c/core/+/186613 Reviewed-by: Mike Kaganski <mike.kagan...@collabora.com> Tested-by: Jenkins Reviewed-on: https://gerrit.libreoffice.org/c/core/+/186682 Reviewed-by: Miklos Vajna <vmik...@collabora.com> Tested-by: Jenkins CollaboraOffice <jenkinscollaboraoff...@gmail.com> diff --git a/sfx2/source/control/dispatch.cxx b/sfx2/source/control/dispatch.cxx index d3b36239aaa9..8bd78428bc32 100644 --- a/sfx2/source/control/dispatch.cxx +++ b/sfx2/source/control/dispatch.cxx @@ -1645,54 +1645,50 @@ bool SfxDispatcher::FindServer_(sal_uInt16 nSlot, SfxSlotServer& rServer) SfxInterface *pIFace = pObjShell->GetInterface(); const SfxSlot *pSlot = pIFace->GetSlot(nSlot); + if (!pSlot) + continue; // This check can be true only if Lokit is active and view is readonly. - if (pSlot && bCheckForCommentCommands) + if (bCheckForCommentCommands) bReadOnly = !IsCommandAllowedInLokReadOnlyViewMode(pSlot->GetCommand()); - if ( pSlot && pSlot->nDisableFlags != SfxDisableFlags::NONE && + if ( pSlot->nDisableFlags != SfxDisableFlags::NONE && ( static_cast<int>(pSlot->nDisableFlags) & static_cast<int>(pObjShell->GetDisableFlags()) ) != 0 ) return false; - if (pSlot && !(pSlot->nFlags & SfxSlotMode::VIEWERAPP) && isViewerAppMode) + if (!(pSlot->nFlags & SfxSlotMode::VIEWERAPP) && isViewerAppMode) return false; - if ( pSlot && !( pSlot->nFlags & SfxSlotMode::READONLYDOC ) && bReadOnly ) + if ( !( pSlot->nFlags & SfxSlotMode::READONLYDOC ) && bReadOnly ) return false; - if ( pSlot ) - { - // Slot belongs to Container? - bool bIsContainerSlot = pSlot->IsMode(SfxSlotMode::CONTAINER); - bool bIsInPlace = xImp->pFrame && xImp->pFrame->GetObjectShell()->IsInPlaceActive(); - - // Shell belongs to Server? - // AppDispatcher or IPFrame-Dispatcher - bool bIsServerShell = !xImp->pFrame || bIsInPlace; + // Slot belongs to Container? + bool bIsContainerSlot = pSlot->IsMode(SfxSlotMode::CONTAINER); + bool bIsInPlace = xImp->pFrame && xImp->pFrame->GetObjectShell()->IsInPlaceActive(); - // Of course ShellServer-Slots are also executable even when it is - // executed on a container dispatcher without an IPClient. - if ( !bIsServerShell ) - { - SfxViewShell *pViewSh = xImp->pFrame->GetViewShell(); - bIsServerShell = !pViewSh || !pViewSh->GetUIActiveClient(); - } + // Shell belongs to Server? + // AppDispatcher or IPFrame-Dispatcher + bool bIsServerShell = !xImp->pFrame || bIsInPlace; - // Shell belongs to Container? - // AppDispatcher or no IPFrameDispatcher - bool bIsContainerShell = !xImp->pFrame || !bIsInPlace; - // Shell and Slot match - if ( !( ( bIsContainerSlot && bIsContainerShell ) || - ( !bIsContainerSlot && bIsServerShell ) ) ) - pSlot = nullptr; - } - - if ( pSlot ) + // Of course ShellServer-Slots are also executable even when it is + // executed on a container dispatcher without an IPClient. + if ( !bIsServerShell ) { - rServer.SetSlot(pSlot); - rServer.SetShellLevel(i); - return true; + SfxViewShell *pViewSh = xImp->pFrame->GetViewShell(); + bIsServerShell = !pViewSh || !pViewSh->GetUIActiveClient(); } + + // Shell belongs to Container? + // AppDispatcher or no IPFrameDispatcher + bool bIsContainerShell = !xImp->pFrame || !bIsInPlace; + // Shell and Slot match + if ( !( ( bIsContainerSlot && bIsContainerShell ) || + ( !bIsContainerSlot && bIsServerShell ) ) ) + continue; + + rServer.SetSlot(pSlot); + rServer.SetShellLevel(i); + return true; } return false;