summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorStephan Bergmann <sbergman@redhat.com>2012-08-28 09:58:56 +0200
committerStephan Bergmann <sbergman@redhat.com>2012-09-05 14:56:18 +0200
commit55aa40bcd6ae3116c63a0eac18056bcfd011f43a (patch)
tree847c45045ae4d1829f38046d9bd31c08971312ec
parent24f691867d02e853153a53e49276c2a8c30ea1fe (diff)
Quick and dirty adaption of ModuleManager to WeakImplHelper
...to better be able to change its set of implemented interfaces later on. Some potential for further clean up: * a generic helper for supportsService; * remove need for impl_createFactory; * base impl_createInstance on XComponentContext instead of XMultiServiceFactory; * replace ThreadHelpBase with a plain osl::Mutex. Change-Id: Ia2cbd14872a609c2ed57d9ce58b546f087c2fdfb
-rw-r--r--framework/inc/services/modulemanager.hxx65
-rw-r--r--framework/source/services/modulemanager.cxx83
2 files changed, 92 insertions, 56 deletions
diff --git a/framework/inc/services/modulemanager.hxx b/framework/inc/services/modulemanager.hxx
index 7d5950abf501..d50b0da116df 100644
--- a/framework/inc/services/modulemanager.hxx
+++ b/framework/inc/services/modulemanager.hxx
@@ -20,23 +20,23 @@
#ifndef __FRAMEWORK_SERVICES_MODULEMANAGER_HXX_
#define __FRAMEWORK_SERVICES_MODULEMANAGER_HXX_
+#include "sal/config.h"
+
#include <threadhelp/threadhelpbase.hxx>
-#include <macros/xinterface.hxx>
-#include <macros/xtypeprovider.hxx>
-#include <macros/xserviceinfo.hxx>
-#include <general.h>
-#include <general.h>
-#include <stdtypes.h>
-
-#include <com/sun/star/uno/XInterface.hpp>
-#include <com/sun/star/lang/XTypeProvider.hpp>
+
+#include <boost/noncopyable.hpp>
#include <com/sun/star/lang/XServiceInfo.hpp>
#include <com/sun/star/lang/XMultiServiceFactory.hpp>
#include <com/sun/star/frame/XModuleManager.hpp>
#include <com/sun/star/container/XNameReplace.hpp>
#include <com/sun/star/container/XContainerQuery.hpp>
+#include <cppuhelper/implbase4.hxx>
+
+namespace com { namespace sun { namespace star { namespace lang {
+ class XSingleServiceFactory;
+} } } }
-#include <cppuhelper/weak.hxx>
+namespace css = com::sun::star;
//_______________________________________________
// definition
@@ -48,14 +48,11 @@ namespace framework
/**
implements the service com.sun.star.frame.ModuleManager
*/
-class ModuleManager : public css::lang::XTypeProvider
- , public css::lang::XServiceInfo
- , public css::frame::XModuleManager
- , public css::container::XNameReplace // => XNameAccess, XElementAccess
- , public css::container::XContainerQuery
- // attention! Must be the first base class to guarentee right initialize lock ...
- , private ThreadHelpBase
- , public ::cppu::OWeakObject
+class ModuleManager:
+ public cppu::WeakImplHelper4<
+ css::lang::XServiceInfo, css::frame::XModuleManager,
+ css::container::XNameReplace, css::container::XContainerQuery >,
+ private ThreadHelpBase, private boost::noncopyable
{
//___________________________________________
// member
@@ -80,13 +77,37 @@ class ModuleManager : public css::lang::XTypeProvider
public:
+ static rtl::OUString SAL_CALL impl_getStaticImplementationName();
+
+ static css::uno::Reference< css::lang::XSingleServiceFactory > SAL_CALL
+ impl_createFactory(
+ css::uno::Reference< css::lang::XMultiServiceFactory > const &
+ manager);
+
+ private:
+
+ static css::uno::Sequence< rtl::OUString >
+ impl_getSupportedServiceNames();
+
+ static css::uno::Reference< css::uno::XInterface > SAL_CALL
+ impl_createInstance(
+ css::uno::Reference< css::lang::XMultiServiceFactory > const &
+ manager);
+
ModuleManager(const css::uno::Reference< css::lang::XMultiServiceFactory >& xSMGR);
+
virtual ~ModuleManager( );
- // XInterface, XTypeProvider, XServiceInfo
- FWK_DECLARE_XINTERFACE
- FWK_DECLARE_XTYPEPROVIDER
- DECLARE_XSERVICEINFO
+ // XServiceInfo
+ virtual rtl::OUString SAL_CALL getImplementationName()
+ throw (css::uno::RuntimeException);
+
+ virtual sal_Bool SAL_CALL supportsService(
+ rtl::OUString const & ServiceName)
+ throw (css::uno::RuntimeException);
+
+ virtual css::uno::Sequence< rtl::OUString > SAL_CALL
+ getSupportedServiceNames() throw (css::uno::RuntimeException);
// XModuleManager
virtual ::rtl::OUString SAL_CALL identify(const css::uno::Reference< css::uno::XInterface >& xModule)
diff --git a/framework/source/services/modulemanager.cxx b/framework/source/services/modulemanager.cxx
index ce2d959a2d25..d5d4522eba90 100644
--- a/framework/source/services/modulemanager.cxx
+++ b/framework/source/services/modulemanager.cxx
@@ -51,40 +51,31 @@ namespace framework
static const char CFGPATH_FACTORIES[] = "/org.openoffice.Setup/Office/Factories";
static const char MODULEPROP_IDENTIFIER[] = "ooSetupFactoryModuleIdentifier";
-DEFINE_XINTERFACE_7(ModuleManager ,
- OWeakObject ,
- DIRECT_INTERFACE(css::lang::XTypeProvider ),
- DIRECT_INTERFACE(css::lang::XServiceInfo ),
- DIRECT_INTERFACE(css::container::XNameReplace ),
- DIRECT_INTERFACE(css::container::XNameAccess ),
- DIRECT_INTERFACE(css::container::XElementAccess ),
- DIRECT_INTERFACE(css::container::XContainerQuery),
- DIRECT_INTERFACE(css::frame::XModuleManager ))
-
-DEFINE_XTYPEPROVIDER_7(ModuleManager ,
- css::lang::XTypeProvider ,
- css::lang::XServiceInfo ,
- css::container::XNameReplace ,
- css::container::XNameAccess ,
- css::container::XElementAccess ,
- css::container::XContainerQuery,
- css::frame::XModuleManager )
-
-DEFINE_XSERVICEINFO_ONEINSTANCESERVICE(ModuleManager ,
- ::cppu::OWeakObject ,
- SERVICENAME_MODULEMANAGER ,
- IMPLEMENTATIONNAME_MODULEMANAGER)
-
-DEFINE_INIT_SERVICE(
- ModuleManager,
- {
- /*Attention
- I think we don't need any mutex or lock here ... because we are called by our own static method impl_createInstance()
- to create a new instance of this class by our own supported service factory.
- see macro DEFINE_XSERVICEINFO_MULTISERVICE and "impl_initService()" for further informations!
- */
- }
- )
+rtl::OUString ModuleManager::impl_getStaticImplementationName() {
+ return IMPLEMENTATIONNAME_MODULEMANAGER;
+}
+
+css::uno::Reference< css::lang::XSingleServiceFactory >
+ModuleManager::impl_createFactory(
+ css::uno::Reference< css::lang::XMultiServiceFactory > const & manager)
+{
+ return cppu::createSingleFactory(
+ manager, impl_getStaticImplementationName(), &impl_createInstance,
+ impl_getSupportedServiceNames());
+}
+
+css::uno::Sequence< rtl::OUString >
+ModuleManager::impl_getSupportedServiceNames() {
+ css::uno::Sequence< rtl::OUString > s(1);
+ s[0] = SERVICENAME_MODULEMANAGER;
+ return s;
+}
+
+css::uno::Reference< css::uno::XInterface > ModuleManager::impl_createInstance(
+ css::uno::Reference< css::lang::XMultiServiceFactory > const & manager)
+{
+ return static_cast< cppu::OWeakObject * >(new ModuleManager(manager));
+}
ModuleManager::ModuleManager(const css::uno::Reference< css::lang::XMultiServiceFactory >& xSMGR)
: ThreadHelpBase( )
@@ -98,6 +89,30 @@ ModuleManager::~ModuleManager()
m_xCFG.clear();
}
+rtl::OUString ModuleManager::getImplementationName()
+ throw (css::uno::RuntimeException)
+{
+ return impl_getStaticImplementationName();
+}
+
+sal_Bool ModuleManager::supportsService(rtl::OUString const & ServiceName)
+ throw (css::uno::RuntimeException)
+{
+ css::uno::Sequence< rtl::OUString > s(getSupportedServiceNames());
+ for (sal_Int32 i = 0; i != s.getLength(); ++i) {
+ if (s[i] == ServiceName) {
+ return true;
+ }
+ }
+ return false;
+}
+
+css::uno::Sequence< rtl::OUString > ModuleManager::getSupportedServiceNames()
+ throw (css::uno::RuntimeException)
+{
+ return impl_getSupportedServiceNames();
+}
+
::rtl::OUString SAL_CALL ModuleManager::identify(const css::uno::Reference< css::uno::XInterface >& xModule)
throw(css::lang::IllegalArgumentException,
css::frame::UnknownModuleException,