summaryrefslogtreecommitdiff
path: root/sw/qa
diff options
context:
space:
mode:
authorMike Kaganski <mike.kaganski@collabora.com>2018-01-28 18:16:19 +0300
committerMike Kaganski <mike.kaganski@collabora.com>2018-01-28 21:08:56 +0100
commit21a15d5106bf081d3c896f9f1b01702b2c61d135 (patch)
tree62e31408815a772e65def3666050075ca956bda9 /sw/qa
parent7c13aa5b37dcf1ca586de78c2dea91733822bd22 (diff)
Change-Id: Id64041090a0be4df847f2962e32011ef2500de0e Reviewed-on: https://gerrit.libreoffice.org/48760 Tested-by: Jenkins <ci@libreoffice.org> Reviewed-by: Mike Kaganski <mike.kaganski@collabora.com>
Diffstat (limited to 'sw/qa')
-rw-r--r--sw/qa/extras/rtfimport/data/default-values.rtf18
-rw-r--r--sw/qa/extras/rtfimport/rtfimport.cxx130
2 files changed, 148 insertions, 0 deletions
diff --git a/sw/qa/extras/rtfimport/data/default-values.rtf b/sw/qa/extras/rtfimport/data/default-values.rtf
new file mode 100644
index 000000000000..d9623f3599d1
--- /dev/null
+++ b/sw/qa/extras/rtfimport/data/default-values.rtf
@@ -0,0 +1,18 @@
+{\rtf1
+{\colortbl;\red255\green255\blue255\red\green\blue;\red255;\green255;\blue255;}
+\charscalex50 scaleWidth50%
+\charscalex scaleWidth100%
+\fs50 fontSize25
+\fs fontSize12
+\dn textDown3pt
+\up textUp3pt
+\up0\expnd4 expand1pt
+\expnd expand0pt
+\expndtw20 expand1pt
+\expndtw expand0pt
+\cf1 colorBlack
+\cf2 colorRed
+\cf3 colorGreen
+\cf4 colorBlue
+\cf colorAuto
+\par} \ No newline at end of file
diff --git a/sw/qa/extras/rtfimport/rtfimport.cxx b/sw/qa/extras/rtfimport/rtfimport.cxx
index 87824294180d..103c6726abe4 100644
--- a/sw/qa/extras/rtfimport/rtfimport.cxx
+++ b/sw/qa/extras/rtfimport/rtfimport.cxx
@@ -1380,6 +1380,136 @@ DECLARE_RTFIMPORT_TEST(testTdf104016, "tdf104016.rtf")
xParagraph->getPropertyState("ParaLeftMargin"));
}
+DECLARE_RTFIMPORT_TEST(testDefaultValues, "default-values.rtf")
+{
+ // tdf#105910: control words without values must be treated as having default values,
+ // instead of being silently ignored
+
+ uno::Reference<text::XTextRange> paragraph = getParagraph(1);
+
+ uno::Reference<text::XTextRange> run = getRun(paragraph, 1, "scaleWidth50%");
+ CPPUNIT_ASSERT_EQUAL(sal_Int16(50), getProperty<sal_Int16>(run, "CharScaleWidth"));
+ CPPUNIT_ASSERT_EQUAL(double(12), getProperty<double>(run, "CharHeight"));
+ CPPUNIT_ASSERT_EQUAL(sal_Int32(0), getProperty<sal_Int32>(run, "CharEscapement"));
+ CPPUNIT_ASSERT_EQUAL(sal_Int32(100), getProperty<sal_Int32>(run, "CharEscapementHeight"));
+ CPPUNIT_ASSERT_EQUAL(sal_Int16(0), getProperty<sal_Int16>(run, "CharKerning"));
+ CPPUNIT_ASSERT_EQUAL(sal_Int32(COL_AUTO), getProperty<sal_Int32>(run, "CharColor"));
+
+ run = getRun(paragraph, 2, "scaleWidth100%");
+ CPPUNIT_ASSERT_EQUAL(sal_Int16(100), getProperty<sal_Int16>(run, "CharScaleWidth"));
+ CPPUNIT_ASSERT_EQUAL(double(12), getProperty<double>(run, "CharHeight"));
+ CPPUNIT_ASSERT_EQUAL(sal_Int32(0), getProperty<sal_Int32>(run, "CharEscapement"));
+ CPPUNIT_ASSERT_EQUAL(sal_Int32(100), getProperty<sal_Int32>(run, "CharEscapementHeight"));
+ CPPUNIT_ASSERT_EQUAL(sal_Int16(0), getProperty<sal_Int16>(run, "CharKerning"));
+ CPPUNIT_ASSERT_EQUAL(sal_Int32(COL_AUTO), getProperty<sal_Int32>(run, "CharColor"));
+
+ run = getRun(paragraph, 3, "fontSize25");
+ CPPUNIT_ASSERT_EQUAL(sal_Int16(100), getProperty<sal_Int16>(run, "CharScaleWidth"));
+ CPPUNIT_ASSERT_EQUAL(double(25), getProperty<double>(run, "CharHeight"));
+ CPPUNIT_ASSERT_EQUAL(sal_Int32(0), getProperty<sal_Int32>(run, "CharEscapement"));
+ CPPUNIT_ASSERT_EQUAL(sal_Int32(100), getProperty<sal_Int32>(run, "CharEscapementHeight"));
+ CPPUNIT_ASSERT_EQUAL(sal_Int16(0), getProperty<sal_Int16>(run, "CharKerning"));
+ CPPUNIT_ASSERT_EQUAL(sal_Int32(COL_AUTO), getProperty<sal_Int32>(run, "CharColor"));
+
+ run = getRun(paragraph, 4, "fontSize12");
+ CPPUNIT_ASSERT_EQUAL(sal_Int16(100), getProperty<sal_Int16>(run, "CharScaleWidth"));
+ CPPUNIT_ASSERT_EQUAL(double(12), getProperty<double>(run, "CharHeight"));
+ CPPUNIT_ASSERT_EQUAL(sal_Int32(0), getProperty<sal_Int32>(run, "CharEscapement"));
+ CPPUNIT_ASSERT_EQUAL(sal_Int32(100), getProperty<sal_Int32>(run, "CharEscapementHeight"));
+ CPPUNIT_ASSERT_EQUAL(sal_Int16(0), getProperty<sal_Int16>(run, "CharKerning"));
+ CPPUNIT_ASSERT_EQUAL(sal_Int32(COL_AUTO), getProperty<sal_Int32>(run, "CharColor"));
+
+ run = getRun(paragraph, 5, "textDown3pt");
+ CPPUNIT_ASSERT_EQUAL(sal_Int16(100), getProperty<sal_Int16>(run, "CharScaleWidth"));
+ CPPUNIT_ASSERT_EQUAL(double(12), getProperty<double>(run, "CharHeight"));
+ CPPUNIT_ASSERT_EQUAL(sal_Int32(-25), getProperty<sal_Int32>(run, "CharEscapement"));
+ CPPUNIT_ASSERT_EQUAL(sal_Int32(100), getProperty<sal_Int32>(run, "CharEscapementHeight"));
+ CPPUNIT_ASSERT_EQUAL(sal_Int16(0), getProperty<sal_Int16>(run, "CharKerning"));
+ CPPUNIT_ASSERT_EQUAL(sal_Int32(COL_AUTO), getProperty<sal_Int32>(run, "CharColor"));
+
+ run = getRun(paragraph, 6, "textUp3pt");
+ CPPUNIT_ASSERT_EQUAL(sal_Int16(100), getProperty<sal_Int16>(run, "CharScaleWidth"));
+ CPPUNIT_ASSERT_EQUAL(double(12), getProperty<double>(run, "CharHeight"));
+ CPPUNIT_ASSERT_EQUAL(sal_Int32(25), getProperty<sal_Int32>(run, "CharEscapement"));
+ CPPUNIT_ASSERT_EQUAL(sal_Int32(100), getProperty<sal_Int32>(run, "CharEscapementHeight"));
+ CPPUNIT_ASSERT_EQUAL(sal_Int16(0), getProperty<sal_Int16>(run, "CharKerning"));
+ CPPUNIT_ASSERT_EQUAL(sal_Int32(COL_AUTO), getProperty<sal_Int32>(run, "CharColor"));
+
+ run = getRun(paragraph, 7, "expand1pt");
+ CPPUNIT_ASSERT_EQUAL(sal_Int16(100), getProperty<sal_Int16>(run, "CharScaleWidth"));
+ CPPUNIT_ASSERT_EQUAL(double(12), getProperty<double>(run, "CharHeight"));
+ CPPUNIT_ASSERT_EQUAL(sal_Int32(0), getProperty<sal_Int32>(run, "CharEscapement"));
+ CPPUNIT_ASSERT_EQUAL(sal_Int32(100), getProperty<sal_Int32>(run, "CharEscapementHeight"));
+ CPPUNIT_ASSERT_EQUAL(sal_Int64(20),
+ convertMm100ToTwip(getProperty<sal_Int16>(run, "CharKerning")));
+ CPPUNIT_ASSERT_EQUAL(sal_Int32(COL_AUTO), getProperty<sal_Int32>(run, "CharColor"));
+
+ run = getRun(paragraph, 8, "expand0pt");
+ CPPUNIT_ASSERT_EQUAL(sal_Int16(100), getProperty<sal_Int16>(run, "CharScaleWidth"));
+ CPPUNIT_ASSERT_EQUAL(double(12), getProperty<double>(run, "CharHeight"));
+ CPPUNIT_ASSERT_EQUAL(sal_Int32(0), getProperty<sal_Int32>(run, "CharEscapement"));
+ CPPUNIT_ASSERT_EQUAL(sal_Int32(100), getProperty<sal_Int32>(run, "CharEscapementHeight"));
+ CPPUNIT_ASSERT_EQUAL(sal_Int16(0), getProperty<sal_Int16>(run, "CharKerning"));
+ CPPUNIT_ASSERT_EQUAL(sal_Int32(COL_AUTO), getProperty<sal_Int32>(run, "CharColor"));
+
+ run = getRun(paragraph, 9, "expand1pt");
+ CPPUNIT_ASSERT_EQUAL(sal_Int16(100), getProperty<sal_Int16>(run, "CharScaleWidth"));
+ CPPUNIT_ASSERT_EQUAL(double(12), getProperty<double>(run, "CharHeight"));
+ CPPUNIT_ASSERT_EQUAL(sal_Int32(0), getProperty<sal_Int32>(run, "CharEscapement"));
+ CPPUNIT_ASSERT_EQUAL(sal_Int32(100), getProperty<sal_Int32>(run, "CharEscapementHeight"));
+ CPPUNIT_ASSERT_EQUAL(sal_Int64(20),
+ convertMm100ToTwip(getProperty<sal_Int16>(run, "CharKerning")));
+ CPPUNIT_ASSERT_EQUAL(sal_Int32(COL_AUTO), getProperty<sal_Int32>(run, "CharColor"));
+
+ run = getRun(paragraph, 10, "expand0pt");
+ CPPUNIT_ASSERT_EQUAL(sal_Int16(100), getProperty<sal_Int16>(run, "CharScaleWidth"));
+ CPPUNIT_ASSERT_EQUAL(double(12), getProperty<double>(run, "CharHeight"));
+ CPPUNIT_ASSERT_EQUAL(sal_Int32(0), getProperty<sal_Int32>(run, "CharEscapement"));
+ CPPUNIT_ASSERT_EQUAL(sal_Int32(100), getProperty<sal_Int32>(run, "CharEscapementHeight"));
+ CPPUNIT_ASSERT_EQUAL(sal_Int16(0), getProperty<sal_Int16>(run, "CharKerning"));
+ CPPUNIT_ASSERT_EQUAL(sal_Int32(COL_AUTO), getProperty<sal_Int32>(run, "CharColor"));
+
+ run = getRun(paragraph, 11, "colorBlack");
+ CPPUNIT_ASSERT_EQUAL(sal_Int16(100), getProperty<sal_Int16>(run, "CharScaleWidth"));
+ CPPUNIT_ASSERT_EQUAL(double(12), getProperty<double>(run, "CharHeight"));
+ CPPUNIT_ASSERT_EQUAL(sal_Int32(0), getProperty<sal_Int32>(run, "CharEscapement"));
+ CPPUNIT_ASSERT_EQUAL(sal_Int32(100), getProperty<sal_Int32>(run, "CharEscapementHeight"));
+ CPPUNIT_ASSERT_EQUAL(sal_Int16(0), getProperty<sal_Int16>(run, "CharKerning"));
+ CPPUNIT_ASSERT_EQUAL(sal_Int32(COL_BLACK), getProperty<sal_Int32>(run, "CharColor"));
+
+ run = getRun(paragraph, 12, "colorRed");
+ CPPUNIT_ASSERT_EQUAL(sal_Int16(100), getProperty<sal_Int16>(run, "CharScaleWidth"));
+ CPPUNIT_ASSERT_EQUAL(double(12), getProperty<double>(run, "CharHeight"));
+ CPPUNIT_ASSERT_EQUAL(sal_Int32(0), getProperty<sal_Int32>(run, "CharEscapement"));
+ CPPUNIT_ASSERT_EQUAL(sal_Int32(100), getProperty<sal_Int32>(run, "CharEscapementHeight"));
+ CPPUNIT_ASSERT_EQUAL(sal_Int16(0), getProperty<sal_Int16>(run, "CharKerning"));
+ CPPUNIT_ASSERT_EQUAL(sal_Int32(COL_LIGHTRED), getProperty<sal_Int32>(run, "CharColor"));
+
+ run = getRun(paragraph, 13, "colorGreen");
+ CPPUNIT_ASSERT_EQUAL(sal_Int16(100), getProperty<sal_Int16>(run, "CharScaleWidth"));
+ CPPUNIT_ASSERT_EQUAL(double(12), getProperty<double>(run, "CharHeight"));
+ CPPUNIT_ASSERT_EQUAL(sal_Int32(0), getProperty<sal_Int32>(run, "CharEscapement"));
+ CPPUNIT_ASSERT_EQUAL(sal_Int32(100), getProperty<sal_Int32>(run, "CharEscapementHeight"));
+ CPPUNIT_ASSERT_EQUAL(sal_Int16(0), getProperty<sal_Int16>(run, "CharKerning"));
+ CPPUNIT_ASSERT_EQUAL(sal_Int32(COL_LIGHTGREEN), getProperty<sal_Int32>(run, "CharColor"));
+
+ run = getRun(paragraph, 14, "colorBlue");
+ CPPUNIT_ASSERT_EQUAL(sal_Int16(100), getProperty<sal_Int16>(run, "CharScaleWidth"));
+ CPPUNIT_ASSERT_EQUAL(double(12), getProperty<double>(run, "CharHeight"));
+ CPPUNIT_ASSERT_EQUAL(sal_Int32(0), getProperty<sal_Int32>(run, "CharEscapement"));
+ CPPUNIT_ASSERT_EQUAL(sal_Int32(100), getProperty<sal_Int32>(run, "CharEscapementHeight"));
+ CPPUNIT_ASSERT_EQUAL(sal_Int16(0), getProperty<sal_Int16>(run, "CharKerning"));
+ CPPUNIT_ASSERT_EQUAL(sal_Int32(COL_LIGHTBLUE), getProperty<sal_Int32>(run, "CharColor"));
+
+ run = getRun(paragraph, 15, "colorAuto");
+ CPPUNIT_ASSERT_EQUAL(sal_Int16(100), getProperty<sal_Int16>(run, "CharScaleWidth"));
+ CPPUNIT_ASSERT_EQUAL(double(12), getProperty<double>(run, "CharHeight"));
+ CPPUNIT_ASSERT_EQUAL(sal_Int32(0), getProperty<sal_Int32>(run, "CharEscapement"));
+ CPPUNIT_ASSERT_EQUAL(sal_Int32(100), getProperty<sal_Int32>(run, "CharEscapementHeight"));
+ CPPUNIT_ASSERT_EQUAL(sal_Int16(0), getProperty<sal_Int16>(run, "CharKerning"));
+ CPPUNIT_ASSERT_EQUAL(sal_Int32(COL_AUTO), getProperty<sal_Int32>(run, "CharColor"));
+}
+
// tests should only be added to rtfIMPORT *if* they fail round-tripping in rtfEXPORT
CPPUNIT_PLUGIN_IMPLEMENT();