sw/qa/extras/ooxmlexport/ooxmlexport21.cxx           |   14 +++++++-------
 sw/source/writerfilter/dmapper/DomainMapper.cxx      |    3 ++-
 sw/source/writerfilter/dmapper/DomainMapper_Impl.cxx |   19 ++++++++++++++++---
 sw/source/writerfilter/dmapper/DomainMapper_Impl.hxx |    2 +-
 4 files changed, 26 insertions(+), 12 deletions(-)

New commits:
commit 965d83d3a729b0c01c882e200d8bf18dd347c027
Author:     Justin Luth <[email protected]>
AuthorDate: Wed Jul 17 15:51:46 2024 -0400
Commit:     Justin Luth <[email protected]>
CommitDate: Fri Jul 19 02:49:18 2024 +0200

    related tdf#125469 writerfilter: support negative exact and atLeast
    
    When vmiklos added support for negative auto -> FIX,
    he indicated that there was no documentation for it.
        commit f575f70b8303ba187f6989920281ff02e7a431c9
        Author: Miklos Vajna on Thu Jun 22 13:41:30 2017 +0200
        tdf#108682 DOCX import: fix <w:spacing w:line=...> for negative
            I didn't find UI in Word to create
    
    In working on bug 125469, I hand-crafted a nasty example document
    which had negative exact and atLeast examples,
    and this patch matches what I saw happening in Word 2010.
    Too bad MS isn't completely consistent...
    
    Change-Id: Iaab32aa3f0bbe90dfd0ef8973f9aefd2d6ca3fcc
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/170671
    Tested-by: Jenkins
    Reviewed-by: Justin Luth <[email protected]>

diff --git a/sw/qa/extras/ooxmlexport/ooxmlexport21.cxx 
b/sw/qa/extras/ooxmlexport/ooxmlexport21.cxx
index 91fbf2e7e110..cf9d75b7e871 100644
--- a/sw/qa/extras/ooxmlexport/ooxmlexport21.cxx
+++ b/sw/qa/extras/ooxmlexport/ooxmlexport21.cxx
@@ -342,25 +342,25 @@ DECLARE_OOXMLEXPORT_TEST(testTdf125469_singleSpacing, 
"tdf125469_singleSpacing.d
     // The negative value (always) turns the (inherited) "atLeast" into an 
"exact".
     // Visually, this is hardly readable (36pt font forced into 12pt space)
     aSpacing = getProperty<style::LineSpacing>(getParagraph(2), 
u"ParaLineSpacing"_ustr);
-    // CPPUNIT_ASSERT_EQUAL(sal_Int16(style::LineSpacingMode::FIX), 
aSpacing.Mode);
-    // CPPUNIT_ASSERT_EQUAL(sal_Int16(423), aSpacing.Height);
+    CPPUNIT_ASSERT_EQUAL(sal_Int16(style::LineSpacingMode::FIX), 
aSpacing.Mode);
+    CPPUNIT_ASSERT_EQUAL(sal_Int16(423), aSpacing.Height);
 
     // Paragraph 3 - paragraph style specifies exact 240, para overrides with 
exact -240.
     // The negative value turns the non-inherited "exact" into an "atLeast".
     // Visually, this should clearly say "Negative exact"
     aSpacing = getProperty<style::LineSpacing>(getParagraph(3), 
u"ParaLineSpacing"_ustr);
-    // CPPUNIT_ASSERT_EQUAL(sal_Int16(style::LineSpacingMode::MINIMUM), 
aSpacing.Mode);
-    // CPPUNIT_ASSERT_EQUAL(sal_Int16(423), aSpacing.Height);
+    CPPUNIT_ASSERT_EQUAL(sal_Int16(style::LineSpacingMode::MINIMUM), 
aSpacing.Mode);
+    CPPUNIT_ASSERT_EQUAL(sal_Int16(423), aSpacing.Height);
 
     // Paragraph 4 - paragraph style specifies exact 240, para overrides with 
only -240.
     // The negative value does nothing to the inherited "exact".
     // Visually, this is hardly readable (36pt font forced into 12pt space)
     aSpacing = getProperty<style::LineSpacing>(getParagraph(4), 
u"ParaLineSpacing"_ustr);
-    // CPPUNIT_ASSERT_EQUAL(sal_Int16(style::LineSpacingMode::FIX), 
aSpacing.Mode);
-    // CPPUNIT_ASSERT_EQUAL(sal_Int16(423), aSpacing.Height);
+    CPPUNIT_ASSERT_EQUAL(sal_Int16(style::LineSpacingMode::FIX), 
aSpacing.Mode);
+    CPPUNIT_ASSERT_EQUAL(sal_Int16(423), aSpacing.Height);
 
     // all of this ends up being squeezed onto a single page
-    // CPPUNIT_ASSERT_EQUAL(1, getPages());
+    CPPUNIT_ASSERT_EQUAL(1, getPages());
 }
 
 DECLARE_OOXMLEXPORT_TEST(testTdf43767_caseMapNumbering, 
"tdf43767_caseMapNumbering.odt")
diff --git a/sw/source/writerfilter/dmapper/DomainMapper.cxx 
b/sw/source/writerfilter/dmapper/DomainMapper.cxx
index 13ffe529d09d..8854e7ed9ece 100644
--- a/sw/source/writerfilter/dmapper/DomainMapper.cxx
+++ b/sw/source/writerfilter/dmapper/DomainMapper.cxx
@@ -2423,7 +2423,8 @@ void DomainMapper::sprmWithProps( Sprm& rSprm, const 
PropertyMapPtr& rContext )
             else if (aInheritedSpacing.Mode == style::LineSpacingMode::MINIMUM)
                 nLineRule = NS_ooxml::LN_Value_doc_ST_LineSpacingRule_atLeast;
 
-            m_pImpl->SetLineSpacing(NS_ooxml::LN_CT_Spacing_lineRule, 
nLineRule);
+            const bool bNegativeFlip = nLineRule != 
NS_ooxml::LN_Value_doc_ST_LineSpacingRule_exact;
+            m_pImpl->SetLineSpacing(NS_ooxml::LN_CT_Spacing_lineRule, 
nLineRule, bNegativeFlip);
         }
 
         m_pImpl->appendGrabBag(m_pImpl->m_aInteropGrabBag, u"spacing"_ustr, 
m_pImpl->m_aSubInteropGrabBag);
diff --git a/sw/source/writerfilter/dmapper/DomainMapper_Impl.cxx 
b/sw/source/writerfilter/dmapper/DomainMapper_Impl.cxx
index df28343d3186..83a9301c0738 100644
--- a/sw/source/writerfilter/dmapper/DomainMapper_Impl.cxx
+++ b/sw/source/writerfilter/dmapper/DomainMapper_Impl.cxx
@@ -5092,7 +5092,7 @@ bool DomainMapper_Impl::IsDiscardHeaderFooter() const
     return m_bDiscardHeaderFooter;
 }
 
-void DomainMapper_Impl::SetLineSpacing(const Id nName, sal_Int32 nIntValue)
+void DomainMapper_Impl::SetLineSpacing(const Id nName, sal_Int32 nIntValue, 
bool bNegativeFlip)
 {
     static const int nSingleLineSpacing = 240;
 
@@ -5142,12 +5142,25 @@ void DomainMapper_Impl::SetLineSpacing(const Id nName, 
sal_Int32 nIntValue)
                  == NS_ooxml::LN_Value_doc_ST_LineSpacingRule_atLeast)
         {
             appendGrabBag(m_aSubInteropGrabBag, u"lineRule"_ustr, 
u"atLeast"_ustr);
-            aSpacing.Mode = style::LineSpacingMode::MINIMUM;
+            if (aSpacing.Height < 0)
+            {
+                aSpacing.Mode = style::LineSpacingMode::FIX;
+                aSpacing.Height *= -1;
+            }
+            else
+                aSpacing.Mode = style::LineSpacingMode::MINIMUM;
         }
         else // NS_ooxml::LN_Value_doc_ST_LineSpacingRule_exact
         {
             appendGrabBag(m_aSubInteropGrabBag, u"lineRule"_ustr, 
u"exact"_ustr);
-            aSpacing.Mode = style::LineSpacingMode::FIX;
+            if (aSpacing.Height < 0)
+            {
+                if (bNegativeFlip)
+                    aSpacing.Mode = style::LineSpacingMode::MINIMUM;
+                aSpacing.Height *= -1;
+            }
+            else
+                aSpacing.Mode = style::LineSpacingMode::FIX;
         }
     }
     if (pTopContext)
diff --git a/sw/source/writerfilter/dmapper/DomainMapper_Impl.hxx 
b/sw/source/writerfilter/dmapper/DomainMapper_Impl.hxx
index e63c64778b09..5646d8cf13b2 100644
--- a/sw/source/writerfilter/dmapper/DomainMapper_Impl.hxx
+++ b/sw/source/writerfilter/dmapper/DomainMapper_Impl.hxx
@@ -1222,7 +1222,7 @@ public:
     void SetSpacingHadLine(bool bSet) { m_bSpacingHadLine = bSet; }
     bool GetSpacingHadLineRule() const { return m_bSpacingHadLineRule; }
     void SetSpacingHadLineRule(bool bSet) { m_bSpacingHadLineRule = bSet; }
-    void SetLineSpacing(const Id nName, sal_Int32 nIntValue);
+    void SetLineSpacing(const Id nName, sal_Int32 nIntValue, bool 
bNegativeFlip = true);
 
     /// Forget about the previous paragraph, as it's not inside the same
     /// start/end node.

Reply via email to