diff options
author | Stephan Bergmann <sbergman@redhat.com> | 2018-03-05 13:56:59 +0100 |
---|---|---|
committer | Eike Rathke <erack@redhat.com> | 2018-03-06 12:35:02 +0100 |
commit | db7dae40a2082d5d2b1ac22008d32ef9ebf86f4e (patch) | |
tree | af21312b9eba1295e6c0c1dd094ff7d97098a0d5 /connectivity | |
parent | a0d74ae3c7c2a555fd633b86269605df89a13138 (diff) |
tdf#116171: Tunnel arbitrary rtl_TextEncoding from sc to sdbc:dbase connection
...including those that have no corresponding textual IANA character set name
representation, like RTL_TEXTENCODING_MS_950 which is apparently used in some
DBase files.
In the past, if eCharSet was RTL_TEXTENCODING_DONTKNOW in lcl_getDBaseConnection
it was sent as an empty string CharSet property, which the receiving
OConnection::construct translated back to
else
m_nTextEncoding = RTL_TEXTENCODING_DONTKNOW;
so the net effect remains the same for that special case.
Change-Id: I84eec8a93d000752b3c429976c58721ea9ea32a4
Reviewed-on: https://gerrit.libreoffice.org/50772
Reviewed-by: Lionel Elie Mamane <lionel@mamane.lu>
Tested-by: Jenkins <ci@libreoffice.org>
(cherry picked from commit 5ad62544bce42396faaae2bc79c7517af6ff085b)
Reviewed-on: https://gerrit.libreoffice.org/50780
Reviewed-by: Eike Rathke <erack@redhat.com>
Diffstat (limited to 'connectivity')
-rw-r--r-- | connectivity/source/drivers/file/FConnection.cxx | 24 |
1 files changed, 16 insertions, 8 deletions
diff --git a/connectivity/source/drivers/file/FConnection.cxx b/connectivity/source/drivers/file/FConnection.cxx index 378bd2d9cd0a..d9d2378c0f7f 100644 --- a/connectivity/source/drivers/file/FConnection.cxx +++ b/connectivity/source/drivers/file/FConnection.cxx @@ -38,6 +38,7 @@ #include <ucbhelper/content.hxx> #include <connectivity/dbcharset.hxx> #include <connectivity/dbexception.hxx> +#include <o3tl/any.hxx> #include <osl/thread.h> #include <osl/nlsupport.h> #include <strings.hrc> @@ -105,15 +106,22 @@ void OConnection::construct(const OUString& url,const Sequence< PropertyValue >& OSL_VERIFY( pIter->Value >>= aExt ); else if( pIter->Name == "CharSet" ) { - OUString sIanaName; - OSL_VERIFY( pIter->Value >>= sIanaName ); - - ::dbtools::OCharsetMap aLookupIanaName; - ::dbtools::OCharsetMap::const_iterator aLookup = aLookupIanaName.find(sIanaName, ::dbtools::OCharsetMap::IANA()); - if (aLookup != aLookupIanaName.end()) - m_nTextEncoding = (*aLookup).getEncoding(); + if (auto const numeric = o3tl::tryAccess<sal_uInt16>(pIter->Value)) + { + m_nTextEncoding = *numeric; + } else - m_nTextEncoding = RTL_TEXTENCODING_DONTKNOW; + { + OUString sIanaName; + OSL_VERIFY( pIter->Value >>= sIanaName ); + + ::dbtools::OCharsetMap aLookupIanaName; + ::dbtools::OCharsetMap::const_iterator aLookup = aLookupIanaName.find(sIanaName, ::dbtools::OCharsetMap::IANA()); + if (aLookup != aLookupIanaName.end()) + m_nTextEncoding = (*aLookup).getEncoding(); + else + m_nTextEncoding = RTL_TEXTENCODING_DONTKNOW; + } } else if( pIter->Name == "ShowDeleted" ) { |