diff options
author | Vitaliy Anderson <vanderson@smartru.com> | 2017-04-04 17:11:12 +0300 |
---|---|---|
committer | Mike Kaganski <mike.kaganski@collabora.com> | 2017-04-17 13:11:53 +0200 |
commit | 9a31d1c83e08600507689dc18f6f0973bc7e4389 (patch) | |
tree | cb2920d25d6fbbd8dba3064de18ed24e4055744e /writerfilter/source/dmapper/DomainMapperTableHandler.cxx | |
parent | 664980f34bb26f34a3365ded3d05e177d2c888d1 (diff) |
tdf#106742: OOXML import/export: treat "tblInd" properly.
Since MS Word 2013+ if you change cell margin at the table, the border won't be shifted.
The decision is to do the same ( see https://bugs.documentfoundation.org/show_bug.cgi?id=106742 ).
Change-Id: Ia58693c44f63ed21dca2cd99591002ba68927b65
Reviewed-on: https://gerrit.libreoffice.org/36084
Tested-by: Jenkins <ci@libreoffice.org>
Reviewed-by: Mike Kaganski <mike.kaganski@collabora.com>
Diffstat (limited to 'writerfilter/source/dmapper/DomainMapperTableHandler.cxx')
-rw-r--r-- | writerfilter/source/dmapper/DomainMapperTableHandler.cxx | 39 |
1 files changed, 36 insertions, 3 deletions
diff --git a/writerfilter/source/dmapper/DomainMapperTableHandler.cxx b/writerfilter/source/dmapper/DomainMapperTableHandler.cxx index c4d26e514429..8fa604a3710c 100644 --- a/writerfilter/source/dmapper/DomainMapperTableHandler.cxx +++ b/writerfilter/source/dmapper/DomainMapperTableHandler.cxx @@ -313,6 +313,34 @@ void lcl_DecrementHoriOrientPosition(std::vector<beans::PropertyValue>& rFramePr } } +sal_Int32 lcl_getWordCompatibilityMode( const css::uno::Sequence< css::beans::PropertyValue >& rCompatSettings ) +{ + for ( int i = 0; i < rCompatSettings.getLength(); ++i ) + { + const css::beans::PropertyValue& rProp = rCompatSettings[i]; + if ( rProp.Name == "compatSetting" ) + { + css::uno::Sequence< css::beans::PropertyValue > aCurrentCompatSettings; + rProp.Value >>= aCurrentCompatSettings; + + OUString sName; + OUString sUri; + OUString sVal; + + aCurrentCompatSettings[0].Value >>= sName; + aCurrentCompatSettings[1].Value >>= sUri; + aCurrentCompatSettings[2].Value >>= sVal; + + if ( sName == "compatibilityMode" && sUri == "http://schemas.microsoft.com/office/word" ) + { + return sVal.toInt32(); + } + } + } + + return -1; // Word compatibility mode not found +} + TableStyleSheetEntry * DomainMapperTableHandler::endTableGetTableStyle(TableInfo & rInfo, std::vector<beans::PropertyValue>& rFrameProperties) { // will receive the table style if any @@ -546,13 +574,18 @@ TableStyleSheetEntry * DomainMapperTableHandler::endTableGetTableStyle(TableInfo // - 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) + + // tdf#106742: since MS Word 2013 (compatibilityMode >= 15), top-level tables are handled the same as nested tables; + // this is also the default behavior in LO when DOCX doesn't define "compatibilityMode" option + sal_Int32 nMode = lcl_getWordCompatibilityMode( m_rDMapper_Impl.GetSettingsTable()->GetCompatSettings() ); + + if ( nMode > 0 && nMode <= 14 && rInfo.nNestLevel == 1 ) { - m_aTableProperties->Insert( PROP_LEFT_MARGIN, uno::makeAny( nLeftMargin - nGapHalf )); + m_aTableProperties->Insert( PROP_LEFT_MARGIN, uno::makeAny( nLeftMargin - nGapHalf - rInfo.nLeftBorderDistance ) ); } else { - m_aTableProperties->Insert( PROP_LEFT_MARGIN, uno::makeAny( nLeftMargin - nGapHalf - rInfo.nLeftBorderDistance )); + m_aTableProperties->Insert( PROP_LEFT_MARGIN, uno::makeAny( nLeftMargin - nGapHalf ) ); } m_aTableProperties->getValue( TablePropertyMap::TABLE_WIDTH, nTableWidth ); |