diff options
-rw-r--r-- | desktop/source/app/app.cxx | 7 | ||||
-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 |
4 files changed, 69 insertions, 19 deletions
diff --git a/desktop/source/app/app.cxx b/desktop/source/app/app.cxx index ae9b3571bed4..400da64ad8fc 100644 --- a/desktop/source/app/app.cxx +++ b/desktop/source/app/app.cxx @@ -66,7 +66,7 @@ #include <com/sun/star/configuration/InstallationIncompleteException.hpp> #include <com/sun/star/configuration/backend/BackendSetupException.hpp> #include <com/sun/star/configuration/backend/BackendAccessException.hpp> -#include <com/sun/star/task/XJobExecutor.hpp> +#include <com/sun/star/task/JobExecutor.hpp> #include <com/sun/star/task/XRestartManager.hpp> #include <com/sun/star/document/XEventListener.hpp> #include <com/sun/star/frame/UICommandDescription.hpp> @@ -2893,9 +2893,8 @@ void Desktop::DoFirstRunInitializations() { try { - Reference< XJobExecutor > xExecutor( ::comphelper::getProcessServiceFactory()->createInstance( ::rtl::OUString("com.sun.star.task.JobExecutor") ), UNO_QUERY ); - if( xExecutor.is() ) - xExecutor->trigger( ::rtl::OUString("onFirstRunInitialization") ); + Reference< XJobExecutor > xExecutor = JobExecutor::create( ::comphelper::getProcessComponentContext() ); + xExecutor->trigger( ::rtl::OUString("onFirstRunInitialization") ); } catch(const ::com::sun::star::uno::Exception&) { 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; } |