Date: prev next · Thread: first prev next last
2013 Archives by date, by thread · List index


Hi,

I have submitted a patch for review:

    https://gerrit.libreoffice.org/3913

To pull it, you can do:

    git pull ssh://gerrit.libreoffice.org:29418/core refs/changes/13/3913/1

fdo#62977 allow SAL_MAX_INT16..SAL_MAX_UINT16 when importing RTF_U

(cherry picked from commit 4a816a816e8b4e213394898bd0e307dd90fcbb64)

Conflicts:
        sw/qa/extras/rtfimport/rtfimport.cxx

Change-Id: Ie36d5881b0ebe8c38526690ca27d02bfb7af7829
---
A sw/qa/extras/rtfimport/data/fdo62977.rtf
M sw/qa/extras/rtfimport/rtfimport.cxx
M writerfilter/source/rtftok/rtfdocumentimpl.cxx
3 files changed, 36 insertions(+), 1 deletion(-)



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 c02dac5..bbac478 100644
--- a/sw/qa/extras/rtfimport/rtfimport.cxx
+++ b/sw/qa/extras/rtfimport/rtfimport.cxx
@@ -147,6 +147,7 @@
     void testFdo51916();
     void testFdo61193();
     void testFdo63023();
+    void testFdo62977();
 
     CPPUNIT_TEST_SUITE(Test);
 #if !defined(MACOSX) && !defined(WNT)
@@ -264,6 +265,7 @@
         {"fdo51916.rtf", &Test::testFdo51916},
         {"hello.rtf", &Test::testFdo61193},
         {"fdo63023.rtf", &Test::testFdo63023},
+        {"fdo62977.rtf", &Test::testFdo62977},
     };
     for (unsigned int i = 0; i < SAL_N_ELEMENTS(aMethods); ++i)
     {
@@ -1214,6 +1216,12 @@
     CPPUNIT_ASSERT_EQUAL(sal_Int32(0xFFFF99), getProperty<sal_Int32>(getRun(getParagraphOfText(1, 
xHeaderText), 1), "CharBackColor"));
 }
 
+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 0a2348d..056ac08 100644
--- a/writerfilter/source/rtftok/rtfdocumentimpl.cxx
+++ b/writerfilter/source/rtftok/rtfdocumentimpl.cxx
@@ -2971,7 +2971,10 @@
                 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;

-- 
To view, visit https://gerrit.libreoffice.org/3913
To unsubscribe, visit https://gerrit.libreoffice.org/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: Ie36d5881b0ebe8c38526690ca27d02bfb7af7829
Gerrit-PatchSet: 1
Gerrit-Project: core
Gerrit-Branch: libreoffice-4-0
Gerrit-Owner: Miklos Vajna <vmiklos@suse.cz>


Context


Privacy Policy | Impressum (Legal Info) | Copyright information: Unless otherwise specified, all text and images on this website are licensed under the Creative Commons Attribution-Share Alike 3.0 License. This does not include the source code of LibreOffice, which is licensed under the Mozilla Public License (MPLv2). "LibreOffice" and "The Document Foundation" are registered trademarks of their corresponding registered owners or are in actual use as trademarks in one or more countries. Their respective logos and icons are also subject to international copyright laws. Use thereof is explained in our trademark policy.