tdf#134385 doc/docxexport: maybe export false contextualspacing
Instead of LO 4.2's solution of never exporting false,
export if the inherited value would be true.
Otherwise there is no way to override an inherited value.
RTF doesn't have a "false" version of
\contextualspace, so I ignored that format.
Change-Id: I6d05eb9a5d3fbfbfca0fddd7eda0c230baa25c5c
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/113064
Tested-by: Jenkins
Reviewed-by: Justin Luth <justin_luth@sil.org>
Reviewed-by: Miklos Vajna <vmiklos@collabora.com>
diff --git a/sw/qa/extras/ooxmlexport/ooxmlexport12.cxx b/sw/qa/extras/ooxmlexport/ooxmlexport12.cxx
index 743671e..3a85307 100644
--- a/sw/qa/extras/ooxmlexport/ooxmlexport12.cxx
+++ b/sw/qa/extras/ooxmlexport/ooxmlexport12.cxx
@@ -974,6 +974,9 @@ DECLARE_OOXMLEXPORT_EXPORTONLY_TEST(testTdf138899, "tdf138899.docx")
xmlDocUniquePtr pXmlDocument = parseExport("word/document.xml");
// This was 6, not removed empty temporary paragraph at the end of the section
assertXPath(pXmlDocument, "/w:document/w:body/w:p", 5);
//tdf#134385: Paragraph property to "add space between paragraphs of the same style" was lost
assertXPath(pXmlDocument, "//w:p[1]/w:pPr/w:contextualSpacing", "val", "false");
}
DECLARE_OOXMLEXPORT_EXPORTONLY_TEST(testTdf122563, "tdf122563.docx")
diff --git a/sw/source/filter/ww8/docxattributeoutput.cxx b/sw/source/filter/ww8/docxattributeoutput.cxx
index 7e67ffd..cd67d87 100644
--- a/sw/source/filter/ww8/docxattributeoutput.cxx
+++ b/sw/source/filter/ww8/docxattributeoutput.cxx
@@ -8928,6 +8928,18 @@ void DocxAttributeOutput::FormatULSpace( const SvxULSpaceItem& rULSpace )
if (rULSpace.GetContext())
m_pSerializer->singleElementNS(XML_w, XML_contextualSpacing);
else
{
// Write out Contextual Spacing = false if it would have inherited a true.
const SvxULSpaceItem* pInherited = nullptr;
if (auto pNd = dynamic_cast<const SwContentNode*>(m_rExport.m_pOutFormatNode)) //paragraph
pInherited = &static_cast<SwTextFormatColl&>(pNd->GetAnyFormatColl()).GetAttrSet().GetULSpace();
else if (m_rExport.m_bStyDef && m_rExport.m_pCurrentStyle && m_rExport.m_pCurrentStyle->DerivedFrom()) //style
pInherited = &m_rExport.m_pCurrentStyle->DerivedFrom()->GetULSpace();
if (pInherited && pInherited->GetContext())
m_pSerializer->singleElementNS(XML_w, XML_contextualSpacing, FSNS(XML_w, XML_val), "false");
}
}
}
diff --git a/sw/source/filter/ww8/ww8atr.cxx b/sw/source/filter/ww8/ww8atr.cxx
index 95b7bab..985df4d 100644
--- a/sw/source/filter/ww8/ww8atr.cxx
+++ b/sw/source/filter/ww8/ww8atr.cxx
@@ -4157,7 +4157,17 @@ void WW8AttributeOutput::FormatULSpace( const SvxULSpaceItem& rUL )
m_rWW8Export.InsUInt16( NS_sprm::PDyaAfter::val );
m_rWW8Export.InsUInt16( rUL.GetLower() );
// sprmPFContextualSpacing
if (rUL.GetContext())
// Write out Contextual Spacing = false if it would have inherited a true.
const SvxULSpaceItem* pInherited = nullptr;
if (!rUL.GetContext())
{
if (auto pNd = dynamic_cast<const SwContentNode*>(m_rWW8Export.m_pOutFormatNode)) //paragraph
pInherited = &static_cast<SwTextFormatColl&>(pNd->GetAnyFormatColl()).GetAttrSet().GetULSpace();
else if (m_rWW8Export.m_bStyDef && m_rWW8Export.m_pCurrentStyle && m_rWW8Export.m_pCurrentStyle->DerivedFrom()) //style
pInherited = &m_rWW8Export.m_pCurrentStyle->DerivedFrom()->GetULSpace();
}
if (rUL.GetContext() || (pInherited && pInherited->GetContext()))
{
m_rWW8Export.InsUInt16(NS_sprm::PFContextualSpacing::val);
m_rWW8Export.pO->push_back( static_cast<sal_uInt8>(rUL.GetContext()) );