diff --git a/sw/qa/extras/ooxmlimport/data/floating-table-with-relative-width.docx b/sw/qa/extras/ooxmlimport/data/floating-table-with-relative-width.docx new file mode 100644 index 000000000000..9d88d930277d Binary files /dev/null and b/sw/qa/extras/ooxmlimport/data/floating-table-with-relative-width.docx differ diff --git a/sw/qa/extras/ooxmlimport/ooxmlimport.cxx b/sw/qa/extras/ooxmlimport/ooxmlimport.cxx index 3b3a227c63d2..d60247e672da 100644 --- a/sw/qa/extras/ooxmlimport/ooxmlimport.cxx +++ b/sw/qa/extras/ooxmlimport/ooxmlimport.cxx @@ -1848,6 +1848,18 @@ DECLARE_OOXMLIMPORT_TEST(testFdo69656, "Table_cell_auto_width_fdo69656.docx") uno::Reference xTables(xTablesSupplier->getTextTables( ), uno::UNO_QUERY); CPPUNIT_ASSERT_EQUAL(sal_Int32(8154), getProperty(xTables->getByIndex(0), "Width")); } + +DECLARE_OOXMLIMPORT_TEST(testFloatingTableWithRelativeWidth, "floating-table-with-relative-width.docx") +{ + // Floating tables are imported to text frames and the size is defined by the frame size. + // Width of the text frame including table was relative to the paragraph area and not to the page. + uno::Reference xTextFramesSupplier(mxComponent, uno::UNO_QUERY); + uno::Reference xIndexAccess(xTextFramesSupplier->getTextFrames(), uno::UNO_QUERY); + uno::Reference xFrame(xIndexAccess->getByIndex(0), uno::UNO_QUERY); + CPPUNIT_ASSERT_EQUAL(sal_Int32(80), getProperty(xFrame, "RelativeWidth")); + CPPUNIT_ASSERT_EQUAL(sal_Int16(text::RelOrientation::PAGE_FRAME), getProperty(xFrame, "RelativeWidthRelation")); + +} #endif CPPUNIT_PLUGIN_IMPLEMENT(); diff --git a/writerfilter/source/dmapper/DomainMapperTableHandler.cxx b/writerfilter/source/dmapper/DomainMapperTableHandler.cxx index 3bc66fac72d7..03be88dc4333 100644 --- a/writerfilter/source/dmapper/DomainMapperTableHandler.cxx +++ b/writerfilter/source/dmapper/DomainMapperTableHandler.cxx @@ -944,9 +944,12 @@ void DomainMapperTableHandler::endTable(unsigned int nestedTableLevel) } else { - aFrameProperties.realloc(aFrameProperties.getLength() + 1); - aFrameProperties[aFrameProperties.getLength() - 1].Name = "FrameWidthPercent"; - aFrameProperties[aFrameProperties.getLength() - 1].Value = xTableProperties->getPropertyValue("RelativeWidth"); + aFrameProperties.realloc(aFrameProperties.getLength() + 2); + aFrameProperties[aFrameProperties.getLength() - 2].Name = "FrameWidthPercent"; + aFrameProperties[aFrameProperties.getLength() - 2].Value = xTableProperties->getPropertyValue("RelativeWidth"); + + aFrameProperties[aFrameProperties.getLength() - 1].Name = "RelativeWidthRelation"; + aFrameProperties[aFrameProperties.getLength() - 1].Value = uno::makeAny(text::RelOrientation::PAGE_FRAME); // Applying the relative width to the frame, needs to have the table width to be 100% of the frame width xTableProperties->setPropertyValue("RelativeWidth", uno::makeAny(sal_Int16(100)));