From 6f93c2519940b8e0afb7c50cacf06b2addfc873b Mon Sep 17 00:00:00 2001 From: Miklos Vajna Date: Thu, 22 Jun 2017 13:41:30 +0200 Subject: tdf#108682 DOCX import: fix for negative values I didn't find UI in Word to create the equivalent markup when you set line spacing to exactly 13pt for new documents is: The OOXML spec and Microsoft's implementer notes ([MS-OI29500]) is also pretty silent about what a negative value means. However, if this markup is converted to WW8 by Word, then the WW8 LPSD structure is like this (as presented by doc-dumper): For the 0xfefc value the [MS-DOC] spec clearly states that means the type of the spacing is "exactly", with the value of 0x10000-0xfefc, i.e. the same 260 twips. Change-Id: I84b485d02dea49c610b6df2e06ccce03e1d29d21 Reviewed-on: https://gerrit.libreoffice.org/39091 Tested-by: Jenkins Reviewed-by: Miklos Vajna (cherry picked from commit f575f70b8303ba187f6989920281ff02e7a431c9) Reviewed-on: https://gerrit.libreoffice.org/39162 Reviewed-by: Andras Timar Tested-by: Andras Timar --- writerfilter/source/dmapper/DomainMapper.cxx | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) (limited to 'writerfilter/source') diff --git a/writerfilter/source/dmapper/DomainMapper.cxx b/writerfilter/source/dmapper/DomainMapper.cxx index 08c6bfd7f820..ee9f30dbf66b 100644 --- a/writerfilter/source/dmapper/DomainMapper.cxx +++ b/writerfilter/source/dmapper/DomainMapper.cxx @@ -454,9 +454,19 @@ void DomainMapper::lcl_attribute(Id nName, Value & val) if( sal::static_int_cast(nIntValue) == NS_ooxml::LN_Value_doc_ST_LineSpacingRule_auto) { m_pImpl->appendGrabBag(m_pImpl->m_aSubInteropGrabBag, "lineRule", "auto"); - aSpacing.Mode = style::LineSpacingMode::PROP; - //reinterpret the already set value - aSpacing.Height = sal_Int16( aSpacing.Height * 100 / ConversionHelper::convertTwipToMM100( nSingleLineSpacing )); + if (aSpacing.Height >= 0) + { + aSpacing.Mode = style::LineSpacingMode::PROP; + //reinterpret the already set value + aSpacing.Height = sal_Int16( aSpacing.Height * 100 / ConversionHelper::convertTwipToMM100( nSingleLineSpacing )); + } + else + { + // Negative value still means a positive height, + // just the mode is "exact". + aSpacing.Mode = style::LineSpacingMode::FIX; + aSpacing.Height *= -1; + } } else if( sal::static_int_cast(nIntValue) == NS_ooxml::LN_Value_doc_ST_LineSpacingRule_atLeast) { -- cgit v1.2.3