diff --git a/sw/qa/core/doc/DocumentRedlineManager.cxx b/sw/qa/core/doc/DocumentRedlineManager.cxx
index d2a51a18d897..11194129f49e 100644
--- a/sw/qa/core/doc/DocumentRedlineManager.cxx
+++ b/sw/qa/core/doc/DocumentRedlineManager.cxx
@@ -392,6 +392,51 @@ CPPUNIT_TEST_FIXTURE(Test, testDelThenFormatOwn)
CPPUNIT_ASSERT(!rRedlineData.Next());
}
}
+
+CPPUNIT_TEST_FIXTURE(Test, testFormatThenDel)
+{
+ // Given an "AAA BBB CCC DDD EEE" document:
+ createSwDoc("fmt.docx");
+ SwDocShell* pDocShell = getSwDocShell();
+ SwWrtShell* pWrtShell = pDocShell->GetWrtShell();
+ pWrtShell->SttEndDoc(/*bStt=*/true);
+ // Skip "AAA BBB ".
+ pWrtShell->Right(SwCursorSkipMode::Chars, /*bSelect=*/false, 8, /*bBasicCall=*/false);
+ // Select "CCC".
+ pWrtShell->Right(SwCursorSkipMode::Chars, /*bSelect=*/true, 3, /*bBasicCall=*/false);
+
+ // When deleting CCC:
+ pWrtShell->DelLeft();
+
+ // Then make sure the resulting new "delete" redline still tracks formatting:
+ SwDoc* pDoc = pDocShell->GetDoc();
+ IDocumentRedlineAccess& rIDRA = pDoc->getIDocumentRedlineAccess();
+ SwRedlineTable& rRedlines = rIDRA.GetRedlineTable();
+ CPPUNIT_ASSERT_EQUAL(static_cast(3), rRedlines.size());
+ {
+ const SwRedlineData& rRedlineData = rRedlines[0]->GetRedlineData(0);
+ CPPUNIT_ASSERT_EQUAL(RedlineType::Format, rRedlineData.GetType());
+ CPPUNIT_ASSERT(!rRedlineData.Next());
+ }
+ {
+ const SwRedlineData& rRedlineData = rRedlines[1]->GetRedlineData(0);
+ // Without the accompanying fix in place, this test would have failed with:
+ // - Expected: 2 (Format)
+ // - Actual : 1 (Delete)
+ // i.e. the middle redline was just "delete", not "format-on-delete", so formatting remained
+ // in the document after reject-all.
+ CPPUNIT_ASSERT_EQUAL(RedlineType::Format, rRedlineData.GetType());
+ CPPUNIT_ASSERT(rRedlineData.Next());
+ const SwRedlineData& rRedlineData2 = rRedlines[1]->GetRedlineData(1);
+ CPPUNIT_ASSERT_EQUAL(RedlineType::Delete, rRedlineData2.GetType());
+ CPPUNIT_ASSERT(!rRedlineData2.Next());
+ }
+ {
+ const SwRedlineData& rRedlineData = rRedlines[2]->GetRedlineData(0);
+ CPPUNIT_ASSERT_EQUAL(RedlineType::Format, rRedlineData.GetType());
+ CPPUNIT_ASSERT(!rRedlineData.Next());
+ }
+}
}
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sw/qa/core/doc/data/fmt.docx b/sw/qa/core/doc/data/fmt.docx
new file mode 100644
index 000000000000..29fa091007e2
Binary files /dev/null and b/sw/qa/core/doc/data/fmt.docx differ
diff --git a/sw/source/core/doc/DocumentRedlineManager.cxx b/sw/source/core/doc/DocumentRedlineManager.cxx
index 9f80926582d9..e3f0d864fbf1 100644
--- a/sw/source/core/doc/DocumentRedlineManager.cxx
+++ b/sw/source/core/doc/DocumentRedlineManager.cxx
@@ -2226,6 +2226,12 @@ void DocumentRedlineManager::PreAppendDeleteRedline(AppendRedlineContext& rCtx)
{
if( *rCtx.pEnd != *rCtx.pRStt )
{
+ // At this point, rCtx.pRedl is the old format redline and rCtx.pNewRedl is the
+ // new delete redline. Make sure that when this pNewRedl gets appended, it still
+ // has the formatting redline data from rCtx.pRedl / pNew, and format is on top
+ // of delete.
+ rCtx.pNewRedl->PushData(*rCtx.pRedl);
+
SwRangeRedline* pNew = new SwRangeRedline( *rCtx.pRedl );
pNew->SetStart( *rCtx.pEnd );
rCtx.pRedl->SetEnd( *rCtx.pStart, rCtx.pREnd );