summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--framework/inc/jobs/jobexecutor.hxx115
-rw-r--r--framework/source/jobs/jobexecutor.cxx182
-rw-r--r--framework/source/register/registerservices.cxx2
-rw-r--r--framework/util/fwk.component3
4 files changed, 133 insertions, 169 deletions
diff --git a/framework/inc/jobs/jobexecutor.hxx b/framework/inc/jobs/jobexecutor.hxx
deleted file mode 100644
index d4ed3c3b750a..000000000000
--- a/framework/inc/jobs/jobexecutor.hxx
+++ /dev/null
@@ -1,115 +0,0 @@
-/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
-/*
- * This file is part of the LibreOffice project.
- *
- * This Source Code Form is subject to the terms of the Mozilla Public
- * License, v. 2.0. If a copy of the MPL was not distributed with this
- * file, You can obtain one at http://mozilla.org/MPL/2.0/.
- *
- * This file incorporates work covered by the following license notice:
- *
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed
- * with this work for additional information regarding copyright
- * ownership. The ASF licenses this file to you under the Apache
- * License, Version 2.0 (the "License"); you may not use this file
- * except in compliance with the License. You may obtain a copy of
- * the License at http://www.apache.org/licenses/LICENSE-2.0 .
- */
-
-#ifndef INCLUDED_FRAMEWORK_INC_JOBS_JOBEXECUTOR_HXX
-#define INCLUDED_FRAMEWORK_INC_JOBS_JOBEXECUTOR_HXX
-
-#include <jobs/configaccess.hxx>
-#include <threadhelp/threadhelpbase.hxx>
-#include <macros/xinterface.hxx>
-#include <macros/xtypeprovider.hxx>
-#include <macros/xserviceinfo.hxx>
-#include <stdtypes.h>
-#include <general.h>
-
-#include <com/sun/star/lang/XMultiServiceFactory.hpp>
-#include <com/sun/star/task/XJobExecutor.hpp>
-#include <com/sun/star/lang/XComponent.hpp>
-#include <com/sun/star/container/XContainerListener.hpp>
-#include <com/sun/star/lang/XEventListener.hpp>
-#include <com/sun/star/document/XEventListener.hpp>
-#include <com/sun/star/frame/XModuleManager2.hpp>
-
-#include <cppuhelper/implbase4.hxx>
-#include <rtl/ustring.hxx>
-
-
-namespace framework{
-
-
-//_______________________________________
-/**
- @short implements a job executor, which can be triggered from any code
- @descr It uses the given trigger event to locate any registered job service
- inside the configuration and execute it. Of course it controls the
- liftime of such jobs too.
- */
-class JobExecutor : private ThreadHelpBase
- , public ::cppu::WeakImplHelper4<
- css::lang::XServiceInfo
- , css::task::XJobExecutor
- , css::container::XContainerListener // => lang.XEventListener
- , css::document::XEventListener >
-{
- //___________________________________
- // member
-
- private:
-
- /** reference to the uno service manager */
- css::uno::Reference< css::uno::XComponentContext > m_xContext;
-
- /** reference to the module info service */
- css::uno::Reference< css::frame::XModuleManager2 > m_xModuleManager;
-
- /** cached list of all registered event names of cfg for call optimization. */
- OUStringList m_lEvents;
-
- /** we listen at the configuration for changes at the event list. */
- ConfigAccess m_aConfig;
-
- /** helper to allow us listen to the configuration without a cyclic dependency */
- com::sun::star::uno::Reference<com::sun::star::container::XContainerListener> m_xConfigListener;
-
- //___________________________________
- // native interface methods
-
- public:
-
- JobExecutor( const css::uno::Reference< css::uno::XComponentContext >& xContext );
- virtual ~JobExecutor( );
-
- //___________________________________
- // uno interface methods
-
- public:
-
- // XInterface, XTypeProvider, XServiceInfo
- DECLARE_XSERVICEINFO
-
- // task.XJobExecutor
- virtual void SAL_CALL trigger( const OUString& sEvent ) throw(css::uno::RuntimeException);
-
- // document.XEventListener
- virtual void SAL_CALL notifyEvent( const css::document::EventObject& aEvent ) throw(css::uno::RuntimeException);
-
- // container.XContainerListener
- virtual void SAL_CALL elementInserted( const css::container::ContainerEvent& aEvent ) throw(css::uno::RuntimeException);
- virtual void SAL_CALL elementRemoved ( const css::container::ContainerEvent& aEvent ) throw(css::uno::RuntimeException);
- virtual void SAL_CALL elementReplaced( const css::container::ContainerEvent& aEvent ) throw(css::uno::RuntimeException);
-
- // lang.XEventListener
- virtual void SAL_CALL disposing( const css::lang::EventObject& aEvent ) throw(css::uno::RuntimeException);
-};
-
-} // namespace framework
-
-#endif // INCLUDED_FRAMEWORK_INC_JOBS_JOBEXECUTOR_HXX
-
-/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/framework/source/jobs/jobexecutor.cxx b/framework/source/jobs/jobexecutor.cxx
index dd98699fa94b..e066719e0c90 100644
--- a/framework/source/jobs/jobexecutor.cxx
+++ b/framework/source/jobs/jobexecutor.cxx
@@ -17,16 +17,16 @@
* the License at http://www.apache.org/licenses/LICENSE-2.0 .
*/
-#include <jobs/jobexecutor.hxx>
#include <jobs/job.hxx>
#include <jobs/joburl.hxx>
-
+#include <jobs/configaccess.hxx>
#include <classes/converter.hxx>
#include <threadhelp/transactionguard.hxx>
+#include <threadhelp/threadhelpbase.hxx>
#include <threadhelp/readguard.hxx>
#include <threadhelp/writeguard.hxx>
#include <general.h>
-#include <services.h>
+#include <stdtypes.h>
#include "helper/mischelper.hxx"
@@ -34,56 +34,100 @@
#include <com/sun/star/container/XNameAccess.hpp>
#include <com/sun/star/container/XContainer.hpp>
#include <com/sun/star/frame/ModuleManager.hpp>
-
+#include <com/sun/star/task/XJobExecutor.hpp>
+#include <com/sun/star/container/XContainerListener.hpp>
+#include <com/sun/star/lang/XEventListener.hpp>
+#include <com/sun/star/lang/XInitialization.hpp>
+#include <com/sun/star/lang/XServiceInfo.hpp>
+#include <com/sun/star/document/XEventListener.hpp>
+#include <com/sun/star/frame/XModuleManager2.hpp>
+
+#include <cppuhelper/implbase5.hxx>
+#include <cppuhelper/supportsservice.hxx>
#include <unotools/configpaths.hxx>
+#include <rtl/ref.hxx>
#include <rtl/ustrbuf.hxx>
#include <vcl/svapp.hxx>
+using namespace framework;
-namespace framework{
-
-DEFINE_XSERVICEINFO_ONEINSTANCESERVICE_2( JobExecutor ,
- ::cppu::OWeakObject ,
- "com.sun.star.task.JobExecutor",
- IMPLEMENTATIONNAME_JOBEXECUTOR
- )
-
-DEFINE_INIT_SERVICE( JobExecutor,
- {
- m_xModuleManager = css::frame::ModuleManager::create( m_xContext );
-
- /*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 information!
- */
- // read the list of all currently registered events inside configuration.
- // e.g. "/org.openoffice.Office.Jobs/Events/<event name>"
- // We need it later to check if an incoming event request can be executed successfully
- // or must be rejected. It's an optimization! Of course we must implement updating of this
- // list too ... Be listener at the configuration.
-
- m_aConfig.open(ConfigAccess::E_READONLY);
- if (m_aConfig.getMode() == ConfigAccess::E_READONLY)
- {
- css::uno::Reference< css::container::XNameAccess > xRegistry(m_aConfig.cfg(), css::uno::UNO_QUERY);
- if (xRegistry.is())
- m_lEvents = Converter::convert_seqOUString2OUStringList(xRegistry->getElementNames());
-
- css::uno::Reference< css::container::XContainer > xNotifier(m_aConfig.cfg(), css::uno::UNO_QUERY);
- if (xNotifier.is())
- {
- m_xConfigListener = new WeakContainerListener(this);
- xNotifier->addContainerListener(m_xConfigListener);
- }
-
- // don't close cfg here!
- // It will be done inside disposing ...
- }
- }
- )
+namespace {
-//________________________________
+/**
+ @short implements a job executor, which can be triggered from any code
+ @descr It uses the given trigger event to locate any registered job service
+ inside the configuration and execute it. Of course it controls the
+ liftime of such jobs too.
+ */
+class JobExecutor : private ThreadHelpBase
+ , public ::cppu::WeakImplHelper5<
+ css::lang::XServiceInfo
+ , css::task::XJobExecutor
+ , css::lang::XInitialization
+ , css::container::XContainerListener // => lang.XEventListener
+ , css::document::XEventListener >
+{
+private:
+
+ /** reference to the uno service manager */
+ css::uno::Reference< css::uno::XComponentContext > m_xContext;
+
+ /** reference to the module info service */
+ css::uno::Reference< css::frame::XModuleManager2 > m_xModuleManager;
+
+ /** cached list of all registered event names of cfg for call optimization. */
+ OUStringList m_lEvents;
+
+ /** we listen at the configuration for changes at the event list. */
+ ConfigAccess m_aConfig;
+
+ /** helper to allow us listen to the configuration without a cyclic dependency */
+ com::sun::star::uno::Reference<com::sun::star::container::XContainerListener> m_xConfigListener;
+
+public:
+
+ JobExecutor( const css::uno::Reference< css::uno::XComponentContext >& xContext );
+ virtual ~JobExecutor();
+
+ virtual OUString SAL_CALL getImplementationName()
+ throw (css::uno::RuntimeException)
+ {
+ return OUString("com.sun.star.comp.framework.JobExecutor");
+ }
+
+ virtual sal_Bool SAL_CALL supportsService(OUString const & ServiceName)
+ throw (css::uno::RuntimeException)
+ {
+ return cppu::supportsService(this, ServiceName);
+ }
+
+ virtual css::uno::Sequence<OUString> SAL_CALL getSupportedServiceNames()
+ throw (css::uno::RuntimeException)
+ {
+ css::uno::Sequence< OUString > aSeq(1);
+ aSeq[0] = OUString("com.sun.star.task.JobExecutor");
+ return aSeq;
+ }
+
+ // task.XJobExecutor
+ virtual void SAL_CALL trigger( const OUString& sEvent ) throw(css::uno::RuntimeException);
+
+ // XInitialization
+ virtual void SAL_CALL initialize( const css::uno::Sequence< css::uno::Any >& aArguments ) throw (css::uno::Exception, css::uno::RuntimeException);
+
+ // document.XEventListener
+ virtual void SAL_CALL notifyEvent( const css::document::EventObject& aEvent ) throw(css::uno::RuntimeException);
+
+ // container.XContainerListener
+ virtual void SAL_CALL elementInserted( const css::container::ContainerEvent& aEvent ) throw(css::uno::RuntimeException);
+ virtual void SAL_CALL elementRemoved ( const css::container::ContainerEvent& aEvent ) throw(css::uno::RuntimeException);
+ virtual void SAL_CALL elementReplaced( const css::container::ContainerEvent& aEvent ) throw(css::uno::RuntimeException);
+
+ // lang.XEventListener
+ virtual void SAL_CALL disposing( const css::lang::EventObject& aEvent ) throw(css::uno::RuntimeException);
+
+ void onCreate();
+};
/**
@short standard ctor
@@ -95,11 +139,39 @@ DEFINE_INIT_SERVICE( JobExecutor,
JobExecutor::JobExecutor( /*IN*/ const css::uno::Reference< css::uno::XComponentContext >& xContext )
: ThreadHelpBase (&Application::GetSolarMutex() )
, m_xContext (xContext )
- , m_xModuleManager ( )
+ , m_xModuleManager (css::frame::ModuleManager::create( m_xContext ))
, m_aConfig (xContext, OUString::createFromAscii(JobData::EVENTCFG_ROOT) )
{
- // Don't do any reference related code here! Do it inside special
- // impl_ method() ... see DEFINE_INIT_SERVICE() macro for further information.
+}
+
+void JobExecutor::initialize(const css::uno::Sequence< css::uno::Any >& ) throw (css::uno::Exception, css::uno::RuntimeException)
+{
+ // read the list of all currently registered events inside configuration.
+ // e.g. "/org.openoffice.Office.Jobs/Events/<event name>"
+ // We need it later to check if an incoming event request can be executed successfully
+ // or must be rejected. It's an optimization! Of course we must implement updating of this
+ // list too ... Be listener at the configuration.
+
+ m_aConfig.open(ConfigAccess::E_READONLY);
+ if (m_aConfig.getMode() == ConfigAccess::E_READONLY)
+ {
+ css::uno::Reference< css::container::XNameAccess > xRegistry(
+ m_aConfig.cfg(), css::uno::UNO_QUERY);
+ if (xRegistry.is())
+ m_lEvents = Converter::convert_seqOUString2OUStringList(
+ xRegistry->getElementNames());
+
+ css::uno::Reference< css::container::XContainer > xNotifier(
+ m_aConfig.cfg(), css::uno::UNO_QUERY);
+ if (xNotifier.is())
+ {
+ m_xConfigListener = new WeakContainerListener(this);
+ xNotifier->addContainerListener(m_xConfigListener);
+ }
+
+ // don't close cfg here!
+ // It will be done inside disposing ...
+ }
}
JobExecutor::~JobExecutor()
@@ -329,6 +401,14 @@ void SAL_CALL JobExecutor::disposing( const css::lang::EventObject& aEvent ) thr
/* } SAFE */
}
-} // namespace framework
+}
+
+extern "C" SAL_DLLPUBLIC_EXPORT css::uno::XInterface * SAL_CALL
+com_sun_star_comp_framework_JobExecutor_get_implementation(
+ css::uno::XComponentContext *context,
+ css::uno::Sequence<css::uno::Any> const &)
+{
+ return static_cast<cppu::OWeakObject *>(new JobExecutor(context));
+}
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/framework/source/register/registerservices.cxx b/framework/source/register/registerservices.cxx
index 032a5add2f06..b28fe16fe390 100644
--- a/framework/source/register/registerservices.cxx
+++ b/framework/source/register/registerservices.cxx
@@ -34,7 +34,6 @@
)
=================================================================================================================*/
#include <services/desktop.hxx>
-#include <jobs/jobexecutor.hxx>
#include <uifactory/uielementfactorymanager.hxx>
#include <uifactory/uicontrollerfactory.hxx>
#include <uielement/uicommanddescription.hxx>
@@ -55,7 +54,6 @@
COMPONENTGETFACTORY ( fwk,
IFFACTORY( ::framework::Desktop ) else
- IFFACTORY( ::framework::JobExecutor ) else
IFFACTORY( ::framework::UIElementFactoryManager ) else
IFFACTORY( ::framework::PopupMenuControllerFactory ) else
IFFACTORY( ::framework::UICommandDescription ) else
diff --git a/framework/util/fwk.component b/framework/util/fwk.component
index 4a8b46884c0b..7d6f39464e62 100644
--- a/framework/util/fwk.component
+++ b/framework/util/fwk.component
@@ -55,7 +55,8 @@
constructor="com_sun_star_comp_framework_ImageManager_get_implementation">
<service name="com.sun.star.ui.ImageManager"/>
</implementation>
- <implementation name="com.sun.star.comp.framework.JobExecutor">
+ <implementation name="com.sun.star.comp.framework.JobExecutor"
+ constructor="com_sun_star_comp_framework_JobExecutor_get_implementation">
<service name="com.sun.star.task.JobExecutor"/>
</implementation>
<implementation name="com.sun.star.comp.framework.LangSelectionStatusbarController"