Kaydet (Commit) c433a482 authored tarafından Miklos Vajna's avatar Miklos Vajna

fdo#59273 DOCX import: fix table width when w:tblW is missing

Regression from 6718482c, put back the
table width counting in DomainMapperTableManager::endOfRowAction(), in
case the document has no explicit w:tblW token.

Change-Id: I8bd983045e1950451c9afb4f15f1deb87312524e
üst f0d001a3
......@@ -1297,9 +1297,12 @@ void Test::testFdo59273()
uno::Reference<text::XTextTablesSupplier> xTablesSupplier(mxComponent, uno::UNO_QUERY);
uno::Reference<container::XIndexAccess> xTables(xTablesSupplier->getTextTables( ), uno::UNO_QUERY);
uno::Reference<text::XTextTable> xTextTable(xTables->getByIndex(0), uno::UNO_QUERY);
// Was 115596 (i.e. 10 times wider than necessary), as w:tblW was missing and the importer didn't set it.
CPPUNIT_ASSERT_EQUAL(sal_Int32(12961), getProperty<sal_Int32>(xTextTable, "Width"));
uno::Reference<table::XTableRows> xTableRows(xTextTable->getRows(), uno::UNO_QUERY);
// Was 9997, so the 4th column had ~zero width
CPPUNIT_ASSERT_EQUAL(sal_Int16(7499), getProperty< uno::Sequence<text::TableColumnSeparator> >(xTableRows->getByIndex(0), "TableColumnSeparators")[2].Position);
CPPUNIT_ASSERT_EQUAL(sal_Int16(7498), getProperty< uno::Sequence<text::TableColumnSeparator> >(xTableRows->getByIndex(0), "TableColumnSeparators")[2].Position);
}
void Test::testTableWidth()
......
......@@ -53,6 +53,7 @@ DomainMapperTableManager::DomainMapperTableManager(bool bOOXML) :
m_bOOXML( bOOXML ),
m_bPushCurrentWidth(false),
m_bRowSizeTypeInserted(false),
m_bTableSizeTypeInserted(false),
m_nLayoutType(0),
m_pTablePropsHandler( new TablePropertiesHandler( bOOXML ) )
{
......@@ -132,6 +133,7 @@ bool DomainMapperTableManager::sprm(Sprm & rSprm)
pPropMap->setValue( TablePropertyMap::TABLE_WIDTH_TYPE, text::SizeType::VARIABLE );
pPropMap->setValue( TablePropertyMap::TABLE_WIDTH, 100 );
}
m_bTableSizeTypeInserted = true;
}
#ifdef DEBUG_DOMAINMAPPER
pPropMap->dumpXml( dmapper_logger );
......@@ -493,6 +495,13 @@ void DomainMapperTableManager::endOfRowAction()
m_nTableWidth += *aCellIter++;
}
if (m_nTableWidth > 0 && !m_bTableSizeTypeInserted)
{
TablePropertyMapPtr pPropMap( new TablePropertyMap );
pPropMap->setValue( TablePropertyMap::TABLE_WIDTH, m_nTableWidth );
insertTableProps(pPropMap);
}
#ifdef DEBUG_DOMAINMAPPER
dmapper_logger->endElement();
#endif
......@@ -610,6 +619,7 @@ void DomainMapperTableManager::endOfRowAction()
m_nGridBefore = m_nGridAfter = 0;
m_bRowSizeTypeInserted = false;
m_bTableSizeTypeInserted = false;
#ifdef DEBUG_DOMAINMAPPER
dmapper_logger->endElement();
......
......@@ -56,6 +56,8 @@ class DomainMapperTableManager : public DomainMapperTableManager_Base_t
::std::vector< IntVectorPtr > m_aCellWidths;
/// Remember if a cell already set this, then it should not be set at a row level.
bool m_bRowSizeTypeInserted;
/// Remember if table width was already set, when we lack a w:tblW, it should be set manually at the end.
bool m_bTableSizeTypeInserted;
/// Table layout algorithm, IOW if we should consider fixed column width or not.
sal_uInt32 m_nLayoutType;
......@@ -128,6 +130,11 @@ public:
return m_bRowSizeTypeInserted;
}
bool IsTableSizeTypeInserted() const
{
return m_bTableSizeTypeInserted;
}
void SetLayoutType(sal_uInt32 nLayoutType)
{
m_nLayoutType = nLayoutType;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment