From 7eafd8ccac56d7503b4287dfa3acac2cf0560b20 Mon Sep 17 00:00:00 2001 From: "nrbrtx@gmail.com" Date: Tue, 10 Jun 2014 12:26:26 +0400 Subject: fdo#79599: use \highlightN instead of \chcbpatN in RTF import and export Reviewed on: https://gerrit.libreoffice.org/9776 Change-Id: I98ef606fb73368a3c275819cb83b936e2162769d --- sw/qa/extras/rtfexport/data/fdo79599.rtf | 38 +++++++++++++++++++ sw/qa/extras/rtfexport/rtfexport.cxx | 9 +++++ sw/qa/extras/rtfimport/data/fdo79599.rtf | 38 +++++++++++++++++++ sw/qa/extras/rtfimport/rtfimport.cxx | 57 ++++++++++++++++++++++++++++- sw/source/filter/ww8/rtfattributeoutput.cxx | 2 +- 5 files changed, 141 insertions(+), 3 deletions(-) create mode 100755 sw/qa/extras/rtfexport/data/fdo79599.rtf create mode 100755 sw/qa/extras/rtfimport/data/fdo79599.rtf (limited to 'sw') 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(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 xRun(getRun(getParagraph(11),1), uno::UNO_QUERY); + CPPUNIT_ASSERT_EQUAL(sal_uInt32(0x800080), getProperty(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(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(getRun(getParagraph(1), 1), "CharBackColor")); + + // test \highlight2 = yellow + CPPUNIT_ASSERT_EQUAL(sal_uInt32(0xFFFF00), getProperty(getRun(getParagraph(2), 1), "CharBackColor")); + + // test \highlight3 = green + CPPUNIT_ASSERT_EQUAL(sal_uInt32(0x00FF00), getProperty(getRun(getParagraph(3), 1), "CharBackColor")); + + // test \highlight4 = cyan + CPPUNIT_ASSERT_EQUAL(sal_uInt32(0x00FFFF), getProperty(getRun(getParagraph(4), 1), "CharBackColor")); + + // test \highlight5 = magenta + CPPUNIT_ASSERT_EQUAL(sal_uInt32(0xFF00FF), getProperty(getRun(getParagraph(5), 1), "CharBackColor")); + + // test \highlight6 = blue + CPPUNIT_ASSERT_EQUAL(sal_uInt32(0x0000FF), getProperty(getRun(getParagraph(6), 1), "CharBackColor")); + + // test \highlight7 = red + CPPUNIT_ASSERT_EQUAL(sal_uInt32(0xFF0000), getProperty(getRun(getParagraph(7), 1), "CharBackColor")); + + // test \highlight8 = dark blue + CPPUNIT_ASSERT_EQUAL(sal_uInt32(0x000080), getProperty(getRun(getParagraph(8), 1), "CharBackColor")); + + // test \highlight9 = dark cyan + CPPUNIT_ASSERT_EQUAL(sal_uInt32(0x008080), getProperty(getRun(getParagraph(9), 1), "CharBackColor")); + + // test \highlight10 = dark green + CPPUNIT_ASSERT_EQUAL(sal_uInt32(0x008000), getProperty(getRun(getParagraph(10), 1), "CharBackColor")); + + // test \highlight11 = dark magenta + CPPUNIT_ASSERT_EQUAL(sal_uInt32(0x800080), getProperty(getRun(getParagraph(11), 1), "CharBackColor")); + + // test \highlight12 = dark red + CPPUNIT_ASSERT_EQUAL(sal_uInt32(0x800000), getProperty(getRun(getParagraph(12), 1), "CharBackColor")); + + // test \highlight13 = dark yellow + CPPUNIT_ASSERT_EQUAL(sal_uInt32(0x808000), getProperty(getRun(getParagraph(13), 1), "CharBackColor")); + + // test \highlight14 = dark gray + CPPUNIT_ASSERT_EQUAL(sal_uInt32(0x808080), getProperty(getRun(getParagraph(14), 1), "CharBackColor")); + + // test \highlight15 = light gray + CPPUNIT_ASSERT_EQUAL(sal_uInt32(0xC0C0C0), getProperty(getRun(getParagraph(15), 1), "CharBackColor")); + + // test \highlight1 = black + CPPUNIT_ASSERT_EQUAL(sal_uInt32(0x000000), getProperty(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 xTextRange = getRun(getParagraph(1), 1); // Was the Writer default font. CPPUNIT_ASSERT_EQUAL(OUString("Courier New"), getProperty(xTextRange, "CharFontName")); - // Was 0x008000. - CPPUNIT_ASSERT_EQUAL(COL_AUTO, getProperty(xTextRange, "CharBackColor")); + // It is white (0xFFFFFF) in document + CPPUNIT_ASSERT_EQUAL(sal_uInt32(0xFFFFFF), getProperty(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())); } } -- cgit