diff options
author | nrbrtx@gmail.com <nrbrtx@gmail.com> | 2014-06-10 12:26:26 +0400 |
---|---|---|
committer | Miklos Vajna <vmiklos@collabora.co.uk> | 2014-08-08 19:30:57 +0000 |
commit | 22731ba9e15978ab1d1ed98a29d88431cf674257 (patch) | |
tree | d552386dc8ec6d056fc35788fa9926153fcacdde | |
parent | aae8f8a758f42fec1189d5a8eed5e89c6c388cd0 (diff) |
fdo#79599: use \highlightN instead of \chcbpatN in RTF import and export
Reviewed on:
https://gerrit.libreoffice.org/9776
(cherry picked from commit 7eafd8ccac56d7503b4287dfa3acac2cf0560b20)
Conflicts:
sw/qa/extras/rtfexport/rtfexport.cxx
Change-Id: I98ef606fb73368a3c275819cb83b936e2162769d
Reviewed-on: https://gerrit.libreoffice.org/10813
Reviewed-by: Miklos Vajna <vmiklos@collabora.co.uk>
Tested-by: Miklos Vajna <vmiklos@collabora.co.uk>
-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 | ||||
-rw-r--r-- | writerfilter/source/dmapper/DomainMapper.cxx | 2 | ||||
-rw-r--r-- | writerfilter/source/rtftok/rtfdocumentimpl.cxx | 2 |
7 files changed, 144 insertions, 4 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 e4ed68583a40..06172585cc95 100644 --- a/sw/qa/extras/rtfexport/rtfexport.cxx +++ b/sw/qa/extras/rtfexport/rtfexport.cxx @@ -650,6 +650,15 @@ DECLARE_RTFEXPORT_TEST(testFdo80167, "fdo80167.rtf") CPPUNIT_ASSERT_EQUAL(2, getPages()); } +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 21458df40380..ff2cd1a797c9 100644 --- a/sw/qa/extras/rtfimport/rtfimport.cxx +++ b/sw/qa/extras/rtfimport/rtfimport.cxx @@ -544,6 +544,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 @@ -1091,8 +1144,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 9f143094abe3..51f9033938c0 100644 --- a/sw/source/filter/ww8/rtfattributeoutput.cxx +++ b/sw/source/filter/ww8/rtfattributeoutput.cxx @@ -2244,7 +2244,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())); } } diff --git a/writerfilter/source/dmapper/DomainMapper.cxx b/writerfilter/source/dmapper/DomainMapper.cxx index 35ad80e921e2..d97f4715417e 100644 --- a/writerfilter/source/dmapper/DomainMapper.cxx +++ b/writerfilter/source/dmapper/DomainMapper.cxx @@ -1336,6 +1336,8 @@ void DomainMapper::sprmWithProps( Sprm& rSprm, PropertyMapPtr rContext ) rContext->Insert(PROP_CHAR_BACK_COLOR, uno::makeAny( nColor )); else if (mnBackgroundColor) rContext->Insert(PROP_CHAR_BACK_COLOR, uno::makeAny( mnBackgroundColor )); + else + rContext->Insert(PROP_CHAR_BACK_COLOR, uno::makeAny( nIntValue )); } break; case NS_ooxml::LN_EG_RPrBase_em: diff --git a/writerfilter/source/rtftok/rtfdocumentimpl.cxx b/writerfilter/source/rtftok/rtfdocumentimpl.cxx index 19172761c0fa..37afecce0b77 100644 --- a/writerfilter/source/rtftok/rtfdocumentimpl.cxx +++ b/writerfilter/source/rtftok/rtfdocumentimpl.cxx @@ -3743,7 +3743,7 @@ int RTFDocumentImpl::dispatchValue(RTFKeyword nKeyword, int nParam) break; case RTF_HIGHLIGHT: { - RTFValue::Pointer_t pValue(new RTFValue(getColorTable(nParam))); + RTFValue::Pointer_t pValue(new RTFValue(nParam ? getColorTable(nParam) : COL_AUTO)); m_aStates.top().aCharacterSprms.set(NS_ooxml::LN_EG_RPrBase_highlight, pValue); } break; |