summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMiklos Vajna <vmiklos@collabora.co.uk>2014-10-17 09:59:38 +0200
committerMiklos Vajna <vmiklos@collabora.co.uk>2014-10-17 10:19:41 +0200
commit9e7eb63989ef1cf4b9a0e0404b84ef890db3d8e3 (patch)
tree0f61377814c38bda7efc1bc04583aafc53db4fcb
parent0591ee255aadee27e85a79db87a56b6882993faf (diff)
DOCX import: parse <w:spacing>'s w:before/afterLines attribute
Change-Id: I63b3afda5e8915b562de51aa31e420c135f919ba
-rw-r--r--sw/qa/extras/ooxmlexport/data/afterlines.docxbin0 -> 12622 bytes
-rw-r--r--sw/qa/extras/ooxmlexport/ooxmlexport.cxx6
-rw-r--r--writerfilter/source/dmapper/DomainMapper.cxx12
3 files changed, 14 insertions, 4 deletions
diff --git a/sw/qa/extras/ooxmlexport/data/afterlines.docx b/sw/qa/extras/ooxmlexport/data/afterlines.docx
new file mode 100644
index 000000000000..296f91e2e65d
--- /dev/null
+++ b/sw/qa/extras/ooxmlexport/data/afterlines.docx
Binary files differ
diff --git a/sw/qa/extras/ooxmlexport/ooxmlexport.cxx b/sw/qa/extras/ooxmlexport/ooxmlexport.cxx
index 3d5d727027c1..395c753a4c20 100644
--- a/sw/qa/extras/ooxmlexport/ooxmlexport.cxx
+++ b/sw/qa/extras/ooxmlexport/ooxmlexport.cxx
@@ -477,6 +477,12 @@ DECLARE_OOXMLEXPORT_TEST(testFdo77716, "fdo77716.docx")
CPPUNIT_ASSERT_EQUAL(static_cast<sal_Int32>(convertTwipToMm100(200)), getProperty<sal_Int32>(xStyle, "ParaBottomMargin"));
}
+DECLARE_OOXMLEXPORT_TEST(testAfterlines, "afterlines.docx")
+{
+ // This was 353, i.e. the value of <w:spacing w:after="200"> from <w:pPrDefault>, instead of <w:spacing w:afterLines="100"/> from <w:pPr>.
+ CPPUNIT_ASSERT_EQUAL(static_cast<sal_Int32>(423), getProperty<sal_Int32>(getParagraph(1), "ParaBottomMargin"));
+}
+
CPPUNIT_PLUGIN_IMPLEMENT();
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/writerfilter/source/dmapper/DomainMapper.cxx b/writerfilter/source/dmapper/DomainMapper.cxx
index e8c6e4219d13..c7762f676d9f 100644
--- a/writerfilter/source/dmapper/DomainMapper.cxx
+++ b/writerfilter/source/dmapper/DomainMapper.cxx
@@ -184,6 +184,7 @@ void DomainMapper::lcl_attribute(Id nName, Value & val)
return;
static OUString sLocalBookmarkName;
+ static const int nSingleLineSpacing = 240;
sal_Int32 nIntValue = val.getInt();
OUString sStringValue = val.getString();
@@ -370,6 +371,8 @@ void DomainMapper::lcl_attribute(Id nName, Value & val)
break;
case NS_ooxml::LN_CT_Spacing_beforeLines:
m_pImpl->appendGrabBag(m_pImpl->m_aSubInteropGrabBag, "beforeLines", OUString::number(nIntValue));
+ if (m_pImpl->GetTopContext())
+ m_pImpl->GetTopContext()->Insert(PROP_PARA_TOP_MARGIN, uno::makeAny(ConversionHelper::convertTwipToMM100(nIntValue * nSingleLineSpacing / 100)), false);
break;
case NS_ooxml::LN_CT_Spacing_after:
m_pImpl->appendGrabBag(m_pImpl->m_aSubInteropGrabBag, "after", OUString::number(nIntValue));
@@ -379,11 +382,12 @@ void DomainMapper::lcl_attribute(Id nName, Value & val)
break;
case NS_ooxml::LN_CT_Spacing_afterLines:
m_pImpl->appendGrabBag(m_pImpl->m_aSubInteropGrabBag, "afterLines", OUString::number(nIntValue));
+ if (m_pImpl->GetTopContext())
+ m_pImpl->GetTopContext()->Insert(PROP_PARA_BOTTOM_MARGIN, uno::makeAny(ConversionHelper::convertTwipToMM100(nIntValue * nSingleLineSpacing / 100)), false);
break;
case NS_ooxml::LN_CT_Spacing_line: //91434
case NS_ooxml::LN_CT_Spacing_lineRule: //91435
{
-#define SINGLE_LINE_SPACING 240
style::LineSpacing aSpacing;
PropertyMapPtr pTopContext = m_pImpl->GetTopContext();
boost::optional<PropertyMap::Property> aLineSpacingVal;
@@ -395,14 +399,14 @@ void DomainMapper::lcl_attribute(Id nName, Value & val)
{
//default to single line spacing
aSpacing.Mode = style::LineSpacingMode::FIX;
- aSpacing.Height = sal_Int16(ConversionHelper::convertTwipToMM100( SINGLE_LINE_SPACING ));
+ aSpacing.Height = sal_Int16(ConversionHelper::convertTwipToMM100( nSingleLineSpacing ));
}
if( nName == NS_ooxml::LN_CT_Spacing_line )
{
m_pImpl->appendGrabBag(m_pImpl->m_aSubInteropGrabBag, "line", OUString::number(nIntValue));
//now set the value depending on the Mode
if( aSpacing.Mode == style::LineSpacingMode::PROP )
- aSpacing.Height = sal_Int16(sal_Int32(nIntValue) * 100 / SINGLE_LINE_SPACING );
+ aSpacing.Height = sal_Int16(sal_Int32(nIntValue) * 100 / nSingleLineSpacing );
else
aSpacing.Height = sal_Int16(ConversionHelper::convertTwipToMM100( nIntValue ));
@@ -422,7 +426,7 @@ void DomainMapper::lcl_attribute(Id nName, Value & val)
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( SINGLE_LINE_SPACING ));
+ aSpacing.Height = sal_Int16( aSpacing.Height * 100 / ConversionHelper::convertTwipToMM100( nSingleLineSpacing ));
}
else if( sal::static_int_cast<Id>(nIntValue) == NS_ooxml::LN_Value_doc_ST_LineSpacingRule_atLeast)
{