sfx2/source/control/dispatch.cxx | 3 + sfx2/source/control/unoctitm.cxx | 83 --------------------------------------- 2 files changed, 3 insertions(+), 83 deletions(-)
New commits: commit fb471194d04607eb7706f8650f0c92c6ebbbb5b8 Author: Gökay Şatır <gokaysa...@gmail.com> AuthorDate: Mon Mar 25 16:49:08 2024 +0300 Commit: Caolán McNamara <caolan.mcnam...@collabora.com> CommitDate: Wed Apr 3 13:07:37 2024 +0200 Use sdi properties for checking uno commands'a availability. Signed-off-by: Gökay Şatır <gokaysa...@gmail.com> Change-Id: Ie70851756d1a4272876b07fefb876d7e6f8d4d81 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/165287 Reviewed-by: Michael Meeks <michael.me...@collabora.com> Tested-by: Jenkins CollaboraOffice <jenkinscollaboraoff...@gmail.com> (cherry picked from commit 68422af88576a799b22e472c303ed924c360784b) Reviewed-on: https://gerrit.libreoffice.org/c/core/+/165734 Tested-by: Jenkins Reviewed-by: Caolán McNamara <caolan.mcnam...@collabora.com> diff --git a/sfx2/source/control/dispatch.cxx b/sfx2/source/control/dispatch.cxx index ef59094293b9..6ae4d71a6db9 100644 --- a/sfx2/source/control/dispatch.cxx +++ b/sfx2/source/control/dispatch.cxx @@ -1590,6 +1590,9 @@ bool SfxDispatcher::FindServer_(sal_uInt16 nSlot, SfxSlotServer& rServer) bool bReadOnly = ( SfxSlotFilterState::ENABLED_READONLY != nSlotEnableMode && xImp->bReadOnly ); + if (!bReadOnly && comphelper::LibreOfficeKit::isActive()) + bReadOnly = xImp->pFrame && xImp->pFrame->GetViewShell() && xImp->pFrame->GetViewShell()->IsLokReadOnlyView(); + // search through all the shells of the chained dispatchers // from top to bottom sal_uInt16 nFirstShell = 0; diff --git a/sfx2/source/control/unoctitm.cxx b/sfx2/source/control/unoctitm.cxx index 23a370a4240f..333879c24d0f 100644 --- a/sfx2/source/control/unoctitm.cxx +++ b/sfx2/source/control/unoctitm.cxx @@ -520,83 +520,6 @@ void collectUIInformation(const util::URL& rURL, const css::uno::Sequence< css:: } -// Checks if LOK is active and uno command is allowed for the current LOK view. -static bool isCommandAllowedForViewType(const OUString& command) -{ - if (SfxViewShell::IsCurrentLokViewReadOnly()) - { - // This is a sublist of "sUnoCommands". - constexpr OUString allowedCommandList[] = { - u"Copy"_ustr, - u"SelectAll"_ustr, - u"SelectColumn"_ustr, - u"SelectRow"_ustr, - u"EntireRow"_ustr, - u"EntireColumn"_ustr, - u"EntireCell"_ustr, - u"RowColSelCount"_ustr, - u"SpellOnline"_ustr, - u"StatePageNumber"_ustr, - u"StateWordCount"_ustr, - u"StateTableCell"_ustr, - u"SelectionMode"_ustr, - u"PageStatus"_ustr, - u"LayoutStatus"_ustr, - u"ToolbarMode"_ustr, - u"ChangeTheme"_ustr, - u"CopyHyperlinkLocation"_ustr, - u"ExportDirectToPDF"_ustr, - u"ExportToPDF"_ustr, - u"ExportToEPUB"_ustr, - u"CharRightSel"_ustr, - u"CharLeftSel"_ustr, - u"WordRightSel"_ustr, - u"WordLeftSel"_ustr, - u"EndOfParaSel"_ustr, - u"StartOfParaSel"_ustr, - u"GoRight"_ustr, - u"GoLeft"_ustr, - u"GoToNextWord"_ustr, - u"GoToPrevWord"_ustr, - u"GoToNextPara"_ustr, - u"GoToStartOfPara"_ustr, - u"GoUp"_ustr, - u"GoDown"_ustr, - u"GoRightSel"_ustr, - u"GoLeftSel"_ustr, - u"GoUpSel"_ustr, - u"GoDownSel"_ustr, - u"GoLeftToStartOfData"_ustr, - u"GoRightToEndOfData"_ustr, - u"GoToStart"_ustr, - u"GoToEndOfData"_ustr, - u"GoUpToStartOfData"_ustr, - u"GoDownToEndOfData"_ustr, - u"GoLeftToStartOfDataSel"_ustr, - u"GoRightToEndOfDataSel"_ustr, - u"GoUpToStartOfDataSel"_ustr, - u"GoDownToEndOfDataSel"_ustr - }; - - bool allowed = std::find(std::begin(allowedCommandList), std::end(allowedCommandList), command) != std::end(allowedCommandList); - - if (!allowed && SfxViewShell::Current() && SfxViewShell::Current()->IsAllowChangeComments()) - { - constexpr OUString allowedCommentCommandList[] = { - u"InsertAnnotation"_ustr, - u"DeleteComment"_ustr, - u"DeleteAnnotation"_ustr, - u"EditAnnotation"_ustr - }; - allowed = std::find(std::begin(allowedCommentCommandList), std::end(allowedCommentCommandList), command) != std::end(allowedCommentCommandList); - } - - return allowed; - } - - return true; -} - void SfxDispatchController_Impl::dispatch( const css::util::URL& aURL, const css::uno::Sequence< css::beans::PropertyValue >& aArgs, const css::uno::Reference< css::frame::XDispatchResultListener >& rListener ) @@ -623,12 +546,6 @@ void SfxDispatchController_Impl::dispatch( const css::util::URL& aURL, return; } - - if (aURL.Protocol == ".uno:" && !isCommandAllowedForViewType(aURL.Path)) - { - return; - } - if ( !(pDispatch && (