diff options
author | sb <sb@openoffice.org> | 2010-10-25 14:43:41 +0200 |
---|---|---|
committer | sb <sb@openoffice.org> | 2010-10-25 14:43:41 +0200 |
commit | 7e5eda3334b1fb465e957e00c11c26f0375ce1ca (patch) | |
tree | 043c53e8dd35bb410bc8673e0a86a69e8fbe8080 /configmgr | |
parent | cc065c4937433f944cd7f6e4332f599d5346a5e9 (diff) |
sb132: #i115142# component factories should implement XServiceInfo
Diffstat (limited to 'configmgr')
-rw-r--r-- | configmgr/source/configurationprovider.cxx | 18 | ||||
-rw-r--r-- | configmgr/source/configurationregistry.cxx | 58 | ||||
-rw-r--r-- | configmgr/source/configurationregistry.hxx | 22 | ||||
-rw-r--r-- | configmgr/source/defaultprovider.cxx | 68 | ||||
-rw-r--r-- | configmgr/source/defaultprovider.hxx | 22 | ||||
-rw-r--r-- | configmgr/source/services.cxx | 15 | ||||
-rw-r--r-- | configmgr/source/update.cxx | 56 | ||||
-rw-r--r-- | configmgr/source/update.hxx | 22 |
8 files changed, 66 insertions, 215 deletions
diff --git a/configmgr/source/configurationprovider.cxx b/configmgr/source/configurationprovider.cxx index 3cd58b145bff..d636737a299e 100644 --- a/configmgr/source/configurationprovider.cxx +++ b/configmgr/source/configurationprovider.cxx @@ -55,7 +55,7 @@ #include "cppu/unotype.hxx" #include "cppuhelper/compbase5.hxx" #include "cppuhelper/factory.hxx" -#include "cppuhelper/implbase1.hxx" +#include "cppuhelper/implbase2.hxx" #include "cppuhelper/interfacecontainer.hxx" #include "cppuhelper/weak.hxx" #include "osl/diagnose.h" @@ -127,7 +127,6 @@ private: virtual css::uno::Sequence< rtl::OUString > SAL_CALL getSupportedServiceNames() throw (css::uno::RuntimeException) { return configuration_provider::getSupportedServiceNames(); } - //TODO: DefaultProvider? virtual css::uno::Reference< css::uno::XInterface > SAL_CALL createInstance( rtl::OUString const & aServiceSpecifier) @@ -395,7 +394,8 @@ void Service::flushModifications() const { } class Factory: - public cppu::WeakImplHelper1< css::lang::XSingleComponentFactory >, + public cppu::WeakImplHelper2< + css::lang::XSingleComponentFactory, css::lang::XServiceInfo >, private boost::noncopyable { public: @@ -414,6 +414,18 @@ private: css::uno::Sequence< css::uno::Any > const & Arguments, css::uno::Reference< css::uno::XComponentContext > const & Context) throw (css::uno::Exception, css::uno::RuntimeException); + + virtual rtl::OUString SAL_CALL getImplementationName() + throw (css::uno::RuntimeException) + { return configuration_provider::getImplementationName(); } + + virtual sal_Bool SAL_CALL supportsService(rtl::OUString const & ServiceName) + throw (css::uno::RuntimeException) + { return ServiceName == getSupportedServiceNames()[0]; } //TODO + + virtual css::uno::Sequence< rtl::OUString > SAL_CALL + getSupportedServiceNames() throw (css::uno::RuntimeException) + { return configuration_provider::getSupportedServiceNames(); } }; css::uno::Reference< css::uno::XInterface > Factory::createInstanceWithContext( diff --git a/configmgr/source/configurationregistry.cxx b/configmgr/source/configurationregistry.cxx index ffd7174c0ad7..f4810eb34ff8 100644 --- a/configmgr/source/configurationregistry.cxx +++ b/configmgr/source/configurationregistry.cxx @@ -36,7 +36,6 @@ #include "com/sun/star/lang/XMultiComponentFactory.hpp" #include "com/sun/star/lang/XMultiServiceFactory.hpp" #include "com/sun/star/lang/XServiceInfo.hpp" -#include "com/sun/star/lang/XSingleComponentFactory.hpp" #include "com/sun/star/registry/InvalidRegistryException.hpp" #include "com/sun/star/registry/InvalidValueException.hpp" #include "com/sun/star/registry/MergeConflictException.hpp" @@ -56,13 +55,11 @@ #include "com/sun/star/uno/XInterface.hpp" #include "com/sun/star/util/XFlushable.hpp" #include "cppu/unotype.hxx" -#include "cppuhelper/factory.hxx" #include "cppuhelper/implbase1.hxx" #include "cppuhelper/implbase3.hxx" #include "cppuhelper/weak.hxx" #include "osl/diagnose.h" #include "osl/mutex.hxx" -#include "rtl/unload.h" #include "rtl/ustring.h" #include "rtl/ustring.hxx" #include "sal/types.h" @@ -877,53 +874,12 @@ rtl::OUString RegistryKey::getResolvedName(rtl::OUString const & aKeyName) return aKeyName; } -class Factory: - public cppu::WeakImplHelper1< css::lang::XSingleComponentFactory >, - private boost::noncopyable -{ -public: - Factory() {} - -private: - virtual ~Factory() {} - - virtual css::uno::Reference< css::uno::XInterface > SAL_CALL - createInstanceWithContext( - css::uno::Reference< css::uno::XComponentContext > const & Context) - throw (css::uno::Exception, css::uno::RuntimeException); - - virtual css::uno::Reference< css::uno::XInterface > SAL_CALL - createInstanceWithArgumentsAndContext( - css::uno::Sequence< css::uno::Any > const & Arguments, - css::uno::Reference< css::uno::XComponentContext > const & Context) - throw (css::uno::Exception, css::uno::RuntimeException); -}; - -css::uno::Reference< css::uno::XInterface > Factory::createInstanceWithContext( - css::uno::Reference< css::uno::XComponentContext > const & Context) - throw (css::uno::Exception, css::uno::RuntimeException) -{ - return createInstanceWithArgumentsAndContext( - css::uno::Sequence< css::uno::Any >(), Context); } -css::uno::Reference< css::uno::XInterface > -Factory::createInstanceWithArgumentsAndContext( - css::uno::Sequence< css::uno::Any > const & Arguments, - css::uno::Reference< css::uno::XComponentContext > const & Context) - throw (css::uno::Exception, css::uno::RuntimeException) +css::uno::Reference< css::uno::XInterface > create( + css::uno::Reference< css::uno::XComponentContext > const & context) { - if (Arguments.getLength() != 0) { - throw css::uno::Exception( - rtl::OUString( - RTL_CONSTASCII_USTRINGPARAM( - "com.sun.star.configuration.ConfigurationRegistry must be" - " instantiated without arguments")), - static_cast< cppu::OWeakObject * >(this)); - } - return static_cast< cppu::OWeakObject * >(new Service(Context)); -} - + return static_cast< cppu::OWeakObject * >(new Service(context)); } rtl::OUString getImplementationName() { @@ -939,12 +895,4 @@ css::uno::Sequence< rtl::OUString > getSupportedServiceNames() { return css::uno::Sequence< rtl::OUString >(&name, 1); } -css::uno::Reference< css::lang::XSingleComponentFactory > createFactory( - cppu::ComponentFactoryFunc, rtl::OUString const &, - css::uno::Sequence< rtl::OUString > const &, rtl_ModuleCount *) - SAL_THROW(()) -{ - return new Factory; -} - } } diff --git a/configmgr/source/configurationregistry.hxx b/configmgr/source/configurationregistry.hxx index 6cba122188b1..417c519b97f4 100644 --- a/configmgr/source/configurationregistry.hxx +++ b/configmgr/source/configurationregistry.hxx @@ -30,28 +30,28 @@ #include "com/sun/star/uno/Reference.hxx" #include "com/sun/star/uno/Sequence.hxx" -#include "cppuhelper/factory.hxx" -#include "rtl/unload.h" #include "sal/types.h" -namespace com { namespace sun { namespace star { namespace lang { - class XSingleComponentFactory; -} } } } +namespace com { namespace sun { namespace star { + namespace uno { + class XComponentContext; + class XInterface; + } +} } } namespace rtl { class OUString; } namespace configmgr { namespace configuration_registry { +com::sun::star::uno::Reference< com::sun::star::uno::XInterface > SAL_CALL +create( + com::sun::star::uno::Reference< com::sun::star::uno::XComponentContext > + const & context); + rtl::OUString SAL_CALL getImplementationName(); com::sun::star::uno::Sequence< rtl::OUString > SAL_CALL getSupportedServiceNames(); -com::sun::star::uno::Reference< com::sun::star::lang::XSingleComponentFactory > -SAL_CALL createFactory( - cppu::ComponentFactoryFunc, rtl::OUString const &, - com::sun::star::uno::Sequence< rtl::OUString > const &, rtl_ModuleCount *) - SAL_THROW(()); - } } #endif diff --git a/configmgr/source/defaultprovider.cxx b/configmgr/source/defaultprovider.cxx index d069663290e8..9079d4736a6c 100644 --- a/configmgr/source/defaultprovider.cxx +++ b/configmgr/source/defaultprovider.cxx @@ -28,24 +28,16 @@ #include "precompiled_configmgr.hxx" #include "sal/config.h" -#include "boost/noncopyable.hpp" -#include "com/sun/star/lang/XSingleComponentFactory.hpp" -#include "com/sun/star/uno/Any.hxx" -#include "com/sun/star/uno/Exception.hpp" #include "com/sun/star/uno/Reference.hxx" -#include "com/sun/star/uno/RuntimeException.hpp" #include "com/sun/star/uno/Sequence.hxx" #include "com/sun/star/uno/XComponentContext.hpp" #include "com/sun/star/uno/XInterface.hpp" -#include "cppuhelper/factory.hxx" -#include "cppuhelper/implbase1.hxx" -#include "cppuhelper/weak.hxx" -#include "sal/types.h" -#include "rtl/unload.h" +#include "osl/mutex.hxx" #include "rtl/ustring.h" #include "rtl/ustring.hxx" #include "configurationprovider.hxx" +#include "defaultprovider.hxx" #include "lock.hxx" namespace configmgr { namespace default_provider { @@ -54,58 +46,17 @@ namespace { namespace css = com::sun::star; -class Factory: - public cppu::WeakImplHelper1< css::lang::XSingleComponentFactory >, - private boost::noncopyable -{ -public: - Factory() {} - -private: - virtual ~Factory() {} - - virtual css::uno::Reference< css::uno::XInterface > SAL_CALL - createInstanceWithContext( - css::uno::Reference< css::uno::XComponentContext > const & Context) - throw (css::uno::Exception, css::uno::RuntimeException); - - virtual css::uno::Reference< css::uno::XInterface > SAL_CALL - createInstanceWithArgumentsAndContext( - css::uno::Sequence< css::uno::Any > const & Arguments, - css::uno::Reference< css::uno::XComponentContext > const & Context) - throw (css::uno::Exception, css::uno::RuntimeException); -}; - -css::uno::Reference< css::uno::XInterface > Factory::createInstanceWithContext( - css::uno::Reference< css::uno::XComponentContext > const & Context) - throw (css::uno::Exception, css::uno::RuntimeException) -{ - return createInstanceWithArgumentsAndContext( - css::uno::Sequence< css::uno::Any >(), Context); } -css::uno::Reference< css::uno::XInterface > -Factory::createInstanceWithArgumentsAndContext( - css::uno::Sequence< css::uno::Any > const & Arguments, - css::uno::Reference< css::uno::XComponentContext > const & Context) - throw (css::uno::Exception, css::uno::RuntimeException) +css::uno::Reference< css::uno::XInterface > create( + css::uno::Reference< css::uno::XComponentContext > const & context) { - if (Arguments.getLength() != 0) { - throw css::uno::Exception( - rtl::OUString( - RTL_CONSTASCII_USTRINGPARAM( - "com.sun.star.configuration.DefaultProvider must be" - " instantiated without arguments")), - static_cast< cppu::OWeakObject * >(this)); - } osl::MutexGuard guard(lock); static css::uno::Reference< css::uno::XInterface > singleton( - configuration_provider::createDefault(Context)); + configuration_provider::createDefault(context)); return singleton; } -} - rtl::OUString getImplementationName() { return rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( @@ -119,13 +70,4 @@ css::uno::Sequence< rtl::OUString > getSupportedServiceNames() { return css::uno::Sequence< rtl::OUString >(&name, 1); } -css::uno::Reference< css::lang::XSingleComponentFactory > -SAL_CALL createFactory( - cppu::ComponentFactoryFunc, rtl::OUString const &, - css::uno::Sequence< rtl::OUString > const &, rtl_ModuleCount *) - SAL_THROW(()) -{ - return new Factory; -} - } } diff --git a/configmgr/source/defaultprovider.hxx b/configmgr/source/defaultprovider.hxx index 7b267a80b42e..f678931d35fe 100644 --- a/configmgr/source/defaultprovider.hxx +++ b/configmgr/source/defaultprovider.hxx @@ -32,28 +32,28 @@ #include "com/sun/star/uno/Reference.hxx" #include "com/sun/star/uno/Sequence.hxx" -#include "cppuhelper/factory.hxx" -#include "rtl/unload.h" #include "sal/types.h" -namespace com { namespace sun { namespace star { namespace lang { - class XSingleComponentFactory; -} } } } +namespace com { namespace sun { namespace star { + namespace uno { + class XComponentContext; + class XInterface; + } +} } } namespace rtl { class OUString; } namespace configmgr { namespace default_provider { +com::sun::star::uno::Reference< com::sun::star::uno::XInterface > SAL_CALL +create( + com::sun::star::uno::Reference< com::sun::star::uno::XComponentContext > + const & context); + rtl::OUString SAL_CALL getImplementationName(); com::sun::star::uno::Sequence< rtl::OUString > SAL_CALL getSupportedServiceNames(); -com::sun::star::uno::Reference< com::sun::star::lang::XSingleComponentFactory > -SAL_CALL createFactory( - cppu::ComponentFactoryFunc, rtl::OUString const &, - com::sun::star::uno::Sequence< rtl::OUString > const &, rtl_ModuleCount *) - SAL_THROW(()); - } } #endif diff --git a/configmgr/source/services.cxx b/configmgr/source/services.cxx index b1ef8d2169bb..dd01189be6e2 100644 --- a/configmgr/source/services.cxx +++ b/configmgr/source/services.cxx @@ -32,6 +32,7 @@ #include "com/sun/star/uno/Reference.hxx" #include "com/sun/star/uno/XComponentContext.hpp" #include "com/sun/star/uno/XInterface.hpp" +#include "cppuhelper/factory.hxx" #include "cppuhelper/implementationentry.hxx" #include "osl/diagnose.h" #include "uno/lbnames.h" @@ -58,15 +59,17 @@ static cppu::ImplementationEntry const services[] = { { &dummy, &configmgr::configuration_provider::getImplementationName, &configmgr::configuration_provider::getSupportedServiceNames, &configmgr::configuration_provider::createFactory, 0, 0 }, - { &dummy, &configmgr::default_provider::getImplementationName, + { &configmgr::default_provider::create, + &configmgr::default_provider::getImplementationName, &configmgr::default_provider::getSupportedServiceNames, - &configmgr::default_provider::createFactory, 0, 0 }, - { &dummy, &configmgr::configuration_registry::getImplementationName, + &cppu::createSingleComponentFactory, 0, 0 }, + { &configmgr::configuration_registry::create, + &configmgr::configuration_registry::getImplementationName, &configmgr::configuration_registry::getSupportedServiceNames, - &configmgr::configuration_registry::createFactory, 0, 0 }, - { &dummy, &configmgr::update::getImplementationName, + &cppu::createSingleComponentFactory, 0, 0 }, + { &configmgr::update::create, &configmgr::update::getImplementationName, &configmgr::update::getSupportedServiceNames, - &configmgr::update::createFactory, 0, 0 }, + &cppu::createSingleComponentFactory, 0, 0 }, { 0, 0, 0, 0, 0, 0 } }; diff --git a/configmgr/source/update.cxx b/configmgr/source/update.cxx index 403b761a5abd..73074aa7c338 100644 --- a/configmgr/source/update.cxx +++ b/configmgr/source/update.cxx @@ -32,20 +32,15 @@ #include "boost/noncopyable.hpp" #include "com/sun/star/configuration/XUpdate.hpp" -#include "com/sun/star/lang/XSingleComponentFactory.hpp" -#include "com/sun/star/uno/Any.hxx" -#include "com/sun/star/uno/Exception.hpp" #include "com/sun/star/uno/Reference.hxx" #include "com/sun/star/uno/RuntimeException.hpp" #include "com/sun/star/uno/Sequence.hxx" #include "com/sun/star/uno/XComponentContext.hpp" #include "com/sun/star/uno/XInterface.hpp" -#include "cppuhelper/factory.hxx" #include "cppuhelper/implbase1.hxx" #include "cppuhelper/weak.hxx" #include "osl/mutex.hxx" #include "rtl/ref.hxx" -#include "rtl/unload.h" #include "rtl/ustring.h" #include "rtl/ustring.hxx" #include "sal/types.h" @@ -155,55 +150,14 @@ void Service::insertModificationXcuFile( bc.send(); } -class Factory: - public cppu::WeakImplHelper1< css::lang::XSingleComponentFactory >, - private boost::noncopyable -{ -public: - Factory() {} - -private: - virtual ~Factory() {} - - virtual css::uno::Reference< css::uno::XInterface > SAL_CALL - createInstanceWithContext( - css::uno::Reference< css::uno::XComponentContext > const & Context) - throw (css::uno::Exception, css::uno::RuntimeException); - - virtual css::uno::Reference< css::uno::XInterface > SAL_CALL - createInstanceWithArgumentsAndContext( - css::uno::Sequence< css::uno::Any > const & Arguments, - css::uno::Reference< css::uno::XComponentContext > const & Context) - throw (css::uno::Exception, css::uno::RuntimeException); -}; - -css::uno::Reference< css::uno::XInterface > Factory::createInstanceWithContext( - css::uno::Reference< css::uno::XComponentContext > const & Context) - throw (css::uno::Exception, css::uno::RuntimeException) -{ - return createInstanceWithArgumentsAndContext( - css::uno::Sequence< css::uno::Any >(), Context); } -css::uno::Reference< css::uno::XInterface > -Factory::createInstanceWithArgumentsAndContext( - css::uno::Sequence< css::uno::Any > const & Arguments, +css::uno::Reference< css::uno::XInterface > create( css::uno::Reference< css::uno::XComponentContext > const &) - throw (css::uno::Exception, css::uno::RuntimeException) { - if (Arguments.getLength() != 0) { - throw css::uno::Exception( - rtl::OUString( - RTL_CONSTASCII_USTRINGPARAM( - "com.sun.star.comp.configuration.Update must be" - " instantiated without arguments")), - static_cast< cppu::OWeakObject * >(this)); - } return static_cast< cppu::OWeakObject * >(new Service); } -} - rtl::OUString getImplementationName() { return rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("com.sun.star.comp.configuration.Update")); @@ -216,12 +170,4 @@ css::uno::Sequence< rtl::OUString > getSupportedServiceNames() { return css::uno::Sequence< rtl::OUString >(&name, 1); } -css::uno::Reference< css::lang::XSingleComponentFactory > createFactory( - cppu::ComponentFactoryFunc, rtl::OUString const &, - css::uno::Sequence< rtl::OUString > const &, rtl_ModuleCount *) - SAL_THROW(()) -{ - return new Factory; -} - } } diff --git a/configmgr/source/update.hxx b/configmgr/source/update.hxx index faa5c86b15fa..a60264e67ac3 100644 --- a/configmgr/source/update.hxx +++ b/configmgr/source/update.hxx @@ -32,28 +32,28 @@ #include "com/sun/star/uno/Reference.hxx" #include "com/sun/star/uno/Sequence.hxx" -#include "cppuhelper/factory.hxx" -#include "rtl/unload.h" #include "sal/types.h" -namespace com { namespace sun { namespace star { namespace lang { - class XSingleComponentFactory; -} } } } +namespace com { namespace sun { namespace star { + namespace uno { + class XComponentContext; + class XInterface; + } +} } } namespace rtl { class OUString; } namespace configmgr { namespace update { +com::sun::star::uno::Reference< com::sun::star::uno::XInterface > SAL_CALL +create( + com::sun::star::uno::Reference< com::sun::star::uno::XComponentContext > + const &); + rtl::OUString SAL_CALL getImplementationName(); com::sun::star::uno::Sequence< rtl::OUString > SAL_CALL getSupportedServiceNames(); -com::sun::star::uno::Reference< com::sun::star::lang::XSingleComponentFactory > -SAL_CALL createFactory( - cppu::ComponentFactoryFunc, rtl::OUString const &, - com::sun::star::uno::Sequence< rtl::OUString > const &, rtl_ModuleCount *) - SAL_THROW(()); - } } #endif |