diff options
author | Andras Timar <andras.timar@collabora.com> | 2014-11-24 11:33:17 +0100 |
---|---|---|
committer | Andras Timar <andras.timar@collabora.com> | 2014-11-24 13:48:55 +0100 |
commit | 7839633fb356285652ed96f4bf3f85bcd5b561a4 (patch) | |
tree | 53a7da865d7450332c49a0fee13bbb7b27946276 | |
parent | 8dc475380a19bb707274491788abfe61d491f0e7 (diff) |
fdo#85889 handle pc, pca and mac rtf keywords in writerfilter
Change-Id: Ic54f2233a37562bdc516e440af0b4b7973f56342
-rw-r--r-- | sw/qa/extras/rtfimport/data/fdo85889-mac.rtf | 3 | ||||
-rw-r--r-- | sw/qa/extras/rtfimport/data/fdo85889-pc.rtf | 3 | ||||
-rw-r--r-- | sw/qa/extras/rtfimport/data/fdo85889-pca.rtf | 3 | ||||
-rw-r--r-- | sw/qa/extras/rtfimport/rtfimport.cxx | 26 | ||||
-rw-r--r-- | writerfilter/source/rtftok/rtfdocumentimpl.cxx | 12 |
5 files changed, 47 insertions, 0 deletions
diff --git a/sw/qa/extras/rtfimport/data/fdo85889-mac.rtf b/sw/qa/extras/rtfimport/data/fdo85889-mac.rtf new file mode 100644 index 000000000000..8056d47aacce --- /dev/null +++ b/sw/qa/extras/rtfimport/data/fdo85889-mac.rtf @@ -0,0 +1,3 @@ +{\rtf1\mac \deff0{\fonttbl{\f0\fmodern Helvetica;}} +\pard\f0\fs20 \'f1\'f2\'f3\par +} diff --git a/sw/qa/extras/rtfimport/data/fdo85889-pc.rtf b/sw/qa/extras/rtfimport/data/fdo85889-pc.rtf new file mode 100644 index 000000000000..a3b9d2745397 --- /dev/null +++ b/sw/qa/extras/rtfimport/data/fdo85889-pc.rtf @@ -0,0 +1,3 @@ +{\rtf1\pc \deff0{\fonttbl{\f0\fmodern Helvetica;}} +\pard\f0\fs20 \'f1\'f2\'f3\par +} diff --git a/sw/qa/extras/rtfimport/data/fdo85889-pca.rtf b/sw/qa/extras/rtfimport/data/fdo85889-pca.rtf new file mode 100644 index 000000000000..34eeb18ef29d --- /dev/null +++ b/sw/qa/extras/rtfimport/data/fdo85889-pca.rtf @@ -0,0 +1,3 @@ +{\rtf1\pca \deff0{\fonttbl{\f0\fmodern Helvetica;}} +\pard\f0\fs20 \'f1\'f2\'f3\par +} diff --git a/sw/qa/extras/rtfimport/rtfimport.cxx b/sw/qa/extras/rtfimport/rtfimport.cxx index b89472a35ff5..7dc67c346473 100644 --- a/sw/qa/extras/rtfimport/rtfimport.cxx +++ b/sw/qa/extras/rtfimport/rtfimport.cxx @@ -2181,6 +2181,32 @@ DECLARE_RTFIMPORT_TEST(testChtOutlineNumberingRtf, "chtoutline.rtf") CPPUNIT_ASSERT_EQUAL(OUString(aExpectedPrefix,SAL_N_ELEMENTS(aExpectedPrefix)), aPrefix); CPPUNIT_ASSERT_EQUAL(OUString(aExpectedSuffix,SAL_N_ELEMENTS(aExpectedSuffix)), aSuffix); } + +DECLARE_RTFIMPORT_TEST(testFdo85889pc, "fdo85889-pc.rtf") +{ + uno::Reference<text::XTextRange> xTextRange = getRun(getParagraph(1), 1); + + OUString aExpected("\xc2\xb1\xe2\x89\xa5\xe2\x89\xa4", 8, RTL_TEXTENCODING_UTF8); + CPPUNIT_ASSERT_EQUAL(aExpected, xTextRange->getString()); +} + +DECLARE_RTFIMPORT_TEST(testFdo85889pca, "fdo85889-pca.rtf") +{ + uno::Reference<text::XTextRange> xTextRange = getRun(getParagraph(1), 1); + + OUString aExpected("\xc2\xb1\xe2\x80\x97\xc2\xbe", 7, RTL_TEXTENCODING_UTF8); + CPPUNIT_ASSERT_EQUAL(aExpected, xTextRange->getString()); +} + +DECLARE_RTFIMPORT_TEST(testFdo85889mac, "fdo85889-mac.rtf") +{ + uno::Reference<text::XTextRange> xTextRange = getRun(getParagraph(1), 1); + + OUString aExpected("\xc3\x92\xc3\x9a\xc3\x9b", 6, RTL_TEXTENCODING_UTF8); + CPPUNIT_ASSERT_EQUAL(aExpected, xTextRange->getString()); +} + + CPPUNIT_PLUGIN_IMPLEMENT(); /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/writerfilter/source/rtftok/rtfdocumentimpl.cxx b/writerfilter/source/rtftok/rtfdocumentimpl.cxx index a99835110b83..fe4c870017d0 100644 --- a/writerfilter/source/rtftok/rtfdocumentimpl.cxx +++ b/writerfilter/source/rtftok/rtfdocumentimpl.cxx @@ -2913,6 +2913,18 @@ int RTFDocumentImpl::dispatchFlag(RTFKeyword nKeyword) case RTF_ANSI: m_aStates.top().nCurrentEncoding = RTL_TEXTENCODING_MS_1252; break; + case RTF_MAC: + m_nCurrentEncoding = RTL_TEXTENCODING_APPLE_ROMAN; + m_aStates.top().nCurrentEncoding = m_nCurrentEncoding; + break; + case RTF_PC: + m_nCurrentEncoding = RTL_TEXTENCODING_IBM_437; + m_aStates.top().nCurrentEncoding = m_nCurrentEncoding; + break; + case RTF_PCA: + m_nCurrentEncoding = RTL_TEXTENCODING_IBM_850; + m_aStates.top().nCurrentEncoding = m_nCurrentEncoding; + break; case RTF_PLAIN: { m_aStates.top().aCharacterSprms = getDefaultState().aCharacterSprms; |