diff options
-rw-r--r-- | sw/qa/extras/ooxmlimport/data/tdf95755.docx | bin | 0 -> 16864 bytes | |||
-rw-r--r-- | sw/qa/extras/ooxmlimport/ooxmlimport.cxx | 15 | ||||
-rw-r--r-- | writerfilter/source/dmapper/DomainMapperTableManager.cxx | 26 |
3 files changed, 27 insertions, 14 deletions
diff --git a/sw/qa/extras/ooxmlimport/data/tdf95755.docx b/sw/qa/extras/ooxmlimport/data/tdf95755.docx Binary files differnew file mode 100644 index 000000000000..194c43199c02 --- /dev/null +++ b/sw/qa/extras/ooxmlimport/data/tdf95755.docx diff --git a/sw/qa/extras/ooxmlimport/ooxmlimport.cxx b/sw/qa/extras/ooxmlimport/ooxmlimport.cxx index e19d1ba4c91e..f5cc1f6fd0ba 100644 --- a/sw/qa/extras/ooxmlimport/ooxmlimport.cxx +++ b/sw/qa/extras/ooxmlimport/ooxmlimport.cxx @@ -2933,6 +2933,21 @@ DECLARE_OOXMLIMPORT_TEST(testTdf78902, "tdf78902.docx") CPPUNIT_ASSERT_EQUAL(2, getPages()); } +DECLARE_OOXMLIMPORT_TEST(testTdf95755, "tdf95755.docx") +{ + /* + * The problem was that the width of a second table with single cell was discarded + * and resulted in too wide table + */ + uno::Reference<text::XTextTablesSupplier> xTablesSupplier(mxComponent, uno::UNO_QUERY); + uno::Reference<container::XIndexAccess> xTables(xTablesSupplier->getTextTables(), uno::UNO_QUERY); + uno::Reference<beans::XPropertySet> xTableProperties(xTables->getByIndex(0), uno::UNO_QUERY); + uno::Any aValue = xTableProperties->getPropertyValue("Width"); + sal_Int32 nWidth; + aValue >>= nWidth; + CPPUNIT_ASSERT_EQUAL(sal_Int32(10659), nWidth); +} + DECLARE_OOXMLIMPORT_TEST(testTdf95775, "tdf95775.docx") { // This must not fail in layout diff --git a/writerfilter/source/dmapper/DomainMapperTableManager.cxx b/writerfilter/source/dmapper/DomainMapperTableManager.cxx index 64199398d874..61988b67c87d 100644 --- a/writerfilter/source/dmapper/DomainMapperTableManager.cxx +++ b/writerfilter/source/dmapper/DomainMapperTableManager.cxx @@ -177,9 +177,8 @@ bool DomainMapperTableManager::sprm(Sprm & rSprm) (See 17.18.87 of the ISO/IEC 29500-1:2011.) */ bool bFixed = true; - sal_Int32 nRowFixedWidth = 0; IntVectorPtr pCellWidths = getCurrentCellWidths(); - // Step 1. Check whether all cells have fixed widths in the given row of table. + // Check whether all cells have fixed widths in the given row of table. for (std::vector<sal_Int32>::const_iterator aValIter = pCellWidths->begin(); aValIter != pCellWidths->end(); ++aValIter) { if (*aValIter == -1) @@ -187,14 +186,11 @@ bool DomainMapperTableManager::sprm(Sprm & rSprm) bFixed = false; break; } - // Sum the width of cells to find the total width of given row - nRowFixedWidth += (*aValIter); } - // Check whether the total width of given row is compared with the maximum value of rows (m_nMaxFixedWidth). if (!bFixed) { - // Set the width type of table with 'Auto' and set the width value to 100(%) + // Set the width type of table with 'Auto' and set the width value to 0 (as per grid values) pPropMap->setValue( TablePropertyMap::TABLE_WIDTH_TYPE, text::SizeType::VARIABLE ); pPropMap->setValue( TablePropertyMap::TABLE_WIDTH, 0 ); } @@ -523,7 +519,7 @@ void DomainMapperTableManager::endOfRowAction() // into two tables if those are different. We surely don't want to do anything // if we don't have any row yet. TablePositionHandlerPtr pTmpPosition = m_aTmpPosition.back(); - TablePropertyMapPtr pTmpTableProperties = m_aTmpTableProperties.back( ); + TablePropertyMapPtr pTablePropMap = m_aTmpTableProperties.back( ); TablePositionHandlerPtr pCurrentPosition = m_aTablePositions.back(); bool bSamePosition = ( pTmpPosition == pCurrentPosition ) || ( pTmpPosition && pCurrentPosition && *pTmpPosition == *pCurrentPosition ); @@ -533,6 +529,7 @@ void DomainMapperTableManager::endOfRowAction() IntVectorPtr pTmpTableGrid = m_aTableGrid.back(); IntVectorPtr pTmpGridSpans = m_aGridSpans.back(); IntVectorPtr pTmpCellWidths = m_aCellWidths.back(); + sal_uInt32 nTmpCell = m_nCell.back(); // endLevel and startLevel are taking care of the non finished row // to carry it over to the next table @@ -544,9 +541,11 @@ void DomainMapperTableManager::endOfRowAction() m_aTableGrid.pop_back(); m_aGridSpans.pop_back(); m_aCellWidths.pop_back(); + m_nCell.pop_back(); m_aTableGrid.push_back(pTmpTableGrid); m_aGridSpans.push_back(pTmpGridSpans); m_aCellWidths.push_back(pTmpCellWidths); + m_nCell.push_back(nTmpCell); } // Push the tmp position now that we compared it @@ -633,21 +632,20 @@ void DomainMapperTableManager::endOfRowAction() * If table width property set earlier is smaller than the current table width, * then replace the TABLE_WIDTH property, set earlier. */ - TablePropertyMapPtr propMap = m_aTmpTableProperties.back(); sal_Int32 nTableWidth(0); sal_Int32 nTableWidthType(text::SizeType::VARIABLE); - propMap->getValue( TablePropertyMap::TABLE_WIDTH, nTableWidth ); - propMap->getValue( TablePropertyMap::TABLE_WIDTH_TYPE, nTableWidthType ); + pTablePropMap->getValue(TablePropertyMap::TABLE_WIDTH, nTableWidth); + pTablePropMap->getValue(TablePropertyMap::TABLE_WIDTH_TYPE, nTableWidthType); if ((nTableWidthType == text::SizeType::FIX) && (nTableWidth < m_nTableWidth)) { - propMap->setValue( TablePropertyMap::TABLE_WIDTH, m_nTableWidth ); + pTablePropMap->setValue(TablePropertyMap::TABLE_WIDTH, m_nTableWidth); } if (nTableWidthType == text::SizeType::VARIABLE ) { if(nTableWidth > 100 || nTableWidth <= 0) { - propMap->setValue( TablePropertyMap::TABLE_WIDTH, m_nTableWidth); - propMap->setValue( TablePropertyMap::TABLE_WIDTH_TYPE, text::SizeType::FIX); + pTablePropMap->setValue(TablePropertyMap::TABLE_WIDTH, m_nTableWidth); + pTablePropMap->setValue(TablePropertyMap::TABLE_WIDTH_TYPE, text::SizeType::FIX); } } uno::Sequence< text::TableColumnSeparator > aSeparators( m_nCell.back( ) - 1 ); @@ -734,7 +732,7 @@ void DomainMapperTableManager::endOfRowAction() } // Now that potentially opened table is closed, save the table properties - TableManager::insertTableProps( pTmpTableProperties ); + TableManager::insertTableProps(pTablePropMap); m_aTmpTableProperties.pop_back(); TablePropertyMapPtr pEmptyTableProps( new TablePropertyMap() ); |