sw/qa/extras/ooxmlexport/data/tdf125546.docx |binary sw/qa/extras/ooxmlexport/ooxmlexport11.cxx | 7 ++++ sw/qa/extras/ooxmlimport/ooxmlimport.cxx | 35 +++++++++++++++------- sw/qa/extras/uiwriter/uiwriter2.cxx | 4 -- writerfilter/source/dmapper/DomainMapper_Impl.cxx | 7 +++- 5 files changed, 39 insertions(+), 14 deletions(-)
New commits: commit a5abe0fc4d435d3a7a7de8bf55ec74087fdd299a Author: László Németh <nem...@numbertext.org> AuthorDate: Thu Jul 18 19:44:05 2019 +0200 Commit: László Németh <nem...@numbertext.org> CommitDate: Fri Jul 19 15:32:50 2019 +0200 tdf#125546 DOCX import: fix overgrowth of change tracking entries The same text portion could get double redlines including ParagraphFormat. This broke redline compression, sometimes resulting huge amount of redundant change tracking entries based on rsId, or losing paragraph styles after deletion. Change-Id: I5930eab2ef0bc7eb9c93a10cdd30b96cd41c9098 Reviewed-on: https://gerrit.libreoffice.org/75926 Tested-by: Jenkins Reviewed-by: László Németh <nem...@numbertext.org> diff --git a/sw/qa/extras/ooxmlexport/data/tdf125546.docx b/sw/qa/extras/ooxmlexport/data/tdf125546.docx new file mode 100644 index 000000000000..92e3bdcd1586 Binary files /dev/null and b/sw/qa/extras/ooxmlexport/data/tdf125546.docx differ diff --git a/sw/qa/extras/ooxmlexport/ooxmlexport11.cxx b/sw/qa/extras/ooxmlexport/ooxmlexport11.cxx index c542a7b4394b..e4c60af21ea9 100644 --- a/sw/qa/extras/ooxmlexport/ooxmlexport11.cxx +++ b/sw/qa/extras/ooxmlexport/ooxmlexport11.cxx @@ -891,6 +891,13 @@ DECLARE_OOXMLEXPORT_EXPORTONLY_TEST(testTdf125894, "tdf125894.docx") assertXPath(pXmlDoc, "//w:ins"); } +DECLARE_OOXMLEXPORT_EXPORTONLY_TEST(testTdf125546, "tdf125546.docx") +{ + xmlDocPtr pXmlDoc = parseExport("word/document.xml"); + // compress redlines (it was 15) + assertXPath(pXmlDoc, "//w:rPrChange", 2); +} + DECLARE_OOXMLEXPORT_TEST(testTdf118691, "tdf118691.docx") { uno::Reference<text::XTextTablesSupplier> xTablesSupplier(mxComponent, uno::UNO_QUERY); diff --git a/sw/qa/extras/ooxmlimport/ooxmlimport.cxx b/sw/qa/extras/ooxmlimport/ooxmlimport.cxx index b49583b3b4d0..e9901a72cba7 100644 --- a/sw/qa/extras/ooxmlimport/ooxmlimport.cxx +++ b/sw/qa/extras/ooxmlimport/ooxmlimport.cxx @@ -942,6 +942,7 @@ DECLARE_OOXMLIMPORT_TEST(testBnc821804, "bnc821804.docx") CPPUNIT_ASSERT_EQUAL(OUString(" (1st run of an insert) (2nd run of an insert)"), getRun(getParagraph(1),3)->getString()); CPPUNIT_ASSERT(!hasProperty(getRun(getParagraph(1), 3), "RedlineType")); // And the end SwXRedlinePortion of the redline. + CPPUNIT_ASSERT(hasProperty(getRun(getParagraph(1), 4), "RedlineType")); CPPUNIT_ASSERT_EQUAL(OUString("Insert"),getProperty<OUString>(getRun(getParagraph(1), 4), "RedlineType")); CPPUNIT_ASSERT_EQUAL(OUString("unknown1"),getProperty<OUString>(getRun(getParagraph(1), 4), "RedlineAuthor")); CPPUNIT_ASSERT_EQUAL(OString("2006-08-29T09:46:00Z"),dateTimeToString(getProperty<util::DateTime>(getRun(getParagraph(1), 4), "RedlineDateTime"))); @@ -950,6 +951,7 @@ DECLARE_OOXMLIMPORT_TEST(testBnc821804, "bnc821804.docx") CPPUNIT_ASSERT_EQUAL(OUString("Normal text"), getRun(getParagraph(2),1)->getString()); CPPUNIT_ASSERT(!hasProperty(getRun(getParagraph(2), 1), "RedlineType")); + CPPUNIT_ASSERT(hasProperty(getRun(getParagraph(3), 1), "RedlineType")); CPPUNIT_ASSERT_EQUAL(OUString("Delete"),getProperty<OUString>(getRun(getParagraph(3), 1), "RedlineType")); CPPUNIT_ASSERT_EQUAL(OUString("unknown2"),getProperty<OUString>(getRun(getParagraph(3), 1), "RedlineAuthor")); CPPUNIT_ASSERT_EQUAL(OString("2006-08-29T09:47:00Z"),dateTimeToString(getProperty<util::DateTime>(getRun(getParagraph(3), 1), "RedlineDateTime"))); @@ -957,34 +959,40 @@ DECLARE_OOXMLIMPORT_TEST(testBnc821804, "bnc821804.docx") // This is both inserted and formatted, so there are two SwXRedlinePortion "runs". Given that the redlines overlap and Writer core // doesn't officially expect that (even though it copes, the redline info will be split depending on how Writer deal with it). + CPPUNIT_ASSERT(hasProperty(getRun(getParagraph(4), 1), "RedlineType")); CPPUNIT_ASSERT_EQUAL(OUString("Insert"),getProperty<OUString>(getRun(getParagraph(4), 1), "RedlineType")); CPPUNIT_ASSERT_EQUAL(true,getProperty<bool>(getRun(getParagraph(4), 1), "IsStart")); - CPPUNIT_ASSERT_EQUAL(OUString("ParagraphFormat"),getProperty<OUString>(getRun(getParagraph(4), 2), "RedlineType")); - CPPUNIT_ASSERT_EQUAL(true,getProperty<bool>(getRun(getParagraph(4), 2), "IsStart")); - CPPUNIT_ASSERT_EQUAL(OUString("Inserted and formatted"), getRun(getParagraph(4),3)->getString()); - CPPUNIT_ASSERT_EQUAL(OUString("Insert"),getProperty<OUString>(getRun(getParagraph(4), 4), "RedlineType")); - CPPUNIT_ASSERT_EQUAL(false,getProperty<bool>(getRun(getParagraph(4), 4), "IsStart")); + CPPUNIT_ASSERT(!hasProperty(getRun(getParagraph(4), 2), "RedlineType")); + CPPUNIT_ASSERT_EQUAL(OUString("Inserted and formatted"), getRun(getParagraph(4),2)->getString()); + CPPUNIT_ASSERT(hasProperty(getRun(getParagraph(4), 3), "RedlineType")); + CPPUNIT_ASSERT_EQUAL(OUString("Insert"),getProperty<OUString>(getRun(getParagraph(4), 3), "RedlineType")); + CPPUNIT_ASSERT_EQUAL(false,getProperty<bool>(getRun(getParagraph(4), 3), "IsStart")); CPPUNIT_ASSERT_EQUAL(OUString(" and this is only formatted"), getRun(getParagraph(4),5)->getString()); + CPPUNIT_ASSERT(hasProperty(getRun(getParagraph(4), 6), "RedlineType")); CPPUNIT_ASSERT_EQUAL(OUString("ParagraphFormat"),getProperty<OUString>(getRun(getParagraph(4), 6), "RedlineType")); CPPUNIT_ASSERT_EQUAL(false,getProperty<bool>(getRun(getParagraph(4), 6), "IsStart")); CPPUNIT_ASSERT_EQUAL(OUString("Normal text"), getRun(getParagraph(5),1)->getString()); CPPUNIT_ASSERT(!hasProperty(getRun(getParagraph(5), 1), "RedlineType")); + CPPUNIT_ASSERT(hasProperty(getRun(getParagraph(6), 1), "RedlineType")); CPPUNIT_ASSERT_EQUAL(OUString("Format"),getProperty<OUString>(getRun(getParagraph(6), 1), "RedlineType")); CPPUNIT_ASSERT_EQUAL(true,getProperty<bool>(getRun(getParagraph(6), 1), "IsStart")); CPPUNIT_ASSERT_EQUAL(OUString("unknown5"),getProperty<OUString>(getRun(getParagraph(6), 1), "RedlineAuthor")); CPPUNIT_ASSERT_EQUAL(OString("2006-08-29T10:02:00Z"),dateTimeToString(getProperty<util::DateTime>(getRun(getParagraph(6), 1), "RedlineDateTime"))); CPPUNIT_ASSERT_EQUAL(OUString("Formatted run"), getRun(getParagraph(6),2)->getString()); + CPPUNIT_ASSERT(hasProperty(getRun(getParagraph(6), 3), "RedlineType")); CPPUNIT_ASSERT_EQUAL(OUString("Format"),getProperty<OUString>(getRun(getParagraph(6), 3), "RedlineType")); CPPUNIT_ASSERT_EQUAL(false,getProperty<bool>(getRun(getParagraph(6), 3), "IsStart")); CPPUNIT_ASSERT_EQUAL(OUString(" and normal text here "), getRun(getParagraph(6),4)->getString()); CPPUNIT_ASSERT(!hasProperty(getRun(getParagraph(6), 4), "RedlineType")); + CPPUNIT_ASSERT(hasProperty(getRun(getParagraph(6), 5), "RedlineType")); CPPUNIT_ASSERT_EQUAL(OUString("Insert"),getProperty<OUString>(getRun(getParagraph(6), 5), "RedlineType")); CPPUNIT_ASSERT_EQUAL(true,getProperty<bool>(getRun(getParagraph(6), 5), "IsStart")); CPPUNIT_ASSERT_EQUAL(OUString("unknown6"),getProperty<OUString>(getRun(getParagraph(6), 5), "RedlineAuthor")); CPPUNIT_ASSERT_EQUAL(OString("2006-08-29T09:48:00Z"),dateTimeToString(getProperty<util::DateTime>(getRun(getParagraph(6), 5), "RedlineDateTime"))); CPPUNIT_ASSERT_EQUAL(OUString("and inserted again"), getRun(getParagraph(6),6)->getString()); + CPPUNIT_ASSERT(hasProperty(getRun(getParagraph(6), 7), "RedlineType")); CPPUNIT_ASSERT_EQUAL(OUString("Insert"),getProperty<OUString>(getRun(getParagraph(6), 7), "RedlineType")); CPPUNIT_ASSERT_EQUAL(false,getProperty<bool>(getRun(getParagraph(6), 7), "IsStart")); CPPUNIT_ASSERT_EQUAL(OUString(" and normal text again "), getRun(getParagraph(6),8)->getString()); @@ -997,27 +1005,32 @@ DECLARE_OOXMLIMPORT_TEST(testBnc821804, "bnc821804.docx") CPPUNIT_ASSERT_EQUAL(OUString(" and normal."), getRun(getParagraph(6),12)->getString()); CPPUNIT_ASSERT(!hasProperty(getRun(getParagraph(6), 12), "RedlineType")); + CPPUNIT_ASSERT(hasProperty(getRun(getParagraph(7), 1), "RedlineType")); CPPUNIT_ASSERT_EQUAL(OUString("Insert"),getProperty<OUString>(getRun(getParagraph(7), 1), "RedlineType")); CPPUNIT_ASSERT_EQUAL(true,getProperty<bool>(getRun(getParagraph(7), 1), "IsStart")); CPPUNIT_ASSERT_EQUAL(OUString("unknown8"),getProperty<OUString>(getRun(getParagraph(7), 1), "RedlineAuthor")); CPPUNIT_ASSERT_EQUAL(OUString("One insert."), getRun(getParagraph(7),2)->getString()); + CPPUNIT_ASSERT(hasProperty(getRun(getParagraph(7), 3), "RedlineType")); CPPUNIT_ASSERT_EQUAL(OUString("Insert"),getProperty<OUString>(getRun(getParagraph(7), 3), "RedlineType")); CPPUNIT_ASSERT_EQUAL(false,getProperty<bool>(getRun(getParagraph(7), 3), "IsStart")); + CPPUNIT_ASSERT(hasProperty(getRun(getParagraph(7), 4), "RedlineType")); CPPUNIT_ASSERT_EQUAL(OUString("Insert"),getProperty<OUString>(getRun(getParagraph(7), 4), "RedlineType")); CPPUNIT_ASSERT_EQUAL(true,getProperty<bool>(getRun(getParagraph(7), 4), "IsStart")); CPPUNIT_ASSERT_EQUAL(OUString("unknown9"),getProperty<OUString>(getRun(getParagraph(7), 4), "RedlineAuthor")); CPPUNIT_ASSERT_EQUAL(OUString("Second insert."), getRun(getParagraph(7),5)->getString()); + CPPUNIT_ASSERT(hasProperty(getRun(getParagraph(7), 6), "RedlineType")); CPPUNIT_ASSERT_EQUAL(OUString("Insert"),getProperty<OUString>(getRun(getParagraph(7), 6), "RedlineType")); CPPUNIT_ASSERT_EQUAL(false,getProperty<bool>(getRun(getParagraph(7), 6), "IsStart")); // Overlapping again. + CPPUNIT_ASSERT(hasProperty(getRun(getParagraph(8), 1), "RedlineType")); CPPUNIT_ASSERT_EQUAL(OUString("Delete"),getProperty<OUString>(getRun(getParagraph(8), 1), "RedlineType")); CPPUNIT_ASSERT_EQUAL(true,getProperty<bool>(getRun(getParagraph(8), 1), "IsStart")); - CPPUNIT_ASSERT_EQUAL(OUString("ParagraphFormat"),getProperty<OUString>(getRun(getParagraph(8), 2), "RedlineType")); - CPPUNIT_ASSERT_EQUAL(true,getProperty<bool>(getRun(getParagraph(8), 2), "IsStart")); - CPPUNIT_ASSERT_EQUAL(OUString("Deleted and formatted"), getRun(getParagraph(8),3)->getString()); - CPPUNIT_ASSERT_EQUAL(OUString("Delete"),getProperty<OUString>(getRun(getParagraph(8), 4), "RedlineType")); - CPPUNIT_ASSERT_EQUAL(false,getProperty<bool>(getRun(getParagraph(8), 4), "IsStart")); + CPPUNIT_ASSERT(!hasProperty(getRun(getParagraph(8), 2), "RedlineType")); + CPPUNIT_ASSERT_EQUAL(OUString("Deleted and formatted"), getRun(getParagraph(8),2)->getString()); + CPPUNIT_ASSERT(hasProperty(getRun(getParagraph(8), 4), "RedlineType")); + CPPUNIT_ASSERT_EQUAL(OUString("ParagraphFormat"),getProperty<OUString>(getRun(getParagraph(8), 4), "RedlineType")); + CPPUNIT_ASSERT_EQUAL(true,getProperty<bool>(getRun(getParagraph(8), 4), "IsStart")); CPPUNIT_ASSERT_EQUAL(OUString(" and this is only formatted"), getRun(getParagraph(8),5)->getString()); CPPUNIT_ASSERT_EQUAL(OUString("ParagraphFormat"),getProperty<OUString>(getRun(getParagraph(8), 6), "RedlineType")); CPPUNIT_ASSERT_EQUAL(false,getProperty<bool>(getRun(getParagraph(8), 6), "IsStart")); @@ -1025,9 +1038,11 @@ DECLARE_OOXMLIMPORT_TEST(testBnc821804, "bnc821804.docx") CPPUNIT_ASSERT_EQUAL(OUString("Normal text"), getRun(getParagraph(9),1)->getString()); CPPUNIT_ASSERT(!hasProperty(getRun(getParagraph(9), 1), "RedlineType")); + CPPUNIT_ASSERT(hasProperty(getRun(getParagraph(10), 1), "RedlineType")); CPPUNIT_ASSERT_EQUAL(OUString("ParagraphFormat"),getProperty<OUString>(getRun(getParagraph(10), 1), "RedlineType")); CPPUNIT_ASSERT_EQUAL(true,getProperty<bool>(getRun(getParagraph(10), 1), "IsStart")); CPPUNIT_ASSERT_EQUAL(OUString("This is only formatted."), getRun(getParagraph(10),2)->getString()); + CPPUNIT_ASSERT(hasProperty(getRun(getParagraph(10), 3), "RedlineType")); CPPUNIT_ASSERT_EQUAL(OUString("ParagraphFormat"),getProperty<OUString>(getRun(getParagraph(10), 3), "RedlineType")); CPPUNIT_ASSERT_EQUAL(false,getProperty<bool>(getRun(getParagraph(10), 3), "IsStart")); } diff --git a/sw/qa/extras/uiwriter/uiwriter2.cxx b/sw/qa/extras/uiwriter/uiwriter2.cxx index b48dfdf40dd4..a5298652f5a2 100644 --- a/sw/qa/extras/uiwriter/uiwriter2.cxx +++ b/sw/qa/extras/uiwriter/uiwriter2.cxx @@ -711,9 +711,7 @@ CPPUNIT_TEST_FIXTURE(SwUiWriterTest2, testTdf119824) // and a tracked text deletion at the beginning of the paragraph CPPUNIT_ASSERT_EQUAL(OUString("Pellentesque habitant morbi tristique senectus "), - getRun(getParagraph(3), 3)->getString()); - CPPUNIT_ASSERT_EQUAL(OUString(""), getRun(getParagraph(3), 2)->getString()); - CPPUNIT_ASSERT(hasProperty(getRun(getParagraph(3), 2), "RedlineType")); + getRun(getParagraph(3), 2)->getString()); // delete last word of the third paragraph to remove tracked paragraph formatting // of this paragraph to track and show word deletion correctly. diff --git a/writerfilter/source/dmapper/DomainMapper_Impl.cxx b/writerfilter/source/dmapper/DomainMapper_Impl.cxx index 21beb6965bf9..62eab11b16cc 100644 --- a/writerfilter/source/dmapper/DomainMapper_Impl.cxx +++ b/writerfilter/source/dmapper/DomainMapper_Impl.cxx @@ -2146,11 +2146,16 @@ void DomainMapper_Impl::CheckRedline( uno::Reference< text::XTextRange > const& // (and so if that happens, it may be better to fix Writer). // Create the redlines here from lowest (formats) to highest (inserts/removals) priority, since the last one is // what Writer presents graphically, so this will show deletes as deleted text and not as just formatted text being there. - if( GetTopContextOfType(CONTEXT_PARAGRAPH) ) + bool bUsedRange = m_aRedlines.top().size() > 0 || (GetTopContextOfType(CONTEXT_CHARACTER) && + GetTopContextOfType(CONTEXT_CHARACTER)->Redlines().size() > 0); + + // only export ParagraphFormat, when there is no other redline in the same text portion to avoid missing redline compression + if( !bUsedRange && GetTopContextOfType(CONTEXT_PARAGRAPH) ) { std::vector<RedlineParamsPtr>& avRedLines = GetTopContextOfType(CONTEXT_PARAGRAPH)->Redlines(); for( const auto& rRedline : avRedLines ) CreateRedline( xRange, rRedline ); + return; } if( GetTopContextOfType(CONTEXT_CHARACTER) ) { _______________________________________________ Libreoffice-commits mailing list libreoffice-comm...@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits