From 6c80a8fe89fadf9a2c7260a09c037a09462f53d1 Mon Sep 17 00:00:00 2001 From: Noel Grandin Date: Fri, 6 Nov 2015 09:23:33 +0200 Subject: new loplugin: oncevar Change-Id: If57390510dde4d166be3141b9f658a7453755d3f Reviewed-on: https://gerrit.libreoffice.org/19815 Tested-by: Jenkins Reviewed-by: Noel Grandin --- connectivity/source/commontools/DateConversion.cxx | 3 +-- connectivity/source/commontools/dbtools.cxx | 6 +----- connectivity/source/drivers/hsqldb/HDriver.cxx | 7 ++++--- connectivity/source/drivers/postgresql/pq_connection.cxx | 3 +-- connectivity/source/drivers/postgresql/pq_driver.cxx | 10 +--------- connectivity/source/manager/mdrivermanager.cxx | 14 +++++--------- 6 files changed, 13 insertions(+), 30 deletions(-) (limited to 'connectivity/source') diff --git a/connectivity/source/commontools/DateConversion.cxx b/connectivity/source/commontools/DateConversion.cxx index b50fd8c3e653..4fa406653e4a 100644 --- a/connectivity/source/commontools/DateConversion.cxx +++ b/connectivity/source/commontools/DateConversion.cxx @@ -83,13 +83,12 @@ OUString DBTypeConversion::toSQLString(sal_Int32 eType, const Any& _rVal, bool b _rxTypeConverter->convertToSimpleType(_rVal, TypeClass_STRING) >>= aTemp; sal_Int32 nIndex = (sal_Int32)-1; const OUString sQuot("\'"); - const OUString sQuotToReplace("\'\'"); do { nIndex += 2; nIndex = aTemp.indexOf(sQuot,nIndex); if(nIndex != -1) - aTemp = aTemp.replaceAt(nIndex,sQuot.getLength(),sQuotToReplace); + aTemp = aTemp.replaceAt(nIndex,sQuot.getLength(), "\'\'"); } while (nIndex != -1); aRet.append(aTemp); diff --git a/connectivity/source/commontools/dbtools.cxx b/connectivity/source/commontools/dbtools.cxx index feed005fd073..247b8d71dd72 100644 --- a/connectivity/source/commontools/dbtools.cxx +++ b/connectivity/source/commontools/dbtools.cxx @@ -943,8 +943,6 @@ try Property* pOldProps = aOldProperties.getArray(); Property* pNewProps = aNewProperties.getArray(); - OUString sPropDefaultControl("DefaultControl"); - OUString sPropLabelControl("LabelControl"); OUString sPropFormatsSupplier("FormatsSupplier"); OUString sPropCurrencySymbol("CurrencySymbol"); OUString sPropDecimals("Decimals"); @@ -962,9 +960,7 @@ try for (sal_Int32 i=0; i aArguments(2); // the path to the node to open - OUString sNodePath("/org.openoffice.Setup/L10N" ); - aArguments[0] <<= PropertyValue( OUString("nodepath"), 0, - makeAny( sNodePath ), PropertyState_DIRECT_VALUE + aArguments[0] <<= PropertyValue( + OUString("nodepath"), 0, + makeAny( OUString("/org.openoffice.Setup/L10N" ) ), + PropertyState_DIRECT_VALUE ); // the depth: -1 means unlimited aArguments[1] <<= PropertyValue( diff --git a/connectivity/source/drivers/postgresql/pq_connection.cxx b/connectivity/source/drivers/postgresql/pq_connection.cxx index d93d7baa0f68..9df93ea8c05f 100644 --- a/connectivity/source/drivers/postgresql/pq_connection.cxx +++ b/connectivity/source/drivers/postgresql/pq_connection.cxx @@ -137,8 +137,7 @@ OUString ConnectionGetImplementationName() } com::sun::star::uno::Sequence ConnectionGetSupportedServiceNames() { - OUString serv( "com.sun.star.sdbc.Connection" ); - return Sequence< OUString> (&serv,1); + return Sequence< OUString > { "com.sun.star.sdbc.Connection" }; } static sal_Int32 readLogLevelFromConfiguration() diff --git a/connectivity/source/drivers/postgresql/pq_driver.cxx b/connectivity/source/drivers/postgresql/pq_driver.cxx index 8ff522348834..d67d14a1777b 100644 --- a/connectivity/source/drivers/postgresql/pq_driver.cxx +++ b/connectivity/source/drivers/postgresql/pq_driver.cxx @@ -76,15 +76,7 @@ OUString DriverGetImplementationName() Sequence< OUString > DriverGetSupportedServiceNames() { - static Sequence< OUString > *p; - if( ! p ) - { - MutexGuard guard( osl::Mutex::getGlobalMutex() ); - OUString tmp( "com.sun.star.sdbc.Driver" ); - static Sequence< OUString > instance( &tmp,1 ); - p = &instance; - } - return *p; + return Sequence< OUString > { "com.sun.star.sdbc.Driver" }; } Reference< XConnection > Driver::connect( diff --git a/connectivity/source/manager/mdrivermanager.cxx b/connectivity/source/manager/mdrivermanager.cxx index cddcf29630d8..686fdf6ee1a4 100644 --- a/connectivity/source/manager/mdrivermanager.cxx +++ b/connectivity/source/manager/mdrivermanager.cxx @@ -180,28 +180,24 @@ Any SAL_CALL ODriverEnumeration::nextElement( ) throw(NoSuchElementException, W _rPrecedence.realloc( 0 ); try { - // some strings we need - const OUString sDriverManagerConfigLocation( "org.openoffice.Office.DataAccess/DriverManager" ); - const OUString sDriverPreferenceLocation( "DriverPrecedence" ); - const OUString sNodePathArgumentName( "nodepath" ); - const OUString sNodeAccessServiceName( "com.sun.star.configuration.ConfigurationAccess" ); - // create a configuration provider Reference< XMultiServiceFactory > xConfigurationProvider( com::sun::star::configuration::theDefaultProvider::get( _rContext ) ); // one argument for creating the node access: the path to the configuration node Sequence< Any > aCreationArgs(1); - aCreationArgs[0] <<= NamedValue( sNodePathArgumentName, makeAny( sDriverManagerConfigLocation ) ); + aCreationArgs[0] <<= NamedValue( "nodepath", makeAny( OUString("org.openoffice.Office.DataAccess/DriverManager") ) ); // create the node access - Reference< XNameAccess > xDriverManagerNode(xConfigurationProvider->createInstanceWithArguments(sNodeAccessServiceName, aCreationArgs), UNO_QUERY); + Reference< XNameAccess > xDriverManagerNode( + xConfigurationProvider->createInstanceWithArguments("com.sun.star.configuration.ConfigurationAccess", aCreationArgs), + UNO_QUERY); OSL_ENSURE(xDriverManagerNode.is(), "lcl_getDriverPrecedence: could not open my configuration node!"); if (xDriverManagerNode.is()) { // obtain the preference list - Any aPreferences = xDriverManagerNode->getByName(sDriverPreferenceLocation); + Any aPreferences = xDriverManagerNode->getByName("DriverPrecedence"); bool bSuccess = aPreferences >>= _rPrecedence; OSL_ENSURE(bSuccess || !aPreferences.hasValue(), "lcl_getDriverPrecedence: invalid value for the preferences node (no string sequence but not NULL)!"); } -- cgit