diff options
author | Pierre-Eric Pelloux-Prayer <pierre-eric@lanedo.com> | 2012-09-20 11:49:29 +0200 |
---|---|---|
committer | Cédric Bosdonnat <cedric.bosdonnat@free.fr> | 2012-09-20 18:20:18 +0200 |
commit | 53b7f7df0617bcbd7bbef9a34ef53e5097eb16dc (patch) | |
tree | d7dc599a9a9b566275dcc40af28c1dbe80dd85f9 /writerfilter/source/dmapper/DomainMapperTableHandler.cxx | |
parent | 064ae986a0aa55db9f3ee829a7c83bf2ac65c77f (diff) |
docx import: position table using tblInd OR tblCellMar
Previously cell-margin was unconditionnaly used to compute table position.
Office only does so on top-level tables and if tblInd is missing.
Change-Id: I183647bcf090d5822b3f2e04e097c8bbd277168d
Diffstat (limited to 'writerfilter/source/dmapper/DomainMapperTableHandler.cxx')
-rw-r--r-- | writerfilter/source/dmapper/DomainMapperTableHandler.cxx | 24 |
1 files changed, 22 insertions, 2 deletions
diff --git a/writerfilter/source/dmapper/DomainMapperTableHandler.cxx b/writerfilter/source/dmapper/DomainMapperTableHandler.cxx index fbdabd982bc4..dce337d40ea0 100644 --- a/writerfilter/source/dmapper/DomainMapperTableHandler.cxx +++ b/writerfilter/source/dmapper/DomainMapperTableHandler.cxx @@ -262,6 +262,7 @@ struct WRITERFILTER_DLLPRIVATE TableInfo sal_Int32 nRightBorderDistance; sal_Int32 nTopBorderDistance; sal_Int32 nBottomBorderDistance; + sal_Int32 nNestLevel; PropertyMapPtr pTableDefaults; PropertyMapPtr pTableBorders; TableStyleSheetEntry* pTableStyle; @@ -272,6 +273,7 @@ struct WRITERFILTER_DLLPRIVATE TableInfo , nRightBorderDistance(DEF_BORDER_DIST) , nTopBorderDistance(0) , nBottomBorderDistance(0) + , nNestLevel(0) , pTableDefaults(new PropertyMap) , pTableBorders(new PropertyMap) , pTableStyle(NULL) @@ -433,7 +435,24 @@ TableStyleSheetEntry * DomainMapperTableHandler::endTableGetTableStyle(TableInfo lcl_debug_TableBorder(aTableBorder); #endif - m_aTableProperties->Insert( PROP_LEFT_MARGIN, false, uno::makeAny( nLeftMargin - nGapHalf - rInfo.nLeftBorderDistance)); + // Mimic Office behavior : if tlbInd is defined, use it place table. + // Otherwise, top-level table's position depends w:tblCellMar attribute (but not nested tables) + if (nLeftMargin) + { + m_aTableProperties->Insert( PROP_LEFT_MARGIN, false, uno::makeAny( nLeftMargin - nGapHalf)); + } + else + { + // TODO: top-level position depends on w:tblCellMar attribute, not w:cellMar + if (rInfo.nNestLevel > 1) + { + m_aTableProperties->Insert( PROP_LEFT_MARGIN, false, uno::makeAny( - nGapHalf)); + } + else + { + m_aTableProperties->Insert( PROP_LEFT_MARGIN, false, uno::makeAny( - nGapHalf - rInfo.nLeftBorderDistance)); + } + } m_aTableProperties->getValue( TablePropertyMap::TABLE_WIDTH, nTableWidth ); if( nTableWidth > 0 ) @@ -672,13 +691,14 @@ RowPropertyValuesSeq_t DomainMapperTableHandler::endTableGetRowProperties() return aRowProperties; } -void DomainMapperTableHandler::endTable() +void DomainMapperTableHandler::endTable(unsigned int nestedTableLevel) { #ifdef DEBUG_DMAPPER_TABLE_HANDLER dmapper_logger->startElement("tablehandler.endTable"); #endif TableInfo aTableInfo; + aTableInfo.nNestLevel = nestedTableLevel; aTableInfo.pTableStyle = endTableGetTableStyle(aTableInfo); // expands to uno::Sequence< Sequence< beans::PropertyValues > > |