[Libreoffice-commits] core.git: sw/qa sw/source
László Németh (via logerrit)
logerrit at kemper.freedesktop.org
Thu Aug 1 07:44:58 UTC 2019
sw/qa/extras/uiwriter/uiwriter2.cxx | 14 +--
sw/source/core/doc/DocumentRedlineManager.cxx | 96 +++++++++++++-------------
2 files changed, 57 insertions(+), 53 deletions(-)
New commits:
commit 26c2cea1ab0efeb3ea641c335472e411dab2e928
Author: László Németh <nemeth at numbertext.org>
AuthorDate: Fri Jul 26 15:02:50 2019 +0200
Commit: László Németh <nemeth at numbertext.org>
CommitDate: Thu Aug 1 09:44:25 2019 +0200
tdf#118699 change tracking: fix accept before empty line
Empty paragraph after deletion of wholly paragraphs doesn't
get the style of the tracked deletion by accepting the change.
Fix also tdf#125916 again. Note: lcl_CopyStyle() hasn't been changed.
Change-Id: I07720ec7e11fe99c6e7accf19535e2eebade191f
Reviewed-on: https://gerrit.libreoffice.org/76381
Tested-by: Jenkins
Reviewed-by: László Németh <nemeth at numbertext.org>
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
More information about the Libreoffice-commits
mailing list