sfx2/source/control/dispatch.cxx | 56 ++++++++++++++++++++------------------- 1 file changed, 29 insertions(+), 27 deletions(-)
New commits: commit 082cdd16289f06db0de95bd25430d46d31d65077 Author: Mike Kaganski <[email protected]> AuthorDate: Tue Jun 17 19:06:37 2025 +0500 Commit: Miklos Vajna <[email protected]> CommitDate: Fri Jun 20 08:53:09 2025 +0200 Restructure SfxDispatcher::FindServer_ * Move checking the shell kind (server, container) out of loop. * Move checking if slot matches the shell kind before checking if it can be used in read-only mode. The reasoning is that if mode isn't read-only, this slot will not be picked, and the search continues. This shouldn't be different in read-only mode, even if the slot that should be skipped happens to be not suitable for current mode. * IsCommandAllowedInLokReadOnlyViewMode checks are now only done in "slot isn't read-only" case: they make no sense for read-only slots. Change-Id: I2ad3935e8105ba7df26c823f47fea34637de7624 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/186622 Reviewed-by: Mike Kaganski <[email protected]> Tested-by: Jenkins Reviewed-on: https://gerrit.libreoffice.org/c/core/+/186684 Reviewed-by: Miklos Vajna <[email protected]> Tested-by: Jenkins CollaboraOffice <[email protected]> diff --git a/sfx2/source/control/dispatch.cxx b/sfx2/source/control/dispatch.cxx index 9b3242a5d5a2..adf72165bd92 100644 --- a/sfx2/source/control/dispatch.cxx +++ b/sfx2/source/control/dispatch.cxx @@ -1634,6 +1634,21 @@ bool SfxDispatcher::FindServer_(sal_uInt16 nSlot, SfxSlotServer& rServer) bCheckForCommentCommands = true; } + const bool bIsInPlace = xImp->pFrame && xImp->pFrame->GetObjectShell()->IsInPlaceActive(); + // Shell belongs to Server? + // AppDispatcher or IPFrame-Dispatcher + bool bIsServerShell = !xImp->pFrame || bIsInPlace; + // 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 Container? + // AppDispatcher or no IPFrameDispatcher + const bool bIsContainerShell = !bIsInPlace; + // search through all the shells of the chained dispatchers // from top to bottom sal_uInt16 nFirstShell = 0; @@ -1648,11 +1663,13 @@ bool SfxDispatcher::FindServer_(sal_uInt16 nSlot, SfxSlotServer& rServer) if (!pSlot) continue; - bool bLocalReadOnly = bReadOnly; + // Slot belongs to Container? + bool bIsContainerSlot = pSlot->IsMode(SfxSlotMode::CONTAINER); - // This check can be true only if Lokit is active and view is readonly. - if (bCheckForCommentCommands) - bLocalReadOnly = !IsCommandAllowedInLokReadOnlyViewMode(pSlot->GetCommand()); + // Shell and Slot match + if ( !( ( bIsContainerSlot && bIsContainerShell ) || + ( !bIsContainerSlot && bIsServerShell ) ) ) + continue; if ( pSlot->nDisableFlags != SfxDisableFlags::NONE && ( static_cast<int>(pSlot->nDisableFlags) & static_cast<int>(pObjShell->GetDisableFlags()) ) != 0 ) @@ -1661,33 +1678,18 @@ bool SfxDispatcher::FindServer_(sal_uInt16 nSlot, SfxSlotServer& rServer) if (!(pSlot->nFlags & SfxSlotMode::VIEWERAPP) && isViewerAppMode) return false; - if (!(pSlot->nFlags & SfxSlotMode::READONLYDOC) && bLocalReadOnly) - return false; - - // Slot belongs to Container? - bool bIsContainerSlot = pSlot->IsMode(SfxSlotMode::CONTAINER); - bool bIsInPlace = xImp->pFrame && xImp->pFrame->GetObjectShell()->IsInPlaceActive(); + if (!(pSlot->nFlags & SfxSlotMode::READONLYDOC) && bReadOnly) + { + bool bAllowThis = false; - // Shell belongs to Server? - // AppDispatcher or IPFrame-Dispatcher - bool bIsServerShell = !xImp->pFrame || bIsInPlace; + // This check can be true only if Lokit is active and view is readonly. + if (bCheckForCommentCommands) + bAllowThis = IsCommandAllowedInLokReadOnlyViewMode(pSlot->GetCommand()); - // 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(); + if (!bAllowThis) + return false; } - // 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;
