summaryrefslogtreecommitdiff
path: root/sw
diff options
context:
space:
mode:
authorJustin Luth <justin.luth@collabora.com>2023-03-07 07:43:14 -0500
committerMiklos Vajna <vmiklos@collabora.com>2023-03-22 10:42:17 +0000
commit888c55f357a5a60067e35e4a420c849cabaf949c (patch)
tree8504051b20cfa8a1bb253b52d7d45983f8b47ffe /sw
parent13658021cf7028369ee85a5478f5c0c9ed96c11a (diff)
tdf#153964 writerfilter compat15: top margin after break split
The problem was that the top margin was being applied to the new paragraph after the split. This is absolutely attrocious in MS Word before 2013. If I am going to be in error, I want to error on the side of being compliant with compat15, since all other versions of MS Word are now unsupported. I think I have the logic of it mostly figured out. In compat15, the top margin never applies after the break. In compat14, if the paragraph properties are not applied to a run before the break, then they can be applied after the break. make CppunitTest_sw_ooxmlexport18 \ CPPUNIT_TEST_NAME=testTdf153964_topMarginAfterBreak14 make CppunitTest_sw_ooxmlexport18 \ CPPUNIT_TEST_NAME=testTdf153964_topMarginAfterBreak15 Change-Id: I8816b391e898cfea58c2e0dbf01c881f87bbc4c4 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/148451 Tested-by: Justin Luth <jluth@mail.com> Reviewed-by: Justin Luth <jluth@mail.com> Reviewed-on: https://gerrit.libreoffice.org/c/core/+/149226 Tested-by: Jenkins CollaboraOffice <jenkinscollaboraoffice@gmail.com> Reviewed-by: Miklos Vajna <vmiklos@collabora.com>
Diffstat (limited to 'sw')
-rw-r--r--sw/qa/extras/ooxmlexport/data/tdf153964_topMarginAfterBreak14.docxbin0 -> 14353 bytes
-rw-r--r--sw/qa/extras/ooxmlexport/data/tdf153964_topMarginAfterBreak15.docxbin0 -> 14358 bytes
-rw-r--r--sw/qa/extras/ooxmlexport/ooxmlexport18.cxx90
3 files changed, 90 insertions, 0 deletions
diff --git a/sw/qa/extras/ooxmlexport/data/tdf153964_topMarginAfterBreak14.docx b/sw/qa/extras/ooxmlexport/data/tdf153964_topMarginAfterBreak14.docx
new file mode 100644
index 000000000000..6c57bcfdc8ef
--- /dev/null
+++ b/sw/qa/extras/ooxmlexport/data/tdf153964_topMarginAfterBreak14.docx
Binary files differ
diff --git a/sw/qa/extras/ooxmlexport/data/tdf153964_topMarginAfterBreak15.docx b/sw/qa/extras/ooxmlexport/data/tdf153964_topMarginAfterBreak15.docx
new file mode 100644
index 000000000000..e4d5c45ed034
--- /dev/null
+++ b/sw/qa/extras/ooxmlexport/data/tdf153964_topMarginAfterBreak15.docx
Binary files differ
diff --git a/sw/qa/extras/ooxmlexport/ooxmlexport18.cxx b/sw/qa/extras/ooxmlexport/ooxmlexport18.cxx
index 7ab327f7e007..8497e0f58dc8 100644
--- a/sw/qa/extras/ooxmlexport/ooxmlexport18.cxx
+++ b/sw/qa/extras/ooxmlexport/ooxmlexport18.cxx
@@ -68,6 +68,96 @@ DECLARE_OOXMLEXPORT_TEST(testTdf153613_sdtAfterPgBreak, "tdf153613_sdtAfterPgBre
CPPUNIT_ASSERT_EQUAL(2, getPages());
}
+DECLARE_OOXMLEXPORT_TEST(testTdf153964_topMarginAfterBreak14, "tdf153964_topMarginAfterBreak14.docx")
+{
+ //The top margin should only apply once in a split paragraph.
+ //In this compat14 (Windows 2010) version, it applies after the break if no prior visible run.
+ uno::Reference<beans::XPropertySet> xPara(getParagraph(2, "a w:br at the start of the document. Does it use 60 point top margin?"), uno::UNO_QUERY);
+ //CPPUNIT_ASSERT_EQUAL(sal_Int32(2117), getProperty<sal_Int32>(xPara, "ParaTopMargin"));
+
+ xPara.set(getParagraph(3, u"60 pt spacing before"), uno::UNO_QUERY);
+ CPPUNIT_ASSERT_EQUAL(sal_Int32(2117), getProperty<sal_Int32>(xPara, "ParaTopMargin"));
+ CPPUNIT_ASSERT_EQUAL(Color(0xfbe4d5), getProperty<Color>(xPara, "ParaBackColor"));
+
+ // The top margin was applied to paragraph 3, so it shouldn't apply here
+ xPara.set(getParagraph(4, u"column break1"), uno::UNO_QUERY);
+ CPPUNIT_ASSERT_EQUAL(sal_Int32(0), getProperty<sal_Int32>(xPara, "ParaTopMargin"));
+ //CPPUNIT_ASSERT_EQUAL(Color(0xfbe4d5), getProperty<Color>(xPara, "ParaBackColor"));
+
+ xPara.set(getParagraph(5, u"60 pt followed by page break"), uno::UNO_QUERY);
+ CPPUNIT_ASSERT_EQUAL(sal_Int32(2117), getProperty<sal_Int32>(xPara, "ParaTopMargin"));
+ CPPUNIT_ASSERT_EQUAL(Color(0xdeeaf6), getProperty<Color>(xPara, "ParaBackColor"));
+
+ // The top margin was applied to paragraph 5, so it shouldn't apply here
+ xPara.set(getParagraph(6, u"page break1"), uno::UNO_QUERY);
+ CPPUNIT_ASSERT_EQUAL(sal_Int32(0), getProperty<sal_Int32>(xPara, "ParaTopMargin"));
+ CPPUNIT_ASSERT_EQUAL(Color(0xdeeaf6), getProperty<Color>(xPara, "ParaBackColor"));
+
+ // The top margin was not applied yet, so with compat14 it should apply here.
+ xPara.set(getParagraph(7, u"column break2"), uno::UNO_QUERY);
+ CPPUNIT_ASSERT_EQUAL(sal_Int32(2117), getProperty<sal_Int32>(xPara, "ParaTopMargin"));
+ CPPUNIT_ASSERT_EQUAL(Color(0xe2efd9), getProperty<Color>(xPara, "ParaBackColor"));
+
+ // In an odd twist, the w:br was actually at the end of the previous w:p, so in that case
+ // we ignore the top margin definition this time.
+ xPara.set(getParagraph(9, u"page break2"), uno::UNO_QUERY);
+ CPPUNIT_ASSERT_EQUAL(sal_Int32(0), getProperty<sal_Int32>(xPara, "ParaTopMargin"));
+
+ // The top margin was not applied before the column break, so with compat14 it should apply here
+ xPara.set(getParagraph(10, u""), uno::UNO_QUERY); // after column break
+ CPPUNIT_ASSERT_EQUAL(sal_Int32(2117), getProperty<sal_Int32>(xPara, "ParaTopMargin"));
+ //CPPUNIT_ASSERT_EQUAL(Color(0xfff2cc), getProperty<Color>(xPara, "ParaBackColor"));
+
+ // In an odd twist, the w:br was actually at the end of the previous w:p, so in that case
+ // we ignore the top margin definition this time.
+ xPara.set(getParagraph(12, u""), uno::UNO_QUERY); // after page break
+ CPPUNIT_ASSERT_EQUAL(sal_Int32(0), getProperty<sal_Int32>(xPara, "ParaTopMargin"));
+}
+
+DECLARE_OOXMLEXPORT_TEST(testTdf153964_topMarginAfterBreak15, "tdf153964_topMarginAfterBreak15.docx")
+{
+ //The top margin should only apply once (at most) in a split paragraph.
+ //In this compat15 (Windows 2013) version, it never applies after the break.
+ uno::Reference<beans::XPropertySet> xPara(getParagraph(2, "a w:br at the start of the document. Does it use 60 point top margin?"), uno::UNO_QUERY);
+ CPPUNIT_ASSERT_EQUAL(sal_Int32(0), getProperty<sal_Int32>(xPara, "ParaTopMargin"));
+
+ xPara.set(getParagraph(3, u"60 pt spacing before"), uno::UNO_QUERY);
+ CPPUNIT_ASSERT_EQUAL(sal_Int32(2117), getProperty<sal_Int32>(xPara, "ParaTopMargin"));
+ CPPUNIT_ASSERT_EQUAL(Color(0xfbe4d5), getProperty<Color>(xPara, "ParaBackColor"));
+
+ // The top margin was applied to paragraph 3, so it shouldn't apply here
+ xPara.set(getParagraph(4, u"column break1"), uno::UNO_QUERY);
+ CPPUNIT_ASSERT_EQUAL(sal_Int32(0), getProperty<sal_Int32>(xPara, "ParaTopMargin"));
+ //CPPUNIT_ASSERT_EQUAL(Color(0xfbe4d5), getProperty<Color>(xPara, "ParaBackColor"));
+
+ xPara.set(getParagraph(5, u"60 pt followed by page break"), uno::UNO_QUERY);
+ CPPUNIT_ASSERT_EQUAL(sal_Int32(2117), getProperty<sal_Int32>(xPara, "ParaTopMargin"));
+ CPPUNIT_ASSERT_EQUAL(Color(0xdeeaf6), getProperty<Color>(xPara, "ParaBackColor"));
+
+ // The top margin was applied to paragraph 5, so it shouldn't apply here
+ xPara.set(getParagraph(6, u"page break1"), uno::UNO_QUERY);
+ CPPUNIT_ASSERT_EQUAL(sal_Int32(0), getProperty<sal_Int32>(xPara, "ParaTopMargin"));
+ CPPUNIT_ASSERT_EQUAL(Color(0xdeeaf6), getProperty<Color>(xPara, "ParaBackColor"));
+
+ // The top margin was not applied to paragraph 6, and with compat15 it shouldn't apply here.
+ xPara.set(getParagraph(7, u"column break2"), uno::UNO_QUERY);
+ CPPUNIT_ASSERT_EQUAL(sal_Int32(0), getProperty<sal_Int32>(xPara, "ParaTopMargin"));
+ CPPUNIT_ASSERT_EQUAL(Color(0xe2efd9), getProperty<Color>(xPara, "ParaBackColor"));
+
+ // The top margin not was applied to paragraph 8, and with compat15 it shouldn't apply here.
+ xPara.set(getParagraph(9, u"page break2"), uno::UNO_QUERY);
+ CPPUNIT_ASSERT_EQUAL(sal_Int32(0), getProperty<sal_Int32>(xPara, "ParaTopMargin"));
+
+ // The top margin was not applied to paragraph 9, and with compat15 it shouldn't apply here.
+ xPara.set(getParagraph(10, u""), uno::UNO_QUERY); // after column break
+ CPPUNIT_ASSERT_EQUAL(sal_Int32(0), getProperty<sal_Int32>(xPara, "ParaTopMargin"));
+ //CPPUNIT_ASSERT_EQUAL(Color(0xfff2cc), getProperty<Color>(xPara, "ParaBackColor"));
+
+ // The top margin was not applied to paragraph 11, and with compat15 it shouldn't apply here.
+ xPara.set(getParagraph(12, u""), uno::UNO_QUERY); // after page break
+ CPPUNIT_ASSERT_EQUAL(sal_Int32(0), getProperty<sal_Int32>(xPara, "ParaTopMargin"));
+}
+
CPPUNIT_TEST_FIXTURE(Test, testTdf152636_lostPageBreak2)
{
loadAndReload("tdf152636_lostPageBreak2.docx");