diff options
author | Noel Grandin <noel.grandin@collabora.co.uk> | 2021-07-19 13:18:49 +0200 |
---|---|---|
committer | Noel Grandin <noel.grandin@collabora.co.uk> | 2021-08-05 09:39:11 +0200 |
commit | 14cfff500e93f0d6cbf8412065feea85c01ea81d (patch) | |
tree | 76e3fb8fbf2b0d8a12c8406d8cf994ea6a37aaff /connectivity | |
parent | d924ce30e0ca260682bd2aed192b8b1b2ca3e7c0 (diff) |
Pass context and resource string down to boost::locale separately
because this is often on a hot path, and we can avoid the splitting and
joining of strings like this.
Change-Id: Ia36047209368ca53431178c2e8723a18cfe8260a
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/119220
Tested-by: Jenkins
Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
Diffstat (limited to 'connectivity')
-rw-r--r-- | connectivity/CppunitTest_connectivity_sharedresources.mk | 1 | ||||
-rw-r--r-- | connectivity/Library_ado.mk | 1 | ||||
-rw-r--r-- | connectivity/Library_mysql_jdbc.mk | 1 | ||||
-rw-r--r-- | connectivity/Library_odbc.mk | 1 | ||||
-rw-r--r-- | connectivity/inc/strings.hrc | 2 | ||||
-rw-r--r-- | connectivity/source/commontools/TConnection.cxx | 2 | ||||
-rw-r--r-- | connectivity/source/commontools/sqlerror.cxx | 4 | ||||
-rw-r--r-- | connectivity/source/drivers/dbase/DIndex.cxx | 2 | ||||
-rw-r--r-- | connectivity/source/drivers/dbase/DTable.cxx | 2 | ||||
-rw-r--r-- | connectivity/source/drivers/file/FResultSet.cxx | 2 | ||||
-rw-r--r-- | connectivity/source/drivers/macab/MacabStatement.cxx | 2 | ||||
-rw-r--r-- | connectivity/source/drivers/macab/macabutilities.hxx | 3 | ||||
-rw-r--r-- | connectivity/source/inc/TConnection.hxx | 2 | ||||
-rw-r--r-- | connectivity/source/inc/dbase/DIndex.hxx | 2 | ||||
-rw-r--r-- | connectivity/source/inc/dbase/DTable.hxx | 2 | ||||
-rw-r--r-- | connectivity/source/inc/resource/sharedresources.hxx | 12 | ||||
-rw-r--r-- | connectivity/source/resource/sharedresources.cxx | 14 |
17 files changed, 30 insertions, 25 deletions
diff --git a/connectivity/CppunitTest_connectivity_sharedresources.mk b/connectivity/CppunitTest_connectivity_sharedresources.mk index 9af3f8ca2442..f9f8172c6fce 100644 --- a/connectivity/CppunitTest_connectivity_sharedresources.mk +++ b/connectivity/CppunitTest_connectivity_sharedresources.mk @@ -30,6 +30,7 @@ $(eval $(call gb_CppunitTest_use_libraries,connectivity_sharedresources, \ dbtools \ sal \ test \ + utl \ unotest \ )) diff --git a/connectivity/Library_ado.mk b/connectivity/Library_ado.mk index ca9633eca0bd..4886c5aa6d61 100644 --- a/connectivity/Library_ado.mk +++ b/connectivity/Library_ado.mk @@ -42,6 +42,7 @@ $(eval $(call gb_Library_use_libraries,ado,\ cppuhelper \ sal \ salhelper \ + utl \ dbtools \ comphelper \ )) diff --git a/connectivity/Library_mysql_jdbc.mk b/connectivity/Library_mysql_jdbc.mk index b6916ce784b1..ce4649f88580 100644 --- a/connectivity/Library_mysql_jdbc.mk +++ b/connectivity/Library_mysql_jdbc.mk @@ -29,6 +29,7 @@ $(eval $(call gb_Library_use_libraries,mysql_jdbc,\ cppuhelper \ sal \ salhelper \ + utl \ dbtools \ comphelper \ )) diff --git a/connectivity/Library_odbc.mk b/connectivity/Library_odbc.mk index ae2b131c3649..9ab70270cfc7 100644 --- a/connectivity/Library_odbc.mk +++ b/connectivity/Library_odbc.mk @@ -41,6 +41,7 @@ $(eval $(call gb_Library_use_libraries,odbc,\ dbtools \ sal \ salhelper \ + utl \ )) $(eval $(call gb_Library_add_exception_objects,odbc,\ diff --git a/connectivity/inc/strings.hrc b/connectivity/inc/strings.hrc index ce4177493bd9..47a857bd1226 100644 --- a/connectivity/inc/strings.hrc +++ b/connectivity/inc/strings.hrc @@ -19,7 +19,7 @@ #pragma once -#define NC_(Context, String) reinterpret_cast<char const *>(Context "\004" u8##String) +#define NC_(Context, String) TranslateId(Context, reinterpret_cast<char const *>(u8##String)) // = common strings #define STR_NO_CONNECTION_GIVEN NC_("STR_NO_CONNECTION_GIVEN", "No connection to the database exists.") diff --git a/connectivity/source/commontools/TConnection.cxx b/connectivity/source/commontools/TConnection.cxx index 134aa5960115..89ab7e9ca11d 100644 --- a/connectivity/source/commontools/TConnection.cxx +++ b/connectivity/source/commontools/TConnection.cxx @@ -75,7 +75,7 @@ Sequence< sal_Int8 > OMetaConnection::getUnoTunnelId() return s_aPropertyNameMap; } -void OMetaConnection::throwGenericSQLException(const char* pErrorResourceId, const Reference< XInterface>& _xContext ) +void OMetaConnection::throwGenericSQLException(TranslateId pErrorResourceId, const Reference< XInterface>& _xContext ) { OUString sErrorMessage; if (pErrorResourceId) diff --git a/connectivity/source/commontools/sqlerror.cxx b/connectivity/source/commontools/sqlerror.cxx index 513a5cf9dc81..383743906520 100644 --- a/connectivity/source/commontools/sqlerror.cxx +++ b/connectivity/source/commontools/sqlerror.cxx @@ -103,7 +103,7 @@ namespace connectivity _rMessage = _rMessage.replaceAt( nIndex, nPlaceholderLen, *rParamValue ); } - const char* lcl_getResourceErrorID(const ErrorCondition _eCondition) + TranslateId lcl_getResourceErrorID(const ErrorCondition _eCondition) { switch (_eCondition) { @@ -126,7 +126,7 @@ namespace connectivity case css::sdb::ErrorCondition::DATA_CANNOT_SELECT_UNFILTERED: return STR_DATA_CANNOT_SELECT_UNFILTERED; } - return nullptr; + return {}; } OUString lcl_getResourceState(const ErrorCondition _eCondition) diff --git a/connectivity/source/drivers/dbase/DIndex.cxx b/connectivity/source/drivers/dbase/DIndex.cxx index d168de39eb77..04f46be9a513 100644 --- a/connectivity/source/drivers/dbase/DIndex.cxx +++ b/connectivity/source/drivers/dbase/DIndex.cxx @@ -461,7 +461,7 @@ void ODbaseIndex::DropImpl() } } -void ODbaseIndex::impl_killFileAndthrowError_throw(const char* pErrorId, const OUString& _sFile) +void ODbaseIndex::impl_killFileAndthrowError_throw(TranslateId pErrorId, const OUString& _sFile) { closeImpl(); if(UCBContentHelper::Exists(_sFile)) diff --git a/connectivity/source/drivers/dbase/DTable.cxx b/connectivity/source/drivers/dbase/DTable.cxx index 5b1ea452f61a..f597ce615b5f 100644 --- a/connectivity/source/drivers/dbase/DTable.cxx +++ b/connectivity/source/drivers/dbase/DTable.cxx @@ -1103,7 +1103,7 @@ bool ODbaseTable::CreateImpl() return true; } -void ODbaseTable::throwInvalidColumnType(const char* pErrorId, const OUString& _sColumnName) +void ODbaseTable::throwInvalidColumnType(TranslateId pErrorId, const OUString& _sColumnName) { try { diff --git a/connectivity/source/drivers/file/FResultSet.cxx b/connectivity/source/drivers/file/FResultSet.cxx index 595ca2be7281..4d29f1de7a84 100644 --- a/connectivity/source/drivers/file/FResultSet.cxx +++ b/connectivity/source/drivers/file/FResultSet.cxx @@ -57,7 +57,7 @@ using namespace com::sun::star::container; namespace { - void lcl_throwError(const char* pErrorId, const css::uno::Reference< css::uno::XInterface>& _xContext) + void lcl_throwError(TranslateId pErrorId, const css::uno::Reference< css::uno::XInterface>& _xContext) { ::connectivity::SharedResources aResources; const OUString sMessage = aResources.getResourceString(pErrorId); diff --git a/connectivity/source/drivers/macab/MacabStatement.cxx b/connectivity/source/drivers/macab/MacabStatement.cxx index 1f317150d249..6c8a02cd7391 100644 --- a/connectivity/source/drivers/macab/MacabStatement.cxx +++ b/connectivity/source/drivers/macab/MacabStatement.cxx @@ -47,7 +47,7 @@ using namespace com::sun::star::util; namespace connectivity::macab { - void impl_throwError(const char* pErrorId) + void impl_throwError(TranslateId pErrorId) { ::connectivity::SharedResources aResources; const OUString sError( aResources.getResourceString(pErrorId) ); diff --git a/connectivity/source/drivers/macab/macabutilities.hxx b/connectivity/source/drivers/macab/macabutilities.hxx index abf65c73d152..cfe46f37f286 100644 --- a/connectivity/source/drivers/macab/macabutilities.hxx +++ b/connectivity/source/drivers/macab/macabutilities.hxx @@ -21,6 +21,7 @@ #include <com/sun/star/util/DateTime.hpp> #include <com/sun/star/sdbc/DataType.hpp> +#include <unotools/resmgr.hxx> #include <time.h> #include <premac.h> @@ -131,7 +132,7 @@ namespace connectivity::macab return dataType; } - void impl_throwError(const char* pErrorId); + void impl_throwError(TranslateId pErrorId); } /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/connectivity/source/inc/TConnection.hxx b/connectivity/source/inc/TConnection.hxx index 0e9c4c22e750..246e968b8a32 100644 --- a/connectivity/source/inc/TConnection.hxx +++ b/connectivity/source/inc/TConnection.hxx @@ -61,7 +61,7 @@ namespace connectivity rtl_TextEncoding getTextEncoding() const { return m_nTextEncoding; } const OUString& getURL() const { return m_sURL; } void setURL(const OUString& _rsUrl) { m_sURL = _rsUrl; } - void throwGenericSQLException(const char* pErrorResourceId, const css::uno::Reference< css::uno::XInterface>& _xContext); + void throwGenericSQLException(TranslateId pErrorResourceId, const css::uno::Reference< css::uno::XInterface>& _xContext); const SharedResources& getResources() const { return m_aResources;} void setConnectionInfo(const css::uno::Sequence< css::beans::PropertyValue >& _aInfo) { m_aConnectionInfo = _aInfo; } diff --git a/connectivity/source/inc/dbase/DIndex.hxx b/connectivity/source/inc/dbase/DIndex.hxx index 3c5374f298e2..12d7574e4b28 100644 --- a/connectivity/source/inc/dbase/DIndex.hxx +++ b/connectivity/source/inc/dbase/DIndex.hxx @@ -81,7 +81,7 @@ namespace connectivity::dbase OUString getCompletePath() const; void closeImpl(); // Closes and kills the index file and throws an error - void impl_killFileAndthrowError_throw(const char* pErrorId, const OUString& _sFile); + void impl_killFileAndthrowError_throw(TranslateId pErrorId, const OUString& _sFile); protected: virtual ~ODbaseIndex() override; public: diff --git a/connectivity/source/inc/dbase/DTable.hxx b/connectivity/source/inc/dbase/DTable.hxx index c41ee9f7e9e1..79048b56d96f 100644 --- a/connectivity/source/inc/dbase/DTable.hxx +++ b/connectivity/source/inc/dbase/DTable.hxx @@ -130,7 +130,7 @@ namespace connectivity::dbase /// @throws css::container::ElementExistException /// @throws css::uno::RuntimeException void renameImpl( const OUString& newName ); - void throwInvalidColumnType(const char* pErrorId, const OUString& _sColumnName); + void throwInvalidColumnType(TranslateId pErrorId, const OUString& _sColumnName); protected: virtual void FileClose() override; diff --git a/connectivity/source/inc/resource/sharedresources.hxx b/connectivity/source/inc/resource/sharedresources.hxx index 8b4f3f98899d..0c439cdf24e3 100644 --- a/connectivity/source/inc/resource/sharedresources.hxx +++ b/connectivity/source/inc/resource/sharedresources.hxx @@ -22,7 +22,7 @@ #include <rtl/ustring.hxx> #include <vector> #include <connectivity/dbtoolsdllapi.hxx> - +#include <unotools/resmgr.hxx> namespace connectivity { @@ -47,7 +47,7 @@ namespace connectivity */ OUString getResourceString( - const char* pResId + TranslateId pResId ) const; /** loads a string from the shared resource file, and replaces @@ -65,7 +65,7 @@ namespace connectivity */ OUString getResourceStringWithSubstitution( - const char* pResId, + TranslateId pResId, const char* _pAsciiPatternToReplace, const OUString& _rStringToSubstitute ) const; @@ -89,7 +89,7 @@ namespace connectivity */ OUString getResourceStringWithSubstitution( - const char* pResId, + TranslateId pResId, const char* _pAsciiPatternToReplace1, const OUString& _rStringToSubstitute1, const char* _pAsciiPatternToReplace2, @@ -119,7 +119,7 @@ namespace connectivity */ OUString getResourceStringWithSubstitution( - const char* pResId, + TranslateId pResId, const char* _pAsciiPatternToReplace1, const OUString& _rStringToSubstitute1, const char* _pAsciiPatternToReplace2, @@ -138,7 +138,7 @@ namespace connectivity @return the string from the resource file, with applied string substitution */ - OUString getResourceStringWithSubstitution( const char* pResId, + OUString getResourceStringWithSubstitution( TranslateId pResId, const std::vector< std::pair<const char* , OUString > >& _rStringToSubstitutes) const; }; diff --git a/connectivity/source/resource/sharedresources.cxx b/connectivity/source/resource/sharedresources.cxx index 3f7062f6be52..b7c204c9f1cc 100644 --- a/connectivity/source/resource/sharedresources.cxx +++ b/connectivity/source/resource/sharedresources.cxx @@ -44,7 +44,7 @@ namespace connectivity static SharedResources_Impl& getInstance(); - OUString getResourceString(const char* pId); + OUString getResourceString(TranslateId pId); private: SharedResources_Impl(); @@ -66,7 +66,7 @@ namespace connectivity { } - OUString SharedResources_Impl::getResourceString(const char* pId) + OUString SharedResources_Impl::getResourceString(TranslateId pId) { return Translate::get(pId, m_aLocale); } @@ -129,13 +129,13 @@ namespace connectivity } - OUString SharedResources::getResourceString(const char* pResId) const + OUString SharedResources::getResourceString(TranslateId pResId) const { return SharedResources_Impl::getInstance().getResourceString(pResId); } - OUString SharedResources::getResourceStringWithSubstitution(const char* pResId, + OUString SharedResources::getResourceStringWithSubstitution(TranslateId pResId, const char* _pAsciiPatternToReplace, const OUString& _rStringToSubstitute ) const { OUString sString( SharedResources_Impl::getInstance().getResourceString(pResId) ); @@ -145,7 +145,7 @@ namespace connectivity } - OUString SharedResources::getResourceStringWithSubstitution(const char* pResId, + OUString SharedResources::getResourceStringWithSubstitution(TranslateId pResId, const char* _pAsciiPatternToReplace1, const OUString& _rStringToSubstitute1, const char* _pAsciiPatternToReplace2, const OUString& _rStringToSubstitute2 ) const { @@ -158,7 +158,7 @@ namespace connectivity } - OUString SharedResources::getResourceStringWithSubstitution(const char* pResId, + OUString SharedResources::getResourceStringWithSubstitution(TranslateId pResId, const char* _pAsciiPatternToReplace1, const OUString& _rStringToSubstitute1, const char* _pAsciiPatternToReplace2, const OUString& _rStringToSubstitute2, const char* _pAsciiPatternToReplace3, const OUString& _rStringToSubstitute3 ) const @@ -173,7 +173,7 @@ namespace connectivity return sString; } - OUString SharedResources::getResourceStringWithSubstitution(const char* pResId, + OUString SharedResources::getResourceStringWithSubstitution(TranslateId pResId, const std::vector< std::pair<const char* , OUString > >& _rStringToSubstitutes) const { OUString sString( SharedResources_Impl::getInstance().getResourceString(pResId) ); |