sw/source/core/undo/rolbck.cxx |   15 ++++++++++++++-
 1 file changed, 14 insertions(+), 1 deletion(-)

New commits:
commit 1724c2fe47d36ac8f8049e428ebfa7284b390a14
Author:     Michael Stahl <[email protected]>
AuthorDate: Fri May 16 12:42:57 2025 +0200
Commit:     Michael Stahl <[email protected]>
CommitDate: Fri May 16 20:34:42 2025 +0200

    LOCRDT sw: fix undo of deleting comment
    
    CppunitTest_sw_uiwriter4 CPPUNIT_TEST_NAME="testRedlineViewAuthor"
    fails because Undo of deleting a comment doesn't add it back to the yrs
    model
    
    Change-Id: Ib8d559799a350d7d12caadcde1630ab904211b4a
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/185425
    Tested-by: Jenkins
    Reviewed-by: Michael Stahl <[email protected]>

diff --git a/sw/source/core/undo/rolbck.cxx b/sw/source/core/undo/rolbck.cxx
index 9ddb31df3634..ad90afca7dae 100644
--- a/sw/source/core/undo/rolbck.cxx
+++ b/sw/source/core/undo/rolbck.cxx
@@ -44,11 +44,13 @@
 #include <IDocumentUndoRedo.hxx>
 #include <IDocumentFieldsAccess.hxx>
 #include <IDocumentLayoutAccess.hxx>
+#include <IDocumentState.hxx>
 #include <docary.hxx>
 #include <ndtxt.hxx>
 #include <paratr.hxx>
 #include <cellatr.hxx>
 #include <fldbas.hxx>
+#include <docufld.hxx>
 #include <pam.hxx>
 #include <swtable.hxx>
 #include <UndoCore.hxx>
@@ -329,12 +331,23 @@ void SwHistorySetTextField::SetInDoc( SwDoc* pDoc, bool )
     m_pField->GetField()->ChgTyp( pNewFieldType ); // change field type
 
     SwTextNode * pTextNd = pDoc->GetNodes()[ m_nNodeIndex ]->GetTextNode();
-    OSL_ENSURE( pTextNd, "SwHistorySetTextField: no TextNode" );
+    assert(pTextNd);
 
     if ( pTextNd )
     {
         pTextNd->InsertItem( *m_pField, m_nPos, m_nPos,
                     SetAttrMode::NOTXTATRCHR );
+#if ENABLE_YRS
+        if (m_nFieldWhich == SwFieldIds::Postit)
+        {
+            SwPosition const pos{*pTextNd, m_nPos};
+            pTextNd->GetDoc().getIDocumentState().YrsAddComment(
+                pos, {}, // FIXME no way to get anchor start here?
+                static_cast<SwPostItField 
const&>(*pTextNd->GetFieldTextAttrAt(pos.GetContentIndex(),
+                    
::sw::GetTextAttrMode::Default)->GetFormatField().GetField()),
+                true);
+        }
+#endif
     }
 }
 

Reply via email to