[Libreoffice-commits] core.git: 2 commits - connectivity/source

Lionel Elie Mamane lionel at mamane.lu
Fri Sep 5 00:54:11 PDT 2014


 connectivity/source/drivers/odbc/OPreparedStatement.cxx |    2 +
 connectivity/source/drivers/odbc/OTools.cxx             |   21 +++++++++-------
 2 files changed, 15 insertions(+), 8 deletions(-)

New commits:
commit b0b4a721b4f33ef132fcbdf4e5069c11269b121e
Author: Lionel Elie Mamane <lionel at mamane.lu>
Date:   Sat Jun 28 17:14:57 2014 +0200

    odbc: no, RTL_TEXTENCODING_UCS2/4 doesn't work as we intended
    
    Change-Id: Ie1bcbb41319f5ddfd349f6ef1ec888715ab2b9e2

diff --git a/connectivity/source/drivers/odbc/OTools.cxx b/connectivity/source/drivers/odbc/OTools.cxx
index fe3b391..b38564d 100644
--- a/connectivity/source/drivers/odbc/OTools.cxx
+++ b/connectivity/source/drivers/odbc/OTools.cxx
@@ -416,14 +416,8 @@ OUString OTools::getStringValue(OConnection* _pConnection,
     {
         SQLWCHAR waCharArray[2048];
         BOOST_STATIC_ASSERT(sizeof(waCharArray) % sizeof(SQLWCHAR) == 0);
-        rtl_TextEncoding nSQLWCHAREncoding = RTL_TEXTENCODING_UCS2;
         BOOST_STATIC_ASSERT(sizeof(SQLWCHAR) == 2 || sizeof(SQLWCHAR) == 4);
-        if(sizeof(SQLWCHAR) == 4)
-        {
-            // we assume LibO uses UTF-16 and & ODBC uses UCS4 (UTF-32); see OPreparedStatement::setParameter
-            nSQLWCHAREncoding = RTL_TEXTENCODING_UCS4;
-        }
-        // Size == number of bytes, Len == number of UTF-16 code units
+        // Size == number of bytes, Len == number of UTF-16 or UCS4 code units
         const SQLLEN nMaxSize = sizeof(waCharArray);
         const SQLLEN nMaxLen  = sizeof(waCharArray) / sizeof(SQLWCHAR);
         BOOST_STATIC_ASSERT(nMaxLen * sizeof(SQLWCHAR) == nMaxSize);
@@ -463,7 +457,17 @@ OUString OTools::getStringValue(OConnection* _pConnection,
                 nReadChars = pcbValue/sizeof(SQLWCHAR);
             }
 
-            aData.append(OUString((sal_Char*)waCharArray, nReadChars, nSQLWCHAREncoding));
+            if (sizeof (SQLWCHAR) == 2)
+            {
+                aData.append(waCharArry, nReadChars);
+            }
+            else
+            {
+                for (sal_Int32 i = 0; i < nReadChars; ++i)
+                {
+                    aData.appendUtf32(waCharArray[i]);
+                }
+            }
         }
         break;
     }
commit 22a13cab85398846ed521989531f9471b9a1835a
Author: Lionel Elie Mamane <lionel at mamane.lu>
Date:   Fri Jun 27 17:29:42 2014 +0200

    be more paranoid
    
    Change-Id: I8ab6c26a489f5cbb6b92c36313c6912939895e52

diff --git a/connectivity/source/drivers/odbc/OPreparedStatement.cxx b/connectivity/source/drivers/odbc/OPreparedStatement.cxx
index cf737a0..54f6a26 100644
--- a/connectivity/source/drivers/odbc/OPreparedStatement.cxx
+++ b/connectivity/source/drivers/odbc/OPreparedStatement.cxx
@@ -359,6 +359,8 @@ void OPreparedStatement::setParameter(const sal_Int32 parameterIndex, const sal_
     }
     else
     {
+        assert(getOwnConnection()->getTextEncoding() != RTL_TEXTENCODING_UCS2 &&
+               getOwnConnection()->getTextEncoding() != RTL_TEXTENCODING_UCS4);
         OString sOData(
             OUStringToOString(_sData, getOwnConnection()->getTextEncoding()));
         nCharLen = nByteLen = sOData.getLength();
diff --git a/connectivity/source/drivers/odbc/OTools.cxx b/connectivity/source/drivers/odbc/OTools.cxx
index bbfc1ea..fe3b391 100644
--- a/connectivity/source/drivers/odbc/OTools.cxx
+++ b/connectivity/source/drivers/odbc/OTools.cxx
@@ -415,6 +415,7 @@ OUString OTools::getStringValue(OConnection* _pConnection,
     case SQL_WLONGVARCHAR:
     {
         SQLWCHAR waCharArray[2048];
+        BOOST_STATIC_ASSERT(sizeof(waCharArray) % sizeof(SQLWCHAR) == 0);
         rtl_TextEncoding nSQLWCHAREncoding = RTL_TEXTENCODING_UCS2;
         BOOST_STATIC_ASSERT(sizeof(SQLWCHAR) == 2 || sizeof(SQLWCHAR) == 4);
         if(sizeof(SQLWCHAR) == 4)


More information about the Libreoffice-commits mailing list