writerfilter/qa/cppunittests/dmapper/DomainMapperTableHandler.cxx | 15 ++++++++++ writerfilter/qa/cppunittests/dmapper/data/nested-floating-table.docx |binary writerfilter/source/dmapper/DomainMapperTableHandler.cxx | 8 +++++ 3 files changed, 23 insertions(+)
New commits: commit 1984bfb30d4af77a0aff63d5c6e9a00b9cc90a78 Author: Miklos Vajna <vmik...@collabora.com> AuthorDate: Thu Jul 30 10:37:25 2020 +0200 Commit: Miklos Vajna <vmik...@collabora.com> CommitDate: Thu Jul 30 16:46:15 2020 +0200 DOCX import: fix overlapping floating tables when anchored inside a table The WW8 import does the same in SwWW8ImplReader::StartTable(), now we're on par with that. (cherry picked from commit 6c82a9fa1da15d5f83f524f6897028906dda337e) Change-Id: I2ce0d96d255d8f405203f36a358559687b36e9e3 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/99797 Tested-by: Jenkins CollaboraOffice <jenkinscollaboraoff...@gmail.com> Reviewed-by: Miklos Vajna <vmik...@collabora.com> diff --git a/writerfilter/qa/cppunittests/dmapper/DomainMapperTableHandler.cxx b/writerfilter/qa/cppunittests/dmapper/DomainMapperTableHandler.cxx index c3b52060646b..ecca969fe27b 100644 --- a/writerfilter/qa/cppunittests/dmapper/DomainMapperTableHandler.cxx +++ b/writerfilter/qa/cppunittests/dmapper/DomainMapperTableHandler.cxx @@ -15,6 +15,7 @@ #include <com/sun/star/table/BorderLine2.hpp> #include <com/sun/star/text/XTextTable.hpp> #include <com/sun/star/text/XTextTablesSupplier.hpp> +#include <com/sun/star/drawing/XDrawPageSupplier.hpp> #include <comphelper/processfactory.hxx> @@ -69,6 +70,20 @@ CPPUNIT_TEST_FIXTURE(Test, test1cellInsidevRightborder) // i.e. the request to have no table-level right border was lost on import. CPPUNIT_ASSERT_EQUAL(static_cast<sal_uInt32>(0), aBorder.LineWidth); } + +CPPUNIT_TEST_FIXTURE(Test, testNestedFloatingTable) +{ + OUString aURL = m_directories.getURLFromSrc(DATA_DIRECTORY) + "nested-floating-table.docx"; + getComponent() = loadFromDesktop(aURL); + uno::Reference<drawing::XDrawPageSupplier> xDrawPageSupplier(getComponent(), uno::UNO_QUERY); + uno::Reference<container::XIndexAccess> xDrawPage = xDrawPageSupplier->getDrawPage(); + uno::Reference<beans::XPropertySet> xFrame(xDrawPage->getByIndex(0), uno::UNO_QUERY); + bool bIsFollowingTextFlow = false; + xFrame->getPropertyValue("IsFollowingTextFlow") >>= bIsFollowingTextFlow; + // Without the accompanying fix in place, this test would have failed, the nested floating table + // was partly positioned outside the table cell, leading to overlapping text. + CPPUNIT_ASSERT(bIsFollowingTextFlow); +} } CPPUNIT_PLUGIN_IMPLEMENT(); diff --git a/writerfilter/qa/cppunittests/dmapper/data/nested-floating-table.docx b/writerfilter/qa/cppunittests/dmapper/data/nested-floating-table.docx new file mode 100644 index 000000000000..73fd922fccd5 Binary files /dev/null and b/writerfilter/qa/cppunittests/dmapper/data/nested-floating-table.docx differ diff --git a/writerfilter/source/dmapper/DomainMapperTableHandler.cxx b/writerfilter/source/dmapper/DomainMapperTableHandler.cxx index c785dacbe0c9..05d3e45a6fc3 100644 --- a/writerfilter/source/dmapper/DomainMapperTableHandler.cxx +++ b/writerfilter/source/dmapper/DomainMapperTableHandler.cxx @@ -36,6 +36,7 @@ #include <osl/diagnose.h> #include <sal/log.hxx> #include <comphelper/sequence.hxx> +#include <comphelper/propertyvalue.hxx> #ifdef DEBUG_WRITERFILTER #include "PropertyMapHelper.hxx" @@ -1145,6 +1146,13 @@ void DomainMapperTableHandler::endTable(unsigned int nestedTableLevel, bool bTab // A non-zero left margin would move the table out of the frame, move the frame itself instead. xTableProperties->setPropertyValue("LeftMargin", uno::makeAny(sal_Int32(0))); + if (nestedTableLevel >= 2) + { + // Floating tables inside a table always stay inside the cell. + aFrameProperties.push_back( + comphelper::makePropertyValue("IsFollowingTextFlow", true)); + } + // In case the document ends with a table, we're called after // SectionPropertyMap::CloseSectionGroup(), so we'll have no idea // about the text area width, nor can fix this by delaying the text _______________________________________________ Libreoffice-commits mailing list libreoffice-comm...@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits