summaryrefslogtreecommitdiff
path: root/sw
diff options
context:
space:
mode:
authorVasily Melenchuk <vasily.melenchuk@cib.de>2022-03-22 14:02:35 +0300
committerAndras Timar <andras.timar@collabora.com>2022-03-25 15:55:11 +0100
commit2723eea9f498586b74671ab10683ae1818b9919b (patch)
tree50f799705aeaa153838c9133957f22574fac9be5 /sw
parent6c90a4f35b6655b382e4e5a4400fce318870b9fa (diff)
tdf#111851: rtf import: fifty shades of grey
Unlike in DOCX in RTF token \clshdngN can represent much more transitional cell shade values from 0 (white) to 10000 (black). So we should not match these values strictly but use ranges instead. Change-Id: I4e0066e2b79e73cf6fbc3dd773047be8dab2b907 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/131931 Tested-by: Jenkins Reviewed-by: Miklos Vajna <vmiklos@collabora.com> Signed-off-by: Xisco Fauli <xiscofauli@libreoffice.org> Reviewed-on: https://gerrit.libreoffice.org/c/core/+/131962
Diffstat (limited to 'sw')
-rw-r--r--sw/qa/extras/rtfexport/data/tdf111851.rtf17
-rw-r--r--sw/qa/extras/rtfexport/rtfexport4.cxx36
2 files changed, 53 insertions, 0 deletions
diff --git a/sw/qa/extras/rtfexport/data/tdf111851.rtf b/sw/qa/extras/rtfexport/data/tdf111851.rtf
new file mode 100644
index 000000000000..242354364e76
--- /dev/null
+++ b/sw/qa/extras/rtfexport/data/tdf111851.rtf
@@ -0,0 +1,17 @@
+{\rtf
+
+\trowd
+\clshdng-20000\cellx200
+\clshdng0\cellx400
+\clshdng666\cellx600
+\clshdng3275\cellx800
+\clshdng10000\cellx1000
+\clshdng20000\cellx1200
+\intbl a\cell
+\intbl b\cell
+\intbl c\cell
+\intbl d\cell
+\intbl e\cell
+\intbl f\cell
+\row
+} \ No newline at end of file
diff --git a/sw/qa/extras/rtfexport/rtfexport4.cxx b/sw/qa/extras/rtfexport/rtfexport4.cxx
index 1b29939ac4fc..55ae121a695b 100644
--- a/sw/qa/extras/rtfexport/rtfexport4.cxx
+++ b/sw/qa/extras/rtfexport/rtfexport4.cxx
@@ -431,6 +431,42 @@ CPPUNIT_TEST_FIXTURE(Test, testGutterTop)
CPPUNIT_ASSERT(bGutterAtTop);
}
+DECLARE_RTFEXPORT_TEST(testTdf111851, "tdf111851.rtf")
+{
+ uno::Reference<text::XTextTable> xTable(getParagraphOrTable(1), uno::UNO_QUERY);
+
+ // No shading
+ uno::Reference<text::XTextRange> xCell1(xTable->getCellByName("A1"), uno::UNO_QUERY);
+ CPPUNIT_ASSERT_EQUAL(OUString("a"), xCell1->getString());
+ CPPUNIT_ASSERT_EQUAL(sal_Int32(-1), getProperty<sal_Int32>(xCell1, "BackColor"));
+
+ uno::Reference<text::XTextRange> xCell2(xTable->getCellByName("B1"), uno::UNO_QUERY);
+ CPPUNIT_ASSERT_EQUAL(OUString("b"), xCell2->getString());
+ CPPUNIT_ASSERT_EQUAL(sal_Int32(-1), getProperty<sal_Int32>(xCell2, "BackColor"));
+
+ // Check some random not standard shading values and ensure some non-white background color
+ uno::Reference<text::XTextRange> xCell3(xTable->getCellByName("C1"), uno::UNO_QUERY);
+ CPPUNIT_ASSERT_EQUAL(OUString("c"), xCell3->getString());
+ sal_Int32 nShadingColor3 = getProperty<sal_Int32>(xCell3, "BackColor");
+ CPPUNIT_ASSERT(0x00FFFFFF > nShadingColor3);
+ CPPUNIT_ASSERT(0 < nShadingColor3);
+
+ uno::Reference<text::XTextRange> xCell4(xTable->getCellByName("D1"), uno::UNO_QUERY);
+ CPPUNIT_ASSERT_EQUAL(OUString("d"), xCell4->getString());
+ sal_Int32 nShadingColor4 = getProperty<sal_Int32>(xCell4, "BackColor");
+ CPPUNIT_ASSERT(0x00FFFFFF > nShadingColor4);
+ CPPUNIT_ASSERT(0 < nShadingColor4);
+
+ // Values 10000 and more - black
+ uno::Reference<text::XTextRange> xCell5(xTable->getCellByName("E1"), uno::UNO_QUERY);
+ CPPUNIT_ASSERT_EQUAL(OUString("e"), xCell5->getString());
+ CPPUNIT_ASSERT_EQUAL(sal_Int32(0), getProperty<sal_Int32>(xCell5, "BackColor"));
+
+ uno::Reference<text::XTextRange> xCell6(xTable->getCellByName("F1"), uno::UNO_QUERY);
+ CPPUNIT_ASSERT_EQUAL(OUString("f"), xCell6->getString());
+ CPPUNIT_ASSERT_EQUAL(sal_Int32(0), getProperty<sal_Int32>(xCell6, "BackColor"));
+}
+
CPPUNIT_PLUGIN_IMPLEMENT();
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */