sw/inc/fmtfld.hxx | 3 ++- sw/source/core/doc/docredln.cxx | 20 ++++++++++++++++++++ sw/source/uibase/docvw/PostItMgr.cxx | 11 ++++++++--- sw/source/uibase/uno/unotxdoc.cxx | 1 + 4 files changed, 31 insertions(+), 4 deletions(-)
New commits: commit 2bd364f4bba9ad60fd342e363ffd58234fbfec04 Author: Gökay Şatır <gokay.sa...@collabora.com> AuthorDate: Tue Jan 30 16:41:04 2024 +0300 Commit: Caolán McNamara <caolan.mcnam...@collabora.com> CommitDate: Thu Feb 8 13:45:41 2024 +0100 Writer: Improve redline communication with libreofficeKit. When changes are tracked and user adds / removes a comment, we need a better communication. This PR improves the communication and sends the layout status of comments. Still there are things to do, like (while tracking is on): * We need to communicate when a change in comment is approved / rejected. * When user performs an undo on the removed comment. Signed-off-by: Gökay Şatır <gokay.sa...@collabora.com> Change-Id: Ia3ea4b44c116cc571337e57960aa4f12f934701c Reviewed-on: https://gerrit.libreoffice.org/c/core/+/162756 Tested-by: Jenkins CollaboraOffice <jenkinscollaboraoff...@gmail.com> Tested-by: Caolán McNamara <caolan.mcnam...@collabora.com> Reviewed-by: Caolán McNamara <caolan.mcnam...@collabora.com> diff --git a/sw/inc/fmtfld.hxx b/sw/inc/fmtfld.hxx index 5807ed8fba70..20614d80c15c 100644 --- a/sw/inc/fmtfld.hxx +++ b/sw/inc/fmtfld.hxx @@ -176,7 +176,8 @@ enum class SwFormatFieldHintWhich FOCUS = 3, CHANGED = 4, LANGUAGE = 5, - RESOLVED = 6 + RESOLVED = 6, + REDLINED_DELETION = 7 }; class SW_DLLPUBLIC SwFormatFieldHint final : public SfxHint diff --git a/sw/source/core/doc/docredln.cxx b/sw/source/core/doc/docredln.cxx index c5a6b6885a71..4e03aab32ff6 100644 --- a/sw/source/core/doc/docredln.cxx +++ b/sw/source/core/doc/docredln.cxx @@ -1325,6 +1325,16 @@ SwRangeRedline::SwRangeRedline(RedlineType eTyp, const SwPaM& rPam, sal_uInt32 n SetComment( RedlineType::Delete == eTyp ? SwResId(STR_REDLINE_COMMENT_DELETED) : SwResId(STR_REDLINE_COMMENT_ADDED) ); + + if (comphelper::LibreOfficeKit::isActive()) + { + auto eHintType = RedlineType::Delete == eTyp ? SwFormatFieldHintWhich::REDLINED_DELETION: SwFormatFieldHintWhich::INSERTED; + const SwTextNode *pTextNode = rPam.GetPointNode().GetTextNode(); + SwTextAttr* pTextAttr = pTextNode ? pTextNode->GetFieldTextAttrAt(rPam.GetPoint()->GetContentIndex() - 1, ::sw::GetTextAttrMode::Default) : nullptr; + SwTextField *const pTextField(static_txtattr_cast<SwTextField*>(pTextAttr)); + if (pTextField) + const_cast<SwFormatField&>(pTextField->GetFormatField()).Broadcast(SwFormatFieldHint(&pTextField->GetFormatField(), eHintType)); + } } } @@ -1623,6 +1633,16 @@ void SwRangeRedline::InvalidateRange(Invalidation const eWhy) sw::RedlineUnDelText const hint(nStart, nLen); pNd->CallSwClientNotify(hint); } + + if (comphelper::LibreOfficeKit::isActive() && IsAnnotation()) + { + auto eHintType = eWhy == Invalidation::Add ? SwFormatFieldHintWhich::INSERTED: SwFormatFieldHintWhich::REMOVED; + const SwTextNode *pTextNode = this->GetPointNode().GetTextNode(); + SwTextAttr* pTextAttr = pTextNode ? pTextNode->GetFieldTextAttrAt(this->GetPoint()->GetContentIndex() - 1, ::sw::GetTextAttrMode::Default) : nullptr; + SwTextField *const pTextField(static_txtattr_cast<SwTextField*>(pTextAttr)); + if (pTextField) + const_cast<SwFormatField&>(pTextField->GetFormatField()).Broadcast(SwFormatFieldHint(&pTextField->GetFormatField(), eHintType)); + } } } } diff --git a/sw/source/uibase/docvw/PostItMgr.cxx b/sw/source/uibase/docvw/PostItMgr.cxx index 10f866e5c9bb..bbc9b15ca322 100644 --- a/sw/source/uibase/docvw/PostItMgr.cxx +++ b/sw/source/uibase/docvw/PostItMgr.cxx @@ -96,7 +96,7 @@ using namespace sw::annotation; namespace { - enum class CommentNotificationType { Add, Remove, Modify, Resolve }; + enum class CommentNotificationType { Add, Remove, Modify, Resolve, RedlinedDeletion }; bool comp_pos(const std::unique_ptr<SwSidebarItem>& a, const std::unique_ptr<SwSidebarItem>& b) { @@ -140,7 +140,9 @@ namespace { aAnnotation.put("action", (nType == CommentNotificationType::Add ? "Add" : (nType == CommentNotificationType::Remove ? "Remove" : (nType == CommentNotificationType::Modify ? "Modify" : - (nType == CommentNotificationType::Resolve ? "Resolve" : "???"))))); + (nType == CommentNotificationType::RedlinedDeletion ? "RedlinedDeletion" : + (nType == CommentNotificationType::Resolve ? "Resolve" : "???")))))); + aAnnotation.put("id", nPostItId); if (nType != CommentNotificationType::Remove && pItem != nullptr) { @@ -175,6 +177,7 @@ namespace { aAnnotation.put("dateTime", utl::toISO8601(pField->GetDateTime().GetUNODateTime())); aAnnotation.put("anchorPos", aSVRect.toString()); aAnnotation.put("textRange", sRects.getStr()); + aAnnotation.put("layoutStatus", pItem->mLayoutStatus); } boost::property_tree::ptree aTree; @@ -383,6 +386,7 @@ void SwPostItMgr::Notify( SfxBroadcaster& rBC, const SfxHint& rHint ) break; } case SwFormatFieldHintWhich::REMOVED: + case SwFormatFieldHintWhich::REDLINED_DELETION: { if (mbDeleteNote) { @@ -400,7 +404,8 @@ void SwPostItMgr::Notify( SfxBroadcaster& rBC, const SfxHint& rHint ) if (comphelper::LibreOfficeKit::isActive() && !comphelper::LibreOfficeKit::isTiledAnnotations()) { SwPostItField* pPostItField = static_cast<SwPostItField*>(pField->GetField()); - lcl_CommentNotification(mpView, CommentNotificationType::Remove, nullptr, pPostItField->GetPostItId()); + auto type = pFormatHint->Which() == SwFormatFieldHintWhich::REMOVED ? CommentNotificationType::Remove: CommentNotificationType::RedlinedDeletion; + lcl_CommentNotification(mpView, type, nullptr, pPostItField->GetPostItId()); } } break; diff --git a/sw/source/uibase/uno/unotxdoc.cxx b/sw/source/uibase/uno/unotxdoc.cxx index 2d185a0c6504..9ed0f762a782 100644 --- a/sw/source/uibase/uno/unotxdoc.cxx +++ b/sw/source/uibase/uno/unotxdoc.cxx @@ -3381,6 +3381,7 @@ void SwXTextDocument::getPostIts(tools::JsonWriter& rJsonWriter) rJsonWriter.put("dateTime", utl::toISO8601(pField->GetDateTime().GetUNODateTime())); rJsonWriter.put("anchorPos", aSVRect.toString()); rJsonWriter.put("textRange", sRects); + rJsonWriter.put("layoutStatus", static_cast< sal_Int16 >(pWin->GetLayoutStatus())); } }