sw/qa/extras/ooxmlexport/ooxmlexport12.cxx   |    3 +++
 sw/source/filter/ww8/docxattributeoutput.cxx |   12 ++++++++++++
 sw/source/filter/ww8/ww8atr.cxx              |   12 +++++++++++-
 3 files changed, 26 insertions(+), 1 deletion(-)

New commits:
commit 5c90f3d28de6262bb730bad106d4652e458054df
Author:     Justin Luth <justin.l...@collabora.com>
AuthorDate: Wed Mar 24 15:49:47 2021 +0200
Commit:     Miklos Vajna <vmik...@collabora.com>
CommitDate: Wed Mar 31 09:08:25 2021 +0200

    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_l...@sil.org>
    Reviewed-by: Miklos Vajna <vmik...@collabora.com>

diff --git a/sw/qa/extras/ooxmlexport/ooxmlexport12.cxx 
b/sw/qa/extras/ooxmlexport/ooxmlexport12.cxx
index 743671e465b3..3a8530733c76 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 7e67ffda5590..cd67d87495bd 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 95b7bab8034b..985df4df45a2 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()) );
_______________________________________________
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits

Reply via email to