summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--sw/qa/extras/ooxmlimport/data/tdf109524.docxbin0 -> 1291 bytes
-rw-r--r--sw/qa/extras/ooxmlimport/ooxmlimport.cxx12
-rw-r--r--writerfilter/source/dmapper/DomainMapperTableHandler.cxx13
3 files changed, 22 insertions, 3 deletions
diff --git a/sw/qa/extras/ooxmlimport/data/tdf109524.docx b/sw/qa/extras/ooxmlimport/data/tdf109524.docx
new file mode 100644
index 000000000000..534245b8f907
--- /dev/null
+++ b/sw/qa/extras/ooxmlimport/data/tdf109524.docx
Binary files differ
diff --git a/sw/qa/extras/ooxmlimport/ooxmlimport.cxx b/sw/qa/extras/ooxmlimport/ooxmlimport.cxx
index ce4676dcab88..8b0ad8f3b512 100644
--- a/sw/qa/extras/ooxmlimport/ooxmlimport.cxx
+++ b/sw/qa/extras/ooxmlimport/ooxmlimport.cxx
@@ -1500,6 +1500,18 @@ DECLARE_OOXMLIMPORT_TEST(testTdf108849, "tdf108849.docx")
CPPUNIT_ASSERT_EQUAL_MESSAGE("Misplaced body-level sectPr's create extra sections!", 2, getPages());
}
+DECLARE_OOXMLIMPORT_TEST(testTdf109524, "tdf109524.docx")
+{
+ uno::Reference<text::XTextTablesSupplier> xTablesSupplier(mxComponent, uno::UNO_QUERY);
+ uno::Reference<container::XIndexAccess> xTables(xTablesSupplier->getTextTables(), uno::UNO_QUERY);
+ // The table should have a small width (just to hold the short text in its single cell).
+ // Until it's correctly implemented, we assign it 100% relative width.
+ // Previously, the table (without explicitly set width) had huge actual width
+ // and extended far outside of page's right border.
+ CPPUNIT_ASSERT_EQUAL(true, bool(getProperty<bool>(xTables->getByIndex(0), "IsWidthRelative")));
+ CPPUNIT_ASSERT_EQUAL(sal_Int16(100), getProperty<sal_Int16>(xTables->getByIndex(0), "RelativeWidth"));
+}
+
// tests should only be added to ooxmlIMPORT *if* they fail round-tripping in ooxmlEXPORT
CPPUNIT_PLUGIN_IMPLEMENT();
diff --git a/writerfilter/source/dmapper/DomainMapperTableHandler.cxx b/writerfilter/source/dmapper/DomainMapperTableHandler.cxx
index 5676a3c3ce80..4c8365f0ad6f 100644
--- a/writerfilter/source/dmapper/DomainMapperTableHandler.cxx
+++ b/writerfilter/source/dmapper/DomainMapperTableHandler.cxx
@@ -325,8 +325,6 @@ TableStyleSheetEntry * DomainMapperTableHandler::endTableGetTableStyle(TableInfo
//pPropMap->Insert( PROP_HORI_ORIENT, uno::makeAny( text::HoriOrientation::RIGHT ));
sal_Int32 nGapHalf = 0;
sal_Int32 nLeftMargin = 0;
- sal_Int32 nTableWidth = 0;
- sal_Int32 nTableWidthType = text::SizeType::FIX;
comphelper::SequenceAsHashMap aGrabBag;
@@ -555,14 +553,23 @@ TableStyleSheetEntry * DomainMapperTableHandler::endTableGetTableStyle(TableInfo
m_aTableProperties->Insert( PROP_LEFT_MARGIN, uno::makeAny( nLeftMargin - nGapHalf - rInfo.nLeftBorderDistance ));
}
+ sal_Int32 nTableWidth = 0;
+ sal_Int32 nTableWidthType = text::SizeType::FIX;
m_aTableProperties->getValue( TablePropertyMap::TABLE_WIDTH, nTableWidth );
m_aTableProperties->getValue( TablePropertyMap::TABLE_WIDTH_TYPE, nTableWidthType );
if( nTableWidthType == text::SizeType::FIX )
{
if( nTableWidth > 0 )
m_aTableProperties->Insert( PROP_WIDTH, uno::makeAny( nTableWidth ));
+ else
+ {
+ // tdf#109524: If there is no width for the table, make it simply 100% by default.
+ // TODO: use cell contents to evaluate width (according to ECMA-376-1:2016 17.18.87)
+ nTableWidth = 100;
+ nTableWidthType = text::SizeType::VARIABLE;
+ }
}
- else
+ if (nTableWidthType != text::SizeType::FIX)
{
m_aTableProperties->Insert( PROP_RELATIVE_WIDTH, uno::makeAny( sal_Int16( nTableWidth ) ) );
m_aTableProperties->Insert( PROP_IS_WIDTH_RELATIVE, uno::makeAny( true ) );