diff options
author | Stephan Bergmann <sbergman@redhat.com> | 2011-11-14 22:07:23 +0100 |
---|---|---|
committer | Stephan Bergmann <sbergman@redhat.com> | 2011-11-14 22:07:23 +0100 |
commit | 8b75883b87c9f7989f98fb413f5e51200c52891c (patch) | |
tree | 5eaf6d052d25c61654b4e06ffb67784eab9d263b /comphelper | |
parent | f72516ed25d25963f497396985d56344eb3ff465 (diff) |
Simplified some uses of css.configuration.theDefaultProvider.
* Retro-added new-style UNOIDL singleton specification for it, for easy
instantiation.
* Plus new comphelper::getComponentContext to map from XMultiServiceFactory
to XComponentContext.
Diffstat (limited to 'comphelper')
-rw-r--r-- | comphelper/inc/comphelper/processfactory.hxx | 11 | ||||
-rw-r--r-- | comphelper/source/misc/configurationhelper.cxx | 5 | ||||
-rw-r--r-- | comphelper/source/misc/mimeconfighelper.cxx | 8 | ||||
-rw-r--r-- | comphelper/source/processfactory/processfactory.cxx | 11 |
4 files changed, 27 insertions, 8 deletions
diff --git a/comphelper/inc/comphelper/processfactory.hxx b/comphelper/inc/comphelper/processfactory.hxx index 6f608ccd6839..e3651530cfc3 100644 --- a/comphelper/inc/comphelper/processfactory.hxx +++ b/comphelper/inc/comphelper/processfactory.hxx @@ -75,6 +75,17 @@ COMPHELPER_DLLPUBLIC ::com::sun::star::uno::Reference< ::com::sun::star::uno::XI const ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Any >& _rArgs ) SAL_THROW( ( ::com::sun::star::uno::RuntimeException ) ); +/** Tries to obtain a component context from a service factory. + + @param factory may be null + @return may be null + */ +COMPHELPER_DLLPUBLIC +com::sun::star::uno::Reference< com::sun::star::uno::XComponentContext > +getComponentContext( + com::sun::star::uno::Reference< com::sun::star::lang::XMultiServiceFactory > + const & factory); + /** * This function gets the process service factory's default component context. * If no service factory is set the function returns a null interface. diff --git a/comphelper/source/misc/configurationhelper.cxx b/comphelper/source/misc/configurationhelper.cxx index 1016c88b341c..9911fd23d5f4 100644 --- a/comphelper/source/misc/configurationhelper.cxx +++ b/comphelper/source/misc/configurationhelper.cxx @@ -32,7 +32,9 @@ //_______________________________________________ // includes #include <comphelper/configurationhelper.hxx> +#include <comphelper/processfactory.hxx> #include <com/sun/star/beans/XPropertySet.hpp> +#include <com/sun/star/configuration/theDefaultProvider.hpp> #include <com/sun/star/container/XNameAccess.hpp> #include <com/sun/star/container/XNameContainer.hpp> #include <com/sun/star/lang/XSingleServiceFactory.hpp> @@ -53,7 +55,8 @@ css::uno::Reference< css::uno::XInterface > ConfigurationHelper::openConfig(cons sal_Int32 eMode ) { css::uno::Reference< css::lang::XMultiServiceFactory > xConfigProvider( - xSMGR->createInstance(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("com.sun.star.configuration.ConfigurationProvider"))), css::uno::UNO_QUERY_THROW); + css::configuration::theDefaultProvider::get( + getComponentContext( xSMGR ) ) ); ::comphelper::SequenceAsVector< css::uno::Any > lParams; css::beans::PropertyValue aParam ; diff --git a/comphelper/source/misc/mimeconfighelper.cxx b/comphelper/source/misc/mimeconfighelper.cxx index dfa66e839bd9..92f4a2578930 100644 --- a/comphelper/source/misc/mimeconfighelper.cxx +++ b/comphelper/source/misc/mimeconfighelper.cxx @@ -29,11 +29,13 @@ // MARKER(update_precomp.py): autogen include statement, do not remove #include "precompiled_comphelper.hxx" #include <com/sun/star/beans/PropertyValue.hpp> +#include <com/sun/star/configuration/theDefaultProvider.hpp> #include <com/sun/star/container/XContainerQuery.hpp> #include <com/sun/star/document/XTypeDetection.hpp> #include <comphelper/fileformat.h> #include <comphelper/mimeconfighelper.hxx> +#include <comphelper/processfactory.hxx> #include <comphelper/classids.hxx> #include <comphelper/sequenceashashmap.hxx> #include <comphelper/documentconstants.hxx> @@ -131,10 +133,8 @@ uno::Reference< container::XNameAccess > MimeConfigurationHelper::GetConfigurati try { if ( !m_xConfigProvider.is() ) - m_xConfigProvider = uno::Reference< lang::XMultiServiceFactory >( - m_xFactory->createInstance( - ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.configuration.ConfigurationProvider" )) ), - uno::UNO_QUERY_THROW ); + m_xConfigProvider = configuration::theDefaultProvider::get( + getComponentContext( m_xFactory ) ); uno::Sequence< uno::Any > aArgs( 1 ); beans::PropertyValue aPathProp; diff --git a/comphelper/source/processfactory/processfactory.cxx b/comphelper/source/processfactory/processfactory.cxx index f9b2218f7018..c07d195190a2 100644 --- a/comphelper/source/processfactory/processfactory.cxx +++ b/comphelper/source/processfactory/processfactory.cxx @@ -96,11 +96,11 @@ Reference< XInterface > createProcessComponentWithArguments( const ::rtl::OUStri return xComponent; } -Reference< XComponentContext > getProcessComponentContext() +Reference< XComponentContext > getComponentContext( + Reference< XMultiServiceFactory > const & factory) { Reference< XComponentContext > xRet; - uno::Reference<beans::XPropertySet> const xProps( - comphelper::getProcessServiceFactory(), uno::UNO_QUERY ); + uno::Reference<beans::XPropertySet> const xProps( factory, uno::UNO_QUERY ); if (xProps.is()) { try { xRet.set( xProps->getPropertyValue( rtl::OUString( @@ -113,6 +113,11 @@ Reference< XComponentContext > getProcessComponentContext() return xRet; } +Reference< XComponentContext > getProcessComponentContext() +{ + return getComponentContext( getProcessServiceFactory() ); +} + } // namespace comphelper extern "C" { |