summaryrefslogtreecommitdiff
path: root/sw/qa
diff options
context:
space:
mode:
authorVasily Melenchuk <vasily.melenchuk@cib.de>2022-03-21 13:54:28 +0300
committerMiklos Vajna <vmiklos@collabora.com>2022-03-21 15:58:54 +0100
commit79b5ff92b17fde902c2f9db3e806f1c77a387dff (patch)
tree70592adfae2ab7d8b2f46268fe0a46b4376edd29 /sw/qa
parentf8b482f6d601b40c0263333da393bc218c8114eb (diff)
tdf#118047: RTF import: better deduplication for header/footer
Here are two related fixes in one patch: 1. By default current style index is 0, not -1. Due to this we can assume usage of default "Normal" style during deduplication. Seems there is no difference in case of no style mentioning in run or mentioning "Normal" one (\s0), so value -1 looks unnesesary. 2. During header/footer "substreams" processing StyleTableEntires was not reused in new domain mapper impl instance. So deduplication did not work well. 2a. To avoid copying of whole StyleTableEntries between instances it is stored as pointer in domain mapper impl. Change-Id: Id003d35554e9b43186238920d9a6373452095121 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/131899 Tested-by: Jenkins Reviewed-by: Miklos Vajna <vmiklos@collabora.com>
Diffstat (limited to 'sw/qa')
-rw-r--r--sw/qa/extras/rtfexport/data/tdf118047.rtf14
-rw-r--r--sw/qa/extras/rtfexport/rtfexport5.cxx15
2 files changed, 29 insertions, 0 deletions
diff --git a/sw/qa/extras/rtfexport/data/tdf118047.rtf b/sw/qa/extras/rtfexport/data/tdf118047.rtf
new file mode 100644
index 000000000000..258d99de9bef
--- /dev/null
+++ b/sw/qa/extras/rtfexport/data/tdf118047.rtf
@@ -0,0 +1,14 @@
+{\rtf1\ansi
+
+{\stylesheet
+{\fs72\sa3200 Normal;}
+}
+
+\sectd
+{
+\headerr
+Header\par
+}
+
+Text\par
+}
diff --git a/sw/qa/extras/rtfexport/rtfexport5.cxx b/sw/qa/extras/rtfexport/rtfexport5.cxx
index 04c857ade582..c59448af2514 100644
--- a/sw/qa/extras/rtfexport/rtfexport5.cxx
+++ b/sw/qa/extras/rtfexport/rtfexport5.cxx
@@ -1348,6 +1348,21 @@ DECLARE_RTFEXPORT_TEST(testTdf131234, "tdf131234.rtf")
CPPUNIT_ASSERT_EQUAL(awt::FontSlant_NONE, getProperty<awt::FontSlant>(xRun, "CharPosture"));
}
+DECLARE_RTFEXPORT_TEST(testTdf118047, "tdf118047.rtf")
+{
+ uno::Reference<text::XTextRange> xPara = getParagraph(1);
+
+ // Ensure that default "Normal" style properties are not applied to text:
+ // text remains with fontsize 12pt and no huge margin below
+ CPPUNIT_ASSERT_EQUAL(12.f, getProperty<float>(getRun(xPara, 1), "CharHeight"));
+ CPPUNIT_ASSERT_EQUAL(sal_Int32(0), getProperty<sal_Int32>(getParagraph(1), "ParaBottomMargin"));
+
+ // Same for header, it should not derive props from "Normal" style
+ CPPUNIT_ASSERT_EQUAL(OUString("Header"), parseDump("/root/page[1]/header/txt/text()"));
+ sal_Int32 nHeight = parseDump("/root/page[1]/header/infos/bounds", "height").toInt32();
+ CPPUNIT_ASSERT_MESSAGE("Header is too large", 1000 > nHeight);
+}
+
CPPUNIT_PLUGIN_IMPLEMENT();
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */