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 cca71aa4c5b79302a4f30c5ab5582da2b9d378e8 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: Thu Aug 4 15:16:10 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> 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 8ab2149b861c..c4d1a976fe7c 100644 --- a/sw/qa/extras/layout/layout2.cxx +++ b/sw/qa/extras/layout/layout2.cxx @@ -624,6 +624,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 31d625b815ae..586f36ed0c82 100644 --- a/sw/qa/extras/ooxmlexport/ooxmlexport12.cxx +++ b/sw/qa/extras/ooxmlexport/ooxmlexport12.cxx @@ -1492,11 +1492,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); @@ -1514,11 +1529,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 654a209e99cf..f0b834039066 100644 --- a/sw/qa/extras/ooxmlexport/ooxmlexport16.cxx +++ b/sw/qa/extras/ooxmlexport/ooxmlexport16.cxx @@ -666,12 +666,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"); } CPPUNIT_TEST_FIXTURE(Test, testTdf139580) diff --git a/sw/source/core/doc/docredln.cxx b/sw/source/core/doc/docredln.cxx index 9fc6314e218e..e29ed4d1f8e0 100644 --- a/sw/source/core/doc/docredln.cxx +++ b/sw/source/core/doc/docredln.cxx @@ -786,7 +786,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;