diff options
author | Noel Grandin <noel@peralex.com> | 2012-10-18 11:37:13 +0200 |
---|---|---|
committer | Stephan Bergmann <sbergman@redhat.com> | 2012-10-29 17:32:57 +0100 |
commit | eebcaa02585bda0656ca1032082c4dd676de732d (patch) | |
tree | dcadfa83e28c72bfd8becbe2eddef0b476d29056 /sfx2 | |
parent | 96b60cf69bf973136c5755fe741a6c210b4915f7 (diff) |
fdo#46808, use service constructor for task::JobExecutor
Also remove some unnecessary fields.
Diffstat (limited to 'sfx2')
-rw-r--r-- | sfx2/inc/sfx2/sfxuno.hxx | 57 | ||||
-rw-r--r-- | sfx2/source/inc/eventsupplier.hxx | 6 | ||||
-rw-r--r-- | sfx2/source/notify/eventsupplier.cxx | 18 |
3 files changed, 66 insertions, 15 deletions
diff --git a/sfx2/inc/sfx2/sfxuno.hxx b/sfx2/inc/sfx2/sfxuno.hxx index 9e68dc4f913d..103806456caf 100644 --- a/sfx2/inc/sfx2/sfxuno.hxx +++ b/sfx2/inc/sfx2/sfxuno.hxx @@ -564,6 +564,63 @@ bool GetEncryptionData_Impl( const SfxItemSet* pSet, ::com::sun::star::uno::Sequ } //************************************************************************************************************************ +// implementation of XServiceInfo::getImplementationName() +// XServiceInfo::supportsService() +// XServiceInfo::getSupportedServiceNames() +// static xxx::impl_getStaticSupportedServiceNames() +// static xxx::impl_getStaticImplementationName() +// static xxx::impl_createInstance() +//************************************************************************************************************************ +#define SFX_IMPL_XSERVICEINFO_CTX( IMPLCLASS, IMPLSERVICENAME, IMPLNAME ) \ + \ + /* XServiceInfo */ \ + rtl::OUString SAL_CALL IMPLCLASS::getImplementationName() throw( UNORUNTIMEEXCEPTION ) \ + { \ + return impl_getStaticImplementationName(); \ + } \ + \ + /* XServiceInfo */ \ + sal_Bool SAL_CALL IMPLCLASS::supportsService( const rtl::OUString& sServiceName ) throw( UNORUNTIMEEXCEPTION ) \ + { \ + UNOSEQUENCE< rtl::OUString > seqServiceNames = getSupportedServiceNames(); \ + const rtl::OUString* pArray = seqServiceNames.getConstArray(); \ + for ( sal_Int32 nCounter=0; nCounter<seqServiceNames.getLength(); nCounter++ ) \ + { \ + if ( pArray[nCounter] == sServiceName ) \ + { \ + return sal_True ; \ + } \ + } \ + return sal_False ; \ + } \ + \ + /* XServiceInfo */ \ + UNOSEQUENCE< rtl::OUString > SAL_CALL IMPLCLASS::getSupportedServiceNames() throw( UNORUNTIMEEXCEPTION ) \ + { \ + return impl_getStaticSupportedServiceNames(); \ + } \ + \ + /* Helper for XServiceInfo */ \ + UNOSEQUENCE< rtl::OUString > IMPLCLASS::impl_getStaticSupportedServiceNames() \ + { \ + UNOSEQUENCE< rtl::OUString > seqServiceNames( 1 ); \ + seqServiceNames.getArray() [0] = rtl::OUString::createFromAscii( IMPLSERVICENAME ); \ + return seqServiceNames ; \ + } \ + \ + /* Helper for XServiceInfo */ \ + rtl::OUString IMPLCLASS::impl_getStaticImplementationName() \ + { \ + return rtl::OUString::createFromAscii( IMPLNAME ); \ + } \ + \ + /* Helper for registry */ \ + UNOREFERENCE< UNOXINTERFACE > SAL_CALL IMPLCLASS::impl_createInstance( const UNOREFERENCE< UNOXMULTISERVICEFACTORY >& xServiceManager ) throw( UNOEXCEPTION ) \ + { \ + return UNOREFERENCE< UNOXINTERFACE >( *new IMPLCLASS( comphelper::getComponentContext(xServiceManager) ) ); \ + } + +//************************************************************************************************************************ // definition of createFactory() for MultiServices //************************************************************************************************************************ #define SFX_IMPL_SINGLEFACTORY( IMPLCLASS ) \ diff --git a/sfx2/source/inc/eventsupplier.hxx b/sfx2/source/inc/eventsupplier.hxx index 2a8aea49fc04..b00a2a02a41c 100644 --- a/sfx2/source/inc/eventsupplier.hxx +++ b/sfx2/source/inc/eventsupplier.hxx @@ -142,7 +142,6 @@ class ModelCollectionEnumeration : public ModelCollectionMutexBase // member //------------------------------------------------------------------------- private: - ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory > m_xSMGR; TModelList m_lModels; TModelList::iterator m_pEnumerationIt; @@ -150,7 +149,7 @@ class ModelCollectionEnumeration : public ModelCollectionMutexBase // native interface //------------------------------------------------------------------------- public: - ModelCollectionEnumeration(const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >& xSMGR); + ModelCollectionEnumeration(); virtual ~ModelCollectionEnumeration(); void setModelList(const TModelList& rList); @@ -177,7 +176,6 @@ class SfxGlobalEvents_Impl : public ModelCollectionMutexBase , ::com::sun::star::document::XEventListener > { - ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory > m_xSMGR; ::com::sun::star::uno::Reference< ::com::sun::star::container::XNameReplace > m_xEvents; ::com::sun::star::uno::WeakReference< ::com::sun::star::document::XEventListener > m_xJobExecutorListener; OINTERFACECONTAINERHELPER m_aLegacyListeners; @@ -186,7 +184,7 @@ class SfxGlobalEvents_Impl : public ModelCollectionMutexBase GlobalEventConfig* pImp; public: - SfxGlobalEvents_Impl(const com::sun::star::uno::Reference < ::com::sun::star::lang::XMultiServiceFactory >& xSMGR); + SfxGlobalEvents_Impl(const com::sun::star::uno::Reference < ::com::sun::star::uno::XComponentContext >& rxContext); virtual ~SfxGlobalEvents_Impl(); SFX_DECL_XSERVICEINFO diff --git a/sfx2/source/notify/eventsupplier.cxx b/sfx2/source/notify/eventsupplier.cxx index 2b4508e891fa..625fedbd5cfa 100644 --- a/sfx2/source/notify/eventsupplier.cxx +++ b/sfx2/source/notify/eventsupplier.cxx @@ -21,6 +21,7 @@ #include <com/sun/star/util/URL.hpp> +#include <com/sun/star/task/JobExecutor.hpp> #include <com/sun/star/util/URLTransformer.hpp> #include <com/sun/star/util/XURLTransformer.hpp> #include <tools/urlobj.hxx> @@ -496,9 +497,8 @@ void SfxEvents_Impl::NormalizeMacro( const ::comphelper::NamedValueCollection& i } } -ModelCollectionEnumeration::ModelCollectionEnumeration(const css::uno::Reference< css::lang::XMultiServiceFactory >& xSMGR) +ModelCollectionEnumeration::ModelCollectionEnumeration() : ModelCollectionMutexBase( ) - , m_xSMGR (xSMGR ) , m_pEnumerationIt (m_lModels.begin()) { } @@ -545,13 +545,12 @@ css::uno::Any SAL_CALL ModelCollectionEnumeration::nextElement() return css::uno::makeAny(xModel); } -SFX_IMPL_XSERVICEINFO( SfxGlobalEvents_Impl, "com.sun.star.frame.GlobalEventBroadcaster", "com.sun.star.comp.sfx2.GlobalEventBroadcaster" ) +SFX_IMPL_XSERVICEINFO_CTX( SfxGlobalEvents_Impl, "com.sun.star.frame.GlobalEventBroadcaster", "com.sun.star.comp.sfx2.GlobalEventBroadcaster" ) SFX_IMPL_ONEINSTANCEFACTORY( SfxGlobalEvents_Impl ); //----------------------------------------------------------------------------- -SfxGlobalEvents_Impl::SfxGlobalEvents_Impl( const com::sun::star::uno::Reference < ::com::sun::star::lang::XMultiServiceFactory >& xSMGR) +SfxGlobalEvents_Impl::SfxGlobalEvents_Impl( const css::uno::Reference < css::uno::XComponentContext >& rxContext) : ModelCollectionMutexBase( ) - , m_xSMGR (xSMGR ) , m_aLegacyListeners (m_aLock) , m_aDocumentListeners (m_aLock) , pImp (0 ) @@ -560,9 +559,7 @@ SfxGlobalEvents_Impl::SfxGlobalEvents_Impl( const com::sun::star::uno::Reference SFX_APP(); pImp = new GlobalEventConfig(); m_xEvents = pImp; - m_xJobExecutorListener = css::uno::Reference< css::document::XEventListener >( - xSMGR->createInstance(::rtl::OUString("com.sun.star.task.JobExecutor")), - UNO_QUERY); + m_xJobExecutorListener = css::uno::Reference< css::document::XEventListener >( css::task::JobExecutor::create( rxContext ), css::uno::UNO_QUERY_THROW ); m_refCount--; } @@ -754,7 +751,7 @@ css::uno::Reference< css::container::XEnumeration > SAL_CALL SfxGlobalEvents_Imp { // SAFE -> ::osl::ResettableMutexGuard aLock(m_aLock); - ModelCollectionEnumeration* pEnum = new ModelCollectionEnumeration(m_xSMGR); + ModelCollectionEnumeration* pEnum = new ModelCollectionEnumeration(); pEnum->setModelList(m_lModels); css::uno::Reference< css::container::XEnumeration > xEnum( static_cast< css::container::XEnumeration* >(pEnum), @@ -792,8 +789,7 @@ void SfxGlobalEvents_Impl::implts_notifyJobExecution(const css::document::EventO css::uno::Reference< css::document::XEventListener > xJobExecutor(m_xJobExecutorListener); aLock.clear(); // <- SAFE - if (xJobExecutor.is()) - xJobExecutor->notifyEvent(aEvent); + xJobExecutor->notifyEvent(aEvent); } catch(const css::uno::RuntimeException&) { throw; } |