diff options
author | Miklos Vajna <vmiklos@suse.cz> | 2013-03-18 12:40:46 +0100 |
---|---|---|
committer | Fridrich Strba <fridrich@documentfoundation.org> | 2013-03-18 14:57:14 +0000 |
commit | 65f42760736d656b4999aa8830cb4f44f6d4e718 (patch) | |
tree | d8e3819aec488488fcc5df7e1fc6769ff1775d45 | |
parent | f6001794c67d76cb8efc7151263ae847c9137feb (diff) |
fdo#61909 fix import of RTF_HIGHLIGHT and of default font without RTF_PLAIN
(cherry picked from commits 60c17b2873506ed8b068b34840aecda0c1d9bd65 and
c412cba28ebc00783041bcec74978fc959cc1351)
Change-Id: Ifa7b14e88231e5053c84dfbdd9b453715df1aaa6
Reviewed-on: https://gerrit.libreoffice.org/2817
Reviewed-by: Fridrich Strba <fridrich@documentfoundation.org>
Tested-by: Fridrich Strba <fridrich@documentfoundation.org>
-rw-r--r-- | sw/qa/extras/rtfimport/data/fdo61909.rtf | 28 | ||||
-rw-r--r-- | sw/qa/extras/rtfimport/rtfimport.cxx | 11 | ||||
-rw-r--r-- | writerfilter/source/rtftok/rtfdocumentimpl.cxx | 7 |
3 files changed, 45 insertions, 1 deletions
diff --git a/sw/qa/extras/rtfimport/data/fdo61909.rtf b/sw/qa/extras/rtfimport/data/fdo61909.rtf new file mode 100644 index 000000000000..e31414a9b655 --- /dev/null +++ b/sw/qa/extras/rtfimport/data/fdo61909.rtf @@ -0,0 +1,28 @@ +{\rtf1\deff0 +{\fonttbl +{\f000 Courier New;} +} +{\colortbl +\red000\green000\blue000; +\red255\green255\blue255; +\red255\green128\blue000; +\red255\green255\blue255; +\red000\green000\blue255; +\red255\green255\blue255; +\red128\green128\blue128; +\red255\green255\blue255; +\red128\green128\blue128; +\red255\green255\blue255; +\red128\green064\blue000; +\red255\green255\blue255; +\red000\green000\blue128; +\red255\green255\blue255; +\red000\green000\blue000; +\red255\green255\blue255; +\red128\green000\blue255; +\red255\green255\blue255; +\red000\green000\blue000; +\red255\green255\blue255; +} +\highlight11 #include<iostream.h>\par +} diff --git a/sw/qa/extras/rtfimport/rtfimport.cxx b/sw/qa/extras/rtfimport/rtfimport.cxx index 3d3cbe6827ce..07583fc244ee 100644 --- a/sw/qa/extras/rtfimport/rtfimport.cxx +++ b/sw/qa/extras/rtfimport/rtfimport.cxx @@ -141,6 +141,7 @@ public: void testFdo59953(); void testFdo59638(); void testFdo60722(); + void testFdo61909(); CPPUNIT_TEST_SUITE(Test); #if !defined(MACOSX) && !defined(WNT) @@ -232,6 +233,7 @@ void Test::run() {"fdo59953.rtf", &Test::testFdo59953}, {"fdo59638.rtf", &Test::testFdo59638}, {"fdo60722.rtf", &Test::testFdo60722}, + {"fdo61909.rtf", &Test::testFdo61909}, }; for (unsigned int i = 0; i < SAL_N_ELEMENTS(aMethods); ++i) { @@ -1131,6 +1133,15 @@ void Test::testFdo60722() CPPUNIT_ASSERT_EQUAL(sal_uInt32(0), getProperty<sal_uInt32>(xShape, "LineColor")); } +void Test::testFdo61909() +{ + 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")); +} + CPPUNIT_TEST_SUITE_REGISTRATION(Test); CPPUNIT_PLUGIN_IMPLEMENT(); diff --git a/writerfilter/source/rtftok/rtfdocumentimpl.cxx b/writerfilter/source/rtftok/rtfdocumentimpl.cxx index 401ebb783f9e..34b779d8ba6d 100644 --- a/writerfilter/source/rtftok/rtfdocumentimpl.cxx +++ b/writerfilter/source/rtftok/rtfdocumentimpl.cxx @@ -393,6 +393,11 @@ void RTFDocumentImpl::checkFirstRun() if (!m_pSuperstream) Mapper().startSectionGroup(); Mapper().startParagraphGroup(); + + // set the requested default font + RTFValue::Pointer_t pFont = m_aDefaultState.aCharacterSprms.find(NS_sprm::LN_CRgFtc0); + if (pFont.get()) + dispatchValue(RTF_F, pFont->getInt()); m_bFirstRun = false; } } @@ -2835,7 +2840,7 @@ int RTFDocumentImpl::dispatchValue(RTFKeyword nKeyword, int nParam) break; case RTF_HIGHLIGHT: { - RTFValue::Pointer_t pValue(new RTFValue(nParam)); + RTFValue::Pointer_t pValue(new RTFValue(getColorTable(nParam))); m_aStates.top().aCharacterSprms.set(NS_sprm::LN_CHighlight, pValue); } break; |