summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMiklos Vajna <vmiklos@collabora.com>2020-07-30 10:37:25 +0200
committerMiklos Vajna <vmiklos@collabora.com>2020-07-30 16:46:15 +0200
commit1984bfb30d4af77a0aff63d5c6e9a00b9cc90a78 (patch)
treea45fddbb173ef20dbb9a9508243127911c9fa1ff
parentvcl: use HAVE_FEATURE_PDFIUM in VectorGraphicSearch impl. (diff)
downloadcore-1984bfb30d4af77a0aff63d5c6e9a00b9cc90a78.tar.gz
core-1984bfb30d4af77a0aff63d5c6e9a00b9cc90a78.zip
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 <jenkinscollaboraoffice@gmail.com> Reviewed-by: Miklos Vajna <vmiklos@collabora.com>
-rw-r--r--writerfilter/qa/cppunittests/dmapper/DomainMapperTableHandler.cxx15
-rw-r--r--writerfilter/qa/cppunittests/dmapper/data/nested-floating-table.docxbin0 -> 12915 bytes
-rw-r--r--writerfilter/source/dmapper/DomainMapperTableHandler.cxx8
3 files changed, 23 insertions, 0 deletions
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
--- /dev/null
+++ b/writerfilter/qa/cppunittests/dmapper/data/nested-floating-table.docx
Binary files 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