From 0ac9a10d312dc8f12a74720ce211823ce4addf7b Mon Sep 17 00:00:00 2001 From: Noel Grandin Date: Tue, 30 Oct 2012 14:02:56 +0200 Subject: fdo#46808, Deprecate configuration::ConfigurationProvider old-style service ...in favor of existing new-style configuration::theDefaultProvider singleton. Theoretically, ConfigurationProvider instances can be created with specific Locale and EnableAsync arguments, but this is hardly used in practice, and thus effectively all uses of the ConfigurationProvider service use the theDefaultProvider instance, anyway. theDefaultProvider is restricted to the XMultiServiceFactory interface, while ConfigurationProvider also makes available XComponent. However, dispose must not be called manually on theDefaultProvider singleton anyway, and calls to add-/removeEventListener are so few (and in dubious code that should better be cleaned up) that requiring an explicit queryInterface does not really hurt there. This commit originated as a patch by Noel Grandin to "Adapt configuration::ConfigurationProvider UNO service to new style [by creating] a merged XConfigurationProvider interface for this service to implement." It was then modified by Stephan Bergmann by deprecating ConfigurationProvider instead of adding XConfigurationProvider and by replacing calls to ConfigurationProvider::create with calls to theDefaultProvider::get. Change-Id: I9c16700afe0faff1ef6f20338a66bd7a9af990bd --- sdext/source/minimizer/configurationaccess.cxx | 49 +++++++++------------- .../presenter/PresenterConfigurationAccess.cxx | 11 ++--- 2 files changed, 24 insertions(+), 36 deletions(-) (limited to 'sdext') diff --git a/sdext/source/minimizer/configurationaccess.cxx b/sdext/source/minimizer/configurationaccess.cxx index d55cc63a8935..e0ba19b8f708 100644 --- a/sdext/source/minimizer/configurationaccess.cxx +++ b/sdext/source/minimizer/configurationaccess.cxx @@ -21,6 +21,7 @@ #include "configurationaccess.hxx" #include #include +#include #include #include #include @@ -33,13 +34,6 @@ using namespace ::com::sun::star::uno; using namespace ::com::sun::star::beans; using namespace ::com::sun::star::container; -static const OUString& GetConfigurationProviderServiceName (void) -{ - static const OUString sConfigurationProviderServiceName ( - RTL_CONSTASCII_USTRINGPARAM( - "com.sun.star.configuration.ConfigurationProvider")); - return sConfigurationProviderServiceName; -} static const OUString& GetPathToConfigurationRoot (void) { static const OUString sPathToConfigurationRoot ( @@ -328,28 +322,25 @@ Reference< XInterface > ConfigurationAccess::OpenConfiguration( bool bReadOnly ) Reference< XInterface > xRoot; try { - Reference< lang::XMultiServiceFactory > xProvider( mxMSF->getServiceManager()->createInstanceWithContext( GetConfigurationProviderServiceName(), mxMSF ), UNO_QUERY ); - if ( xProvider.is() ) - { - Sequence< Any > aCreationArguments( 2 ); - aCreationArguments[0] = makeAny( PropertyValue( - OUString( RTL_CONSTASCII_USTRINGPARAM( "nodepath" ) ), 0, - makeAny( GetPathToConfigurationRoot() ), - PropertyState_DIRECT_VALUE ) ); - aCreationArguments[1] = makeAny(beans::PropertyValue( - OUString( RTL_CONSTASCII_USTRINGPARAM( "lazywrite" ) ), 0, makeAny( true ), - PropertyState_DIRECT_VALUE ) ); - OUString sAccessService; - if ( bReadOnly ) - sAccessService = OUString( RTL_CONSTASCII_USTRINGPARAM( - "com.sun.star.configuration.ConfigurationAccess" ) ); - else - sAccessService = OUString( RTL_CONSTASCII_USTRINGPARAM( - "com.sun.star.configuration.ConfigurationUpdateAccess" ) ); - - xRoot = xProvider->createInstanceWithArguments( - sAccessService, aCreationArguments ); - } + Reference< lang::XMultiServiceFactory > xProvider = configuration::theDefaultProvider::get( mxMSF ); + Sequence< Any > aCreationArguments( 2 ); + aCreationArguments[0] = makeAny( PropertyValue( + OUString( RTL_CONSTASCII_USTRINGPARAM( "nodepath" ) ), 0, + makeAny( GetPathToConfigurationRoot() ), + PropertyState_DIRECT_VALUE ) ); + aCreationArguments[1] = makeAny(beans::PropertyValue( + OUString( RTL_CONSTASCII_USTRINGPARAM( "lazywrite" ) ), 0, makeAny( true ), + PropertyState_DIRECT_VALUE ) ); + OUString sAccessService; + if ( bReadOnly ) + sAccessService = OUString( RTL_CONSTASCII_USTRINGPARAM( + "com.sun.star.configuration.ConfigurationAccess" ) ); + else + sAccessService = OUString( RTL_CONSTASCII_USTRINGPARAM( + "com.sun.star.configuration.ConfigurationUpdateAccess" ) ); + + xRoot = xProvider->createInstanceWithArguments( + sAccessService, aCreationArguments ); } catch (const Exception&) { diff --git a/sdext/source/presenter/PresenterConfigurationAccess.cxx b/sdext/source/presenter/PresenterConfigurationAccess.cxx index e321b71215a5..2ae90dc1085a 100644 --- a/sdext/source/presenter/PresenterConfigurationAccess.cxx +++ b/sdext/source/presenter/PresenterConfigurationAccess.cxx @@ -22,6 +22,7 @@ #include #include #include +#include #include using namespace ::com::sun::star; @@ -44,8 +45,7 @@ PresenterConfigurationAccess::PresenterConfigurationAccess ( { try { - Reference xFactory (rxContext->getServiceManager()); - if (xFactory.is()) + if (rxContext.is()) { Sequence aCreationArguments(3); aCreationArguments[0] = makeAny(beans::PropertyValue( @@ -70,11 +70,8 @@ PresenterConfigurationAccess::PresenterConfigurationAccess ( else sAccessService = A2S("com.sun.star.configuration.ConfigurationUpdateAccess"); - Reference xProvider ( - xFactory->createInstanceWithContext( - A2S("com.sun.star.configuration.ConfigurationProvider"), - rxContext), - UNO_QUERY_THROW); + Reference xProvider = + configuration::theDefaultProvider::get( rxContext ); mxRoot = xProvider->createInstanceWithArguments( sAccessService, aCreationArguments); maNode <<= mxRoot; -- cgit