diff options
author | Gökay Şatır <gokaysatir@gmail.com> | 2024-02-22 13:54:06 +0300 |
---|---|---|
committer | Gökay ŞATIR <gokaysatir@collabora.com> | 2024-03-06 11:21:47 +0100 |
commit | c60598390725cc23dc1401beec057f1386226ac8 (patch) | |
tree | 073d256e05923fde7597d3f54e1e35feb0ae63ac /desktop | |
parent | 81dae2ca5187bd24aea0befb099a5b53535b5d03 (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.
Signed-off-by: Gökay Şatır <gokaysatir@gmail.com>
Change-Id: I71fc353976256bce22042bbb6042ee464b65cc13
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/163731
Tested-by: Jenkins CollaboraOffice <jenkinscollaboraoffice@gmail.com>
Reviewed-by: Gökay ŞATIR <gokaysatir@collabora.com>
Diffstat (limited to 'desktop')
-rw-r--r-- | desktop/source/lib/init.cxx | 28 |
1 files changed, 28 insertions, 0 deletions
diff --git a/desktop/source/lib/init.cxx b/desktop/source/lib/init.cxx index 939fe2afc09f..586d9b4d84cc 100644 --- a/desktop/source/lib/init.cxx +++ b/desktop/source/lib/init.cxx @@ -4726,6 +4726,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) { @@ -5107,6 +5111,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"); @@ -5116,6 +5137,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)); @@ -7167,6 +7192,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) |