From 0b8f585f8a3123e06d700dc18f4df1ec7d463440 Mon Sep 17 00:00:00 2001 From: Noel Grandin Date: Tue, 14 May 2024 19:30:05 +0200 Subject: [PATCH] use more officecfg in OSDBCDriverManager Change-Id: I2b1758572a6436d829d547d60bca5fa2d1a3c98f Reviewed-on: https://gerrit.libreoffice.org/c/core/+/167641 Reviewed-by: Noel Grandin Tested-by: Jenkins --- connectivity/Library_sdbc2.mk | 4 ++ .../source/manager/mdrivermanager.cxx | 42 ++----------------- 2 files changed, 7 insertions(+), 39 deletions(-) diff --git a/connectivity/Library_sdbc2.mk b/connectivity/Library_sdbc2.mk index e7296a2efc59..611eba1d6fab 100644 --- a/connectivity/Library_sdbc2.mk +++ b/connectivity/Library_sdbc2.mk @@ -14,6 +14,10 @@ $(eval $(call gb_Library_set_componentfile,sdbc2,connectivity/source/manager/sdb $(eval $(call gb_Library_use_external,sdbc2,boost_headers)) +$(eval $(call gb_Library_use_custom_headers,sdbc2,\ + officecfg/registry \ +)) + $(eval $(call gb_Library_use_sdk_api,sdbc2)) $(eval $(call gb_Library_set_include,sdbc2,\ diff --git a/connectivity/source/manager/mdrivermanager.cxx b/connectivity/source/manager/mdrivermanager.cxx index 2c9b32adc4b3..61b5b528f624 100644 --- a/connectivity/source/manager/mdrivermanager.cxx +++ b/connectivity/source/manager/mdrivermanager.cxx @@ -32,6 +32,7 @@ #include #include #include +#include #include #include @@ -158,43 +159,6 @@ namespace return _rDriver.is() && _rDriver->acceptsURL( _rURL ); } -#if !ENABLE_FUZZERS - sal_Int32 lcl_getDriverPrecedence( const Reference& _rContext, Sequence< OUString >& _rPrecedence ) - { - _rPrecedence.realloc( 0 ); - try - { - // create a configuration provider - Reference< XMultiServiceFactory > xConfigurationProvider( - css::configuration::theDefaultProvider::get( _rContext ) ); - - // one argument for creating the node access: the path to the configuration node - Sequence< Any > aCreationArgs{ Any(NamedValue( - u"nodepath"_ustr, Any( u"org.openoffice.Office.DataAccess/DriverManager"_ustr ) )) }; - - // create the node access - Reference< XNameAccess > xDriverManagerNode( - xConfigurationProvider->createInstanceWithArguments(u"com.sun.star.configuration.ConfigurationAccess"_ustr, 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(u"DriverPrecedence"_ustr); - bool bSuccess = aPreferences >>= _rPrecedence; - OSL_ENSURE(bSuccess || !aPreferences.hasValue(), "lcl_getDriverPrecedence: invalid value for the preferences node (no string sequence but not NULL)!"); - } - } - catch( const Exception& ) - { - DBG_UNHANDLED_EXCEPTION("connectivity.manager"); - } - - return _rPrecedence.getLength(); - } -#endif - /// an STL algorithm compatible predicate comparing two DriverAccess instances by their implementation names struct CompareDriverAccessByName { @@ -318,8 +282,8 @@ void OSDBCDriverManager::initializeDriverPrecedence() try { // get the precedence of the drivers from the configuration - Sequence< OUString > aDriverOrder; - if ( 0 == lcl_getDriverPrecedence( m_xContext, aDriverOrder ) ) + Sequence< OUString > aDriverOrder = officecfg::Office::DataAccess::DriverManager::DriverPrecedence::get(); + if ( 0 == aDriverOrder.getLength() ) // nothing to do return;