diff options
author | Gökay Şatır <gokaysatir@gmail.com> | 2024-03-06 15:36:44 +0300 |
---|---|---|
committer | Miklos Vajna <vmiklos@collabora.com> | 2024-03-19 16:53:37 +0100 |
commit | d50d40b12cf3077dd83e7d3da33e6f3a15e44e14 (patch) | |
tree | 95b24ad435664b5b88a1d8de3a137a505b045cfd | |
parent | 02c67183f14fffb3578fa8713b865a568dc6b648 (diff) |
Allow enabling comment editing in readonly view mode.
Online side can set this property to allow comment editing. This is the infra.
Implementation will be in another commit.
Change-Id: I3a6f1ad6818c2c6587d98896c3d6d913d51a2295
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/164988
Tested-by: Jenkins
Reviewed-by: Miklos Vajna <vmiklos@collabora.com>
-rw-r--r-- | desktop/qa/desktop_lib/test_desktop_lib.cxx | 3 | ||||
-rw-r--r-- | desktop/source/lib/init.cxx | 15 | ||||
-rw-r--r-- | include/LibreOfficeKit/LibreOfficeKit.h | 3 | ||||
-rw-r--r-- | include/LibreOfficeKit/LibreOfficeKit.hxx | 10 | ||||
-rw-r--r-- | include/sfx2/viewsh.hxx | 3 |
5 files changed, 33 insertions, 1 deletions
diff --git a/desktop/qa/desktop_lib/test_desktop_lib.cxx b/desktop/qa/desktop_lib/test_desktop_lib.cxx index 1239af480598..1a0c2fed27b1 100644 --- a/desktop/qa/desktop_lib/test_desktop_lib.cxx +++ b/desktop/qa/desktop_lib/test_desktop_lib.cxx @@ -3677,9 +3677,10 @@ void DesktopLOKTest::testABI() CPPUNIT_ASSERT_EQUAL(documentClassOffset(70), offsetof(struct _LibreOfficeKitDocumentClass, getA11yFocusedParagraph)); CPPUNIT_ASSERT_EQUAL(documentClassOffset(71), offsetof(struct _LibreOfficeKitDocumentClass, getA11yCaretPosition)); CPPUNIT_ASSERT_EQUAL(documentClassOffset(72), offsetof(struct _LibreOfficeKitDocumentClass, setViewReadOnly)); + CPPUNIT_ASSERT_EQUAL(documentClassOffset(73), offsetof(struct _LibreOfficeKitDocumentClass, setAllowChangeComments)); // As above - CPPUNIT_ASSERT_EQUAL(documentClassOffset(73), sizeof(struct _LibreOfficeKitDocumentClass)); + CPPUNIT_ASSERT_EQUAL(documentClassOffset(74), sizeof(struct _LibreOfficeKitDocumentClass)); } CPPUNIT_TEST_SUITE_REGISTRATION(DesktopLOKTest); diff --git a/desktop/source/lib/init.cxx b/desktop/source/lib/init.cxx index 90bddb4fb899..8550b9d91b1b 100644 --- a/desktop/source/lib/init.cxx +++ b/desktop/source/lib/init.cxx @@ -1293,6 +1293,8 @@ static void doc_setViewTimezone(LibreOfficeKitDocument* pThis, int nId, const ch static void doc_setViewReadOnly(LibreOfficeKitDocument* pThis, int nId, const bool readonly); +static void doc_setAllowChangeComments(LibreOfficeKitDocument* pThis, int nId, const bool allow); + static void doc_setAccessibilityState(LibreOfficeKitDocument* pThis, int nId, bool bEnabled); static char* doc_getA11yFocusedParagraph(LibreOfficeKitDocument* pThis); @@ -1493,6 +1495,8 @@ LibLODocument_Impl::LibLODocument_Impl(uno::Reference <css::lang::XComponent> xC m_pDocumentClass->setViewReadOnly = doc_setViewReadOnly; + m_pDocumentClass->setAllowChangeComments = doc_setAllowChangeComments; + gDocumentClass = m_pDocumentClass; } pClass = m_pDocumentClass.get(); @@ -7210,6 +7214,17 @@ static void doc_setViewReadOnly(SAL_UNUSED_PARAMETER LibreOfficeKitDocument* pTh SfxViewShell::Current()->SetLokReadOnlyView(readOnly); } +static void doc_setAllowChangeComments(SAL_UNUSED_PARAMETER LibreOfficeKitDocument* pThis, int nId, const bool allow) +{ + comphelper::ProfileZone aZone("doc_setAllowChangeComments"); + + SolarMutexGuard aGuard; + SetLastExceptionMsg(); + + doc_setView(pThis, nId); + SfxViewShell::Current()->SetAllowChangeComments(allow); +} + static void doc_setAccessibilityState(SAL_UNUSED_PARAMETER LibreOfficeKitDocument* pThis, int nId, bool nEnabled) { SolarMutexGuard aGuard; diff --git a/include/LibreOfficeKit/LibreOfficeKit.h b/include/LibreOfficeKit/LibreOfficeKit.h index b28bae7e1ebc..de7be575e445 100644 --- a/include/LibreOfficeKit/LibreOfficeKit.h +++ b/include/LibreOfficeKit/LibreOfficeKit.h @@ -517,6 +517,9 @@ struct _LibreOfficeKitDocumentClass /// @see lok::Document::setViewReadOnly(). void (*setViewReadOnly) (LibreOfficeKitDocument* pThis, int nId, const bool readOnly); + /// @see lok::Document::setAllowChangeComments(). + void (*setAllowChangeComments) (LibreOfficeKitDocument* pThis, int nId, const bool allow); + #endif // defined LOK_USE_UNSTABLE_API || defined LIBO_INTERNAL_ONLY }; diff --git a/include/LibreOfficeKit/LibreOfficeKit.hxx b/include/LibreOfficeKit/LibreOfficeKit.hxx index 4bf818fad747..7858f90c953b 100644 --- a/include/LibreOfficeKit/LibreOfficeKit.hxx +++ b/include/LibreOfficeKit/LibreOfficeKit.hxx @@ -869,6 +869,16 @@ public: mpDoc->pClass->setViewReadOnly(mpDoc, nId, readOnly); } + /** Set if the view can edit comments on readonly mode or not. + * + * @param nId view ID + * @param allow + */ + void setAllowChangeComments(int nId, const bool allow) + { + mpDoc->pClass->setAllowChangeComments(mpDoc, nId, allow); + } + /** * Enable/Disable accessibility support for the window with the specified nId. * diff --git a/include/sfx2/viewsh.hxx b/include/sfx2/viewsh.hxx index b52b8b520992..adecc4e1a968 100644 --- a/include/sfx2/viewsh.hxx +++ b/include/sfx2/viewsh.hxx @@ -222,6 +222,7 @@ private: LOKDocumentFocusListener& GetLOKDocumentFocusListener(); const LOKDocumentFocusListener& GetLOKDocumentFocusListener() const; bool lokReadOnlyView = false; // When true, this is a LOK readonly view. + bool allowChangeComments = false; // When true, user can edit comments in readonly view mode. public: @@ -247,6 +248,8 @@ public: void SetLokReadOnlyView(bool readOnlyView) { lokReadOnlyView = readOnlyView; }; bool IsLokReadOnlyView() const { return lokReadOnlyView; }; + void SetAllowChangeComments(bool allow) { allowChangeComments = allow; } + bool IsAllowChangeComments() { return allowChangeComments; } // Misc |