[Libreoffice-commits] core.git: sw/qa writerfilter/source

Miklos Vajna vmiklos at suse.cz
Wed May 15 01:30:58 PDT 2013


 sw/qa/extras/rtfimport/data/fdo62977.rtf       |   24 ++++++++++++++++++++++++
 sw/qa/extras/rtfimport/rtfimport.cxx           |    8 ++++++++
 writerfilter/source/rtftok/rtfdocumentimpl.cxx |    5 ++++-
 3 files changed, 36 insertions(+), 1 deletion(-)

New commits:
commit 4a816a816e8b4e213394898bd0e307dd90fcbb64
Author: Miklos Vajna <vmiklos at suse.cz>
Date:   Wed May 15 09:59:18 2013 +0200

    fdo#62977 allow SAL_MAX_INT16..SAL_MAX_UINT16 when importing RTF_U
    
    Change-Id: Ie36d5881b0ebe8c38526690ca27d02bfb7af7829

diff --git a/sw/qa/extras/rtfimport/data/fdo62977.rtf b/sw/qa/extras/rtfimport/data/fdo62977.rtf
new file mode 100644
index 0000000..f16135d
--- /dev/null
+++ b/sw/qa/extras/rtfimport/data/fdo62977.rtf
@@ -0,0 +1,24 @@
+{\rtf1 \ansi 
+{\fonttbl; 
+{
+\f0 \'41\'72\'69\'61\'6c;}
+{
+\f1 \'53\'79\'6d\'62\'6f\'6c;}
+{
+\f2 \'54\'69\'6d\'65\'73\'20\'4e\'65\'77\'20\'52\'6f\'6d\'61\'6e;}
+{
+\f3 \'82\'6c\'82\'72\'20\'96\'be\'92\'a9;}
+}
+{\*\generator Apache XML Graphics RTF Library;}
+\fet0 \ftnbj \paperw11905 \paperh16837 \margt1984 \margb1700 \margl1700 \margr1700 \itap0 \sectd \headery720 \footery720 \stextflow0 \cols1 
+{\ri0 \li0 
+{\qr \b0 \fi0 \cf1 \loch\af3 \hich\af3 \dbch\f3 \ri0 \sl420 \i0 \li0 \fs21 
+{\b0 \cf1 \loch\af3 \hich\af3 \dbch\f3 \i0 \fs21 
+{\strike0 \b0 \cf1 \loch\af3 \hich\af3 \dbch\f3 \ul0 \i0 \fs21 \sa0 \sb0 
+\u24180\'3f\u65300\'3f\u26376\'3f
+\par 
+}
+}
+}
+}
+}
diff --git a/sw/qa/extras/rtfimport/rtfimport.cxx b/sw/qa/extras/rtfimport/rtfimport.cxx
index f8c8a2f..d2ccfba 100644
--- a/sw/qa/extras/rtfimport/rtfimport.cxx
+++ b/sw/qa/extras/rtfimport/rtfimport.cxx
@@ -134,6 +134,7 @@ public:
     void testFdo61193();
     void testFdo63023();
     void testFdo42109();
+    void testFdo62977();
 
     CPPUNIT_TEST_SUITE(Test);
 #if !defined(MACOSX) && !defined(WNT)
@@ -257,6 +258,7 @@ void Test::run()
         {"hello.rtf", &Test::testFdo61193},
         {"fdo63023.rtf", &Test::testFdo63023},
         {"fdo42109.rtf", &Test::testFdo42109},
+        {"fdo62977.rtf", &Test::testFdo62977},
     };
     header();
     for (unsigned int i = 0; i < SAL_N_ELEMENTS(aMethods); ++i)
@@ -1224,6 +1226,12 @@ void Test::testFdo42109()
     CPPUNIT_ASSERT_EQUAL(OUString("TextField"), getProperty<OUString>(getRun(getParagraphOfText(1, xCell->getText()), 1), "TextPortionType"));
 }
 
+void Test::testFdo62977()
+{
+    // The middle character was imported as '?' instead of the proper unicode value.
+    getRun(getParagraph(1), 1, OUString("\xE5\xB9\xB4\xEF\xBC\x94\xE6\x9C\x88", 9, RTL_TEXTENCODING_UTF8));
+}
+
 CPPUNIT_TEST_SUITE_REGISTRATION(Test);
 
 CPPUNIT_PLUGIN_IMPLEMENT();
diff --git a/writerfilter/source/rtftok/rtfdocumentimpl.cxx b/writerfilter/source/rtftok/rtfdocumentimpl.cxx
index 361ab17..9943d74 100644
--- a/writerfilter/source/rtftok/rtfdocumentimpl.cxx
+++ b/writerfilter/source/rtftok/rtfdocumentimpl.cxx
@@ -3061,7 +3061,10 @@ int RTFDocumentImpl::dispatchValue(RTFKeyword nKeyword, int nParam)
                 m_aStates.top().nUc = nParam;
             break;
         case RTF_U:
-            if ((SAL_MIN_INT16 <= nParam) && (nParam <= SAL_MAX_INT16))
+            // sal_Unicode is unsigned 16-bit, RTF may represent that as a
+            // signed SAL_MIN_INT16..SAL_MAX_INT16 or 0..SAL_MAX_UINT16. The
+            // static_cast() will do the right thing.
+            if ((SAL_MIN_INT16 <= nParam) && (nParam <= SAL_MAX_UINT16))
             {
                 m_aUnicodeBuffer.append(static_cast<sal_Unicode>(nParam));
                 m_aStates.top().nCharsToSkip = m_aStates.top().nUc;


More information about the Libreoffice-commits mailing list