tdf#143318 DOCX import: fix missing redlines in flying tables
makeRedline() exceptions (in the case of already existing
redlines) skip the creation of the next (not existing yet)
redlines in tables inside fly frames. Here: a tracked table
moving revealed the problem, with the missing rejection of the
new position, i.e. the "new" (second) table of the document.
Note: fix also collecting redlines within tables: IsInTable()
isn't true in the first cell of the table, losing the
redline here, so it's replaced with m_nTableDepth > 0.
Follow-up to commit 7f3c0bbc174b9b0316991c174ca3b407c0e3d141
"tdf#143510 DOCX import: fix tracked table drag & drop".
Change-Id: Icf6dd62eb950e5af6a75353dffabb9e9433c1b44
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/120333
Tested-by: Jenkins
Reviewed-by: László Németh <nemeth@numbertext.org>
(cherry picked from commit afc0c718ec9ca6a4fbe1324f68eb292d9a67b058)
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/120356
diff --git a/sw/qa/extras/uiwriter/data/TC-table-DnD-move.docx b/sw/qa/extras/uiwriter/data/TC-table-DnD-move.docx
new file mode 100644
index 0000000..f231d6f
--- /dev/null
+++ b/sw/qa/extras/uiwriter/data/TC-table-DnD-move.docx
Binary files differ
diff --git a/sw/qa/extras/uiwriter/uiwriter2.cxx b/sw/qa/extras/uiwriter/uiwriter2.cxx
index 97e14b7..c6c205a 100644
--- a/sw/qa/extras/uiwriter/uiwriter2.cxx
+++ b/sw/qa/extras/uiwriter/uiwriter2.cxx
@@ -4251,6 +4251,35 @@ CPPUNIT_TEST_FIXTURE(SwUiWriterTest2, testRedlineDOCXTableInsertion)
CPPUNIT_ASSERT_EQUAL(sal_Int32(0), xTables->getCount());
}
CPPUNIT_TEST_FIXTURE(SwUiWriterTest2, testRedlineDOCXTableMoveToFrame)
{
// load a table with tracked drag & drop: Table1 is the moveFrom,
// Table2 is the moveTo - and framed - table
SwDoc* pDoc = createSwDoc(DATA_DIRECTORY, "TC-table-DnD-move.docx");
uno::Reference<text::XTextTablesSupplier> xTextTablesSupplier(mxComponent, uno::UNO_QUERY);
uno::Reference<container::XIndexAccess> xTables(xTextTablesSupplier->getTextTables(),
uno::UNO_QUERY);
uno::Reference<container::XNameAccess> xTableNames = xTextTablesSupplier->getTextTables();
// check table count (2)
CPPUNIT_ASSERT_EQUAL(sal_Int32(2), xTables->getCount());
// accept tracked table moving, remaining table is Table2
IDocumentRedlineAccess& rIDRA(pDoc->getIDocumentRedlineAccess());
rIDRA.AcceptAllRedline(true);
CPPUNIT_ASSERT_EQUAL(sal_Int32(1), xTables->getCount());
CPPUNIT_ASSERT(xTableNames->hasByName("Table2"));
CPPUNIT_ASSERT(!xTableNames->hasByName("Table1"));
// Undo and reject tracked table moving, remaining table is Table1
dispatchCommand(mxComponent, ".uno:Undo", {});
rIDRA.AcceptAllRedline(false);
// This was 2 (not deleted Table2 – framed)
CPPUNIT_ASSERT_EQUAL(sal_Int32(1), xTables->getCount());
CPPUNIT_ASSERT(xTableNames->hasByName("Table1"));
CPPUNIT_ASSERT(!xTableNames->hasByName("Table2"));
}
CPPUNIT_TEST_FIXTURE(SwUiWriterTest2, testTdf128335)
{
// Load the bugdoc, which has 3 textboxes.
diff --git a/writerfilter/source/dmapper/DomainMapper_Impl.cxx b/writerfilter/source/dmapper/DomainMapper_Impl.cxx
index 56451b7..b175e37 100644
--- a/writerfilter/source/dmapper/DomainMapper_Impl.cxx
+++ b/writerfilter/source/dmapper/DomainMapper_Impl.cxx
@@ -2930,7 +2930,7 @@ void DomainMapper_Impl::CreateRedline(uno::Reference<text::XTextRange> const& xR
}
// store frame and (possible floating) table redline data for restoring them after frame conversion
enum StoredRedlines eType;
if (m_bIsActualParagraphFramed || (hasTableManager() && getTableManager().isInTable()))
if (m_bIsActualParagraphFramed || m_nTableDepth > 0)
eType = StoredRedlines::FRAME;
else if (IsInFootOrEndnote())
eType = IsInFootnote() ? StoredRedlines::FOOTNOTE : StoredRedlines::ENDNOTE;
diff --git a/writerfilter/source/dmapper/PropertyMap.cxx b/writerfilter/source/dmapper/PropertyMap.cxx
index cacadef..b4c58c0 100644
--- a/writerfilter/source/dmapper/PropertyMap.cxx
+++ b/writerfilter/source/dmapper/PropertyMap.cxx
@@ -1473,7 +1473,14 @@ void SectionPropertyMap::CloseSectionGroup( DomainMapper_Impl& rDM_Impl )
xCrsr->goRight(redPos[i/3], false);
xCrsr->goRight(redLen[i/3], true);
uno::Reference < text::XRedline > xRedline( xCrsr, uno::UNO_QUERY_THROW );
xRedline->makeRedline( sType, aRedlineProperties );
try
{
xRedline->makeRedline( sType, aRedlineProperties );
}
catch (const uno::Exception&)
{
DBG_UNHANDLED_EXCEPTION("writerfilter", "makeRedline() failed");
}
}
}
catch (const uno::Exception&)