diff options
author | Matúš Kukan <matus.kukan@gmail.com> | 2015-12-26 22:18:38 +0100 |
---|---|---|
committer | Matúš Kukan <matus.kukan@gmail.com> | 2015-12-27 13:55:29 +0100 |
commit | 9e3c7725909ebce86e30f1e774d5f9e1d761c16a (patch) | |
tree | 92a8b524558c792b19d674d34b2567b8d58ceb79 /comphelper | |
parent | 6b723132daacae5e007589ffdbe78d7569b06fa0 (diff) |
tdf#74608: Constructor function for OfficeRestartManager singleton
Change-Id: I6c1383c292418b6744dacee95d4f289a6ca1c781
Diffstat (limited to 'comphelper')
-rw-r--r-- | comphelper/source/inc/comphelper_services.hxx | 1 | ||||
-rw-r--r-- | comphelper/source/misc/comphelper_services.cxx | 1 | ||||
-rw-r--r-- | comphelper/source/misc/officerestartmanager.cxx | 59 | ||||
-rw-r--r-- | comphelper/source/misc/officerestartmanager.hxx | 10 | ||||
-rw-r--r-- | comphelper/util/comphelp.component | 3 |
5 files changed, 29 insertions, 45 deletions
diff --git a/comphelper/source/inc/comphelper_services.hxx b/comphelper/source/inc/comphelper_services.hxx index 77d4dd905492..08ed94d31d2c 100644 --- a/comphelper/source/inc/comphelper_services.hxx +++ b/comphelper/source/inc/comphelper_services.hxx @@ -27,7 +27,6 @@ void createRegistryInfo_IndexedPropertyValuesContainer(); void createRegistryInfo_Map(); void createRegistryInfo_NamedPropertyValuesContainer(); void createRegistryInfo_OInstanceLocker(); -void createRegistryInfo_OOfficeRestartManager(); void createRegistryInfo_OPropertyBag(); void createRegistryInfo_OSimpleLogRing(); void createRegistryInfo_OfficeInstallationDirectories(); diff --git a/comphelper/source/misc/comphelper_services.cxx b/comphelper/source/misc/comphelper_services.cxx index e86055cc836a..122f192cdd94 100644 --- a/comphelper/source/misc/comphelper_services.cxx +++ b/comphelper/source/misc/comphelper_services.cxx @@ -45,7 +45,6 @@ namespace comphelper { namespace module createRegistryInfo_OInstanceLocker(); createRegistryInfo_Map(); createRegistryInfo_OSimpleLogRing(); - createRegistryInfo_OOfficeRestartManager(); } }; diff --git a/comphelper/source/misc/officerestartmanager.cxx b/comphelper/source/misc/officerestartmanager.cxx index 54bdac95ff1c..a8895285a0fb 100644 --- a/comphelper/source/misc/officerestartmanager.cxx +++ b/comphelper/source/misc/officerestartmanager.cxx @@ -23,9 +23,8 @@ #include <com/sun/star/frame/Desktop.hpp> #include <com/sun/star/beans/XPropertySet.hpp> -#include <comphelper_module.hxx> -#include <comphelper_services.hxx> #include <cppuhelper/supportsservice.hxx> +#include <rtl/ref.hxx> #include "officerestartmanager.hxx" using namespace ::com::sun::star; @@ -33,31 +32,6 @@ using namespace ::com::sun::star; namespace comphelper { - -uno::Sequence< OUString > SAL_CALL OOfficeRestartManager::getSupportedServiceNames_static() -{ - uno::Sequence<OUString> aResult { getServiceName_static() }; - return aResult; -} - - -OUString SAL_CALL OOfficeRestartManager::getImplementationName_static() -{ - return OUString( "com.sun.star.comp.task.OfficeRestartManager" ); -} - - -OUString SAL_CALL OOfficeRestartManager::getServiceName_static() -{ - return OUString( "com.sun.star.comp.task.OfficeRestartManager" ); -} - - -uno::Reference< uno::XInterface > SAL_CALL OOfficeRestartManager::Create( const uno::Reference< uno::XComponentContext >& rxContext ) -{ - return static_cast< cppu::OWeakObject* >( new OOfficeRestartManager( rxContext ) ); -} - // XRestartManager void SAL_CALL OOfficeRestartManager::requestRestart( const uno::Reference< task::XInteractionHandler >& /* xInteractionHandler */ ) @@ -160,7 +134,7 @@ void SAL_CALL OOfficeRestartManager::notify( const uno::Any& /* aData */ ) OUString SAL_CALL OOfficeRestartManager::getImplementationName() throw (uno::RuntimeException, std::exception) { - return getImplementationName_static(); + return OUString("com.sun.star.comp.task.OfficeRestartManager"); } sal_Bool SAL_CALL OOfficeRestartManager::supportsService( const OUString& aServiceName ) throw (uno::RuntimeException, std::exception) @@ -170,15 +144,36 @@ sal_Bool SAL_CALL OOfficeRestartManager::supportsService( const OUString& aServi uno::Sequence< OUString > SAL_CALL OOfficeRestartManager::getSupportedServiceNames() throw (uno::RuntimeException, std::exception) { - return getSupportedServiceNames_static(); + return { "com.sun.star.comp.task.OfficeRestartManager" }; } } // namespace comphelper -void createRegistryInfo_OOfficeRestartManager() +namespace { + +struct Instance { + explicit Instance( + css::uno::Reference<css::uno::XComponentContext> const & context): + instance(static_cast<cppu::OWeakObject *>(new comphelper::OOfficeRestartManager(context))) + {} + + rtl::Reference<css::uno::XInterface> instance; +}; + +struct Singleton: + public rtl::StaticWithArg< + Instance, css::uno::Reference<css::uno::XComponentContext>, Singleton> +{}; + +} + +extern "C" SAL_DLLPUBLIC_EXPORT css::uno::XInterface * SAL_CALL +com_sun_star_comp_task_OfficeRestartManager( + css::uno::XComponentContext *context, + css::uno::Sequence<css::uno::Any> const &) { - static ::comphelper::module::OAutoRegistration< ::comphelper::OOfficeRestartManager > aAutoRegistration; - static ::comphelper::module::OSingletonRegistration< ::comphelper::OOfficeRestartManager > aSingletonRegistration; + return cppu::acquire(static_cast<cppu::OWeakObject *>( + Singleton::get(context).instance.get())); } /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/comphelper/source/misc/officerestartmanager.hxx b/comphelper/source/misc/officerestartmanager.hxx index 15a050f3855c..43d707c36363 100644 --- a/comphelper/source/misc/officerestartmanager.hxx +++ b/comphelper/source/misc/officerestartmanager.hxx @@ -51,16 +51,6 @@ public: virtual ~OOfficeRestartManager() {} - static css::uno::Sequence< OUString > SAL_CALL - getSupportedServiceNames_static(); - - static OUString SAL_CALL getImplementationName_static(); - - static OUString SAL_CALL getServiceName_static(); - - static css::uno::Reference< css::uno::XInterface > SAL_CALL - Create( const css::uno::Reference< css::uno::XComponentContext >& rxContext ); - // XRestartManager virtual void SAL_CALL requestRestart( const css::uno::Reference< css::task::XInteractionHandler >& xInteractionHandler ) throw (css::uno::Exception, css::uno::RuntimeException, std::exception) override; virtual sal_Bool SAL_CALL isRestartRequested( sal_Bool bInitialized ) throw (css::uno::Exception, css::uno::RuntimeException, std::exception) override; diff --git a/comphelper/util/comphelp.component b/comphelper/util/comphelp.component index 4def104c426c..95432c655704 100644 --- a/comphelper/util/comphelp.component +++ b/comphelper/util/comphelp.component @@ -47,7 +47,8 @@ <service name="com.sun.star.logging.SimpleLogRing"/> <singleton name="com.sun.star.logging.DocumentIOLogRing"/> </implementation> - <implementation name="com.sun.star.comp.task.OfficeRestartManager"> + <implementation name="com.sun.star.comp.task.OfficeRestartManager" + constructor="com_sun_star_comp_task_OfficeRestartManager"> <service name="com.sun.star.comp.task.OfficeRestartManager"/> <singleton name="com.sun.star.task.OfficeRestartManager"/> </implementation> |