diff options
author | Pranam Lashkari <lpranam@collabora.com> | 2024-02-14 15:07:38 +0530 |
---|---|---|
committer | Pranam Lashkari <lpranam@collabora.com> | 2024-02-16 15:51:50 +0100 |
commit | 5952bde2ad94f27cc7b5111266abbdd90552e564 (patch) | |
tree | b8c927b12caa9165a08a8365c23fb501e2e252bd /sw | |
parent | f7a570fd5d64ba2964a33ac4c5ecfe9f236d316b (diff) |
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 <jenkinscollaboraoffice@gmail.com>
Reviewed-by: Gökay ŞATIR <gokaysatir@collabora.com>
(cherry picked from commit 0b7a9c231f66b5c2659ab3aa6a0f3c7991b9e721)
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/163500
Reviewed-by: Pranam Lashkari <lpranam@collabora.com>
Diffstat (limited to 'sw')
-rw-r--r-- | sw/source/core/doc/DocumentRedlineManager.cxx | 12 | ||||
-rw-r--r-- | sw/source/core/doc/docredln.cxx | 36 |
2 files changed, 37 insertions, 11 deletions
diff --git a/sw/source/core/doc/DocumentRedlineManager.cxx b/sw/source/core/doc/DocumentRedlineManager.cxx index 8d52c814e81a..1c6ba5ccd482 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 45af1e8e3f85..6093001bf086 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 ) |