summaryrefslogtreecommitdiff
path: root/sw
diff options
context:
space:
mode:
authorJustin Luth <justin.luth@collabora.com>2018-08-28 15:37:59 +0300
committerLászló Németh <nemeth@numbertext.org>2018-09-02 15:08:14 +0200
commit61821277ed4974debd05af89cb7284602512088f (patch)
treec94c0da16e6295ff7af397090515d9cdc0adec24 /sw
parent56dfe00a424e57e6103ed80374d571f0f2a015ec (diff)
tdf#104354 writerfilter: rewrite Autospacing
which also resolves a regression from tdf#113258. The previous code segments were being spread out all over the place. It all consolidates nicely in finishParagraph, and the code is much easier to read using the new GetAnyProperty function. Plus there were regressions creeping in. The mere presense of the Autospacing property normally, but not necessarily means that it is on. Verify that it is enabled, and update grabbag if autoSpacing changes. Additionally, support was added for a zero top margin for the first paragraph of the document. This will be too hard to backport since it depends on 150c12fc0fba2c2f4b08b4298678ee49676ebae0 from tdf#72560 and the many code fixes related to GetPropertyFromStyleSheets. Change-Id: Iaf1600fffea54e9800e215e89cad40006d5bcdda Reviewed-on: https://gerrit.libreoffice.org/59705 Reviewed-by: László Németh <nemeth@numbertext.org> Tested-by: László Németh <nemeth@numbertext.org>
Diffstat (limited to 'sw')
-rw-r--r--sw/qa/extras/ooxmlexport/data/tdf104354-2.docxbin15779 -> 15263 bytes
-rw-r--r--sw/qa/extras/ooxmlexport/data/tdf113258_noBeforeAutospacing.docxbin0 -> 16284 bytes
-rw-r--r--sw/qa/extras/ooxmlexport/ooxmlexport11.cxx9
-rw-r--r--sw/qa/extras/ooxmlexport/ooxmlexport9.cxx12
-rw-r--r--sw/qa/extras/rtfexport/rtfexport.cxx8
5 files changed, 21 insertions, 8 deletions
diff --git a/sw/qa/extras/ooxmlexport/data/tdf104354-2.docx b/sw/qa/extras/ooxmlexport/data/tdf104354-2.docx
index 9f40bf77976e..5b67e015fb1b 100644
--- a/sw/qa/extras/ooxmlexport/data/tdf104354-2.docx
+++ b/sw/qa/extras/ooxmlexport/data/tdf104354-2.docx
Binary files differ
diff --git a/sw/qa/extras/ooxmlexport/data/tdf113258_noBeforeAutospacing.docx b/sw/qa/extras/ooxmlexport/data/tdf113258_noBeforeAutospacing.docx
new file mode 100644
index 000000000000..de74eb2268df
--- /dev/null
+++ b/sw/qa/extras/ooxmlexport/data/tdf113258_noBeforeAutospacing.docx
Binary files differ
diff --git a/sw/qa/extras/ooxmlexport/ooxmlexport11.cxx b/sw/qa/extras/ooxmlexport/ooxmlexport11.cxx
index e412f8703c07..fc7c469e1c2f 100644
--- a/sw/qa/extras/ooxmlexport/ooxmlexport11.cxx
+++ b/sw/qa/extras/ooxmlexport/ooxmlexport11.cxx
@@ -369,6 +369,15 @@ DECLARE_OOXMLEXPORT_TEST(testTdf113258, "tdf113258.docx")
getProperty<sal_Int32>(xShape->getStart(), "ParaTopMargin"));
}
+DECLARE_OOXMLEXPORT_TEST(testTdf113258_noBeforeAutospacing, "tdf113258_noBeforeAutospacing.docx")
+{
+ uno::Reference<text::XTextRange> xShape(getShape(1), uno::UNO_QUERY);
+ // This was 0, i.e. disabled automatic spacing still resulted in zero paragraph
+ // top margin for the first paragraph in a shape.
+ CPPUNIT_ASSERT_EQUAL(static_cast<sal_Int32>(1764),
+ getProperty<sal_Int32>(xShape->getStart(), "ParaTopMargin"));
+}
+
DECLARE_OOXMLEXPORT_TEST(testTdf104354, "tdf104354.docx")
{
uno::Reference<text::XTextRange> xShape(getShape(1), uno::UNO_QUERY);
diff --git a/sw/qa/extras/ooxmlexport/ooxmlexport9.cxx b/sw/qa/extras/ooxmlexport/ooxmlexport9.cxx
index ed841f245459..fbe0c2339b6b 100644
--- a/sw/qa/extras/ooxmlexport/ooxmlexport9.cxx
+++ b/sw/qa/extras/ooxmlexport/ooxmlexport9.cxx
@@ -1241,8 +1241,7 @@ DECLARE_OOXMLEXPORT_TEST(testTdf104354_2, "tdf104354-2.docx")
// bottom margin is not auto spacing
uno::Reference<text::XTextRange> xCell3(xTable->getCellByName("A3"), uno::UNO_QUERY);
- // FIXME next top margin will be 0 after fixing this, too
- CPPUNIT_ASSERT_EQUAL(static_cast<sal_Int32>(494), getProperty<sal_Int32>(getParagraphOfText(1, xCell3->getText()), "ParaTopMargin"));
+ CPPUNIT_ASSERT_EQUAL(static_cast<sal_Int32>(0), getProperty<sal_Int32>(getParagraphOfText(1, xCell3->getText()), "ParaTopMargin"));
CPPUNIT_ASSERT_EQUAL(static_cast<sal_Int32>(847), getProperty<sal_Int32>(getParagraphOfText(1, xCell3->getText()), "ParaBottomMargin"));
// auto spacing, if the paragraph contains footnotes
@@ -1250,6 +1249,15 @@ DECLARE_OOXMLEXPORT_TEST(testTdf104354_2, "tdf104354-2.docx")
CPPUNIT_ASSERT_EQUAL(static_cast<sal_Int32>(0), getProperty<sal_Int32>(getParagraphOfText(1, xCell4->getText()), "ParaTopMargin"));
CPPUNIT_ASSERT_EQUAL(static_cast<sal_Int32>(0), getProperty<sal_Int32>(getParagraphOfText(1, xCell4->getText()), "ParaBottomMargin"));
+ // auto spacing is explicitly disabled, and no margins are defined.
+ xCell.set(xTable->getCellByName("A5"), uno::UNO_QUERY);
+ CPPUNIT_ASSERT_EQUAL(static_cast<sal_Int32>(0), getProperty<sal_Int32>(getParagraphOfText(1, xCell->getText()), "ParaTopMargin"));
+ CPPUNIT_ASSERT_EQUAL(static_cast<sal_Int32>(0), getProperty<sal_Int32>(getParagraphOfText(1, xCell->getText()), "ParaBottomMargin"));
+ CPPUNIT_ASSERT_EQUAL(static_cast<sal_Int32>(0), getProperty<sal_Int32>(getParagraphOfText(2, xCell->getText()), "ParaTopMargin"));
+ CPPUNIT_ASSERT_EQUAL(static_cast<sal_Int32>(0), getProperty<sal_Int32>(getParagraphOfText(2, xCell->getText()), "ParaBottomMargin"));
+ CPPUNIT_ASSERT_EQUAL(static_cast<sal_Int32>(0), getProperty<sal_Int32>(getParagraphOfText(3, xCell->getText()), "ParaTopMargin"));
+ CPPUNIT_ASSERT_EQUAL(static_cast<sal_Int32>(0), getProperty<sal_Int32>(getParagraphOfText(3, xCell->getText()), "ParaBottomMargin"));
+
// auto spacing on a paragraph
uno::Reference<text::XTextTable> xTable2(xTables->getByIndex(1), uno::UNO_QUERY);
uno::Reference<text::XTextRange> xCell5(xTable2->getCellByName("A1"), uno::UNO_QUERY);
diff --git a/sw/qa/extras/rtfexport/rtfexport.cxx b/sw/qa/extras/rtfexport/rtfexport.cxx
index 78a2c77a9e80..009cd00eb14d 100644
--- a/sw/qa/extras/rtfexport/rtfexport.cxx
+++ b/sw/qa/extras/rtfexport/rtfexport.cxx
@@ -982,9 +982,7 @@ 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.
- // FIXME Exception: first paragraph gets zero top margin, see tdf#118533.
- CPPUNIT_ASSERT_EQUAL(sal_Int32(convertTwipToMm100(280)),
- getProperty<sal_Int32>(getParagraph(1), "ParaTopMargin"));
+ CPPUNIT_ASSERT_EQUAL(sal_Int32(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)),
@@ -1425,9 +1423,7 @@ DECLARE_RTFEXPORT_TEST(testTdf112507, "tdf112507.rtf")
DECLARE_RTFEXPORT_TEST(testTdf107480, "tdf107480.rtf")
{
// These were 176 (100 twips), as \htmautsp was parsed too late.
- // FIXME Exception: first paragraph gets zero top margin, see tdf#118533.
- CPPUNIT_ASSERT_EQUAL(sal_Int32(convertTwipToMm100(280)),
- getProperty<sal_Int32>(getParagraph(1), "ParaTopMargin"));
+ CPPUNIT_ASSERT_EQUAL(sal_Int32(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)),