sw/qa/core/docnode/docnode.cxx | 4 +- sw/qa/extras/layout/data/tdf145719.odt |binary sw/qa/extras/layout/layout2.cxx | 34 +++++++++++++++++++++++ sw/qa/extras/ooxmlexport/data/tdf149388.docx |binary sw/qa/extras/ooxmlexport/data/tdf149388_fly.docx |binary sw/qa/extras/ooxmlexport/ooxmlexport12.cxx | 32 ++++++++++++++++++++- sw/qa/extras/ooxmlexport/ooxmlexport16.cxx | 7 ++-- sw/source/core/doc/docredln.cxx | 6 +++- 8 files changed, 75 insertions(+), 8 deletions(-)
New commits: commit 7d410442ad6d04a3da71d8b0f6ceca6e5e30adbf Author: László Németh <nem...@numbertext.org> AuthorDate: Wed Aug 3 14:11:36 2022 +0200 Commit: László Németh <nem...@numbertext.org> CommitDate: Fri Aug 19 08:01:34 2022 +0200 tdf#149388 sw: add better limit to detect tracked text moving Detection of tracked text moving needs at least 6 characters with an inner space after stripping white spaces of its redline. This way frequent deletion and insertion of articles or other common word parts, e.g. 'the' and 'of a' won't detected as text moving by mistake. Note: to still detect their redlines, as text moving, update test document of testTdf145719 to contain moved text "dolor sit" instead of "dolor", also testRedlineMoving to move list item "An ItemIt" instead of "It", and add testTdf149388 with test document of the original testTdf132371, where redline containing "Third" is not detected as text moving, unlike the new test document of the new testTdf132371, which contains "Third etc." (at least 6 character text with at least an inner space). Change-Id: I7f24fadebe2e21ae303677f74001dbc2d2ad87a1 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/137749 Tested-by: Jenkins Reviewed-by: László Németh <nem...@numbertext.org> (cherry picked from commit 4b885c30c292f4a08983630cb140e16a437cc63d) Reviewed-on: https://gerrit.libreoffice.org/c/core/+/137814 diff --git a/sw/qa/core/docnode/docnode.cxx b/sw/qa/core/docnode/docnode.cxx index 4dbf3630f3f4..4967b95d955d 100644 --- a/sw/qa/core/docnode/docnode.cxx +++ b/sw/qa/core/docnode/docnode.cxx @@ -40,10 +40,10 @@ CPPUNIT_TEST_FIXTURE(Test, testTdf150086) // Load a document where an insert redline ends right before a ToC SwDoc* pDoc = createSwDoc(DATA_DIRECTORY, "tdf150086.docx"); const SwRedlineTable& rTable = pDoc->getIDocumentRedlineAccess().GetRedlineTable(); - CPPUNIT_ASSERT_EQUAL(static_cast<SwRedlineTable::size_type>(9), rTable.size()); + CPPUNIT_ASSERT_EQUAL(static_cast<SwRedlineTable::size_type>(8), rTable.size()); // This was "Conte" (stripped redline) - CPPUNIT_ASSERT_EQUAL(OUString("Content"), rTable[6]->GetText()); + CPPUNIT_ASSERT_EQUAL(OUString("Content\n"), rTable[6]->GetText()); } CPPUNIT_PLUGIN_IMPLEMENT(); diff --git a/sw/qa/extras/layout/data/tdf145719.odt b/sw/qa/extras/layout/data/tdf145719.odt index 62e4cc4a73e4..5f2c6f665853 100644 Binary files a/sw/qa/extras/layout/data/tdf145719.odt and b/sw/qa/extras/layout/data/tdf145719.odt differ diff --git a/sw/qa/extras/layout/layout2.cxx b/sw/qa/extras/layout/layout2.cxx index d602d74c9bba..00d7a8e65a48 100644 --- a/sw/qa/extras/layout/layout2.cxx +++ b/sw/qa/extras/layout/layout2.cxx @@ -508,6 +508,40 @@ CPPUNIT_TEST_FIXTURE(SwLayoutWriter2, testRedlineMoving) xmlDocUniquePtr pXmlDoc = dumpAndParse(dumper, *xMetaFile); CPPUNIT_ASSERT(pXmlDoc); + // text and numbering colors show moving of the list item + // tdf#145719: the moved text item "It" is not detected as text moving, + // because it consists of less than 6 characters after stripping its spaces + assertXPath(pXmlDoc, "/metafile/push/push/push/textcolor[@color='#008000']", 0); + assertXPath(pXmlDoc, "/metafile/push/push/push/font[@color='#008000']", 0); +} + +CPPUNIT_TEST_FIXTURE(SwLayoutWriter2, testRedlineMoving2) +{ + SwDoc* pDoc = createSwDoc(DATA_DIRECTORY, "tdf42748.fodt"); + SwDocShell* pShell = pDoc->GetDocShell(); + + // create a 3-element list without change tracking + SwEditShell* const pEditShell(pDoc->GetEditShell()); + pEditShell->RejectRedline(0); + pEditShell->AcceptRedline(0); + + // extend the first item to "An ItemIt", because detection of move needs + // at least 6 characters with an inner space after stripping white spaces + // of the redline + dispatchCommand(mxComponent, ".uno:GoToStartOfDoc", {}); + SwWrtShell* pWrtShell = pDoc->GetDocShell()->GetWrtShell(); + pWrtShell->Insert("An Item"); + + // move down first list item with track changes + dispatchCommand(mxComponent, ".uno:TrackChanges", {}); + dispatchCommand(mxComponent, ".uno:MoveDown", {}); + + // Dump the rendering of the first page as an XML file. + std::shared_ptr<GDIMetaFile> xMetaFile = pShell->GetPreviewMetaFile(); + MetafileXmlDump dumper; + xmlDocUniquePtr pXmlDoc = dumpAndParse(dumper, *xMetaFile); + CPPUNIT_ASSERT(pXmlDoc); + // text and numbering colors show moving of the list item // These were 0 (other color, not COL_GREEN, color of the tracked text movement) assertXPath(pXmlDoc, "/metafile/push/push/push/textcolor[@color='#008000']", 5); diff --git a/sw/qa/extras/ooxmlexport/data/tdf149388.docx b/sw/qa/extras/ooxmlexport/data/tdf149388.docx new file mode 100644 index 000000000000..9b9702819959 Binary files /dev/null and b/sw/qa/extras/ooxmlexport/data/tdf149388.docx differ diff --git a/sw/qa/extras/ooxmlexport/data/tdf149388_fly.docx b/sw/qa/extras/ooxmlexport/data/tdf149388_fly.docx new file mode 100644 index 000000000000..92b9cf92ba8d Binary files /dev/null and b/sw/qa/extras/ooxmlexport/data/tdf149388_fly.docx differ diff --git a/sw/qa/extras/ooxmlexport/ooxmlexport12.cxx b/sw/qa/extras/ooxmlexport/ooxmlexport12.cxx index 0f4913375aac..a2103113c2ff 100644 --- a/sw/qa/extras/ooxmlexport/ooxmlexport12.cxx +++ b/sw/qa/extras/ooxmlexport/ooxmlexport12.cxx @@ -1480,11 +1480,26 @@ CPPUNIT_TEST_FIXTURE(Test, testTdf125894) assertXPath(pXmlDoc, "//w:ins"); } -CPPUNIT_TEST_FIXTURE(Test, testTdf132271) +CPPUNIT_TEST_FIXTURE(Test, testTdf149388) { + // see also testTdf132371 loadAndSave("tdf132271.docx"); xmlDocUniquePtr pXmlDoc = parseExport("word/document.xml"); // import change tracking in floating tables + // (don't recognize tracked text moving during the import, + // because the text is too short and it's only a single word) + assertXPath(pXmlDoc, "//w:del", 2); + assertXPath(pXmlDoc, "//w:ins", 2); + assertXPath(pXmlDoc, "//w:moveFrom", 0); + assertXPath(pXmlDoc, "//w:moveTo", 0); +} + +CPPUNIT_TEST_FIXTURE(Test, testTdf132271) +{ + // see also testTdf149388 + loadAndSave("tdf149388.docx"); + xmlDocUniquePtr pXmlDoc = parseExport("word/document.xml"); + // import change tracking in floating tables if (!mbExported) { assertXPath(pXmlDoc, "//w:del", 2); @@ -1502,11 +1517,24 @@ CPPUNIT_TEST_FIXTURE(Test, testTdf132271) } } -CPPUNIT_TEST_FIXTURE(Test, testTdf136667) +CPPUNIT_TEST_FIXTURE(Test, testTdf149388_fly) { + // see also testTdf136667 loadAndSave("tdf136667.docx"); xmlDocUniquePtr pXmlDoc = parseExport("word/document.xml"); // import change tracking in floating tables + assertXPath(pXmlDoc, "//w:del", 2); + assertXPath(pXmlDoc, "//w:ins", 4); + assertXPath(pXmlDoc, "//w:moveFrom", 0); + assertXPath(pXmlDoc, "//w:moveTo", 0); +} + +CPPUNIT_TEST_FIXTURE(Test, testTdf136667) +{ + // see also testTdf149388_fly + loadAndSave("tdf149388_fly.docx"); + xmlDocUniquePtr pXmlDoc = parseExport("word/document.xml"); + // import change tracking in floating tables if (!mbExported) { assertXPath(pXmlDoc, "//w:del", 2); diff --git a/sw/qa/extras/ooxmlexport/ooxmlexport16.cxx b/sw/qa/extras/ooxmlexport/ooxmlexport16.cxx index 6b5f11830dd6..6de87f58ced9 100644 --- a/sw/qa/extras/ooxmlexport/ooxmlexport16.cxx +++ b/sw/qa/extras/ooxmlexport/ooxmlexport16.cxx @@ -664,12 +664,13 @@ CPPUNIT_TEST_FIXTURE(Test, testTdf146171_invalid_change_date) xmlDocUniquePtr pXmlDoc = parseExport(); // This was 0 - assertXPath(pXmlDoc, "//w:ins", 4); + assertXPath(pXmlDoc, "//w:ins", 5); // This was 0 - assertXPath(pXmlDoc, "//w:del", 1); + assertXPath(pXmlDoc, "//w:del", 2); // no date (anonymized change) // This failed, date was exported as w:date="1970-01-01T00:00:00Z" before fixing tdf#147760 - assertXPathNoAttribute(pXmlDoc, "//w:del", "date"); + assertXPathNoAttribute(pXmlDoc, "//w:del[1]", "date"); + assertXPathNoAttribute(pXmlDoc, "//w:del[2]", "date"); } DECLARE_OOXMLEXPORT_TEST(testTdf139580, "tdf139580.odt") diff --git a/sw/source/core/doc/docredln.cxx b/sw/source/core/doc/docredln.cxx index 8c82eaba9948..ec164f5d0bb8 100644 --- a/sw/source/core/doc/docredln.cxx +++ b/sw/source/core/doc/docredln.cxx @@ -795,7 +795,11 @@ bool SwRedlineTable::isMoved( size_type rPos ) const } const OUString sTrimmed = pPaM->GetText().trim(); - if ( sTrimmed.getLength() < 2 ) + // detection of move needs at least 6 characters with an inner + // space after stripping white spaces of the redline to skip + // frequent deleted and inserted articles or other common + // word parts, e.g. 'the' and 'of a' to detect as text moving + if ( sTrimmed.getLength() < 6 || sTrimmed.indexOf(' ') == -1 ) { if ( bDeletePaM ) delete pPaM;