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 --- sd/source/core/CustomAnimationPreset.cxx | 21 +++++++------------ sd/source/core/TransitionPreset.cxx | 7 ++++--- .../ui/slidesorter/cache/SlsCacheConfiguration.cxx | 10 +++------ sd/source/ui/tools/ConfigurationAccess.cxx | 24 +++++++--------------- 4 files changed, 21 insertions(+), 41 deletions(-) (limited to 'sd') diff --git a/sd/source/core/CustomAnimationPreset.cxx b/sd/source/core/CustomAnimationPreset.cxx index 87e19f8ee4a5..cee595c3314f 100644 --- a/sd/source/core/CustomAnimationPreset.cxx +++ b/sd/source/core/CustomAnimationPreset.cxx @@ -30,6 +30,7 @@ #include #include #include +#include #include #include #include @@ -53,16 +54,11 @@ #include using namespace ::com::sun::star; +using namespace ::com::sun::star::uno; using namespace ::com::sun::star::animations; using namespace ::com::sun::star::presentation; using ::rtl::OUString; -using ::com::sun::star::uno::UNO_QUERY; -using ::com::sun::star::uno::UNO_QUERY_THROW; -using ::com::sun::star::uno::Any; -using ::com::sun::star::uno::Sequence; -using ::com::sun::star::uno::Reference; -using ::com::sun::star::uno::Exception; using ::com::sun::star::io::XInputStream; using ::com::sun::star::lang::XMultiServiceFactory; using ::com::sun::star::container::XNameAccess; @@ -320,9 +316,8 @@ void CustomAnimationPresets::importEffects() xContext->getValueByName("/singletons/com.sun.star.util.theMacroExpander"), UNO_QUERY ); - Reference< XMultiServiceFactory > xConfigProvider( - xServiceFactory->createInstance("com.sun.star.configuration.ConfigurationProvider" ), - UNO_QUERY_THROW ); + Reference< XMultiServiceFactory > xConfigProvider = + configuration::theDefaultProvider::get( xContext ); // read path to transition effects files from config Any propValue = uno::makeAny( @@ -404,12 +399,10 @@ void CustomAnimationPresets::importResources() try { // Get service factory - Reference< XMultiServiceFactory > xServiceFactory( comphelper::getProcessServiceFactory() ); - DBG_ASSERT( xServiceFactory.is(), "sd::CustomAnimationPresets::import(), got no service manager" ); - if( !xServiceFactory.is() ) - return; + Reference< XComponentContext > xContext( comphelper::getProcessComponentContext() ); - Reference< XMultiServiceFactory > xConfigProvider( xServiceFactory->createInstance("com.sun.star.configuration.ConfigurationProvider" ), UNO_QUERY ); + Reference< XMultiServiceFactory > xConfigProvider = + configuration::theDefaultProvider::get( xContext ); const OUString aPropertyPath("/org.openoffice.Office.UI.Effects/UserInterface/Properties" ); implImportLabels( xConfigProvider, aPropertyPath, maPropertyNameMap ); diff --git a/sd/source/core/TransitionPreset.cxx b/sd/source/core/TransitionPreset.cxx index 3c77ead958fe..49c0a5851cd3 100644 --- a/sd/source/core/TransitionPreset.cxx +++ b/sd/source/core/TransitionPreset.cxx @@ -30,6 +30,7 @@ #include #include #include +#include #include #include #include @@ -68,7 +69,7 @@ using ::com::sun::star::beans::NamedValue; namespace sd { -extern Reference< XAnimationNode > implImportEffects( const Reference< XMultiServiceFactory >& xConfigProvider, const OUString& rPath ); +extern Reference< XAnimationNode > implImportEffects( const Reference< XMultiServiceFactory >& xServiceFactory, const OUString& rPath ); extern void implImportLabels( const Reference< XMultiServiceFactory >& xConfigProvider, const OUString& rNodePath, UStringMap& rStringMap ); TransitionPreset::TransitionPreset( const ::com::sun::star::uno::Reference< ::com::sun::star::animations::XAnimationNode >& xNode ) @@ -161,8 +162,8 @@ bool TransitionPreset::importTransitionPresetList( TransitionPresetList& rList ) UNO_QUERY ); // import ui strings - Reference< XMultiServiceFactory > xConfigProvider( - xServiceFactory->createInstance("com.sun.star.configuration.ConfigurationProvider" ), UNO_QUERY_THROW ); + Reference< XMultiServiceFactory > xConfigProvider = + configuration::theDefaultProvider::get( xContext ); UStringMap aTransitionNameMape; const OUString aTransitionPath("/org.openoffice.Office.UI.Effects/UserInterface/Transitions" ); diff --git a/sd/source/ui/slidesorter/cache/SlsCacheConfiguration.cxx b/sd/source/ui/slidesorter/cache/SlsCacheConfiguration.cxx index 95c0bab2d814..a3e4b1b6f826 100644 --- a/sd/source/ui/slidesorter/cache/SlsCacheConfiguration.cxx +++ b/sd/source/ui/slidesorter/cache/SlsCacheConfiguration.cxx @@ -35,6 +35,7 @@ #include #include #include +#include #include using namespace ::com::sun::star; @@ -82,19 +83,14 @@ Timer CacheConfiguration::maReleaseTimer; CacheConfiguration::CacheConfiguration (void) { // Get the cache size from configuration. - const ::rtl::OUString sConfigurationProviderServiceName("com.sun.star.configuration.ConfigurationProvider"); const ::rtl::OUString sPathToImpressConfigurationRoot("/org.openoffice.Office.Impress/"); const ::rtl::OUString sPathToNode("MultiPaneGUI/SlideSorter/PreviewCache"); try { // Obtain access to the configuration. - Reference xProvider ( - ::comphelper::getProcessServiceFactory()->createInstance( - sConfigurationProviderServiceName), - UNO_QUERY); - if ( ! xProvider.is()) - return; + Reference xProvider = + configuration::theDefaultProvider::get( ::comphelper::getProcessComponentContext() ); // Obtain access to Impress configuration. Sequence aCreationArguments(3); diff --git a/sd/source/ui/tools/ConfigurationAccess.cxx b/sd/source/ui/tools/ConfigurationAccess.cxx index f56e7dafe190..50bff602a3d5 100644 --- a/sd/source/ui/tools/ConfigurationAccess.cxx +++ b/sd/source/ui/tools/ConfigurationAccess.cxx @@ -31,6 +31,7 @@ #include #include #include +#include #include #include #include @@ -47,17 +48,9 @@ ConfigurationAccess::ConfigurationAccess ( const WriteMode eMode) : mxRoot() { - Reference xFactory (rxContext->getServiceManager()); - if (xFactory.is()) - { - Reference xProvider ( - xFactory->createInstanceWithContext( - "com.sun.star.configuration.ConfigurationProvider", - rxContext), - UNO_QUERY); - if (xProvider.is()) - Initialize(xProvider, rsRootName, eMode); - } + Reference xProvider = + configuration::theDefaultProvider::get( rxContext ); + Initialize(xProvider, rsRootName, eMode); } @@ -68,12 +61,9 @@ ConfigurationAccess::ConfigurationAccess ( const WriteMode eMode) : mxRoot() { - Reference xProvider ( - ::comphelper::getProcessServiceFactory()->createInstance( - "com.sun.star.configuration.ConfigurationProvider"), - UNO_QUERY); - if (xProvider.is()) - Initialize(xProvider, rsRootName, eMode); + Reference xProvider = + configuration::theDefaultProvider::get( ::comphelper::getProcessComponentContext() ); + Initialize(xProvider, rsRootName, eMode); } -- cgit