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 6c82a9fa1da15d5f83f524f6897028906dda337e
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 11:37:00 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.
    
    Change-Id: I2ce0d96d255d8f405203f36a358559687b36e9e3
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/99762
    Reviewed-by: Miklos Vajna <vmik...@collabora.com>
    Tested-by: Jenkins

diff --git a/writerfilter/qa/cppunittests/dmapper/DomainMapperTableHandler.cxx 
b/writerfilter/qa/cppunittests/dmapper/DomainMapperTableHandler.cxx
index a1a7595cee76..e49ea59d9cb5 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>
 
 using namespace ::com::sun::star;
 
@@ -65,6 +66,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 ac667ddefd88..f202bda076e5 100644
--- a/writerfilter/source/dmapper/DomainMapperTableHandler.cxx
+++ b/writerfilter/source/dmapper/DomainMapperTableHandler.cxx
@@ -40,6 +40,7 @@
 #include <sal/log.hxx>
 #include <tools/diagnose_ex.h>
 #include <comphelper/sequence.hxx>
+#include <comphelper/propertyvalue.hxx>
 
 #ifdef DBG_UTIL
 #include "PropertyMapHelper.hxx"
@@ -1400,6 +1401,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

Reply via email to