[Libreoffice-commits] core.git: sw/qa writerfilter/source

László Németh nemeth at numbertext.org
Wed Jul 4 09:39:32 UTC 2018


 sw/qa/extras/ooxmlexport/data/tdf104354.docx |binary
 sw/qa/extras/ooxmlexport/ooxmlexport11.cxx   |    9 +++++++++
 sw/qa/extras/rtfexport/data/fdo82006.rtf     |    1 +
 sw/qa/extras/rtfexport/data/tdf107480.rtf    |    1 +
 sw/qa/extras/rtfexport/rtfexport.cxx         |   14 ++++++++++++--
 writerfilter/source/dmapper/DomainMapper.cxx |    8 +++++++-
 6 files changed, 30 insertions(+), 3 deletions(-)

New commits:
commit 0307a62790b33ee0c02c2323a8f759e53e2035a4
Author: László Németh <nemeth at numbertext.org>
Date:   Fri Jun 29 22:34:21 2018 +0200

    tdf#118533 RTF/DOCX import: fix beforeAutospacing for first paragraph
    
    of a text frame (first bug of tdf#104354), a table cell or a
    document by setting zero top margin here. This bug could result non
    visible paragraph content in narrow frames, as in the test document
    of the commit. See also commit f737c9386a605cb7d8c9dbc210c557f98f6cdc19
    for a similar fix for first paragraph of a shape.
    
    Fix top margins of the first paragraphs of the affected tdf#82006
    and tdf#107480, adding also new paragraphs to their RTF tests cases
    to keep the original tests, too.
    
    Change-Id: Iea3c735eeb262233b82090fb9491991ed2df2b4e
    Reviewed-on: https://gerrit.libreoffice.org/56737
    Reviewed-by: László Németh <nemeth at numbertext.org>
    Tested-by: László Németh <nemeth at numbertext.org>

diff --git a/sw/qa/extras/ooxmlexport/data/tdf104354.docx b/sw/qa/extras/ooxmlexport/data/tdf104354.docx
new file mode 100644
index 000000000000..8645743f1fc1
Binary files /dev/null and b/sw/qa/extras/ooxmlexport/data/tdf104354.docx differ
diff --git a/sw/qa/extras/ooxmlexport/ooxmlexport11.cxx b/sw/qa/extras/ooxmlexport/ooxmlexport11.cxx
index 3e1c80d23ace..6c07df297779 100644
--- a/sw/qa/extras/ooxmlexport/ooxmlexport11.cxx
+++ b/sw/qa/extras/ooxmlexport/ooxmlexport11.cxx
@@ -297,6 +297,15 @@ DECLARE_OOXMLEXPORT_TEST(testTdf113258, "tdf113258.docx")
                          getProperty<sal_Int32>(xShape->getStart(), "ParaTopMargin"));
 }
 
+DECLARE_OOXMLEXPORT_TEST(testTdf104354, "tdf104354.docx")
+{
+    uno::Reference<text::XTextRange> xShape(getShape(1), uno::UNO_QUERY);
+    // This was 494, i.e. automatic spacing resulted in non-zero paragraph top
+    // margin for the first paragraph in a text frame.
+    CPPUNIT_ASSERT_EQUAL(static_cast<sal_Int32>(0),
+                         getProperty<sal_Int32>(xShape->getStart(), "ParaTopMargin"));
+}
+
 DECLARE_OOXMLEXPORT_TEST(testTdf107035, "tdf107035.docx")
 {
     // Select the second run containing the page number field
diff --git a/sw/qa/extras/rtfexport/data/fdo82006.rtf b/sw/qa/extras/rtfexport/data/fdo82006.rtf
index e108d4ceb189..b20ef835244b 100644
--- a/sw/qa/extras/rtfexport/data/fdo82006.rtf
+++ b/sw/qa/extras/rtfexport/data/fdo82006.rtf
@@ -1,4 +1,5 @@
 {\rtf1\htmautsp
 \pard\plain
 \ql \sb100\sa100\sbauto1\saauto1 hello\par
+hello2\par
 }
diff --git a/sw/qa/extras/rtfexport/data/tdf107480.rtf b/sw/qa/extras/rtfexport/data/tdf107480.rtf
index 2edd895e02ab..a11bee98aff6 100644
--- a/sw/qa/extras/rtfexport/data/tdf107480.rtf
+++ b/sw/qa/extras/rtfexport/data/tdf107480.rtf
@@ -13,4 +13,5 @@
 \htmautsp
 \pard\plain \s3 \sbauto1\saauto1
 1.\par
+2.\par
 }
diff --git a/sw/qa/extras/rtfexport/rtfexport.cxx b/sw/qa/extras/rtfexport/rtfexport.cxx
index c69529438e30..06de83bd27f7 100644
--- a/sw/qa/extras/rtfexport/rtfexport.cxx
+++ b/sw/qa/extras/rtfexport/rtfexport.cxx
@@ -1017,10 +1017,15 @@ DECLARE_RTFEXPORT_TEST(testNumOverrideStart, "num-override-start.rtf")
 DECLARE_RTFEXPORT_TEST(testFdo82006, "fdo82006.rtf")
 {
     // These were 176 (100 twips), as \sbauto and \sbbefore were ignored.
-    CPPUNIT_ASSERT_EQUAL(sal_Int32(convertTwipToMm100(280)),
+    // Exception: first paragraph gets zero top margin, see also tdf#104354.
+    CPPUNIT_ASSERT_EQUAL(sal_Int32(convertTwipToMm100(0)),
                          getProperty<sal_Int32>(getParagraph(1), "ParaTopMargin"));
     CPPUNIT_ASSERT_EQUAL(sal_Int32(convertTwipToMm100(280)),
                          getProperty<sal_Int32>(getParagraph(1), "ParaBottomMargin"));
+    CPPUNIT_ASSERT_EQUAL(sal_Int32(convertTwipToMm100(280)),
+                         getProperty<sal_Int32>(getParagraph(2), "ParaTopMargin"));
+    CPPUNIT_ASSERT_EQUAL(sal_Int32(convertTwipToMm100(280)),
+                         getProperty<sal_Int32>(getParagraph(2), "ParaBottomMargin"));
 }
 
 DECLARE_RTFEXPORT_TEST(testTdf104081, "tdf104081.rtf")
@@ -1455,10 +1460,15 @@ DECLARE_RTFEXPORT_TEST(testTdf112507, "tdf112507.rtf")
 DECLARE_RTFEXPORT_TEST(testTdf107480, "tdf107480.rtf")
 {
     // These were 176 (100 twips), as \htmautsp was parsed too late.
-    CPPUNIT_ASSERT_EQUAL(sal_Int32(convertTwipToMm100(280)),
+    // Exception: first paragraph gets zero top margin, see also tdf#104354.
+    CPPUNIT_ASSERT_EQUAL(sal_Int32(convertTwipToMm100(0)),
                          getProperty<sal_Int32>(getParagraph(1), "ParaTopMargin"));
     CPPUNIT_ASSERT_EQUAL(sal_Int32(convertTwipToMm100(280)),
                          getProperty<sal_Int32>(getParagraph(1), "ParaBottomMargin"));
+    CPPUNIT_ASSERT_EQUAL(sal_Int32(convertTwipToMm100(280)),
+                         getProperty<sal_Int32>(getParagraph(2), "ParaTopMargin"));
+    CPPUNIT_ASSERT_EQUAL(sal_Int32(convertTwipToMm100(280)),
+                         getProperty<sal_Int32>(getParagraph(2), "ParaBottomMargin"));
 }
 
 DECLARE_RTFEXPORT_TEST(testWatermark, "watermark.rtf")
diff --git a/writerfilter/source/dmapper/DomainMapper.cxx b/writerfilter/source/dmapper/DomainMapper.cxx
index ea40a7f80385..a11e47a01eb7 100644
--- a/writerfilter/source/dmapper/DomainMapper.cxx
+++ b/writerfilter/source/dmapper/DomainMapper.cxx
@@ -653,7 +653,13 @@ void DomainMapper::lcl_attribute(Id nName, Value & val)
                 if (m_pImpl->GetSettingsTable()->GetView() == NS_ooxml::LN_Value_doc_ST_View_web)
                     default_spacing = 49;
                 else
-                    default_spacing = 280;
+                {
+                    // tdf#104354 fist paragraph has got zero top margin
+                    if (m_pImpl->GetIsFirstParagraphInSection())
+                        default_spacing = 0;
+                    else
+                        default_spacing = 280;
+                }
             }
             if  (nIntValue) // If auto spacing is set, then only store set value in InteropGrabBag
             {


More information about the Libreoffice-commits mailing list