connectivity/source/drivers/odbc/OPreparedStatement.cxx | 33 ++++++++++------ 1 file changed, 22 insertions(+), 11 deletions(-)
New commits: commit 939ce4afbb36673e03e90881c48fd4e2bbb74bb8 Author: Stephan Bergmann <sberg...@redhat.com> Date: Fri Jun 27 23:07:00 2014 +0200 Blind fix for OPreparedStatement::setParameter's useWChar case ...after 0181a13904daef160bee543e9806b23a835f79c8 "odbc properly support platform with sizeof(SQLWCHAR) = 4" introduced usage of RTL_TEXTENCODING_UCS2/4 there, which do not make sense in combination with converting between OString and OUString. OTools::getStringValue will need a corresponding fix, too, in the other direction (where the OUString(sal_uInt32 const * codePoints, sal_Int32 codPointCount) ctor will be useful). Change-Id: Ia94cd0deec46d269b6ee43362f4849837bb011c5 diff --git a/connectivity/source/drivers/odbc/OPreparedStatement.cxx b/connectivity/source/drivers/odbc/OPreparedStatement.cxx index 1a39897..e2bf7ce 100644 --- a/connectivity/source/drivers/odbc/OPreparedStatement.cxx +++ b/connectivity/source/drivers/odbc/OPreparedStatement.cxx @@ -317,7 +317,6 @@ void OPreparedStatement::setParameter(const sal_Int32 parameterIndex, const sal_ sal_Int32 nCharLen; sal_Int32 nByteLen; void *pData; - OString sOData; if (useWChar) { /* @@ -337,23 +336,35 @@ void OPreparedStatement::setParameter(const sal_Int32 parameterIndex, const sal_ * * Our internal OUString storage is always UTF-16, so no conversion to do here. */ - rtl_TextEncoding nSQLWCHAREncoding = RTL_TEXTENCODING_UCS2; - if( sizeof(SQLWCHAR) == 4 ) + BOOST_STATIC_ASSERT(sizeof (SQLWCHAR) == 2 || sizeof (SQLWCHAR) == 4); + if (sizeof (SQLWCHAR) == 2) { - nSQLWCHAREncoding = RTL_TEXTENCODING_UCS4; + nCharLen = _sData.getLength(); + nByteLen = 2 * nCharLen; + pData = allocBindBuf(parameterIndex, nByteLen); + memcpy(pData, _sData.getStr(), nByteLen); + } + else + { + std::vector<sal_uInt32> u; + for (sal_Int32 i = 0; i != _sData.getLength();) + { + u.push_back(_sData.iterateCodePoints(&i)); + } + nCharLen = u.size(); + nByteLen = 4 * nCharLen; + pData = allocBindBuf(parameterIndex, nByteLen); + memcpy(pData, u.empty() ? 0 : &u[0], nByteLen); } - - sOData = OUStringToOString(_sData, nSQLWCHAREncoding); - nByteLen = sOData.getLength(); - nCharLen = nByteLen / sizeof(SQLWCHAR); } else { - sOData = OUStringToOString(_sData, getOwnConnection()->getTextEncoding()); + OString sOData( + OUStringToOString(_sData, getOwnConnection()->getTextEncoding())); nCharLen = nByteLen = sOData.getLength(); + pData = allocBindBuf(parameterIndex, nByteLen); + memcpy(pData, sOData.getStr(), nByteLen); } - pData = allocBindBuf(parameterIndex, nByteLen); - memcpy(pData, sOData.getStr(), nByteLen); setParameter( parameterIndex, _nType, nCharLen, _nScale, pData, nByteLen, nByteLen ); } _______________________________________________ Libreoffice-commits mailing list libreoffice-comm...@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/libreoffice-commits