diff options
author | Cédric Bosdonnat <cedric.bosdonnat@free.fr> | 2013-05-22 11:34:01 +0200 |
---|---|---|
committer | Miklos Vajna <vmiklos@suse.cz> | 2013-09-03 14:46:06 +0200 |
commit | b4951d9993b0bafaa85640dc905567eedc228dc9 (patch) | |
tree | 77e1ba18d9bb74c7bb2f9e6ebf8febc12c6c5900 | |
parent | ce7aeaa358dc0000dbcaf43c55670345fad8ee86 (diff) |
n#816593: Floating table width import fix: adjust the frame width
(cherry picked from commit 9f4c8a8bca06b4c2a916a51909367b453fc41a8b)
Change-Id: I8212bc5981418f6cbd514bf5002e6a5dbdf53152
Signed-off-by: Miklos Vajna <vmiklos@suse.cz>
-rw-r--r-- | sw/qa/extras/ooxmlimport/data/table_width.docx | bin | 6561 -> 6572 bytes | |||
-rw-r--r-- | sw/qa/extras/ooxmlimport/ooxmlimport.cxx | 4 | ||||
-rw-r--r-- | writerfilter/source/dmapper/DomainMapperTableHandler.cxx | 20 |
3 files changed, 21 insertions, 3 deletions
diff --git a/sw/qa/extras/ooxmlimport/data/table_width.docx b/sw/qa/extras/ooxmlimport/data/table_width.docx Binary files differindex 26deb6daf35c..02b77c97d89f 100644 --- a/sw/qa/extras/ooxmlimport/data/table_width.docx +++ b/sw/qa/extras/ooxmlimport/data/table_width.docx diff --git a/sw/qa/extras/ooxmlimport/ooxmlimport.cxx b/sw/qa/extras/ooxmlimport/ooxmlimport.cxx index 1db782971ce1..2d5441ab9bba 100644 --- a/sw/qa/extras/ooxmlimport/ooxmlimport.cxx +++ b/sw/qa/extras/ooxmlimport/ooxmlimport.cxx @@ -1330,6 +1330,10 @@ void Test::testTableWidth() uno::Reference<container::XIndexAccess> xTables(xTablesSupplier->getTextTables(), uno::UNO_QUERY); // Relative width wasn't recognized during import. CPPUNIT_ASSERT_EQUAL(true, bool(getProperty<sal_Bool>(xTables->getByIndex(0), "IsWidthRelative"))); + + uno::Reference<text::XTextFramesSupplier> xFramesSupplier(mxComponent, uno::UNO_QUERY); + uno::Reference<container::XIndexAccess> xFrames(xFramesSupplier->getTextFrames(), uno::UNO_QUERY); + CPPUNIT_ASSERT_EQUAL(sal_Int32(100), getProperty<sal_Int32>(xFrames->getByIndex(0), "FrameWidthPercent")); } void Test::testConditionalstylesTbllook() diff --git a/writerfilter/source/dmapper/DomainMapperTableHandler.cxx b/writerfilter/source/dmapper/DomainMapperTableHandler.cxx index 495165bfe04f..75863963c117 100644 --- a/writerfilter/source/dmapper/DomainMapperTableHandler.cxx +++ b/writerfilter/source/dmapper/DomainMapperTableHandler.cxx @@ -828,9 +828,23 @@ void DomainMapperTableHandler::endTable(unsigned int nestedTableLevel) if (xTable.is() && xStart.is() && xEnd.is()) { uno::Reference<beans::XPropertySet> xTableProperties(xTable, uno::UNO_QUERY); - aFrameProperties.realloc(aFrameProperties.getLength() + 1); - aFrameProperties[aFrameProperties.getLength() - 1].Name = "Width"; - aFrameProperties[aFrameProperties.getLength() - 1].Value = xTableProperties->getPropertyValue("Width"); + sal_Bool bIsRelative = sal_False; + xTableProperties->getPropertyValue("IsWidthRelative") >>= bIsRelative; + if (!bIsRelative) + { + aFrameProperties.realloc(aFrameProperties.getLength() + 1); + aFrameProperties[aFrameProperties.getLength() - 1].Name = "Width"; + aFrameProperties[aFrameProperties.getLength() - 1].Value = xTableProperties->getPropertyValue("Width"); + } + else + { + aFrameProperties.realloc(aFrameProperties.getLength() + 1); + aFrameProperties[aFrameProperties.getLength() - 1].Name = "FrameWidthPercent"; + aFrameProperties[aFrameProperties.getLength() - 1].Value = xTableProperties->getPropertyValue("RelativeWidth"); + + // 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))); + } // 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))); |