summaryrefslogtreecommitdiff
path: root/sw/qa
diff options
context:
space:
mode:
authorLászló Németh <nemeth@numbertext.org>2021-11-16 16:08:57 +0100
committerLászló Németh <nemeth@numbertext.org>2021-11-17 20:05:46 +0100
commitf51fa7534421a195a58b4a737a2e836d8c25ba81 (patch)
treed0e7e23fead69543f388731e79769e9c0d9fe6c9 /sw/qa
parent9acb80943da5aaaf5d515a794f8a825d88bda430 (diff)
tdf#145718 sw, DOCX import: complete tracked text moving
Add IsMoved bit to SwRangeRedline, and keep it in both parts of a split Delete/Insert redline. Set this bit during DOCX import, fixing incomplete import of moveFrom/moveTo elements. Details: - Search text moving only at redline Insert() and AppendRedline() instead in the layout code (which was much slower, because triggered by also mouse hovering): - detect text moving in Hide Changes mode, too; - Insertion inside or directly after tracked text moving keeps "moved text" layout of the original moved text parts (before and after the insertion). - at detection of text moving, invalidate (update) layout of the redline pair, too. - fix DOCX import: extend makeRedline() with property RedlineMoved to keep all moveFrom/moveTo stored in DOCX instead of losing them (joining them with normal redlines) in the case of missing Delete/Insert pair (see unit test document); Follow-up to commit ec577f566fa3e6d2666069180f8ec8474054aea9 "tdf#145233 sw track changes: show moved text in green color", commit bcdebc832b272662d28035007a4796e42d1305ae "tdf#104797 DOCX change tracking: handle moveFrom and moveTo" and commit d32d9a2b3c5e3963f4a18f6c7bbf50fab2e9b2be "tdf#123460 DOCX track changes: moveFrom completely". Change-Id: Iaca80e5e326a172bc7ba5fec64b63668b9378e2d Reviewed-on: https://gerrit.libreoffice.org/c/core/+/125317 Tested-by: László Németh <nemeth@numbertext.org> Reviewed-by: László Németh <nemeth@numbertext.org>
Diffstat (limited to 'sw/qa')
-rw-r--r--sw/qa/extras/layout/data/tdf104797.docxbin0 -> 11710 bytes
-rw-r--r--sw/qa/extras/layout/layout2.cxx20
-rw-r--r--sw/qa/extras/ooxmlexport/ooxmlexport11.cxx20
-rw-r--r--sw/qa/extras/ooxmlexport/ooxmlexport13.cxx20
-rw-r--r--sw/qa/extras/uiwriter/uiwriter2.cxx7
5 files changed, 58 insertions, 9 deletions
diff --git a/sw/qa/extras/layout/data/tdf104797.docx b/sw/qa/extras/layout/data/tdf104797.docx
new file mode 100644
index 000000000000..6e52190ce671
--- /dev/null
+++ b/sw/qa/extras/layout/data/tdf104797.docx
Binary files differ
diff --git a/sw/qa/extras/layout/layout2.cxx b/sw/qa/extras/layout/layout2.cxx
index 9f765b1452c7..9eee8228ea8d 100644
--- a/sw/qa/extras/layout/layout2.cxx
+++ b/sw/qa/extras/layout/layout2.cxx
@@ -330,6 +330,26 @@ CPPUNIT_TEST_FIXTURE(SwLayoutWriter2, testRedlineMoving)
assertXPath(pXmlDoc, "/metafile/push/push/push/font[@color='#008000']", 11);
}
+CPPUNIT_TEST_FIXTURE(SwLayoutWriter2, testRedlineMovingDOCX)
+{
+ SwDoc* pDoc = createSwDoc(DATA_DIRECTORY, "tdf104797.docx");
+ SwDocShell* pShell = pDoc->GetDocShell();
+
+ SwEditShell* const pEditShell(pDoc->GetEditShell());
+ // This was 2 (moveFrom and moveTo joined other redlines)
+ CPPUNIT_ASSERT_EQUAL(static_cast<SwRedlineTable::size_type>(6), pEditShell->GetRedlineCount());
+
+ // 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 colors show moved text
+ // These were 0 (other color, not COL_GREEN, color of the tracked text movement)
+ assertXPath(pXmlDoc, "/metafile/push/push/push/textcolor[@color='#008000']", 6);
+}
+
CPPUNIT_TEST_FIXTURE(SwLayoutWriter2, testTdf145225_RedlineMovingWithBadInsertion)
{
SwDoc* pDoc = createSwDoc(DATA_DIRECTORY, "tdf42748.fodt");
diff --git a/sw/qa/extras/ooxmlexport/ooxmlexport11.cxx b/sw/qa/extras/ooxmlexport/ooxmlexport11.cxx
index d79ebd7a2113..8cb43ffe3e2c 100644
--- a/sw/qa/extras/ooxmlexport/ooxmlexport11.cxx
+++ b/sw/qa/extras/ooxmlexport/ooxmlexport11.cxx
@@ -896,7 +896,25 @@ DECLARE_OOXMLEXPORT_TEST(testTdf104797, "tdf104797.docx")
CPPUNIT_ASSERT(hasProperty(getRun(getParagraph(2), 3), "RedlineType"));
CPPUNIT_ASSERT_EQUAL(OUString("Insert"),getProperty<OUString>(getRun(getParagraph(2), 3), "RedlineType"));
CPPUNIT_ASSERT_EQUAL(true,getProperty<bool>(getRun(getParagraph(2), 3), "IsStart"));
- CPPUNIT_ASSERT_EQUAL( OUString( " Will this sentence be duplicated ADDED STUFF?" ), getRun( getParagraph( 2 ), 4 )->getString());
+
+ if (mbExported)
+ {
+ // TODO fix export of moved text
+ CPPUNIT_ASSERT_EQUAL( OUString( " Will this sentence be duplicated ADDED STUFF?" ), getRun( getParagraph( 2 ), 4 )->getString());
+ }
+ else
+ {
+ CPPUNIT_ASSERT_EQUAL( OUString( " " ), getRun( getParagraph( 2 ), 4 )->getString());
+ CPPUNIT_ASSERT_EQUAL( OUString( "" ), getRun( getParagraph( 2 ), 5 )->getString());
+ CPPUNIT_ASSERT(hasProperty(getRun(getParagraph(2), 5), "RedlineType"));
+ CPPUNIT_ASSERT_EQUAL(OUString("Insert"),getProperty<OUString>(getRun(getParagraph(2), 5), "RedlineType"));
+ CPPUNIT_ASSERT_EQUAL( OUString( "" ), getRun( getParagraph( 2 ), 6 )->getString());
+ CPPUNIT_ASSERT(hasProperty(getRun(getParagraph(2), 6), "RedlineType"));
+ CPPUNIT_ASSERT_EQUAL(true,getProperty<bool>(getRun(getParagraph(2), 6), "IsStart"));
+ CPPUNIT_ASSERT_EQUAL( OUString( "Will this sentence be duplicated" ), getRun( getParagraph( 2 ), 7 )->getString());
+ CPPUNIT_ASSERT_EQUAL( OUString( " ADDED STUFF" ), getRun( getParagraph( 2 ), 10 )->getString());
+ CPPUNIT_ASSERT_EQUAL( OUString( "?" ), getRun( getParagraph( 2 ), 13 )->getString());
+ }
}
DECLARE_OOXMLEXPORT_TEST(testTdf143510, "TC-table-DnD-move.docx")
diff --git a/sw/qa/extras/ooxmlexport/ooxmlexport13.cxx b/sw/qa/extras/ooxmlexport/ooxmlexport13.cxx
index 7d6e0583d312..86473c120cbb 100644
--- a/sw/qa/extras/ooxmlexport/ooxmlexport13.cxx
+++ b/sw/qa/extras/ooxmlexport/ooxmlexport13.cxx
@@ -767,16 +767,20 @@ DECLARE_OOXMLEXPORT_TEST(testTdf123460, "tdf123460.docx")
CPPUNIT_ASSERT_EQUAL(OUString("Delete"),getProperty<OUString>(getRun(getParagraph(2), 1), "RedlineType"));
CPPUNIT_ASSERT_EQUAL(true, getRun( getParagraph( 2 ), 2 )->getString().endsWith("tellus."));
CPPUNIT_ASSERT_EQUAL( OUString( "" ), getRun( getParagraph( 2 ), 3 )->getString());
- bool bCaught = false;
- try
- {
- getRun( getParagraph( 2 ), 4 );
- }
- catch (container::NoSuchElementException&)
+ if (mbExported)
{
- bCaught = true;
+ // TODO fix export of moved text
+ bool bCaught = false;
+ try
+ {
+ getRun( getParagraph( 2 ), 4 );
+ }
+ catch (container::NoSuchElementException&)
+ {
+ bCaught = true;
+ }
+ CPPUNIT_ASSERT_EQUAL(true, bCaught);
}
- CPPUNIT_ASSERT_EQUAL(true, bCaught);
}
//tdf#125298: fix charlimit restrictions in bookmarknames and field references if they contain non-ascii characters
diff --git a/sw/qa/extras/uiwriter/uiwriter2.cxx b/sw/qa/extras/uiwriter/uiwriter2.cxx
index 9666efe9a49e..9797de01576f 100644
--- a/sw/qa/extras/uiwriter/uiwriter2.cxx
+++ b/sw/qa/extras/uiwriter/uiwriter2.cxx
@@ -3663,6 +3663,13 @@ CPPUNIT_TEST_FIXTURE(SwUiWriterTest2, testTdf125916_redline_restart_numbering)
{
SwDoc* pDoc = createSwDoc(DATA_DIRECTORY, "tdf125916.docx");
+ // moveFrom/moveTo are imported as separated redlines from fixing tdf#145718.
+ // Accept the first inline moveFrom redline before accepting the remaining ones
+ // to leave a paragraph long deletion to test the fix for tdf#125916.
+ SwEditShell* const pEditShell(pDoc->GetEditShell());
+ CPPUNIT_ASSERT(pEditShell->GetRedlineCount() > 0);
+ pEditShell->AcceptRedline(0);
+
IDocumentRedlineAccess& rIDRA(pDoc->getIDocumentRedlineAccess());
rIDRA.AcceptAllRedline(true);