diff options
author | Vinaya Mandke <vinaya.mandke@synerzip.com> | 2014-01-20 16:59:56 +0530 |
---|---|---|
committer | Miklos Vajna <vmiklos@collabora.co.uk> | 2014-01-27 10:57:35 +0100 |
commit | c035c3dc527c0756b51865124b96c507c44743ed (patch) | |
tree | e5062321ddf216022699e650afd8ac5a20b0f24c | |
parent | 3db0fdb03ce58a0640fb7c89c22c91169f09ca86 (diff) |
fdo#73556 Docx was exported with incorrect column width
The file contains a table with 3 columns. The girdcols
are as follows: {1210, 1331, 1210}, whereas the
individual cells have {1210, 400, 1210}.
The table column separators were taken from the grid while
the table width was calculated as 2820 from cells
instead of 3751 from the grid.
Hence the table width reduced after export to DOCX
Conflicts:
sw/qa/extras/ooxmlexport/ooxmlexport.cxx
Reviewed on:
https://gerrit.libreoffice.org/7540
Change-Id: I2c590ad6b5ec9fe3e8559971ca8cfa69c5343f47
-rw-r--r-- | sw/qa/extras/ooxmlexport/data/fdo73556.docx | bin | 0 -> 12124 bytes | |||
-rw-r--r-- | sw/qa/extras/ooxmlexport/ooxmlexport.cxx | 21 | ||||
-rw-r--r-- | writerfilter/source/dmapper/DomainMapperTableManager.cxx | 14 |
3 files changed, 35 insertions, 0 deletions
diff --git a/sw/qa/extras/ooxmlexport/data/fdo73556.docx b/sw/qa/extras/ooxmlexport/data/fdo73556.docx Binary files differnew file mode 100644 index 000000000000..50354076d327 --- /dev/null +++ b/sw/qa/extras/ooxmlexport/data/fdo73556.docx diff --git a/sw/qa/extras/ooxmlexport/ooxmlexport.cxx b/sw/qa/extras/ooxmlexport/ooxmlexport.cxx index 7c8fa7ea2b06..90a6b9cbcfd4 100644 --- a/sw/qa/extras/ooxmlexport/ooxmlexport.cxx +++ b/sw/qa/extras/ooxmlexport/ooxmlexport.cxx @@ -2603,6 +2603,27 @@ DECLARE_OOXMLEXPORT_TEST(testFdo69616, "fdo69616.docx") CPPUNIT_ASSERT(getXPath(pXmlDoc, "/w:document/w:body/w:p[1]/w:r[1]/mc:AlternateContent/mc:Fallback/w:pict/v:group", "coordorigin").match("696,725")); } +DECLARE_OOXMLEXPORT_TEST(testFdo73556,"fdo73556.docx") +{ + /* + * The file contains a table with 3 columns + * the girdcols are as follows: {1210, 1331, 1210} + * whereas the individual cells have {1210, 400, 1210} + * The table column separators were taken from the Grid, while + * the table width was calculated as 2820 from cells instead + * of 3751 from the Grid. + */ + xmlDocPtr pXmlDoc = parseExport("word/document.xml"); + if (!pXmlDoc) + return; + assertXPath(pXmlDoc, "/w:document/w:body/w:tbl/w:tblGrid/w:gridCol", 3); + sal_Int32 tableWidth = 0; + tableWidth += getXPath(pXmlDoc, "/w:document/w:body/w:tbl/w:tblGrid/w:gridCol[1]", "w").toInt32(); + tableWidth += getXPath(pXmlDoc, "/w:document/w:body/w:tbl/w:tblGrid/w:gridCol[2]", "w").toInt32(); + tableWidth += getXPath(pXmlDoc, "/w:document/w:body/w:tbl/w:tblGrid/w:gridCol[3]", "w").toInt32(); + CPPUNIT_ASSERT_EQUAL(sal_Int32(3751), tableWidth); +} + #endif CPPUNIT_PLUGIN_IMPLEMENT(); diff --git a/writerfilter/source/dmapper/DomainMapperTableManager.cxx b/writerfilter/source/dmapper/DomainMapperTableManager.cxx index 6969fe337516..2b66761522f0 100644 --- a/writerfilter/source/dmapper/DomainMapperTableManager.cxx +++ b/writerfilter/source/dmapper/DomainMapperTableManager.cxx @@ -654,6 +654,20 @@ void DomainMapperTableManager::endOfRowAction() if( pTableGrid->size() == ( m_nGridBefore + nGrids + m_nGridAfter ) && m_nCell.back( ) > 0 ) { + /* + * 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; + sal_Int32 nTableWidthType; + propMap->getValue( TablePropertyMap::TABLE_WIDTH, nTableWidth ); + propMap->getValue( TablePropertyMap::TABLE_WIDTH_TYPE, nTableWidthType ); + if ((nTableWidthType == text::SizeType::FIX) && (nTableWidth < m_nTableWidth)) + { + propMap->setValue( TablePropertyMap::TABLE_WIDTH, m_nTableWidth ); + } + uno::Sequence< text::TableColumnSeparator > aSeparators( m_nCell.back( ) - 1 ); text::TableColumnSeparator* pSeparators = aSeparators.getArray(); sal_Int16 nLastRelPos = 0; |