diff options
author | Justin Luth <justin.luth@collabora.com> | 2018-08-28 15:37:59 +0300 |
---|---|---|
committer | László Németh <nemeth@numbertext.org> | 2018-09-02 15:08:14 +0200 |
commit | 61821277ed4974debd05af89cb7284602512088f (patch) | |
tree | c94c0da16e6295ff7af397090515d9cdc0adec24 /sw/qa/extras/ooxmlexport | |
parent | 56dfe00a424e57e6103ed80374d571f0f2a015ec (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/qa/extras/ooxmlexport')
-rw-r--r-- | sw/qa/extras/ooxmlexport/data/tdf104354-2.docx | bin | 15779 -> 15263 bytes | |||
-rw-r--r-- | sw/qa/extras/ooxmlexport/data/tdf113258_noBeforeAutospacing.docx | bin | 0 -> 16284 bytes | |||
-rw-r--r-- | sw/qa/extras/ooxmlexport/ooxmlexport11.cxx | 9 | ||||
-rw-r--r-- | sw/qa/extras/ooxmlexport/ooxmlexport9.cxx | 12 |
4 files changed, 19 insertions, 2 deletions
diff --git a/sw/qa/extras/ooxmlexport/data/tdf104354-2.docx b/sw/qa/extras/ooxmlexport/data/tdf104354-2.docx Binary files differindex 9f40bf77976e..5b67e015fb1b 100644 --- a/sw/qa/extras/ooxmlexport/data/tdf104354-2.docx +++ b/sw/qa/extras/ooxmlexport/data/tdf104354-2.docx diff --git a/sw/qa/extras/ooxmlexport/data/tdf113258_noBeforeAutospacing.docx b/sw/qa/extras/ooxmlexport/data/tdf113258_noBeforeAutospacing.docx Binary files differnew file mode 100644 index 000000000000..de74eb2268df --- /dev/null +++ b/sw/qa/extras/ooxmlexport/data/tdf113258_noBeforeAutospacing.docx 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); |