diff options
author | László Németh <nemeth@numbertext.org> | 2018-06-29 22:34:21 +0200 |
---|---|---|
committer | Andras Timar <andras.timar@collabora.com> | 2018-09-12 09:43:33 +0200 |
commit | 57626bd356f7e01bf5a88a204638ba1687ed545f (patch) | |
tree | 180c30f0e9606ba10485bb015a54f8475e81348d | |
parent | a29b9286896e4e236041a86bf2bbad1bc6d95ca9 (diff) |
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.
Reviewed-on: https://gerrit.libreoffice.org/56737
Reviewed-by: László Németh <nemeth@numbertext.org>
Tested-by: László Németh <nemeth@numbertext.org>
(cherry picked from commit 0307a62790b33ee0c02c2323a8f759e53e2035a4)
Change-Id: Iea3c735eeb262233b82090fb9491991ed2df2b4e
-rw-r--r-- | sw/qa/extras/ooxmlexport/data/tdf104354.docx | bin | 0 -> 9412 bytes | |||
-rw-r--r-- | sw/qa/extras/ooxmlexport/ooxmlexport11.cxx | 9 | ||||
-rw-r--r-- | sw/qa/extras/rtfexport/data/fdo82006.rtf | 1 | ||||
-rw-r--r-- | sw/qa/extras/rtfexport/data/tdf107480.rtf | 1 | ||||
-rw-r--r-- | sw/qa/extras/rtfexport/rtfexport.cxx | 14 | ||||
-rw-r--r-- | writerfilter/source/dmapper/DomainMapper.cxx | 8 |
6 files changed, 30 insertions, 3 deletions
diff --git a/sw/qa/extras/ooxmlexport/data/tdf104354.docx b/sw/qa/extras/ooxmlexport/data/tdf104354.docx Binary files differnew file mode 100644 index 000000000000..8645743f1fc1 --- /dev/null +++ b/sw/qa/extras/ooxmlexport/data/tdf104354.docx diff --git a/sw/qa/extras/ooxmlexport/ooxmlexport11.cxx b/sw/qa/extras/ooxmlexport/ooxmlexport11.cxx index 8ef107f51f0e..57c0296b1bd9 100644 --- a/sw/qa/extras/ooxmlexport/ooxmlexport11.cxx +++ b/sw/qa/extras/ooxmlexport/ooxmlexport11.cxx @@ -224,6 +224,15 @@ DECLARE_OOXMLEXPORT_TEST(testTdf44832_testSectionWithDifferentHeader, "tdf44832_ assertXPath(pXmlDoc, "/w:document/w:body/w:sectPr/w:headerReference", 1); } +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 576bfea43398..b59e0c6efc6e 100644 --- a/sw/qa/extras/rtfexport/rtfexport.cxx +++ b/sw/qa/extras/rtfexport/rtfexport.cxx @@ -1012,10 +1012,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") @@ -1450,10 +1455,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 8aabcd02bce2..beb43a5c07f9 100644 --- a/writerfilter/source/dmapper/DomainMapper.cxx +++ b/writerfilter/source/dmapper/DomainMapper.cxx @@ -668,7 +668,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 { |