diff options
author | László Németh <nemeth@numbertext.org> | 2019-08-02 13:14:11 +0200 |
---|---|---|
committer | László Németh <nemeth@numbertext.org> | 2019-08-22 14:59:46 +0200 |
commit | 2f2409fdac98cc3470ad8fa1d45ab84bb50e929c (patch) | |
tree | 79c08f0eb7d11e554d4a07afd438b465b5713bda /sw | |
parent | c76e30707e08705a90bbfc089975b0cafd84dc8a (diff) |
tdf#127097 Change tracking: change style of whole deletion at paragraph join
in all deleted paragraphs to avoid editing problems later.
This reverts the behaviour of paragraph join changed by
commit 705b728d26b4480ec6b51d9fe1362a0154ea9bf9
"tdf#119571 fix style & numbering at tracked deletion", but
now Undo undoes the (sometimes different) styles of the
deleted paragraphs in the same deletion, instead of losing them.
Change-Id: Ic4641356c28f005efb43bf71b5b23a7bd054fecd
Reviewed-on: https://gerrit.libreoffice.org/76862
Reviewed-by: László Németh <nemeth@numbertext.org>
Tested-by: László Németh <nemeth@numbertext.org>
Diffstat (limited to 'sw')
-rw-r--r-- | sw/qa/extras/uiwriter/uiwriter2.cxx | 29 | ||||
-rw-r--r-- | sw/source/core/doc/DocumentRedlineManager.cxx | 24 |
2 files changed, 46 insertions, 7 deletions
diff --git a/sw/qa/extras/uiwriter/uiwriter2.cxx b/sw/qa/extras/uiwriter/uiwriter2.cxx index 4693139a207a..0d35c0cec77f 100644 --- a/sw/qa/extras/uiwriter/uiwriter2.cxx +++ b/sw/qa/extras/uiwriter/uiwriter2.cxx @@ -382,7 +382,8 @@ CPPUNIT_TEST_FIXTURE(SwUiWriterTest2, testTdf54819_keep_numbering_with_Undo) CPPUNIT_TEST_FIXTURE(SwUiWriterTest2, testTdf119571_keep_numbering_with_Undo) { - // as the previous test, but with partial paragraph deletion + // as the previous test, but with partial paragraph deletion: + // all deleted paragraphs get the formatting of the first (the partially deleted) one load(DATA_DIRECTORY, "tdf54819b.odt"); SwXTextDocument* pTextDoc = dynamic_cast<SwXTextDocument*>(mxComponent.get()); @@ -403,6 +404,13 @@ CPPUNIT_TEST_FIXTURE(SwUiWriterTest2, testTdf119571_keep_numbering_with_Undo) CPPUNIT_ASSERT_MESSAGE("Missing numbering style", !sNumName.isEmpty()); CPPUNIT_ASSERT_MESSAGE("Not a bulleted list item", sNumName != "Outline"); + // third paragraph: normal text without numbering + + CPPUNIT_ASSERT_EQUAL(OUString("Standard"), + getProperty<OUString>(getParagraph(4), "ParaStyleName")); + sNumName = getProperty<OUString>(getParagraph(4), "NumberingStyleName"); + CPPUNIT_ASSERT_MESSAGE("Bad numbering", sNumName.isEmpty()); + //turn on red-lining and show changes SwDoc* pDoc = pTextDoc->GetDocShell()->GetDoc(); pDoc->getIDocumentRedlineAccess().SetRedlineFlags(RedlineFlags::On | RedlineFlags::ShowDelete @@ -414,7 +422,7 @@ CPPUNIT_TEST_FIXTURE(SwUiWriterTest2, testTdf119571_keep_numbering_with_Undo) !IDocumentRedlineAccess::IsShowChanges( pDoc->getIDocumentRedlineAccess().GetRedlineFlags())); - // remove only end part of the heading with paragraph break + // remove only end part of the heading and the next numbered paragraph with paragraph break SwWrtShell* pWrtShell = pTextDoc->GetDocShell()->GetWrtShell(); pWrtShell->Down(/*bSelect=*/false); @@ -422,7 +430,9 @@ CPPUNIT_TEST_FIXTURE(SwUiWriterTest2, testTdf119571_keep_numbering_with_Undo) pWrtShell->Down(/*bSelect=*/false); pWrtShell->Down(/*bSelect=*/false); pWrtShell->Down(/*bSelect=*/false); - pWrtShell->Right(CRSR_SKIP_CHARS, /*bSelect=*/false, 1, /*bBasicCall=*/false); + pWrtShell->Right(CRSR_SKIP_CHARS, /*bSelect=*/false, 6, /*bBasicCall=*/false); + pWrtShell->EndPara(/*bSelect=*/true); + pWrtShell->Right(CRSR_SKIP_CHARS, /*bSelect=*/true, 2, /*bBasicCall=*/false); pWrtShell->EndPara(/*bSelect=*/true); pWrtShell->Right(CRSR_SKIP_CHARS, /*bSelect=*/true, 1, /*bBasicCall=*/false); rtl::Reference<SwTransferable> pTransfer = new SwTransferable(*pWrtShell); @@ -436,10 +446,14 @@ CPPUNIT_TEST_FIXTURE(SwUiWriterTest2, testTdf119571_keep_numbering_with_Undo) CPPUNIT_ASSERT_EQUAL(OUString("Outline"), getProperty<OUString>(getParagraph(2), "NumberingStyleName")); - // accept deletion, remaining (now second) paragraph: it is still heading + // accept deletion IDocumentRedlineAccess& rIDRA(pDoc->getIDocumentRedlineAccess()); rIDRA.AcceptAllRedline(true); + // Joined paragraph 2 and paragraph 4: Fusce...nunc. + CPPUNIT_ASSERT(getParagraph(2)->getString().startsWith("Fusce")); + CPPUNIT_ASSERT(getParagraph(2)->getString().endsWith("nunc.")); + // Remaining (now second) paragraph: it is still heading CPPUNIT_ASSERT_EQUAL(OUString("Heading 1"), getProperty<OUString>(getParagraph(2), "ParaStyleName")); CPPUNIT_ASSERT_EQUAL(OUString("Outline"), @@ -464,6 +478,13 @@ CPPUNIT_TEST_FIXTURE(SwUiWriterTest2, testTdf119571_keep_numbering_with_Undo) sNumName = getProperty<OUString>(getParagraph(3), "NumberingStyleName"); CPPUNIT_ASSERT_MESSAGE("Missing numbering style", !sNumName.isEmpty()); CPPUNIT_ASSERT_MESSAGE("Not a bulleted list item", sNumName != "Outline"); + + // third paragraph: normal text without numbering + + CPPUNIT_ASSERT_EQUAL(OUString("Standard"), + getProperty<OUString>(getParagraph(4), "ParaStyleName")); + sNumName = getProperty<OUString>(getParagraph(4), "NumberingStyleName"); + CPPUNIT_ASSERT_MESSAGE("Bad numbering", sNumName.isEmpty()); } CPPUNIT_TEST_FIXTURE(SwUiWriterTest2, testTdf109376_redline) diff --git a/sw/source/core/doc/DocumentRedlineManager.cxx b/sw/source/core/doc/DocumentRedlineManager.cxx index cee1fe0e29ea..84a154ae54ba 100644 --- a/sw/source/core/doc/DocumentRedlineManager.cxx +++ b/sw/source/core/doc/DocumentRedlineManager.cxx @@ -2009,9 +2009,27 @@ DocumentRedlineManager::AppendRedline(SwRangeRedline* pNewRedl, bool const bCall { // tdf#119571 update the style of the joined paragraph // after a partially deleted paragraph to show its correct style - // in "Show changes" mode, too. The paragraph after the deletion - // gets the style of the first (partially deleted) paragraph. - lcl_CopyStyle(*pStt, *pEnd); // TODO: do for all paragraphs of the deletion + // in "Show changes" mode, too. All removed paragraphs + // get the style of the first (partially deleted) paragraph + // to avoid text insertion with bad style in the deleted + // area later. + + SwContentNode* pDelNd = pStt->nNode.GetNode().GetContentNode(); + SwContentNode* pTextNd = pEnd->nNode.GetNode().GetContentNode(); + SwTextNode* pDelNode = pStt->nNode.GetNode().GetTextNode(); + SwTextNode* pTextNode; + SwNodeIndex aIdx( pEnd->nNode.GetNode() ); + + while (pDelNode != nullptr && pTextNd != nullptr && pDelNd->GetIndex() < pTextNd->GetIndex()) + { + pTextNode = pTextNd->GetTextNode(); + if (pTextNode && pDelNode != pTextNode ) + { + SwPosition aPos(aIdx); + lcl_CopyStyle(*pStt, aPos); + } + pTextNd = SwNodes::GoPrevious( &aIdx ); + } } } bool const ret = mpRedlineTable->Insert( pNewRedl ); |