summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMiklos Vajna <vmiklos@collabora.co.uk>2017-10-24 09:27:19 +0200
committerMiklos Vajna <vmiklos@collabora.co.uk>2017-10-25 14:27:23 +0200
commit63054103570377ef8949addfa153b23838c1672a (patch)
treef87c578062bde2aa1492988c4dc8e146a87754d4
parent2851316853b6c9106d9dc89a8ea4c3ca42eab01e (diff)
tdf#113202 RTF import: fix lack of expected contextual spacing
Upper, lower and contextual spacing are all stored in SvxULSpaceItem, so if after spacing is set as direct formatting, contextual spacing has to be set directly as well (having it in the paragraph style has no effect). (cherry picked from commit f8b5ecc622e2b3e82576b27bf0ded9c8eac21cae) Change-Id: Ie331c7561de7f2f16776a1613717e38fa083a541 Reviewed-on: https://gerrit.libreoffice.org/43808 Reviewed-by: Michael Stahl <mstahl@redhat.com> Tested-by: Jenkins <ci@libreoffice.org>
-rw-r--r--sw/qa/extras/rtfexport/data/tdf113202.rtf42
-rw-r--r--sw/qa/extras/rtfexport/rtfexport.cxx6
-rw-r--r--writerfilter/source/dmapper/DomainMapper.cxx8
3 files changed, 56 insertions, 0 deletions
diff --git a/sw/qa/extras/rtfexport/data/tdf113202.rtf b/sw/qa/extras/rtfexport/data/tdf113202.rtf
new file mode 100644
index 000000000000..43860bf0becf
--- /dev/null
+++ b/sw/qa/extras/rtfexport/data/tdf113202.rtf
@@ -0,0 +1,42 @@
+{\rtf1\adeflang1037\ansi\ansicpg1252\uc1\adeff1\deff0\stshfdbch31506\stshfloch31506\stshfhich31506\stshfbi31507\deflang1033\deflangfe1033\themelang1033\themelangfe0\themelangcs0
+{\fonttbl
+{\f0\fbidi \froman\fcharset238\fprq2 Times New Roman;}
+{\f3\fbidi \froman\fcharset2\fprq2 Symbol;}
+{\f40\fbidi \fswiss\fcharset238\fprq2 Verdana;}
+}
+\noqfpromote
+{\stylesheet
+{\s15\ql \li720\ri0\sa200\sl276\slmult1\widctlpar\wrapdefault\aspalpha\aspnum\faauto\adjustright\rin0\lin720\itap0\contextualspace \rtlch\fcs1 \af1\afs22\alang1025 \ltrch\fcs0 \f31506\fs22\lang1033\langfe1033\cgrid\langnp1033\langfenp1033 \sbasedon0 \snext15 \sqformat \spriority34 List Paragraph;}
+}
+{\*\listtable
+{\list\listtemplateid1644085804\listhybrid
+{\listlevel\levelnfc23\levelnfcn23\leveljc0\leveljcn0\levelfollow0\levelstartat1\levelspace0\levelindent0
+{\leveltext
+\leveltemplateid67698689\'01\u-3913 ?;}
+{\levelnumbers;}
+\f3\fbias0 \fi-360\li720\lin720 }
+{\listname ;}
+\listid2028170298}
+}
+{\*\listoverridetable
+{\listoverride\listid2028170298\listoverridecount0\ls1}
+}
+\paperw12240\paperh15840\margl1417\margr1417\margt1417\margb1417
+\pard\plain \ltrpar
+\s15\ql \fi-360\li720\ri0\sa200\sl276\slmult1\widctlpar\wrapdefault\aspalpha\aspnum\faauto\ls1\adjustright\rin0\lin720\itap0\contextualspace \rtlch\fcs1 \af1\afs22\alang1025 \ltrch\fcs0
+\f31506\fs22\lang1033\langfe1033\cgrid\langnp1033\langfenp1033
+{\rtlch\fcs1 \af37\afs16 \ltrch\fcs0 \f40\fs16 Profile 1 \endash A1\par}
+{\rtlch\fcs1 \af37\afs16 \ltrch\fcs0 \f40\fs16 Profile 1 \endash A2\par}
+{\rtlch\fcs1 \af37\afs16 \ltrch\fcs0 \f40\fs16 Profile 1 \endash A3\par}
+\pard \ltrpar\s15\ql \fi-360\li720\ri0\sl276\slmult1
+\widctlpar\wrapdefault\aspalpha\aspnum\faauto\ls1\adjustright\rin0\lin720\itap0\contextualspace
+{\rtlch\fcs1 \af37\afs16 \ltrch\fcs0 \f40\fs16 Profile 4 }
+{\rtlch\fcs1 \af37\afs16 \ltrch\fcs0
+\f40\fs16 \endash }
+{\rtlch\fcs1 \af37\afs16 \ltrch\fcs0 \f40\fs16 }
+{\rtlch\fcs1 \af37\afs16 \ltrch\fcs0 \f40\fs16 A4}
+{\rtlch\fcs1 \af37\afs16 \ltrch\fcs0
+\f40\fs16
+\par }
+\pard\plain\par
+}
diff --git a/sw/qa/extras/rtfexport/rtfexport.cxx b/sw/qa/extras/rtfexport/rtfexport.cxx
index 151d6b0f4d61..fc6290d6ea15 100644
--- a/sw/qa/extras/rtfexport/rtfexport.cxx
+++ b/sw/qa/extras/rtfexport/rtfexport.cxx
@@ -1309,6 +1309,12 @@ DECLARE_RTFEXPORT_TEST(testTdf112211, "tdf112211.rtf")
CPPUNIT_ASSERT_EQUAL(static_cast<sal_Int32>(-635), aRule["FirstLineIndent"].get<sal_Int32>());
}
+DECLARE_RTFEXPORT_TEST(testTdf113202, "tdf113202.rtf")
+{
+ // This failed, contextual spacing in 4th paragraph was lost.
+ CPPUNIT_ASSERT(getProperty<bool>(getParagraph(4), "ParaContextMargin"));
+}
+
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 95ff12ec8ae7..30e8faa54fe3 100644
--- a/writerfilter/source/dmapper/DomainMapper.cxx
+++ b/writerfilter/source/dmapper/DomainMapper.cxx
@@ -407,8 +407,16 @@ void DomainMapper::lcl_attribute(Id nName, Value & val)
case NS_ooxml::LN_CT_Spacing_after:
m_pImpl->appendGrabBag(m_pImpl->m_aSubInteropGrabBag, "after", OUString::number(nIntValue));
if (m_pImpl->GetTopContext())
+ {
// Don't overwrite NS_ooxml::LN_CT_Spacing_afterAutospacing.
m_pImpl->GetTopContext()->Insert(PROP_PARA_BOTTOM_MARGIN, uno::makeAny( ConversionHelper::convertTwipToMM100( nIntValue ) ), false);
+
+ uno::Any aContextualSpacingFromStyle = m_pImpl->GetPropertyFromStyleSheet(PROP_PARA_CONTEXT_MARGIN);
+ if (aContextualSpacingFromStyle.hasValue())
+ // Setting "after" spacing means Writer doesn't inherit
+ // contexual spacing anymore from style, but Word does.
+ m_pImpl->GetTopContext()->Insert(PROP_PARA_CONTEXT_MARGIN, aContextualSpacingFromStyle);
+ }
break;
case NS_ooxml::LN_CT_Spacing_afterLines:
m_pImpl->appendGrabBag(m_pImpl->m_aSubInteropGrabBag, "afterLines", OUString::number(nIntValue));