sw/qa/extras/ooxmlexport/data/tdf167721_chUnits4.docx |binary
 sw/qa/extras/ooxmlexport/ooxmlexport22.cxx            |   33 ++++++++++++++++++
 2 files changed, 33 insertions(+)

New commits:
commit 6f1969379e4d871ebec042d5e1a663df8e5d484b
Author:     Justin Luth <jl...@mail.com>
AuthorDate: Wed Aug 13 15:43:06 2025 -0400
Commit:     Justin Luth <jl...@mail.com>
CommitDate: Thu Aug 14 03:31:06 2025 +0200

    tdf#167721 writerfilter: one more chUnit unit test
    
    The way the right margin gets its value is slightly odd
    (well perhaps not odd because I expected it to inherit a w:right,
    but that doesn't ALWAYS work - in fact it rarely works)
    so I wanted to make sure I had this scenario captured
    in a unit test.
    
    I was also expecting the left margin to fail (as zero),
    because we have a bRightSet but not a bLeftSet.
    I guess mstahl's work to separate Left Margin is working,
    and not all three need to be provided if one is set.
    Perhaps most of this "property spamming" code
    is no longer needed...
    
    make CppunitTest_sw_ooxmlexport22 \
        CPPUNIT_TEST_NAME=testTdf167721_chUnits4
    
    Change-Id: I2e4a510abdbf3233da85670e40be80d1bf8e63b2
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/189537
    Reviewed-by: Justin Luth <jl...@mail.com>
    Tested-by: Jenkins

diff --git a/sw/qa/extras/ooxmlexport/data/tdf167721_chUnits4.docx 
b/sw/qa/extras/ooxmlexport/data/tdf167721_chUnits4.docx
new file mode 100644
index 000000000000..1f40b28b4b7d
Binary files /dev/null and 
b/sw/qa/extras/ooxmlexport/data/tdf167721_chUnits4.docx differ
diff --git a/sw/qa/extras/ooxmlexport/ooxmlexport22.cxx 
b/sw/qa/extras/ooxmlexport/ooxmlexport22.cxx
index c9ca68833efb..9a8fef903b3b 100644
--- a/sw/qa/extras/ooxmlexport/ooxmlexport22.cxx
+++ b/sw/qa/extras/ooxmlexport/ooxmlexport22.cxx
@@ -423,6 +423,39 @@ DECLARE_OOXMLEXPORT_TEST(testTdf167721_chUnits3, 
"tdf167721_chUnits3.docx")
     CPPUNIT_ASSERT_EQUAL(sal_Int32(353), getProperty<sal_Int32>(xPara, 
u"ParaRightMargin"_ustr));
 }
 
+DECLARE_OOXMLEXPORT_TEST(testTdf167721_chUnits4, "tdf167721_chUnits4.docx")
+{
+    // given an edge-case document
+    // Style "List Paragraph": left = 5cm, right = 2 ic
+    //     <w:ind w:left="2835" w:rightChars="200"/>
+    // Style "Inherited List Paragraph": left = 5cmm right = 2 Ch
+    //    <w:ind w:right="2268" />
+    // Paragraph: left = 5cm, right = 4cm
+    //     <w:ind w:rightChars="0" />
+
+    // Test the style 
#############################################################################
+    uno::Reference<beans::XPropertySet> xStyle(
+        getStyles(u"ParagraphStyles"_ustr)->getByName(u"Inherited List 
Paragraph"_ustr),
+        uno::UNO_QUERY);
+
+    CPPUNIT_ASSERT_EQUAL(sal_Int32(5001), getProperty<sal_Int32>(xStyle, 
u"ParaLeftMargin"_ustr));
+
+    auto aRightCh
+        = getProperty<css::beans::Pair<double, sal_Int16>>(xStyle, 
u"ParaRightMarginUnit"_ustr);
+    CPPUNIT_ASSERT_EQUAL(double(2), aRightCh.First);
+
+    // Test the paragraph 
#########################################################################
+    uno::Reference<text::XTextRange> xPara(getParagraph(1));
+
+    CPPUNIT_ASSERT_EQUAL(sal_Int32(0), getProperty<sal_Int32>(xPara, 
u"ParaFirstLineIndent"_ustr));
+
+    // the left margin is inherited from the style, though it is never written 
as a direct property
+    CPPUNIT_ASSERT_EQUAL(sal_Int32(5001), getProperty<sal_Int32>(xPara, 
u"ParaLeftMargin"_ustr));
+
+    // the unused w:right in the style is what gets inherited (and written as 
a direct property)
+    CPPUNIT_ASSERT_EQUAL(sal_Int32(4001), getProperty<sal_Int32>(xPara, 
u"ParaRightMargin"_ustr));
+}
+
 CPPUNIT_TEST_FIXTURE(Test, testTdf83844)
 {
     createSwDoc("tdf83844.fodt");

Reply via email to