summaryrefslogtreecommitdiff
path: root/desktop
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 /desktop
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 'desktop')
-rw-r--r--desktop/source/lib/init.cxx28
1 files changed, 28 insertions, 0 deletions
diff --git a/desktop/source/lib/init.cxx b/desktop/source/lib/init.cxx
index 25ba3ade88c4..6eba39cc32f3 100644
--- a/desktop/source/lib/init.cxx
+++ b/desktop/source/lib/init.cxx
@@ -4686,6 +4686,10 @@ static void doc_postWindowExtTextInputEvent(LibreOfficeKitDocument* pThis, unsig
static void doc_removeTextContext(LibreOfficeKitDocument* pThis, unsigned nLOKWindowId, int nCharBefore, int nCharAfter)
{
SolarMutexGuard aGuard;
+
+ if (SfxViewShell::IsCurrentLokViewReadOnly())
+ return;
+
VclPtr<vcl::Window> pWindow;
if (nLOKWindowId == 0)
{
@@ -5067,6 +5071,23 @@ void LibLibreOffice_Impl::dumpState(rtl::OStringBuffer &rState)
vcl::lok::dumpState(rState);
}
+// We have special handling for some uno commands and it seems we need to check for readonly state.
+static bool isCommandAllowed(OUString& command) {
+ static constexpr OUString nonAllowedList[] = { u".uno:Save"_ustr, u".uno:TransformDialog"_ustr, u".uno:SidebarShow"_ustr, u".uno:SidebarHide"_ustr };
+
+ if (!SfxViewShell::IsCurrentLokViewReadOnly())
+ return true;
+ else
+ {
+ for (size_t i = 0; i < std::size(nonAllowedList); i++)
+ {
+ if (nonAllowedList[i] == command)
+ return false;
+ }
+ return true;
+ }
+}
+
static void doc_postUnoCommand(LibreOfficeKitDocument* pThis, const char* pCommand, const char* pArguments, bool bNotifyWhenFinished)
{
comphelper::ProfileZone aZone("doc_postUnoCommand");
@@ -5076,6 +5097,10 @@ static void doc_postUnoCommand(LibreOfficeKitDocument* pThis, const char* pComma
SfxObjectShell* pDocSh = SfxObjectShell::Current();
OUString aCommand(pCommand, strlen(pCommand), RTL_TEXTENCODING_UTF8);
+
+ if (!isCommandAllowed(aCommand))
+ return;
+
LibLODocument_Impl* pDocument = static_cast<LibLODocument_Impl*>(pThis);
std::vector<beans::PropertyValue> aPropertyValuesVector(jsonToPropertyValuesVector(pArguments));
@@ -7133,6 +7158,9 @@ static void doc_sendContentControlEvent(LibreOfficeKitDocument* pThis, const cha
return;
}
+ if (SfxViewShell::IsCurrentLokViewReadOnly())
+ return;
+
StringMap aMap(jsdialog::jsonToStringMap(pArguments));
ITiledRenderable* pDoc = getTiledRenderable(pThis);
if (!pDoc)