[Libreoffice-commits] core.git: Branch 'libreoffice-5-4-6' - connectivity/source offapi/com sc/source
Stephan Bergmann
sbergman at redhat.com
Wed Mar 7 15:41:09 UTC 2018
connectivity/source/drivers/file/FConnection.cxx | 24 ++++++++++------
offapi/com/sun/star/sdbc/FILEConnectionProperties.idl | 4 ++
sc/source/ui/docshell/docsh8.cxx | 27 +++---------------
3 files changed, 25 insertions(+), 30 deletions(-)
New commits:
commit 5598fa704df171544a913a8cfda62a183f1a1a66
Author: Stephan Bergmann <sbergman at redhat.com>
Date: Mon Mar 5 13:56:59 2018 +0100
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.
Reviewed-on: https://gerrit.libreoffice.org/50772
Reviewed-by: Lionel Elie Mamane <lionel at mamane.lu>
Tested-by: Jenkins <ci at libreoffice.org>
(cherry picked from commit 5ad62544bce42396faaae2bc79c7517af6ff085b)
Conflicts:
sc/source/ui/docshell/docsh8.cxx
Change-Id: I84eec8a93d000752b3c429976c58721ea9ea32a4
Reviewed-on: https://gerrit.libreoffice.org/50793
Reviewed-by: Eike Rathke <erack at redhat.com>
Reviewed-by: Lionel Elie Mamane <lionel at mamane.lu>
Reviewed-by: Michael Stahl <mstahl at redhat.com>
Tested-by: Michael Stahl <mstahl at redhat.com>
diff --git a/connectivity/source/drivers/file/FConnection.cxx b/connectivity/source/drivers/file/FConnection.cxx
index 27d2b2d9ee03..64017737140f 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 "resource/file_res.hrc"
@@ -106,15 +107,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" )
{
diff --git a/offapi/com/sun/star/sdbc/FILEConnectionProperties.idl b/offapi/com/sun/star/sdbc/FILEConnectionProperties.idl
index 1e1f36efc8e1..43c6d4c74740 100644
--- a/offapi/com/sun/star/sdbc/FILEConnectionProperties.idl
+++ b/offapi/com/sun/star/sdbc/FILEConnectionProperties.idl
@@ -45,6 +45,10 @@ service FILEConnectionProperties
<p>See the <a href="http://www.iana.org/assignments/character-sets">IANA character set list</a>
for a list of valid values.</p>
+
+ <p>For internal purposes (e.g., when using an encoding for which no IANA character set name
+ exists), this may also be an UNSIGNED SHORT value representing one of the rtl_TextEncoding
+ values in rtl/textenc.h.</p>
*/
[optional, property] string CharSet;
};
diff --git a/sc/source/ui/docshell/docsh8.cxx b/sc/source/ui/docshell/docsh8.cxx
index a021745855d9..73f8bfffe2ac 100644
--- a/sc/source/ui/docshell/docsh8.cxx
+++ b/sc/source/ui/docshell/docsh8.cxx
@@ -29,10 +29,6 @@
#include <svx/txenctab.hxx>
#include <unotools/sharedunocomponent.hxx>
-#if HAVE_FEATURE_DBCONNECTIVITY
-#include <svx/dbcharsethelper.hxx>
-#endif
-
#include <com/sun/star/sdb/CommandType.hpp>
#include <com/sun/star/sdbc/DataType.hpp>
#include <com/sun/star/sdbc/SQLException.hpp>
@@ -123,28 +119,15 @@ 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<beans::PropertyValue> aProps(2);
aProps[0].Name = SC_DBPROP_EXTENSION;
aProps[0].Value <<= OUString( aExtension );
aProps[1].Name = SC_DBPROP_CHARSET;
- aProps[1].Value <<= aCharSetStr;
+ aProps[1].Value <<= eCharSet;
_rConnection = _rDrvMgr->getConnectionWithInfo( aConnUrl, aProps );
return 0L;
More information about the Libreoffice-commits
mailing list