summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLászló Németh <nemeth@numbertext.org>2018-08-28 21:13:09 +0200
committerLászló Németh <nemeth@numbertext.org>2018-09-05 07:48:59 +0200
commit1bbbe57dfc0b43d6b5444798d77dcdf5e4e76e49 (patch)
tree52b256c96845b7082d916c255cbaa77594da4aa2
parent22639148ae5400bac98f32a75d7431b857c80195 (diff)
tdf#119571 change tracking: show layout changes at paragraph join
in Show changes mode, too. Delayed update of the paragraph layout at file saving etc. resulted invisible style changes. All removed paragraphs get the style of the first (partially deleted) paragraph to avoid text insertion with bad style in the deleted area later, as in MSO (except the incomplete undo of paragraph styles here and at other paragraph formattings during change tracking). Note: see also tdf#105413 for the remaining problem: style changes after deleted paragraphs are losing in Show changes mode. Change-Id: Ic6c6055c2e4da61755b09a1d78b4aa8826212047 Reviewed-on: https://gerrit.libreoffice.org/59821 Tested-by: Jenkins Reviewed-by: László Németh <nemeth@numbertext.org>
-rw-r--r--sw/qa/extras/uiwriter/uiwriter2.cxx39
-rw-r--r--sw/source/core/doc/DocumentRedlineManager.cxx22
2 files changed, 61 insertions, 0 deletions
diff --git a/sw/qa/extras/uiwriter/uiwriter2.cxx b/sw/qa/extras/uiwriter/uiwriter2.cxx
index 0a789a73b87d..77398885940c 100644
--- a/sw/qa/extras/uiwriter/uiwriter2.cxx
+++ b/sw/qa/extras/uiwriter/uiwriter2.cxx
@@ -24,10 +24,12 @@ class SwUiWriterTest2 : public SwModelTestBase
public:
void testTdf101534();
void testTdf54819();
+ void testTdf119571();
CPPUNIT_TEST_SUITE(SwUiWriterTest2);
CPPUNIT_TEST(testTdf101534);
CPPUNIT_TEST(testTdf54819);
+ CPPUNIT_TEST(testTdf119571);
CPPUNIT_TEST_SUITE_END();
};
@@ -91,6 +93,43 @@ void SwUiWriterTest2::testTdf54819()
getProperty<OUString>(getParagraph(1), "ParaStyleName"));
}
+void SwUiWriterTest2::testTdf119571()
+{
+ load(DATA_DIRECTORY, "tdf54819.fodt");
+
+ SwXTextDocument* pTextDoc = dynamic_cast<SwXTextDocument*>(mxComponent.get());
+ CPPUNIT_ASSERT(pTextDoc);
+
+ CPPUNIT_ASSERT_EQUAL(OUString("Heading 1"),
+ getProperty<OUString>(getParagraph(1), "ParaStyleName"));
+ CPPUNIT_ASSERT_EQUAL(OUString("Standard"),
+ getProperty<OUString>(getParagraph(2), "ParaStyleName"));
+
+ //turn on red-lining and show changes
+ SwDoc* pDoc = pTextDoc->GetDocShell()->GetDoc();
+ pDoc->getIDocumentRedlineAccess().SetRedlineFlags(RedlineFlags::On | RedlineFlags::ShowDelete
+ | RedlineFlags::ShowInsert);
+ CPPUNIT_ASSERT_MESSAGE("redlining should be on",
+ pDoc->getIDocumentRedlineAccess().IsRedlineOn());
+ CPPUNIT_ASSERT_MESSAGE(
+ "redlines should be visible",
+ IDocumentRedlineAccess::IsShowChanges(pDoc->getIDocumentRedlineAccess().GetRedlineFlags()));
+
+ // join paragraphs by removing the end of the first one with paragraph break
+ SwWrtShell* pWrtShell = pTextDoc->GetDocShell()->GetWrtShell();
+ pWrtShell->Right(CRSR_SKIP_CHARS, /*bSelect=*/false, 1, /*bBasicCall=*/false);
+ pWrtShell->EndPara(/*bSelect=*/true);
+ pWrtShell->Right(CRSR_SKIP_CHARS, /*bSelect=*/true, 1, /*bBasicCall=*/false);
+ rtl::Reference<SwTransferable> pTransfer = new SwTransferable(*pWrtShell);
+ pTransfer->Cut();
+
+ // second paragraph changes its style in "Show changes" mode
+ CPPUNIT_ASSERT_EQUAL(OUString("Heading 1"),
+ getProperty<OUString>(getParagraph(1), "ParaStyleName"));
+ CPPUNIT_ASSERT_EQUAL(OUString("Heading 1"),
+ getProperty<OUString>(getParagraph(2), "ParaStyleName"));
+}
+
CPPUNIT_TEST_SUITE_REGISTRATION(SwUiWriterTest2);
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sw/source/core/doc/DocumentRedlineManager.cxx b/sw/source/core/doc/DocumentRedlineManager.cxx
index 6838e7fc8dcd..c5b259f6aef6 100644
--- a/sw/source/core/doc/DocumentRedlineManager.cxx
+++ b/sw/source/core/doc/DocumentRedlineManager.cxx
@@ -1692,6 +1692,28 @@ DocumentRedlineManager::AppendRedline(SwRangeRedline* pNewRedl, bool const bCall
if (pDelNode != nullptr && pTextNode != nullptr && pDelNode != pTextNode)
pTextNode->CopyCollFormat( *pDelNode );
}
+ else
+ {
+ // tdf#119571 update the style of the joined paragraph
+ // after a partially deleted paragraph to show its correct style
+ // 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 )
+ pDelNode->CopyCollFormat( *pTextNode );
+ pTextNd = SwNodes::GoPrevious( &aIdx );
+ }
+ }
mpRedlineTable->Insert( pNewRedl );
}
}