diff options
author | Gökay Şatır <gokay.satir@collabora.com> | 2024-01-30 16:41:04 +0300 |
---|---|---|
committer | Caolán McNamara <caolan.mcnamara@collabora.com> | 2024-02-09 11:53:23 +0100 |
commit | 48d2d456d8bcb296b4b2f6cc2d1184f9d799f070 (patch) | |
tree | 1052f1054b14ccf14a43090a3ab2d5bde91d5c17 /sw | |
parent | 30fb8cde7579fb5da15c1d8da9611198f2f5ce78 (diff) |
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.satir@collabora.com>
Change-Id: Ia3ea4b44c116cc571337e57960aa4f12f934701c
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/162756
Tested-by: Jenkins CollaboraOffice <jenkinscollaboraoffice@gmail.com>
Tested-by: Caolán McNamara <caolan.mcnamara@collabora.com>
Reviewed-by: Caolán McNamara <caolan.mcnamara@collabora.com>
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/163155
Diffstat (limited to 'sw')
-rw-r--r-- | sw/inc/fmtfld.hxx | 3 | ||||
-rw-r--r-- | sw/source/core/doc/docredln.cxx | 20 | ||||
-rw-r--r-- | sw/source/uibase/docvw/PostItMgr.cxx | 11 | ||||
-rw-r--r-- | sw/source/uibase/uno/unotxdoc.cxx | 1 |
4 files changed, 31 insertions, 4 deletions
diff --git a/sw/inc/fmtfld.hxx b/sw/inc/fmtfld.hxx index ab1953f00114..ff9f06e5dc66 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 }; /// This SfxHint subclass is produced by code that changes the doc model (e.g. SwNodes::ChgNode()), 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 e10b74671819..ad3c39965c84 100644 --- a/sw/source/uibase/docvw/PostItMgr.cxx +++ b/sw/source/uibase/docvw/PostItMgr.cxx @@ -98,7 +98,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) { @@ -142,7 +142,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) { @@ -177,6 +179,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; @@ -384,6 +387,7 @@ void SwPostItMgr::Notify( SfxBroadcaster& rBC, const SfxHint& rHint ) break; } case SwFormatFieldHintWhich::REMOVED: + case SwFormatFieldHintWhich::REDLINED_DELETION: { if (mbDeleteNote) { @@ -401,7 +405,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 222583517e42..358cdbba532a 100644 --- a/sw/source/uibase/uno/unotxdoc.cxx +++ b/sw/source/uibase/uno/unotxdoc.cxx @@ -3314,6 +3314,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())); } } |