writerfilter/qa/cppunittests/dmapper/DomainMapperTableHandler.cxx | 14 ++++++++++ writerfilter/qa/cppunittests/dmapper/data/floattable-footnote-redline.docx |binary writerfilter/source/dmapper/DomainMapperTableHandler.cxx | 7 ++++- writerfilter/source/dmapper/SettingsTable.cxx | 2 + writerfilter/source/dmapper/SettingsTable.hxx | 2 + 5 files changed, 24 insertions(+), 1 deletion(-)
New commits: commit b04d8e4a3f41c072465c6d4a3fb449fcbfebfe95 Author: Miklos Vajna <vmik...@collabora.com> AuthorDate: Tue Jan 30 08:51:20 2024 +0100 Commit: Miklos Vajna <vmik...@collabora.com> CommitDate: Fri Feb 2 08:19:41 2024 +0100 tdf#159107 sw floattable: prefer inline table in footnote with change tracking Writer doesn't really support tables in footnotes, see the warning at the top of SwFlowFrame::MoveFwd(). Still, there is some initial support for them, since commit 11c51eefe8c3210cef2b5850f401ba67a401d01 (tdf#95806 tdf#125877 tdf#141172 DOCX: fix tables in footnotes, 2021-03-28). Similarly, redlines really just track insertion and deletion, but some initial support for table operations were added in commit eebe4747d2d13545004937bb0267ccfc8ab9d63f (tdf#144270 sw: manage tracked table (row) deletion/insertion, 2022-01-12). The combination of these is a bit fragile, but the bugdoc happened to be imported as an inline table (in a footnote, with recording changes) before commit d477fa8ac1b0d3ee81427217bbb5950278ab16db (sw floattable: unconditionally map <w:tblpPr> to SwFormatFlySplit, 2023-03-17). Fix the problem by explicitly importing floating tables as inline in the footnote + redline case to restore the working use-case. DOCX import of this combination can be enabled again once Writer layout works for the produced model. Change-Id: I9cd0a1fabb9807f5117cb5a36ec8597d6646eece Reviewed-on: https://gerrit.libreoffice.org/c/core/+/162733 Reviewed-by: Miklos Vajna <vmik...@collabora.com> Tested-by: Jenkins (cherry picked from commit af15f8b7f346898677f1eee6521a6be1ff63eb56) Reviewed-on: https://gerrit.libreoffice.org/c/core/+/162716 Reviewed-by: Michael Stahl <michael.st...@allotropia.de> (cherry picked from commit d19f051dd4244bdfb58458d4287305b59c2915c6) diff --git a/writerfilter/qa/cppunittests/dmapper/DomainMapperTableHandler.cxx b/writerfilter/qa/cppunittests/dmapper/DomainMapperTableHandler.cxx index 5d8d5efc50cc..b72b81913978 100644 --- a/writerfilter/qa/cppunittests/dmapper/DomainMapperTableHandler.cxx +++ b/writerfilter/qa/cppunittests/dmapper/DomainMapperTableHandler.cxx @@ -183,6 +183,20 @@ CPPUNIT_TEST_FIXTURE(Test, testDOCXFloatingTableHeader) // 2233 pages and then there was a layout loop. CPPUNIT_ASSERT_EQUAL(static_cast<sal_Int32>(2), nLastPage); } + +CPPUNIT_TEST_FIXTURE(Test, testDOCXFloatingTableFootnoteRedline) +{ + // Given a document with a floating table in a footnote, with track changes recorded (but not + // visible): + // When importing that document: + loadFromFile(u"floattable-footnote-redline.docx"); + + // Then make sure the table is imported as inline, till Writer layout is ready to handle + // floating tables in footnotes: + uno::Reference<drawing::XDrawPageSupplier> xModel(mxComponent, uno::UNO_QUERY); + uno::Reference<drawing::XDrawPage> xDrawPage = xModel->getDrawPage(); + CPPUNIT_ASSERT_EQUAL(static_cast<sal_Int32>(0), xDrawPage->getCount()); +} } CPPUNIT_PLUGIN_IMPLEMENT(); diff --git a/writerfilter/qa/cppunittests/dmapper/data/floattable-footnote-redline.docx b/writerfilter/qa/cppunittests/dmapper/data/floattable-footnote-redline.docx new file mode 100644 index 000000000000..10904ce43eb5 Binary files /dev/null and b/writerfilter/qa/cppunittests/dmapper/data/floattable-footnote-redline.docx differ diff --git a/writerfilter/source/dmapper/DomainMapperTableHandler.cxx b/writerfilter/source/dmapper/DomainMapperTableHandler.cxx index 2092ba4096ae..e63d1cf9615f 100644 --- a/writerfilter/source/dmapper/DomainMapperTableHandler.cxx +++ b/writerfilter/source/dmapper/DomainMapperTableHandler.cxx @@ -1599,7 +1599,12 @@ void DomainMapperTableHandler::endTable(unsigned int nestedTableLevel) // m_xText points to the body text, get the current xText from m_rDMapper_Impl, in case e.g. we would be in a header. uno::Reference<text::XTextAppendAndConvert> xTextAppendAndConvert(m_rDMapper_Impl.GetTopTextAppend(), uno::UNO_QUERY); uno::Reference<beans::XPropertySet> xFrameAnchor; - if (xTextAppendAndConvert.is()) + + // Writer layout has problems with redlines on floating table rows in footnotes, avoid + // them. + bool bInFootnote = m_rDMapper_Impl.IsInFootOrEndnote(); + bool bRecordChanges = m_rDMapper_Impl.GetSettingsTable()->GetRecordChanges(); + if (xTextAppendAndConvert.is() && !(bInFootnote && bRecordChanges)) { std::deque<css::uno::Any> aFramedRedlines = m_rDMapper_Impl.m_aStoredRedlines[StoredRedlines::FRAME]; std::vector<sal_Int32> redPos, redLen; diff --git a/writerfilter/source/dmapper/SettingsTable.cxx b/writerfilter/source/dmapper/SettingsTable.cxx index 43ef02f68134..b16846420682 100644 --- a/writerfilter/source/dmapper/SettingsTable.cxx +++ b/writerfilter/source/dmapper/SettingsTable.cxx @@ -778,6 +778,8 @@ bool SettingsTable::GetNoLeading() const bool SettingsTable::GetGutterAtTop() const { return m_pImpl->m_bGutterAtTop; } +bool SettingsTable::GetRecordChanges() const { return m_pImpl->m_bRecordChanges; } + }//namespace dmapper } //namespace writerfilter diff --git a/writerfilter/source/dmapper/SettingsTable.hxx b/writerfilter/source/dmapper/SettingsTable.hxx index a0af31bed6bb..471d15b7a999 100644 --- a/writerfilter/source/dmapper/SettingsTable.hxx +++ b/writerfilter/source/dmapper/SettingsTable.hxx @@ -97,6 +97,8 @@ public: const OUString& GetCurrentDatabaseDataSource() const; bool GetGutterAtTop() const; + bool GetRecordChanges() const; + private: // Properties virtual void lcl_attribute(Id Name, Value& val) override;