summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndras Timar <andras.timar@collabora.com>2014-11-24 11:33:17 +0100
committerMiklos Vajna <vmiklos@collabora.co.uk>2014-11-24 20:28:57 +0000
commitd74f3f2a1b98fbcba9e5490b6d790fa40d8b863d (patch)
tree5813b88ce7c86ac007171cc0c19850d4df4f52ba
parent493ecf8f17185bbd9ffe1ac9c58791da6d23b0d9 (diff)
fdo#85889 handle pc, pca and mac rtf keywords in writerfilter
(cherry picked from commit 7839633fb356285652ed96f4bf3f85bcd5b561a4) Conflicts: sw/qa/extras/rtfimport/rtfimport.cxx Change-Id: Ic54f2233a37562bdc516e440af0b4b7973f56342 Reviewed-on: https://gerrit.libreoffice.org/13106 Reviewed-by: Miklos Vajna <vmiklos@collabora.co.uk> Tested-by: Miklos Vajna <vmiklos@collabora.co.uk>
-rw-r--r--sw/qa/extras/rtfimport/data/fdo85889-mac.rtf3
-rw-r--r--sw/qa/extras/rtfimport/data/fdo85889-pc.rtf3
-rw-r--r--sw/qa/extras/rtfimport/data/fdo85889-pca.rtf3
-rw-r--r--sw/qa/extras/rtfimport/rtfimport.cxx26
-rw-r--r--writerfilter/source/rtftok/rtfdocumentimpl.cxx12
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 9a274fdcd634..bf4b176f51ca 100644
--- a/sw/qa/extras/rtfimport/rtfimport.cxx
+++ b/sw/qa/extras/rtfimport/rtfimport.cxx
@@ -2023,6 +2023,32 @@ DECLARE_RTFIMPORT_TEST(testFdo83204, "fdo83204.rtf")
CPPUNIT_ASSERT_EQUAL(OUString("Heading 1"), getProperty<OUString>(getParagraph(1), "ParaStyleName"));
}
+
+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 a8d88f3119db..27e0ab227452 100644
--- a/writerfilter/source/rtftok/rtfdocumentimpl.cxx
+++ b/writerfilter/source/rtftok/rtfdocumentimpl.cxx
@@ -2830,6 +2830,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;