desktop/qa/desktop_lib/test_desktop_lib.cxx | 3 ++- desktop/source/lib/init.cxx | 15 +++++++++++++++ include/LibreOfficeKit/LibreOfficeKit.h | 3 +++ include/LibreOfficeKit/LibreOfficeKit.hxx | 10 ++++++++++ include/sfx2/viewsh.hxx | 3 +++ 5 files changed, 33 insertions(+), 1 deletion(-)
New commits: commit 963ec97d3325cfb2d6c001100b1941b243fccdb3 Author: Gökay Şatır <[email protected]> AuthorDate: Wed Mar 6 15:36:44 2024 +0300 Commit: Michael Meeks <[email protected]> CommitDate: Fri Mar 8 14:54:40 2024 +0100 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. Signed-off-by: Gökay Şatır <[email protected]> Change-Id: I3a6f1ad6818c2c6587d98896c3d6d913d51a2295 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/164467 Tested-by: Jenkins CollaboraOffice <[email protected]> Reviewed-by: Michael Meeks <[email protected]> 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 bde805eedce5..c98362b6ba63 100644 --- a/desktop/source/lib/init.cxx +++ b/desktop/source/lib/init.cxx @@ -1298,6 +1298,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); @@ -1498,6 +1500,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(); @@ -7241,6 +7245,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 abcd404af615..450366ccb70c 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 b5340b37232c..8b7a211804be 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 f1564de3795c..8b8a21f77741 100644 --- a/include/sfx2/viewsh.hxx +++ b/include/sfx2/viewsh.hxx @@ -223,6 +223,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: @@ -248,6 +249,8 @@ public: void SetLokReadOnlyView(bool readOnlyView) { lokReadOnlyView = readOnlyView; }; bool IsLokReadOnlyView() const { return lokReadOnlyView; }; + void SetAllowChangeComments(bool allow) { allowChangeComments = allow; } + bool IsAllowChangeComments() { return allowChangeComments; } // Misc
