summaryrefslogtreecommitdiff
path: root/sfx2/source/control
diff options
context:
space:
mode:
authorGökay Şatır <gokaysatir@gmail.com>2024-02-22 13:54:06 +0300
committerMiklos Vajna <vmiklos@collabora.com>2024-03-21 16:32:09 +0100
commit1de1c47471278db2344c986e9d597d6a05e559e9 (patch)
tree14494bf30d8bac21fe058b98030c69df2db688c3 /sfx2/source/control
parent9adcf67c9b164d019eebe45279bcaa91b0ce471a (diff)
Moving parts of readonly checks from model to view.
Summary for what's done with this commit: init.cxx * Add guards for modify commands. viewsh: * Add "IsCurrentLokViewReadOnly" for ease of use. unocitm: * Add guard for modify comamnds dispatch.cxx * Implement readonlyview. objmisc: * Modify IsReadOnlyUI check for LokReadOnly view. svx.sdi: * Disable TableChangeCurrentBorderPosition command for readOnly views. sw-editwin: * Treat mouse moves as readonly when the view is LokReadOnly. gridwin: * For autofilter. impedit2, inputhdl: * For text input. svdedtc: * For sdr object dragging. Change-Id: I71fc353976256bce22042bbb6042ee464b65cc13 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/165093 Tested-by: Jenkins Reviewed-by: Miklos Vajna <vmiklos@collabora.com>
Diffstat (limited to 'sfx2/source/control')
-rw-r--r--sfx2/source/control/dispatch.cxx13
-rw-r--r--sfx2/source/control/unoctitm.cxx39
2 files changed, 48 insertions, 4 deletions
diff --git a/sfx2/source/control/dispatch.cxx b/sfx2/source/control/dispatch.cxx
index a780892b6940..ef59094293b9 100644
--- a/sfx2/source/control/dispatch.cxx
+++ b/sfx2/source/control/dispatch.cxx
@@ -1958,7 +1958,7 @@ void SfxDispatcher::SetReadOnly_Impl( bool bOn )
bool SfxDispatcher::GetReadOnly_Impl() const
{
- return xImp->bReadOnly;
+ return xImp->bReadOnly || SfxViewShell::IsCurrentLokViewReadOnly();
}
/** With 'bOn' the Dispatcher is quasi dead and transfers everything to the
@@ -2020,16 +2020,21 @@ SfxItemState SfxDispatcher::QueryState( sal_uInt16 nSID, css::uno::Any& rAny )
bool SfxDispatcher::IsReadOnlyShell_Impl( sal_uInt16 nShell ) const
{
+ bool bResult = true;
sal_uInt16 nShellCount = xImp->aStack.size();
if ( nShell < nShellCount )
{
SfxShell* pShell = *( xImp->aStack.rbegin() + nShell );
if( dynamic_cast< const SfxModule *>( pShell ) != nullptr || dynamic_cast< const SfxApplication *>( pShell ) != nullptr || dynamic_cast< const SfxViewFrame *>( pShell ) != nullptr )
- return false;
+ bResult = false;
else
- return xImp->bReadOnly;
+ bResult = xImp->bReadOnly;
}
- return true;
+
+ if (!bResult && SfxViewShell::IsCurrentLokViewReadOnly())
+ bResult = true;
+
+ return bResult;
}
void SfxDispatcher::RemoveShell_Impl( SfxShell& rShell )
diff --git a/sfx2/source/control/unoctitm.cxx b/sfx2/source/control/unoctitm.cxx
index 28097661bb7e..f1af18fe672b 100644
--- a/sfx2/source/control/unoctitm.cxx
+++ b/sfx2/source/control/unoctitm.cxx
@@ -520,6 +520,39 @@ 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
+ };
+
+ return std::find(std::begin(allowedCommandList), std::end(allowedCommandList), command) != std::end(allowedCommandList);
+ }
+
+ 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 )
@@ -546,6 +579,12 @@ void SfxDispatchController_Impl::dispatch( const css::util::URL& aURL,
return;
}
+
+ if (aURL.Protocol == ".uno:" && !isCommandAllowedForViewType(aURL.Path))
+ {
+ return;
+ }
+
if (
!(pDispatch &&
(