summaryrefslogtreecommitdiff
path: root/writerfilter
diff options
context:
space:
mode:
authorAdam Co <rattles2013@gmail.com>2013-06-26 11:08:56 +0300
committerLuboš Luňák <l.lunak@suse.cz>2013-08-01 15:24:53 +0200
commit9390bbfd6e0dd1dc2d007bd391b186d7bf4c86ea (patch)
treefb776b6c3cd9968c0186e9bce1be50e3ce33ee84 /writerfilter
parent7574e9dcddb8ade6c31f1930d400fc231ff72b20 (diff)
DOCX import fix for table with auto size
Reviewed-on: https://gerrit.libreoffice.org/4496 Conflicts: sw/qa/extras/ooxmlimport/ooxmlimport.cxx Change-Id: Ic86f4f142e579bdef3e954492e1c1e382a545739
Diffstat (limited to 'writerfilter')
-rw-r--r--writerfilter/source/dmapper/DomainMapperTableManager.cxx44
-rw-r--r--writerfilter/source/dmapper/DomainMapperTableManager.hxx1
2 files changed, 43 insertions, 2 deletions
diff --git a/writerfilter/source/dmapper/DomainMapperTableManager.cxx b/writerfilter/source/dmapper/DomainMapperTableManager.cxx
index 28135ccd91dc..e28c1714e304 100644
--- a/writerfilter/source/dmapper/DomainMapperTableManager.cxx
+++ b/writerfilter/source/dmapper/DomainMapperTableManager.cxx
@@ -52,6 +52,7 @@ DomainMapperTableManager::DomainMapperTableManager(bool bOOXML) :
m_bOOXML( bOOXML ),
m_bPushCurrentWidth(false),
m_nLayoutType(0),
+ m_nMaxFixedWidth(0),
m_pTablePropsHandler( new TablePropertiesHandler( bOOXML ) )
{
m_pTablePropsHandler->SetTableManager( this );
@@ -127,8 +128,47 @@ bool DomainMapperTableManager::sprm(Sprm & rSprm)
}
else if( sal::static_int_cast<Id>(pMeasureHandler->getUnit()) == NS_ooxml::LN_Value_ST_TblWidth_auto )
{
- pPropMap->setValue( TablePropertyMap::TABLE_WIDTH_TYPE, text::SizeType::VARIABLE );
- pPropMap->setValue( TablePropertyMap::TABLE_WIDTH, 100 );
+ /*
+ This attribute specifies the width type of table. This is used as part of the table layout
+ algorithm specified by the tblLayout element.(See 17.4.64 and 17.4.65 of the ISO/IEC 29500-1:2011.)
+ If this valus is 'auto', the table layout has to uses the preferred widths on the table items to generate
+ the final sizing of the table, but then must use the contents of each cell to determine final column widths.
+ (See 17.18.87 of the ISO/IEC 29500-1:2011.)
+ */
+ bool bFixed = false;
+ sal_Int32 nRowFixedWidth = 0;
+ if (!m_aCellWidths.empty())
+ {
+ // Step 1. Check whether any cell has fixed width in the given row of table.
+ ::std::vector< IntVectorPtr >::iterator itr;
+ for (itr = m_aCellWidths.begin(); itr != m_aCellWidths.end(); itr ++)
+ {
+ IntVectorPtr itrVal = (*itr);
+ for (std::vector<sal_Int32>::const_iterator aValIter = itrVal->begin(); aValIter != itrVal->end(); ++aValIter)
+ {
+ // Sum the width of cells to find the total width of given row
+ nRowFixedWidth += (*aValIter);
+ bFixed = true;
+ }
+ }
+ }
+
+ // Check whether the total width of given row is compared with the maximum value of rows (m_nMaxFixedWidth).
+ if (bFixed )
+ {
+ // Check if total width
+ if (m_nMaxFixedWidth < nRowFixedWidth)
+ m_nMaxFixedWidth = nRowFixedWidth;
+
+ pPropMap->setValue( TablePropertyMap::TABLE_WIDTH_TYPE, text::SizeType::FIX );
+ pPropMap->setValue( TablePropertyMap::TABLE_WIDTH, m_nMaxFixedWidth );
+ }
+ else
+ {
+ // Set the width type of table with 'Auto' and set the width value to 100(%)
+ pPropMap->setValue( TablePropertyMap::TABLE_WIDTH_TYPE, text::SizeType::VARIABLE );
+ pPropMap->setValue( TablePropertyMap::TABLE_WIDTH, 100 );
+ }
}
}
#ifdef DEBUG_DOMAINMAPPER
diff --git a/writerfilter/source/dmapper/DomainMapperTableManager.hxx b/writerfilter/source/dmapper/DomainMapperTableManager.hxx
index 0488de444cbc..c3ac115ded3f 100644
--- a/writerfilter/source/dmapper/DomainMapperTableManager.hxx
+++ b/writerfilter/source/dmapper/DomainMapperTableManager.hxx
@@ -56,6 +56,7 @@ class DomainMapperTableManager : public DomainMapperTableManager_Base_t
::std::vector< IntVectorPtr > m_aCellWidths;
/// Table layout algorithm, IOW if we should consider fixed column width or not.
sal_uInt32 m_nLayoutType;
+ sal_Int32 m_nMaxFixedWidth;
TablePropertiesHandler *m_pTablePropsHandler;
PropertyMapPtr m_pStyleProps;