sw/qa/extras/ooxmlexport/ooxmlexport10.cxx        |   14 ++++++++++++++
 writerfilter/source/dmapper/DomainMapper_Impl.cxx |    7 +++++++
 2 files changed, 21 insertions(+)

New commits:
commit e4b1be58db73f5a3c483b40b5615c1c764bbe1d3
Author:     Justin Luth <justin.l...@collabora.com>
AuthorDate: Fri Apr 7 20:42:18 2023 -0400
Commit:     Justin Luth <jl...@mail.com>
CommitDate: Sun Apr 9 03:39:57 2023 +0200

    tdf#154703 writerfilter framePr: don't duplicate top/bot spacing
    
    With framePr, all of the background/border settings
    are really just paragraph properties.
    
    BETTER would be to zero out the frame spacing
    and leave it on the paragraph.
    After all, there could be multiple paragraphs
    and each could have their own spacing.
    
    However, in this case we are getting the whole range as
    one propertySet, so that basically means it is treated as one.
    I presume.
    
    But the biggest reason for zeroing out the paragraph instead of the frame
    is because on export only the frame borders are being written out.
    So that really needs to be fixed first.
    
    make CppunitTest_sw_ooxmlexport10 CPPUNIT_TEST_NAME=testLibreOfficeHang
    
    Change-Id: I1faeef6bf12668fb28e2b3710053ff545a4c36e8
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/150157
    Tested-by: Jenkins
    Reviewed-by: Justin Luth <jl...@mail.com>

diff --git a/sw/qa/extras/ooxmlexport/ooxmlexport10.cxx 
b/sw/qa/extras/ooxmlexport/ooxmlexport10.cxx
index 60f7eb57b711..c4464f9d5cfb 100644
--- a/sw/qa/extras/ooxmlexport/ooxmlexport10.cxx
+++ b/sw/qa/extras/ooxmlexport/ooxmlexport10.cxx
@@ -548,6 +548,20 @@ DECLARE_OOXMLEXPORT_TEST(testLibreOfficeHang, 
"frame-wrap-auto.docx")
     // fdo#72775
     // This was text::WrapTextMode_NONE.
     CPPUNIT_ASSERT_EQUAL(text::WrapTextMode_DYNAMIC, 
getProperty<text::WrapTextMode>(getShape(1), "Surround"));
+
+    // tdf#154703 top/bottom margins should not be duplicated from paragraph(s)
+    uno::Reference<text::XTextRange> xTextRange(getShape(1), uno::UNO_QUERY);
+    uno::Reference<text::XText> xText = xTextRange->getText();
+    CPPUNIT_ASSERT_EQUAL(OUString("test"), getParagraphOfText(1, 
xText)->getString());
+
+    sal_Int32 nFrame = getProperty<sal_Int32>(getShape(1), 
"TopBorderDistance");
+    sal_Int32 nPara = getProperty<sal_Int32>(getParagraphOfText(1, xText), 
"TopBorderDistance");
+    CPPUNIT_ASSERT_EQUAL(sal_Int32(143), nFrame + nPara);
+    // NOTE: left/right are different because of compat flag 
INVERT_BORDER_SPACING]
+    nFrame = getProperty<sal_Int32>(getShape(1), "LeftBorderDistance");
+    nPara = getProperty<sal_Int32>(getParagraphOfText(1, xText), 
"LeftBorderDistance");
+    CPPUNIT_ASSERT_EQUAL(nFrame, nPara);
+    CPPUNIT_ASSERT(nPara);
 }
 
 DECLARE_OOXMLEXPORT_TEST(testI124106, "i124106.docx")
diff --git a/writerfilter/source/dmapper/DomainMapper_Impl.cxx 
b/writerfilter/source/dmapper/DomainMapper_Impl.cxx
index 5e8d2712a13c..f559060704b6 100644
--- a/writerfilter/source/dmapper/DomainMapper_Impl.cxx
+++ b/writerfilter/source/dmapper/DomainMapper_Impl.cxx
@@ -1561,6 +1561,13 @@ static void 
lcl_MoveBorderPropertiesToFrame(std::vector<beans::PropertyValue>& r
             aValue.Value = 
xTextRangeProperties->getPropertyValue(sPropertyName);
             if( nProperty < 4 )
                 xTextRangeProperties->setPropertyValue( sPropertyName, 
uno::Any(table::BorderLine2()));
+            else if (nProperty > 5)
+            {
+                // Do not duplicate the top/bottom border spacing.
+                // [NOTE: left/right need to be duplicated because of 
INVERT_BORDER_SPACING]
+                // Hack: a minimal distance is given so left/right shading 
extends to the edge.
+                xTextRangeProperties->setPropertyValue( sPropertyName, 
uno::Any(sal_Int32(1)));
+            }
             if (aValue.Value.hasValue())
                 rFrameProperties.push_back(aValue);
         }

Reply via email to