sw/qa/extras/uiwriter/data/TC-table-DnD-move.docx |binary sw/qa/extras/uiwriter/uiwriter2.cxx | 29 ++++++++++++++++++++++ writerfilter/source/dmapper/DomainMapper_Impl.cxx | 2 - writerfilter/source/dmapper/PropertyMap.cxx | 9 ++++++ 4 files changed, 38 insertions(+), 2 deletions(-)
New commits: commit afc0c718ec9ca6a4fbe1324f68eb292d9a67b058 Author: László Németh <nem...@numbertext.org> AuthorDate: Wed Aug 11 17:44:03 2021 +0200 Commit: László Németh <nem...@numbertext.org> CommitDate: Thu Aug 12 11:54:11 2021 +0200 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 <nem...@numbertext.org> 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 000000000000..f231d6f84240 Binary files /dev/null and b/sw/qa/extras/uiwriter/data/TC-table-DnD-move.docx differ diff --git a/sw/qa/extras/uiwriter/uiwriter2.cxx b/sw/qa/extras/uiwriter/uiwriter2.cxx index 7dfb8d634255..0af2e6122fb6 100644 --- a/sw/qa/extras/uiwriter/uiwriter2.cxx +++ b/sw/qa/extras/uiwriter/uiwriter2.cxx @@ -4045,6 +4045,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 fc1fbee7440f..7e3b3740c276 100644 --- a/writerfilter/source/dmapper/DomainMapper_Impl.cxx +++ b/writerfilter/source/dmapper/DomainMapper_Impl.cxx @@ -2987,7 +2987,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 cacadef477d4..b4c58c0d8808 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&)