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 d0e71db33b91eeb9f4e4bb4ce13681e972e12a99 Author: Gökay Şatır <[email protected]> AuthorDate: Tue Jan 30 16:41:04 2024 +0300 Commit: Pranam Lashkari <[email protected]> CommitDate: Tue Feb 13 12:20:03 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 <[email protected]> Change-Id: Ia3ea4b44c116cc571337e57960aa4f12f934701c Reviewed-on: https://gerrit.libreoffice.org/c/core/+/162756 Tested-by: Jenkins CollaboraOffice <[email protected]> Tested-by: Caolán McNamara <[email protected]> Reviewed-by: Caolán McNamara <[email protected]> Reviewed-on: https://gerrit.libreoffice.org/c/core/+/163155 (cherry picked from commit 48d2d456d8bcb296b4b2f6cc2d1184f9d799f070) Reviewed-on: https://gerrit.libreoffice.org/c/core/+/163274 Reviewed-by: Gökay ŞATIR <[email protected]> Tested-by: Pranam Lashkari <[email protected]> diff --git a/sw/inc/fmtfld.hxx b/sw/inc/fmtfld.hxx index 0c8d5fda7110..e9da72e5d9c8 100644 --- a/sw/inc/fmtfld.hxx +++ b/sw/inc/fmtfld.hxx @@ -177,7 +177,8 @@ enum class SwFormatFieldHintWhich REMOVED = 2, FOCUS = 3, CHANGED = 4, - RESOLVED = 5 + RESOLVED = 5, + REDLINED_DELETION = 6 }; class SW_DLLPUBLIC SwFormatFieldHint final : public SfxHint diff --git a/sw/source/core/doc/docredln.cxx b/sw/source/core/doc/docredln.cxx index 3b0f8d7b9f53..45af1e8e3f85 100644 --- a/sw/source/core/doc/docredln.cxx +++ b/sw/source/core/doc/docredln.cxx @@ -1392,6 +1392,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)); + } } } @@ -1690,6 +1700,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 12c5e4f52d11..dee622d4b502 100644 --- a/sw/source/uibase/docvw/PostItMgr.cxx +++ b/sw/source/uibase/docvw/PostItMgr.cxx @@ -97,7 +97,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) { @@ -141,7 +141,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) { @@ -176,6 +178,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; @@ -387,6 +390,7 @@ void SwPostItMgr::Notify( SfxBroadcaster& rBC, const SfxHint& rHint ) break; } case SwFormatFieldHintWhich::REMOVED: + case SwFormatFieldHintWhich::REDLINED_DELETION: { if (mbDeleteNote) { @@ -404,7 +408,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 4725c69d6213..1b7c933ec974 100644 --- a/sw/source/uibase/uno/unotxdoc.cxx +++ b/sw/source/uibase/uno/unotxdoc.cxx @@ -3379,6 +3379,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())); } }
