sw/source/core/doc/DocumentRedlineManager.cxx | 12 +++++++- sw/source/core/doc/docredln.cxx | 36 +++++++++++++++++++------- 2 files changed, 37 insertions(+), 11 deletions(-)
New commits: commit a0bd028a00165996224c93a4eba4b6affe6743e0 Author: Pranam Lashkari <lpra...@collabora.com> AuthorDate: Wed Feb 14 15:07:38 2024 +0530 Commit: Caolán McNamara <caolan.mcnam...@collabora.com> CommitDate: Sat Feb 17 21:49:28 2024 +0100 writer: LOK: make sure redline comment undo/redo is notified problem: when actions were performed on comments and changes were tracked, LOK was not notified and actions were not reflected Change-Id: Iad4d9338a6205278b586106e8f39769b731f18dc Reviewed-on: https://gerrit.libreoffice.org/c/core/+/163357 Tested-by: Jenkins CollaboraOffice <jenkinscollaboraoff...@gmail.com> Reviewed-by: Gökay ŞATIR <gokaysa...@collabora.com> (cherry picked from commit 0b7a9c231f66b5c2659ab3aa6a0f3c7991b9e721) Reviewed-on: https://gerrit.libreoffice.org/c/core/+/163502 Tested-by: Jenkins Reviewed-by: Caolán McNamara <caolan.mcnam...@collabora.com> diff --git a/sw/source/core/doc/DocumentRedlineManager.cxx b/sw/source/core/doc/DocumentRedlineManager.cxx index 3f5ccfc0ec5c..710baaf41b94 100644 --- a/sw/source/core/doc/DocumentRedlineManager.cxx +++ b/sw/source/core/doc/DocumentRedlineManager.cxx @@ -20,6 +20,7 @@ #include <frmfmt.hxx> #include <rootfrm.hxx> #include <txtfrm.hxx> +#include <txtfld.hxx> #include <doc.hxx> #include <docsh.hxx> #include <wrtsh.hxx> @@ -40,6 +41,7 @@ #include <swmodule.hxx> #include <osl/diagnose.h> #include <editeng/prntitem.hxx> +#include <comphelper/lok.hxx> using namespace com::sun::star; @@ -383,8 +385,14 @@ void UpdateFramesForRemoveDeleteRedline(SwDoc & rDoc, SwPaM const& rPam) // fields last - SwGetRefField::UpdateField requires up-to-date frames UpdateFieldsForRedline(rDoc.getIDocumentFieldsAccess()); // after footnotes - // update SwPostItMgr / notes in the margin - rDoc.GetDocShell()->Broadcast( + 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 && comphelper::LibreOfficeKit::isActive() ) + rDoc.GetDocShell()->Broadcast( + SwFormatFieldHint(&pTextField->GetFormatField(), SwFormatFieldHintWhich::INSERTED)); + else + rDoc.GetDocShell()->Broadcast( SwFormatFieldHint(nullptr, SwFormatFieldHintWhich::INSERTED) ); } diff --git a/sw/source/core/doc/docredln.cxx b/sw/source/core/doc/docredln.cxx index b8bb35056de1..a629d9d6b432 100644 --- a/sw/source/core/doc/docredln.cxx +++ b/sw/source/core/doc/docredln.cxx @@ -1372,6 +1372,22 @@ void SwRedlineData::dumpAsXml(xmlTextWriterPtr pWriter) const sal_uInt32 SwRangeRedline::s_nLastId = 1; +namespace +{ +void lcl_LOKBroadcastCommentOperation(RedlineType type, const SwPaM& rPam) +{ + if (comphelper::LibreOfficeKit::isActive()) + { + auto eHintType = RedlineType::Delete == type ? 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)); + } +} +} // anonymous namespace + SwRangeRedline::SwRangeRedline(RedlineType eTyp, const SwPaM& rPam, sal_uInt32 nMovedID ) : SwPaM( *rPam.GetMark(), *rPam.GetPoint() ), m_pRedlineData( new SwRedlineData(eTyp, GetDoc().getIDocumentRedlineAccess().GetRedlineAuthor(), nMovedID ) ) @@ -1393,15 +1409,7 @@ SwRangeRedline::SwRangeRedline(RedlineType eTyp, const SwPaM& rPam, sal_uInt32 n ? 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)); - } + lcl_LOKBroadcastCommentOperation(eTyp, rPam); } } @@ -1417,6 +1425,16 @@ SwRangeRedline::SwRangeRedline( const SwRedlineData& rData, const SwPaM& rPam ) m_bIsVisible = true; if( !rPam.HasMark() ) DeleteMark(); + + // set default comment for single annotations added or deleted + if ( IsAnnotation() ) + { + SetComment( RedlineType::Delete == rData.m_eType + ? SwResId(STR_REDLINE_COMMENT_DELETED) + : SwResId(STR_REDLINE_COMMENT_ADDED) ); + + lcl_LOKBroadcastCommentOperation(rData.m_eType, rPam); + } } SwRangeRedline::SwRangeRedline( const SwRedlineData& rData, const SwPosition& rPos )