diff options
author | Noel Grandin <noel@peralex.com> | 2012-10-30 14:02:56 +0200 |
---|---|---|
committer | Stephan Bergmann <sbergman@redhat.com> | 2012-10-31 15:31:36 +0100 |
commit | 0ac9a10d312dc8f12a74720ce211823ce4addf7b (patch) | |
tree | 2c812432eca9315170af8b5b6b7ae5bcbf828d5b /ucbhelper | |
parent | d27c92961b78da138d3563ab596cca416af9eb38 (diff) |
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
Diffstat (limited to 'ucbhelper')
-rw-r--r-- | ucbhelper/inc/ucbhelper/macros.hxx | 21 | ||||
-rw-r--r-- | ucbhelper/inc/ucbhelper/proxydecider.hxx | 3 | ||||
-rw-r--r-- | ucbhelper/source/client/proxydecider.cxx | 16 |
3 files changed, 30 insertions, 10 deletions
diff --git a/ucbhelper/inc/ucbhelper/macros.hxx b/ucbhelper/inc/ucbhelper/macros.hxx index b2cb7cb89346..924989ae6d0f 100644 --- a/ucbhelper/inc/ucbhelper/macros.hxx +++ b/ucbhelper/inc/ucbhelper/macros.hxx @@ -656,6 +656,19 @@ Class##_CreateInstance( const com::sun::star::uno::Reference< \ com::sun::star::uno::XInterface >::query( pX ); \ } +#define XSERVICEINFO_CREATE_INSTANCE_IMPL_CTX( Class ) \ +static com::sun::star::uno::Reference< \ + com::sun::star::uno::XInterface > SAL_CALL \ +Class##_CreateInstance( const com::sun::star::uno::Reference< \ + com::sun::star::lang::XMultiServiceFactory> & rSMgr ) \ + throw( com::sun::star::uno::Exception ) \ +{ \ + com::sun::star::lang::XServiceInfo* pX = \ + (com::sun::star::lang::XServiceInfo*)new Class( comphelper::getComponentContext(rSMgr) ); \ + return com::sun::star::uno::Reference< \ + com::sun::star::uno::XInterface >::query( pX ); \ +} + //========================================================================= // // XServiceInfo impl. @@ -708,6 +721,14 @@ XSERVICEINFO_CREATE_INSTANCE_IMPL( Class ) \ com::sun::star::uno::Sequence< rtl::OUString > \ Class::getSupportedServiceNames_Static() +// Own implementation of getSupportedServiceNames_Static(). +#define XSERVICEINFO_IMPL_0_CTX( Class, ImplName ) \ +XSERVICEINFO_COMMOM_IMPL( Class, ImplName ) \ +XSERVICEINFO_CREATE_INSTANCE_IMPL_CTX( Class ) \ + \ +com::sun::star::uno::Sequence< rtl::OUString > \ +Class::getSupportedServiceNames_Static() + // 1 service name #define XSERVICEINFO_IMPL_1( Class, ImplName, Service1 ) \ XSERVICEINFO_COMMOM_IMPL( Class, ImplName ) \ diff --git a/ucbhelper/inc/ucbhelper/proxydecider.hxx b/ucbhelper/inc/ucbhelper/proxydecider.hxx index fa3d6a03e745..fd59eae29b89 100644 --- a/ucbhelper/inc/ucbhelper/proxydecider.hxx +++ b/ucbhelper/inc/ucbhelper/proxydecider.hxx @@ -22,6 +22,7 @@ #include <rtl/ustring.hxx> #include <com/sun/star/uno/Reference.hxx> +#include <com/sun/star/uno/XComponentContext.hpp> #include "ucbhelper/ucbhelperdllapi.h" namespace com { namespace sun { namespace star { namespace lang { @@ -76,7 +77,7 @@ public: * @param rxSMgr is a Service Manager. */ InternetProxyDecider( const ::com::sun::star::uno::Reference< - ::com::sun::star::lang::XMultiServiceFactory >& rxSMgr ); + ::com::sun::star::uno::XComponentContext >& rxContext ); /** * Destructor. diff --git a/ucbhelper/source/client/proxydecider.cxx b/ucbhelper/source/client/proxydecider.cxx index b67e10929acc..4230eac91108 100644 --- a/ucbhelper/source/client/proxydecider.cxx +++ b/ucbhelper/source/client/proxydecider.cxx @@ -32,6 +32,7 @@ #include <osl/socket.hxx> #include <rtl/ustrbuf.hxx> #include <com/sun/star/container/XNameAccess.hpp> +#include <com/sun/star/configuration/theDefaultProvider.hpp> #include <com/sun/star/lang/XMultiServiceFactory.hpp> #include <com/sun/star/util/XChangesListener.hpp> #include <com/sun/star/util/XChangesNotifier.hpp> @@ -138,7 +139,7 @@ private: bool bUseFullyQualified ) const; public: InternetProxyDecider_Impl( - const uno::Reference< lang::XMultiServiceFactory >& rxSMgr ); + const uno::Reference< uno::XComponentContext >& rxContext ); virtual ~InternetProxyDecider_Impl(); void dispose(); @@ -299,7 +300,7 @@ bool getConfigInt32Value( //========================================================================= InternetProxyDecider_Impl::InternetProxyDecider_Impl( - const uno::Reference< lang::XMultiServiceFactory >& rxSMgr ) + const uno::Reference< uno::XComponentContext >& rxContext ) : m_nProxyType( 0 ), m_aHostnames( 256 ) // cache size { @@ -309,11 +310,8 @@ InternetProxyDecider_Impl::InternetProxyDecider_Impl( // Read proxy configuration from config db. ////////////////////////////////////////////////////////////// - uno::Reference< lang::XMultiServiceFactory > xConfigProv( - rxSMgr->createInstance( - rtl::OUString( - "com.sun.star.configuration.ConfigurationProvider" ) ), - uno::UNO_QUERY ); + uno::Reference< lang::XMultiServiceFactory > xConfigProv = + configuration::theDefaultProvider::get( rxContext ); uno::Sequence< uno::Any > aArguments( 1 ); aArguments[ 0 ] <<= rtl::OUString( CONFIG_ROOT_KEY ); @@ -794,8 +792,8 @@ void InternetProxyDecider_Impl::setNoProxyList( //========================================================================= InternetProxyDecider::InternetProxyDecider( - const uno::Reference< lang::XMultiServiceFactory >& rxSMgr ) -: m_pImpl( new proxydecider_impl::InternetProxyDecider_Impl( rxSMgr ) ) + const uno::Reference< uno::XComponentContext>& rxContext ) +: m_pImpl( new proxydecider_impl::InternetProxyDecider_Impl( rxContext ) ) { m_pImpl->acquire(); } |