From db7dae40a2082d5d2b1ac22008d32ef9ebf86f4e Mon Sep 17 00:00:00 2001 From: Stephan Bergmann Date: Mon, 5 Mar 2018 13:56:59 +0100 Subject: 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 Tested-by: Jenkins (cherry picked from commit 5ad62544bce42396faaae2bc79c7517af6ff085b) Reviewed-on: https://gerrit.libreoffice.org/50780 Reviewed-by: Eike Rathke --- sc/source/ui/docshell/docsh8.cxx | 27 +++++---------------------- 1 file changed, 5 insertions(+), 22 deletions(-) (limited to 'sc/source') diff --git a/sc/source/ui/docshell/docsh8.cxx b/sc/source/ui/docshell/docsh8.cxx index 198cc709debe..6fcce1eafc4d 100644 --- a/sc/source/ui/docshell/docsh8.cxx +++ b/sc/source/ui/docshell/docsh8.cxx @@ -30,10 +30,6 @@ #include #include -#if HAVE_FEATURE_DBCONNECTIVITY -#include -#endif - #include #include #include @@ -124,26 +120,13 @@ namespace OUString aConnUrl("sdbc:dbase:"); aConnUrl += aPath; - ::std::vector< rtl_TextEncoding > aEncodings; - svxform::charset_helper::getSupportedTextEncodings( aEncodings ); - ::std::vector< rtl_TextEncoding >::iterator aIter = ::std::find(aEncodings.begin(),aEncodings.end(), eCharSet); - if ( aIter == aEncodings.end() ) - { - OSL_FAIL( "DBaseImport: dbtools::OCharsetMap doesn't know text encoding" ); - return SCERR_IMPORT_CONNECT; - } // if ( aIter == aMap.end() ) - OUString aCharSetStr; - if ( RTL_TEXTENCODING_DONTKNOW != *aIter ) - { // it's not the virtual "system charset" - const char* pIanaName = rtl_getMimeCharsetFromTextEncoding( *aIter ); - OSL_ENSURE( pIanaName, "invalid mime name!" ); - if ( pIanaName ) - aCharSetStr = OUString::createFromAscii( pIanaName ); - } - + // sdbc:dbase is based on the css.sdbc.FILEConnectionProperties UNOIDL service, so we can + // transport the raw rtl_TextEncoding value instead of having to translate it into a IANA + // character set name string (which might not exist for certain eCharSet values, like + // RTL_TEXTENCODING_MS_950): uno::Sequence aProps( comphelper::InitPropertySequence({ { SC_DBPROP_EXTENSION, uno::Any(aExtension) }, - { SC_DBPROP_CHARSET, uno::Any(aCharSetStr) } + { SC_DBPROP_CHARSET, uno::Any(eCharSet) } })); _rConnection = _rDrvMgr->getConnectionWithInfo( aConnUrl, aProps ); -- cgit v1.2.3