diff options
author | nrbrtx@gmail.com <nrbrtx@gmail.com> | 2014-06-10 12:26:26 +0400 |
---|---|---|
committer | Miklos Vajna <vmiklos@collabora.co.uk> | 2014-06-19 21:51:06 +0200 |
commit | 7eafd8ccac56d7503b4287dfa3acac2cf0560b20 (patch) | |
tree | cfbf3dd2c49aa5ad71ccac9923c07045659f2503 /sw | |
parent | 1d38cb365543924f9c50014e6b2227e77de1d0c9 (diff) |
fdo#79599: use \highlightN instead of \chcbpatN in RTF import and export
Reviewed on:
https://gerrit.libreoffice.org/9776
Change-Id: I98ef606fb73368a3c275819cb83b936e2162769d
Diffstat (limited to 'sw')
-rwxr-xr-x | sw/qa/extras/rtfexport/data/fdo79599.rtf | 38 | ||||
-rw-r--r-- | sw/qa/extras/rtfexport/rtfexport.cxx | 9 | ||||
-rwxr-xr-x | sw/qa/extras/rtfimport/data/fdo79599.rtf | 38 | ||||
-rw-r--r-- | sw/qa/extras/rtfimport/rtfimport.cxx | 57 | ||||
-rw-r--r-- | sw/source/filter/ww8/rtfattributeoutput.cxx | 2 |
5 files changed, 141 insertions, 3 deletions
diff --git a/sw/qa/extras/rtfexport/data/fdo79599.rtf b/sw/qa/extras/rtfexport/data/fdo79599.rtf new file mode 100755 index 000000000000..f9087091e1b3 --- /dev/null +++ b/sw/qa/extras/rtfexport/data/fdo79599.rtf @@ -0,0 +1,38 @@ +{\rtf1\deff0 +{\fonttbl +{\f000 Courier New;} +} +{\colortbl; +\red0\green0\blue0; +\red255\green255\blue0; +\red0\green255\blue0; +\red0\green255\blue255; +\red255\green0\blue255; +\red0\green0\blue255; +\red255\green0\blue0; +\red0\green0\blue128; +\red0\green128\blue128; +\red0\green128\blue0; +\red128\green0\blue128; +\red128\green0\blue0; +\red128\green128\blue0; +\red128\green128\blue128; +\red192\green192\blue192; +} +\highlight0 Should be ignored\par +\highlight2 #FFFF00 = Yellow\par +\highlight3 #00FF00 = Green\par +\highlight4 #00FFFF = Cyan\par +\highlight5 #FF00FF = Magenta\par +\highlight6 #0000FF = Blue\par +\highlight7 #FF0000 = Red\par +\highlight8 #000080 = Dark blue\par +\highlight9 #008080 = Dark cyan\par +\highlight10 #008000 = Dark green\par +\highlight11 #800080 = Dark magenta\par +\highlight12 #800000 = Dark red\par +\highlight13 #808000 = Dark yellow\par +\highlight14 #808080 = Dark gray\par +\highlight15 #C0C0C0 = Light gray\par +\highlight1 #000000 = Black\par +} diff --git a/sw/qa/extras/rtfexport/rtfexport.cxx b/sw/qa/extras/rtfexport/rtfexport.cxx index 71113f1ae46a..c01dc3878682 100644 --- a/sw/qa/extras/rtfexport/rtfexport.cxx +++ b/sw/qa/extras/rtfexport/rtfexport.cxx @@ -634,6 +634,15 @@ DECLARE_RTFEXPORT_TEST(testFdo77600, "fdo77600.rtf") CPPUNIT_ASSERT_EQUAL(OUString("Arial"), getProperty<OUString>(getRun(getParagraph(1), 3), "CharFontName")); } +DECLARE_RTFEXPORT_TEST(testFdo79599, "fdo79599.rtf") +{ + // test for \highlightNN, document has full \colortbl (produced in MS Word 2003 or 2007) + + // test \highlight11 = dark magenta + uno::Reference<beans::XPropertySet> xRun(getRun(getParagraph(11),1), uno::UNO_QUERY); + CPPUNIT_ASSERT_EQUAL(sal_uInt32(0x800080), getProperty<sal_uInt32>(xRun, "CharBackColor")); +} + #endif CPPUNIT_PLUGIN_IMPLEMENT(); diff --git a/sw/qa/extras/rtfimport/data/fdo79599.rtf b/sw/qa/extras/rtfimport/data/fdo79599.rtf new file mode 100755 index 000000000000..f9087091e1b3 --- /dev/null +++ b/sw/qa/extras/rtfimport/data/fdo79599.rtf @@ -0,0 +1,38 @@ +{\rtf1\deff0 +{\fonttbl +{\f000 Courier New;} +} +{\colortbl; +\red0\green0\blue0; +\red255\green255\blue0; +\red0\green255\blue0; +\red0\green255\blue255; +\red255\green0\blue255; +\red0\green0\blue255; +\red255\green0\blue0; +\red0\green0\blue128; +\red0\green128\blue128; +\red0\green128\blue0; +\red128\green0\blue128; +\red128\green0\blue0; +\red128\green128\blue0; +\red128\green128\blue128; +\red192\green192\blue192; +} +\highlight0 Should be ignored\par +\highlight2 #FFFF00 = Yellow\par +\highlight3 #00FF00 = Green\par +\highlight4 #00FFFF = Cyan\par +\highlight5 #FF00FF = Magenta\par +\highlight6 #0000FF = Blue\par +\highlight7 #FF0000 = Red\par +\highlight8 #000080 = Dark blue\par +\highlight9 #008080 = Dark cyan\par +\highlight10 #008000 = Dark green\par +\highlight11 #800080 = Dark magenta\par +\highlight12 #800000 = Dark red\par +\highlight13 #808000 = Dark yellow\par +\highlight14 #808080 = Dark gray\par +\highlight15 #C0C0C0 = Light gray\par +\highlight1 #000000 = Black\par +} diff --git a/sw/qa/extras/rtfimport/rtfimport.cxx b/sw/qa/extras/rtfimport/rtfimport.cxx index 8d8e0481a591..3dec26ee08ae 100644 --- a/sw/qa/extras/rtfimport/rtfimport.cxx +++ b/sw/qa/extras/rtfimport/rtfimport.cxx @@ -530,6 +530,59 @@ DECLARE_RTFIMPORT_TEST(testFdo50539, "fdo50539.rtf") CPPUNIT_ASSERT_EQUAL(sal_Int32(-1), getProperty<sal_Int32>(getRun(getParagraph(1), 1), "CharBackColor")); } +DECLARE_RTFIMPORT_TEST(testFdo79599, "fdo79599.rtf") +{ + // test for \highlightNN, document has full \colortbl (produced in MS Word 2003 or 2007) + + // ignore \highlight0 + CPPUNIT_ASSERT_EQUAL(sal_Int32(-1), getProperty<sal_Int32>(getRun(getParagraph(1), 1), "CharBackColor")); + + // test \highlight2 = yellow + CPPUNIT_ASSERT_EQUAL(sal_uInt32(0xFFFF00), getProperty<sal_uInt32>(getRun(getParagraph(2), 1), "CharBackColor")); + + // test \highlight3 = green + CPPUNIT_ASSERT_EQUAL(sal_uInt32(0x00FF00), getProperty<sal_uInt32>(getRun(getParagraph(3), 1), "CharBackColor")); + + // test \highlight4 = cyan + CPPUNIT_ASSERT_EQUAL(sal_uInt32(0x00FFFF), getProperty<sal_uInt32>(getRun(getParagraph(4), 1), "CharBackColor")); + + // test \highlight5 = magenta + CPPUNIT_ASSERT_EQUAL(sal_uInt32(0xFF00FF), getProperty<sal_uInt32>(getRun(getParagraph(5), 1), "CharBackColor")); + + // test \highlight6 = blue + CPPUNIT_ASSERT_EQUAL(sal_uInt32(0x0000FF), getProperty<sal_uInt32>(getRun(getParagraph(6), 1), "CharBackColor")); + + // test \highlight7 = red + CPPUNIT_ASSERT_EQUAL(sal_uInt32(0xFF0000), getProperty<sal_uInt32>(getRun(getParagraph(7), 1), "CharBackColor")); + + // test \highlight8 = dark blue + CPPUNIT_ASSERT_EQUAL(sal_uInt32(0x000080), getProperty<sal_uInt32>(getRun(getParagraph(8), 1), "CharBackColor")); + + // test \highlight9 = dark cyan + CPPUNIT_ASSERT_EQUAL(sal_uInt32(0x008080), getProperty<sal_uInt32>(getRun(getParagraph(9), 1), "CharBackColor")); + + // test \highlight10 = dark green + CPPUNIT_ASSERT_EQUAL(sal_uInt32(0x008000), getProperty<sal_uInt32>(getRun(getParagraph(10), 1), "CharBackColor")); + + // test \highlight11 = dark magenta + CPPUNIT_ASSERT_EQUAL(sal_uInt32(0x800080), getProperty<sal_uInt32>(getRun(getParagraph(11), 1), "CharBackColor")); + + // test \highlight12 = dark red + CPPUNIT_ASSERT_EQUAL(sal_uInt32(0x800000), getProperty<sal_uInt32>(getRun(getParagraph(12), 1), "CharBackColor")); + + // test \highlight13 = dark yellow + CPPUNIT_ASSERT_EQUAL(sal_uInt32(0x808000), getProperty<sal_uInt32>(getRun(getParagraph(13), 1), "CharBackColor")); + + // test \highlight14 = dark gray + CPPUNIT_ASSERT_EQUAL(sal_uInt32(0x808080), getProperty<sal_uInt32>(getRun(getParagraph(14), 1), "CharBackColor")); + + // test \highlight15 = light gray + CPPUNIT_ASSERT_EQUAL(sal_uInt32(0xC0C0C0), getProperty<sal_uInt32>(getRun(getParagraph(15), 1), "CharBackColor")); + + // test \highlight1 = black + CPPUNIT_ASSERT_EQUAL(sal_uInt32(0x000000), getProperty<sal_uInt32>(getRun(getParagraph(16), 1), "CharBackColor")); +} + DECLARE_RTFIMPORT_TEST(testFdo50665, "fdo50665.rtf") { // Access the second run, which is a textfield @@ -1059,8 +1112,8 @@ DECLARE_RTFIMPORT_TEST(testFdo61909, "fdo61909.rtf") uno::Reference<text::XTextRange> xTextRange = getRun(getParagraph(1), 1); // Was the Writer default font. CPPUNIT_ASSERT_EQUAL(OUString("Courier New"), getProperty<OUString>(xTextRange, "CharFontName")); - // Was 0x008000. - CPPUNIT_ASSERT_EQUAL(COL_AUTO, getProperty<sal_uInt32>(xTextRange, "CharBackColor")); + // It is white (0xFFFFFF) in document + CPPUNIT_ASSERT_EQUAL(sal_uInt32(0xFFFFFF), getProperty<sal_uInt32>(xTextRange, "CharBackColor")); } DECLARE_RTFIMPORT_TEST(testFdo62288, "fdo62288.rtf") diff --git a/sw/source/filter/ww8/rtfattributeoutput.cxx b/sw/source/filter/ww8/rtfattributeoutput.cxx index 969e0e2f893d..5f41c3467d02 100644 --- a/sw/source/filter/ww8/rtfattributeoutput.cxx +++ b/sw/source/filter/ww8/rtfattributeoutput.cxx @@ -2236,7 +2236,7 @@ void RtfAttributeOutput::CharBackground(const SvxBrushItem& rBrush) { if (!rBrush.GetColor().GetTransparency()) { - m_aStyles.append(OOO_STRING_SVTOOLS_RTF_CHCBPAT); + m_aStyles.append(OOO_STRING_SVTOOLS_RTF_HIGHLIGHT); m_aStyles.append((sal_Int32)m_rExport.GetColor(rBrush.GetColor())); } } |