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-02 08:21:13 +0000 |
commit | 3cb619bd15a6017f253891f4c377fc790d8aae82 (patch) | |
tree | b5d5db058b7798dfc0705f4a8a410873396647b4 /writerfilter | |
parent | docx import: set table above/bottom spacing to 0 (diff) | |
download | core-3cb619bd15a6017f253891f4c377fc790d8aae82.tar.gz core-3cb619bd15a6017f253891f4c377fc790d8aae82.zip |
docx import: properly import table position
This a follow up of commit 53b7f7df0617bcbd7bbef9a34ef53e5097eb16dc
Change-Id: Ia0f79ca24418636af14162e9f339237d847dc221
Reviewed-on: https://gerrit.libreoffice.org/714
Reviewed-by: Miklos Vajna <vmiklos@suse.cz>
Tested-by: Miklos Vajna <vmiklos@suse.cz>
Diffstat (limited to 'writerfilter')
-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 e710a1366084..26901057157f 100644 --- a/writerfilter/source/dmapper/DomainMapperTableHandler.cxx +++ b/writerfilter/source/dmapper/DomainMapperTableHandler.cxx @@ -398,7 +398,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)) { @@ -410,10 +410,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)) { @@ -440,23 +441,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 ); |