connectivity/Library_sdbc2.mk | 4 + connectivity/source/manager/mdrivermanager.cxx | 42 +----------------- svtools/source/dialogs/insdlg.cxx | 57 +++++++++---------------- 3 files changed, 29 insertions(+), 74 deletions(-)
New commits: commit 9091fb1c1ee9628e5e43d9d1776fae7b0559228c Author: Noel Grandin <[email protected]> AuthorDate: Tue May 14 19:45:57 2024 +0200 Commit: Noel Grandin <[email protected]> CommitDate: Wed May 15 10:05:52 2024 +0200 use more officecfg in SvObjectServerList Change-Id: I049dedc577e2dc9c44417b041004a9180c19dc59 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/167643 Tested-by: Jenkins Reviewed-by: Noel Grandin <[email protected]> diff --git a/svtools/source/dialogs/insdlg.cxx b/svtools/source/dialogs/insdlg.cxx index b59705dc456c..ff33bea4b782 100644 --- a/svtools/source/dialogs/insdlg.cxx +++ b/svtools/source/dialogs/insdlg.cxx @@ -31,6 +31,7 @@ #include <comphelper/processfactory.hxx> #include <comphelper/propertysequence.hxx> #include <com/sun/star/container/XNameAccess.hpp> +#include <officecfg/Office/Embedding.hxx> #if defined _WIN32 #include <prewin.h> @@ -108,47 +109,33 @@ void SvObjectServerList::FillInsertObjects() */ { try{ - uno::Reference< uno::XComponentContext > xContext = comphelper::getProcessComponentContext(); + uno::Reference< container::XNameAccess > xNameAccess = officecfg::Office::Embedding::ObjectNames::get(); - uno::Reference< lang::XMultiServiceFactory > sProviderMSFactory = - configuration::theDefaultProvider::get(xContext); + const uno::Sequence< OUString > seqNames= xNameAccess->getElementNames(); - uno::Sequence<uno::Any> aArguments(comphelper::InitAnyPropertySequence( + for( const auto& rName : seqNames ) { - {"nodepath", uno::Any(u"/org.openoffice.Office.Embedding/ObjectNames"_ustr)} - })); - uno::Reference< container::XNameAccess > xNameAccess( - sProviderMSFactory->createInstanceWithArguments( u"com.sun.star.configuration.ConfigurationAccess"_ustr, aArguments ), - uno::UNO_QUERY ); + uno::Reference< container::XNameAccess > xEntry ; + xNameAccess->getByName( rName ) >>= xEntry; + if ( xEntry.is() ) + { + OUString aUIName; + OUString aClassID; + xEntry->getByName(u"ObjectUIName"_ustr) >>= aUIName; + xEntry->getByName(u"ClassID"_ustr) >>= aClassID; - if( xNameAccess.is()) - { - const uno::Sequence< OUString > seqNames= xNameAccess->getElementNames(); + if ( !aUIName.isEmpty() ) + { + aUIName = aUIName.replaceAll("%PRODUCTNAME", utl::ConfigManager::getProductName()); + aUIName = aUIName.replaceAll("%PRODUCTVERSION", utl::ConfigManager::getProductVersion()); + } - for( const auto& rName : seqNames ) - { - uno::Reference< container::XNameAccess > xEntry ; - xNameAccess->getByName( rName ) >>= xEntry; - if ( xEntry.is() ) + SvGlobalName aClassName; + if( aClassName.MakeId( aClassID) ) { - OUString aUIName; - OUString aClassID; - xEntry->getByName(u"ObjectUIName"_ustr) >>= aUIName; - xEntry->getByName(u"ClassID"_ustr) >>= aClassID; - - if ( !aUIName.isEmpty() ) - { - aUIName = aUIName.replaceAll("%PRODUCTNAME", utl::ConfigManager::getProductName()); - aUIName = aUIName.replaceAll("%PRODUCTVERSION", utl::ConfigManager::getProductVersion()); - } - - SvGlobalName aClassName; - if( aClassName.MakeId( aClassID) ) - { - if( !Get( aClassName ) ) - // not entered yet - aObjectServerList.emplace_back( aClassName, aUIName ); - } + if( !Get( aClassName ) ) + // not entered yet + aObjectServerList.emplace_back( aClassName, aUIName ); } } } commit 0b8f585f8a3123e06d700dc18f4df1ec7d463440 Author: Noel Grandin <[email protected]> AuthorDate: Tue May 14 19:30:05 2024 +0200 Commit: Noel Grandin <[email protected]> CommitDate: Wed May 15 10:05:45 2024 +0200 use more officecfg in OSDBCDriverManager Change-Id: I2b1758572a6436d829d547d60bca5fa2d1a3c98f Reviewed-on: https://gerrit.libreoffice.org/c/core/+/167641 Reviewed-by: Noel Grandin <[email protected]> Tested-by: Jenkins 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 <cppuhelper/supportsservice.hxx> #include <cppuhelper/weak.hxx> #include <osl/diagnose.h> +#include <officecfg/Office/DataAccess.hxx> #include <algorithm> #include <iterator> @@ -158,43 +159,6 @@ namespace return _rDriver.is() && _rDriver->acceptsURL( _rURL ); } -#if !ENABLE_FUZZERS - sal_Int32 lcl_getDriverPrecedence( const Reference<XComponentContext>& _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;
