diff options
author | Pierre-Eric Pelloux-Prayer <pierre-eric@lanedo.com> | 2012-09-27 10:15:58 +0200 |
---|---|---|
committer | Miklos Vajna <vmiklos@suse.cz> | 2012-10-30 10:14:33 +0100 |
commit | 47d9a8a3397ed2f4ff7e7ec1bba392da34d8519e (patch) | |
tree | 07663e851195fdb61ca6e79bebb61278219e03d7 | |
parent | 2cefbc6622e8838e049542376ea76c4c4179fbb3 (diff) |
n#780645 docx import: properly import table position
This a follow up of commit 53b7f7df0617bcbd7bbef9a34ef53e5097eb16dc
Reviewed-on: https://gerrit.libreoffice.org/714
Reviewed-by: Miklos Vajna <vmiklos@suse.cz>
Tested-by: Miklos Vajna <vmiklos@suse.cz>
(cherry picked from commit 3cb619bd15a6017f253891f4c377fc790d8aae82)
Change-Id: Ia0f79ca24418636af14162e9f339237d847dc221
-rw-r--r-- | writerfilter/source/dmapper/DomainMapperTableHandler.cxx | 27 |
1 files changed, 11 insertions, 16 deletions
diff --git a/writerfilter/source/dmapper/DomainMapperTableHandler.cxx b/writerfilter/source/dmapper/DomainMapperTableHandler.cxx index 91d652d3b3e4..f44e93ce1616 100644 --- a/writerfilter/source/dmapper/DomainMapperTableHandler.cxx +++ b/writerfilter/source/dmapper/DomainMapperTableHandler.cxx @@ -403,7 +403,7 @@ TableStyleSheetEntry * DomainMapperTableHandler::endTableGetTableStyle(TableInfo //table border settings table::TableBorder aTableBorder; - table::BorderLine2 aBorderLine; + table::BorderLine2 aBorderLine, aLeftBorder; if (lcl_extractTableBorderProperty(m_aTableProperties, PROP_TOP_BORDER, rInfo, aBorderLine)) { @@ -415,10 +415,11 @@ TableStyleSheetEntry * DomainMapperTableHandler::endTableGetTableStyle(TableInfo aTableBorder.BottomLine = aBorderLine; aTableBorder.IsBottomLineValid = sal_True; } - if (lcl_extractTableBorderProperty(m_aTableProperties, PROP_LEFT_BORDER, rInfo, aBorderLine)) + if (lcl_extractTableBorderProperty(m_aTableProperties, PROP_LEFT_BORDER, rInfo, aLeftBorder)) { - aTableBorder.LeftLine = aBorderLine; + aTableBorder.LeftLine = aLeftBorder; aTableBorder.IsLeftLineValid = sal_True; + rInfo.nLeftBorderDistance += aLeftBorder.LineWidth * 0.5; } if (lcl_extractTableBorderProperty(m_aTableProperties, PROP_RIGHT_BORDER, rInfo, aBorderLine)) { @@ -445,23 +446,17 @@ TableStyleSheetEntry * DomainMapperTableHandler::endTableGetTableStyle(TableInfo lcl_debug_TableBorder(aTableBorder); #endif - // 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) + // Table position in Office is computed in 2 different ways : + // - top level tables: the goal is to have in-cell text starting at table indent pos (tblInd), + // so table's position depends on table's cells margin + // - nested tables: the goal is to have left-most border starting at table_indent pos + if (rInfo.nNestLevel > 1) { - m_aTableProperties->Insert( PROP_LEFT_MARGIN, false, uno::makeAny( nLeftMargin - nGapHalf)); + 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->Insert( PROP_LEFT_MARGIN, false, uno::makeAny( nLeftMargin - nGapHalf - rInfo.nLeftBorderDistance )); } m_aTableProperties->getValue( TablePropertyMap::TABLE_WIDTH, nTableWidth ); |