summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--sw/qa/extras/uiwriter/uiwriter2.cxx14
-rw-r--r--sw/source/core/doc/DocumentRedlineManager.cxx96
2 files changed, 57 insertions, 53 deletions
diff --git a/sw/qa/extras/uiwriter/uiwriter2.cxx b/sw/qa/extras/uiwriter/uiwriter2.cxx
index e665df63cfbc..6f314401f7e7 100644
--- a/sw/qa/extras/uiwriter/uiwriter2.cxx
+++ b/sw/qa/extras/uiwriter/uiwriter2.cxx
@@ -1457,10 +1457,9 @@ CPPUNIT_TEST_FIXTURE(SwUiWriterTest2, testTdf118699_redline_numbering)
IDocumentRedlineAccess& rIDRA(pDoc->getIDocumentRedlineAccess());
rIDRA.AcceptAllRedline(true);
- // TODO: fix it!
- // uno::Reference<beans::XPropertySet> xProps(getParagraph(2), uno::UNO_QUERY_THROW);
- //CPPUNIT_ASSERT_MESSAGE("first paragraph after the first deletion: erroneous numbering",
- // !xProps->getPropertyValue("NumberingRules").hasValue());
+ uno::Reference<beans::XPropertySet> xProps(getParagraph(2), uno::UNO_QUERY_THROW);
+ CPPUNIT_ASSERT_MESSAGE("first paragraph after the first deletion: erroneous numbering",
+ !xProps->getPropertyValue("NumberingRules").hasValue());
CPPUNIT_ASSERT_MESSAGE(
"first paragraph after the second deletion: missing numbering",
@@ -1499,11 +1498,10 @@ CPPUNIT_TEST_FIXTURE(SwUiWriterTest2, testTdf125916_redline_restart_numbering)
IDocumentRedlineAccess& rIDRA(pDoc->getIDocumentRedlineAccess());
rIDRA.AcceptAllRedline(true);
- // TODO: fix it!
// check unnecessary numbering
- // uno::Reference<beans::XPropertySet> xProps(getParagraph(3), uno::UNO_QUERY_THROW);
- // CPPUNIT_ASSERT_MESSAGE("first paragraph after the first deletion: erroneous numbering",
- // !xProps->getPropertyValue("NumberingRules").hasValue());
+ uno::Reference<beans::XPropertySet> xProps(getParagraph(3), uno::UNO_QUERY_THROW);
+ CPPUNIT_ASSERT_MESSAGE("first paragraph after the first deletion: erroneous numbering",
+ !xProps->getPropertyValue("NumberingRules").hasValue());
}
CPPUNIT_TEST_FIXTURE(SwUiWriterTest2, testTdf125310)
diff --git a/sw/source/core/doc/DocumentRedlineManager.cxx b/sw/source/core/doc/DocumentRedlineManager.cxx
index dd7fade9d4c4..6d491b98c578 100644
--- a/sw/source/core/doc/DocumentRedlineManager.cxx
+++ b/sw/source/core/doc/DocumentRedlineManager.cxx
@@ -294,6 +294,51 @@ namespace
rPos1.nContent.GetIndex() == pCNd->Len();
}
+ void lcl_CopyStyle( const SwPosition & rFrom, const SwPosition & rTo )
+ {
+ SwTextNode* pToNode = rTo.nNode.GetNode().GetTextNode();
+ SwTextNode* pFromNode = rFrom.nNode.GetNode().GetTextNode();
+ if (pToNode != nullptr && pFromNode != nullptr && pToNode != pFromNode)
+ {
+ const SwPaM aPam(*pToNode);
+ SwDoc* pDoc = aPam.GetDoc();
+ // using Undo, copy paragraph style
+ pDoc->SetTextFormatColl(aPam, pFromNode->GetTextColl());
+
+ // using Undo, remove direct paragraph formatting of the "To" paragraph,
+ // and apply here direct paragraph formatting of the "From" paragraph
+ SfxItemSet aTmp(
+ pDoc->GetAttrPool(),
+ svl::Items<
+ RES_PARATR_BEGIN, RES_PARATR_END - 3, // skip RSID and GRABBAG
+ RES_PARATR_LIST_BEGIN, RES_UL_SPACE, // skip PAGEDESC and BREAK
+ RES_CNTNT, RES_FRMATR_END - 1>{});
+
+ SfxItemSet aTmp2(
+ pDoc->GetAttrPool(),
+ svl::Items<
+ RES_PARATR_BEGIN, RES_PARATR_END - 3, // skip RSID and GRABBAG
+ RES_PARATR_LIST_BEGIN, RES_UL_SPACE, // skip PAGEDESC and BREAK
+ RES_CNTNT, RES_FRMATR_END - 1>{});
+
+ pToNode->GetParaAttr(aTmp, 0, 0);
+ pFromNode->GetParaAttr(aTmp2, 0, 0);
+
+ for( sal_uInt16 nItem = 0; nItem < aTmp.TotalCount(); ++nItem)
+ {
+ sal_uInt16 nWhich = aTmp.GetWhichByPos(nItem);
+ if( SfxItemState::SET == aTmp.GetItemState( nWhich, false ) &&
+ SfxItemState::SET != aTmp2.GetItemState( nWhich, false ) )
+ aTmp2.Put( aTmp.GetPool()->GetDefaultItem(nWhich), nWhich );
+ }
+
+ if (aTmp2.Count())
+ pDoc->getIDocumentContentOperations().InsertItemSet(aPam, aTmp2);
+
+ // TODO: store the original paragraph style as ExtraData
+ }
+ }
+
bool lcl_AcceptRedline( SwRedlineTable& rArr, SwRedlineTable::size_type& rPos,
bool bCallDelete,
const SwPosition* pSttRng = nullptr,
@@ -415,6 +460,12 @@ namespace
SwPaM aPam( *pDelStt, *pDelEnd );
SwContentNode* pCSttNd = pDelStt->nNode.GetNode().GetContentNode();
SwContentNode* pCEndNd = pDelEnd->nNode.GetNode().GetContentNode();
+ pRStt = pRedl->Start();
+ pREnd = pRedl->End();
+
+ // keep style of the empty paragraph after deletion of wholly paragraphs
+ if( pCSttNd && pCEndNd && pRStt && pREnd && pRStt->nContent == 0 )
+ lcl_CopyStyle(*pREnd, *pRStt);
if( bDelRedl )
delete pRedl;
@@ -809,51 +860,6 @@ namespace
}
}
- void lcl_CopyStyle( const SwPosition & rFrom, const SwPosition & rTo )
- {
- SwTextNode* pToNode = rTo.nNode.GetNode().GetTextNode();
- SwTextNode* pFromNode = rFrom.nNode.GetNode().GetTextNode();
- if (pToNode != nullptr && pFromNode != nullptr && pToNode != pFromNode)
- {
- const SwPaM aPam(*pToNode);
- SwDoc* pDoc = aPam.GetDoc();
- // using Undo, copy paragraph style
- pDoc->SetTextFormatColl(aPam, pFromNode->GetTextColl());
-
- // using Undo, remove direct paragraph formatting of the "To" paragraph,
- // and apply here direct paragraph formatting of the "From" paragraph
- SfxItemSet aTmp(
- pDoc->GetAttrPool(),
- svl::Items<
- RES_PARATR_BEGIN, RES_PARATR_END - 3, // skip RSID and GRABBAG
- RES_PARATR_LIST_BEGIN, RES_UL_SPACE, // skip PAGEDESC and BREAK
- RES_CNTNT, RES_FRMATR_END - 1>{});
-
- SfxItemSet aTmp2(
- pDoc->GetAttrPool(),
- svl::Items<
- RES_PARATR_BEGIN, RES_PARATR_END - 3, // skip RSID and GRABBAG
- RES_PARATR_LIST_BEGIN, RES_UL_SPACE, // skip PAGEDESC and BREAK
- RES_CNTNT, RES_FRMATR_END - 1>{});
-
- pToNode->GetParaAttr(aTmp, 0, 0);
- pFromNode->GetParaAttr(aTmp2, 0, 0);
-
- for( sal_uInt16 nItem = 0; nItem < aTmp.TotalCount(); ++nItem)
- {
- sal_uInt16 nWhich = aTmp.GetWhichByPos(nItem);
- if( SfxItemState::SET == aTmp.GetItemState( nWhich, false ) &&
- SfxItemState::SET != aTmp2.GetItemState( nWhich, false ) )
- aTmp2.Put( aTmp.GetPool()->GetDefaultItem(nWhich), nWhich );
- }
-
- if (aTmp2.Count())
- pDoc->getIDocumentContentOperations().InsertItemSet(aPam, aTmp2);
-
- // TODO: store the original paragraph style as ExtraData
- }
- }
-
/// in case some text is deleted, ensure that the not-yet-inserted
/// SwRangeRedline has its positions corrected not to point to deleted node
class TemporaryRedlineUpdater