From 9091fb1c1ee9628e5e43d9d1776fae7b0559228c Mon Sep 17 00:00:00 2001 From: Noel Grandin Date: Tue, 14 May 2024 19:45:57 +0200 Subject: [PATCH] use more officecfg in SvObjectServerList Change-Id: I049dedc577e2dc9c44417b041004a9180c19dc59 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/167643 Tested-by: Jenkins Reviewed-by: Noel Grandin --- svtools/source/dialogs/insdlg.cxx | 57 ++++++++++++------------------- 1 file changed, 22 insertions(+), 35 deletions(-) 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 #include #include +#include #if defined _WIN32 #include @@ -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 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 ); - - if( xNameAccess.is()) - { - const uno::Sequence< OUString > seqNames= xNameAccess->getElementNames(); - - for( const auto& rName : seqNames ) + uno::Reference< container::XNameAccess > xEntry ; + xNameAccess->getByName( rName ) >>= xEntry; + if ( xEntry.is() ) { - 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 ( !aUIName.isEmpty() ) { - OUString aUIName; - OUString aClassID; - xEntry->getByName(u"ObjectUIName"_ustr) >>= aUIName; - xEntry->getByName(u"ClassID"_ustr) >>= aClassID; + aUIName = aUIName.replaceAll("%PRODUCTNAME", utl::ConfigManager::getProductName()); + aUIName = aUIName.replaceAll("%PRODUCTVERSION", utl::ConfigManager::getProductVersion()); + } - 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 ); - } + SvGlobalName aClassName; + if( aClassName.MakeId( aClassID) ) + { + if( !Get( aClassName ) ) + // not entered yet + aObjectServerList.emplace_back( aClassName, aUIName ); } } }