sfx2/source/control/dispatch.cxx | 13 +++++++++++++ sw/inc/AnnotationWin.hxx | 5 +---- sw/source/uibase/docvw/AnnotationWin.cxx | 7 ++++++- sw/source/uibase/docvw/AnnotationWin2.cxx | 5 +++-- 4 files changed, 23 insertions(+), 7 deletions(-)
New commits: commit 0a677d53a6c0eba6f859eaa658d4aecf78bee631 Author: Tibor Nagy <[email protected]> AuthorDate: Fri Sep 13 15:16:27 2024 +0200 Commit: Michael Stahl <[email protected]> CommitDate: Wed May 7 13:34:56 2025 +0200 LOCRDT sfx2,sw: add special mode EDIT_COMMENT_IN_READONLY_MODE Create a special mode that allows editing comments and adding new comments, while the rest of the document remains in read-only mode. Since this is a prototype, it is is activated by environment variable. Change-Id: I6a49000127d2c19804596d84377cc5aeb578cc38 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/173340 Tested-by: Michael Stahl <[email protected]> Reviewed-by: Michael Stahl <[email protected]> diff --git a/sfx2/source/control/dispatch.cxx b/sfx2/source/control/dispatch.cxx index 9fd3a0153a66..7b646c57ce14 100644 --- a/sfx2/source/control/dispatch.cxx +++ b/sfx2/source/control/dispatch.cxx @@ -1657,6 +1657,19 @@ bool SfxDispatcher::FindServer_(sal_uInt16 nSlot, SfxSlotServer& rServer) if (pSlot && !(pSlot->nFlags & SfxSlotMode::VIEWERAPP) && isViewerAppMode) return false; + // Enable insert new annotation in Writer in read-only mode + if (pSlot && bReadOnly && getenv("EDIT_COMMENT_IN_READONLY_MODE") != nullptr) + { + OUString sCommand = pSlot->GetCommand(); + if (sCommand == u".uno:InsertAnnotation"_ustr + || ((sCommand == u".uno:FontDialog"_ustr + || sCommand == u".uno:ParagraphDialog"_ustr) + && pIFace->GetClassName() == "SwAnnotationShell"_ostr)) + { + bReadOnly = false; + } + } + if ( pSlot && !( pSlot->nFlags & SfxSlotMode::READONLYDOC ) && bReadOnly ) return false; diff --git a/sw/inc/AnnotationWin.hxx b/sw/inc/AnnotationWin.hxx index 9e5aaeba6aeb..c63d6d339d1d 100644 --- a/sw/inc/AnnotationWin.hxx +++ b/sw/inc/AnnotationWin.hxx @@ -140,10 +140,7 @@ class SAL_DLLPUBLIC_RTTI SwAnnotationWin final : public InterimItemWindow void SetSidebarPosition(sw::sidebarwindows::SidebarPosition eSidebarPosition); void SetReadonly(bool bSet); - bool IsReadOnly() const - { - return mbReadonly; - } + bool IsReadOnly() const; void SetColor(Color aColorDark,Color aColorLight, Color aColorAnchor); const Color& ColorDark() { return mColorDark; } diff --git a/sw/source/uibase/docvw/AnnotationWin.cxx b/sw/source/uibase/docvw/AnnotationWin.cxx index 864603f179a9..474c0757eab9 100644 --- a/sw/source/uibase/docvw/AnnotationWin.cxx +++ b/sw/source/uibase/docvw/AnnotationWin.cxx @@ -514,9 +514,14 @@ OString SwAnnotationWin::GetSimpleHtml() const return GetOutlinerView()->GetEditView().GetSimpleHtml(); } +bool SwAnnotationWin::IsReadOnly() const +{ + return mbReadonly; +} + bool SwAnnotationWin::IsReadOnlyOrProtected() const { - return mbReadonly || + return IsReadOnly() || GetLayoutStatus() == SwPostItHelper::DELETED || ( mpFormatField && mpFormatField->IsProtect() ); } diff --git a/sw/source/uibase/docvw/AnnotationWin2.cxx b/sw/source/uibase/docvw/AnnotationWin2.cxx index f539cc3f5a05..59843da348d6 100644 --- a/sw/source/uibase/docvw/AnnotationWin2.cxx +++ b/sw/source/uibase/docvw/AnnotationWin2.cxx @@ -922,8 +922,9 @@ void SwAnnotationWin::SetSidebarPosition(sw::sidebarwindows::SidebarPosition eSi void SwAnnotationWin::SetReadonly(bool bSet) { - mbReadonly = bSet; - GetOutlinerView()->SetReadOnly(bSet); + // the OutlinerView determines if the comment window accepts key input + mbReadonly = bSet && getenv("EDIT_COMMENT_IN_READONLY_MODE") == nullptr; + GetOutlinerView()->SetReadOnly(mbReadonly); } void SwAnnotationWin::GetFocus()
