summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorZolnai Tamás <tamas.zolnai@collabora.com>2014-02-13 15:19:49 +0100
committerZolnai Tamás <tamas.zolnai@collabora.com>2014-02-13 15:25:58 +0100
commit7ff8414a411ae35e1fe56e9724646d0e94fa17f6 (patch)
treecc85f3c2c5e9cf5e032a0265c6123b2f7585807c
parentf16368777b8b03164e3485143f014486e7cc69e2 (diff)
DOCX import: fix relative width of floating tables
Relative width of tables means relative to the page and not to the paragraph area so we have to set the RelativeWidthRelation property of the containing text frame. Change-Id: I054d22e1883eb0ed9b07b9141bb2bea956e8367e
-rw-r--r--sw/qa/extras/ooxmlimport/data/floating-table-with-relative-width.docxbin0 -> 13314 bytes
-rw-r--r--sw/qa/extras/ooxmlimport/ooxmlimport.cxx12
-rw-r--r--writerfilter/source/dmapper/DomainMapperTableHandler.cxx9
3 files changed, 18 insertions, 3 deletions
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
--- /dev/null
+++ b/sw/qa/extras/ooxmlimport/data/floating-table-with-relative-width.docx
Binary files 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<container::XIndexAccess> xTables(xTablesSupplier->getTextTables( ), uno::UNO_QUERY);
CPPUNIT_ASSERT_EQUAL(sal_Int32(8154), getProperty<sal_Int32>(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<text::XTextFramesSupplier> xTextFramesSupplier(mxComponent, uno::UNO_QUERY);
+ uno::Reference<container::XIndexAccess> xIndexAccess(xTextFramesSupplier->getTextFrames(), uno::UNO_QUERY);
+ uno::Reference<beans::XPropertySet> xFrame(xIndexAccess->getByIndex(0), uno::UNO_QUERY);
+ CPPUNIT_ASSERT_EQUAL(sal_Int32(80), getProperty<sal_Int32>(xFrame, "RelativeWidth"));
+ CPPUNIT_ASSERT_EQUAL(sal_Int16(text::RelOrientation::PAGE_FRAME), getProperty<sal_Int16>(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)));