sw/source/core/crsr/pam.cxx | 2 - sw/source/core/doc/DocumentRedlineManager.cxx | 12 +++++++-- sw/source/core/doc/docredln.cxx | 33 ++++++++++++++++++-------- 3 files changed, 35 insertions(+), 12 deletions(-)
New commits: commit 0b7a9c231f66b5c2659ab3aa6a0f3c7991b9e721 Author: Pranam Lashkari <[email protected]> AuthorDate: Wed Feb 14 15:07:38 2024 +0530 Commit: Pranam Lashkari <[email protected]> CommitDate: Fri Feb 16 13:16:54 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 <[email protected]> Reviewed-by: Gökay ŞATIR <[email protected]> diff --git a/sw/source/core/doc/DocumentRedlineManager.cxx b/sw/source/core/doc/DocumentRedlineManager.cxx index 657a67a61720..ffcab9b1f24f 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 <fmtfld.hxx> @@ -39,6 +40,7 @@ #include <swmodule.hxx> #include <osl/diagnose.h> #include <editeng/prntitem.hxx> +#include <comphelper/lok.hxx> using namespace com::sun::star; @@ -382,8 +384,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 4e03aab32ff6..afe7dfed5686 100644 --- a/sw/source/core/doc/docredln.cxx +++ b/sw/source/core/doc/docredln.cxx @@ -1305,6 +1305,19 @@ OUString SwRedlineData::GetDescr() const sal_uInt32 SwRangeRedline::s_nLastId = 1; +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)); + } +} + SwRangeRedline::SwRangeRedline(RedlineType eTyp, const SwPaM& rPam, sal_uInt32 nMovedID ) : SwPaM( *rPam.GetMark(), *rPam.GetPoint() ), m_pRedlineData( new SwRedlineData(eTyp, GetDoc().getIDocumentRedlineAccess().GetRedlineAuthor(), nMovedID ) ) @@ -1326,15 +1339,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); } } @@ -1350,6 +1355,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 ) commit 0b0b70772f2d9836010e523bff0132b626713862 Author: Pranam Lashkari <[email protected]> AuthorDate: Fri Feb 16 00:59:49 2024 +0530 Commit: Pranam Lashkari <[email protected]> CommitDate: Fri Feb 16 13:16:45 2024 +0100 avoid using subView on empty OUString it causes assertion failure rtl::OUString SwPaM::GetText() const: Assertion `(nEnd-nStart) == (aTmpStr.getLength() - nStart)' failed Change-Id: Ie479f224e8a1516735f96c3a09181d4c46dba10d Reviewed-on: https://gerrit.libreoffice.org/c/core/+/163461 Reviewed-by: Noel Grandin <[email protected]> Tested-by: Jenkins CollaboraOffice <[email protected]> Reviewed-by: Gökay ŞATIR <[email protected]> diff --git a/sw/source/core/crsr/pam.cxx b/sw/source/core/crsr/pam.cxx index bc3f9d7104a2..549959ea7fbc 100644 --- a/sw/source/core/crsr/pam.cxx +++ b/sw/source/core/crsr/pam.cxx @@ -1302,7 +1302,7 @@ OUString SwPaM::GetText() const } const OUString& aTmpStr = pTextNode->GetText(); - if (bIsStartNode || bIsEndNode) + if (aTmpStr.getLength() > 0 && (bIsStartNode || bIsEndNode)) { // Handle corner cases of start/end node(s) const sal_Int32 nStart = bIsStartNode
