summaryrefslogtreecommitdiffstats
path: root/framework/inc/jobs
diff options
context:
space:
mode:
Diffstat (limited to 'framework/inc/jobs')
-rw-r--r--framework/inc/jobs/configaccess.hxx92
-rw-r--r--framework/inc/jobs/helponstartup.hxx189
-rw-r--r--framework/inc/jobs/job.hxx205
-rw-r--r--framework/inc/jobs/jobconst.hxx48
-rw-r--r--framework/inc/jobs/jobdata.hxx210
-rw-r--r--framework/inc/jobs/jobresult.hxx106
-rw-r--r--framework/inc/jobs/joburl.hxx111
-rw-r--r--framework/inc/jobs/shelljob.hxx130
8 files changed, 1091 insertions, 0 deletions
diff --git a/framework/inc/jobs/configaccess.hxx b/framework/inc/jobs/configaccess.hxx
new file mode 100644
index 000000000..1bb8e0110
--- /dev/null
+++ b/framework/inc/jobs/configaccess.hxx
@@ -0,0 +1,92 @@
+/* -*- 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_CONFIGACCESS_HXX
+#define INCLUDED_FRAMEWORK_INC_JOBS_CONFIGACCESS_HXX
+
+#include <config_options.h>
+#include <com/sun/star/uno/XComponentContext.hpp>
+
+#include <rtl/ustring.hxx>
+#include <fwidllapi.h>
+
+namespace framework{
+
+/**
+ @short implements a simple configuration access
+ @descr Sometimes it's better to have direct config access
+ instead of using specialized config items of the svtools
+ project. This class can wrap such configuration access.
+ */
+class UNLESS_MERGELIBS(FWI_DLLPUBLIC) ConfigAccess final
+{
+
+ public:
+
+ /** represent the possible modes of the internal wrapped configuration access */
+ enum EOpenMode
+ {
+ /// config isn't used yet
+ E_CLOSED,
+ /// config access is open for reading only
+ E_READONLY,
+ /// config access is open for reading/writing data
+ E_READWRITE
+ };
+
+ // member
+
+ private:
+ mutable osl::Mutex m_mutex;
+
+ /**
+ reference to the uno service manager
+ It's necessary to instantiate own needed services.
+ */
+ css::uno::Reference< css::uno::XComponentContext > m_xContext;
+
+ /** hold an opened configuration alive */
+ css::uno::Reference< css::uno::XInterface > m_xConfig;
+
+ /** knows the root of the opened config access point */
+ OUString m_sRoot;
+
+ /** represent the current open mode */
+ EOpenMode m_eMode;
+
+ // native interface methods
+
+ public:
+
+ ConfigAccess( const css::uno::Reference< css::uno::XComponentContext >& rxContext,
+ const OUString& sRoot );
+ ~ConfigAccess();
+
+ void open ( EOpenMode eMode );
+ void close ( );
+ EOpenMode getMode( ) const;
+
+ const css::uno::Reference< css::uno::XInterface >& cfg();
+};
+
+} // namespace framework
+
+#endif // INCLUDED_FRAMEWORK_INC_JOBS_CONFIGACCESS_HXX
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/framework/inc/jobs/helponstartup.hxx b/framework/inc/jobs/helponstartup.hxx
new file mode 100644
index 000000000..723526f92
--- /dev/null
+++ b/framework/inc/jobs/helponstartup.hxx
@@ -0,0 +1,189 @@
+/* -*- 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_HELPONSTARTUP_HXX
+#define INCLUDED_FRAMEWORK_INC_JOBS_HELPONSTARTUP_HXX
+
+#include <macros/xserviceinfo.hxx>
+
+#include <cppuhelper/implbase.hxx>
+
+#include <com/sun/star/task/XJob.hpp>
+#include <com/sun/star/lang/XEventListener.hpp>
+#include <com/sun/star/container/XNameAccess.hpp>
+#include <com/sun/star/frame/XDesktop2.hpp>
+#include <com/sun/star/frame/XModuleManager2.hpp>
+
+namespace framework{
+
+/** @short implements a job component, which handle the special
+ feature to show a suitable help page for every (visible!)
+ loaded document.
+ */
+class HelpOnStartup final : public ::cppu::WeakImplHelper< css::lang::XServiceInfo,css::lang::XEventListener,css::task::XJob >
+{
+
+ // member
+ private:
+ osl::Mutex m_mutex;
+
+ /** @short reference to a uno service manager. */
+ css::uno::Reference< css::uno::XComponentContext > m_xContext;
+
+ /** @short such module manager is used to classify new opened documents. */
+ css::uno::Reference< css::frame::XModuleManager2 > m_xModuleManager;
+
+ /** @short is needed to locate a might open help frame. */
+ css::uno::Reference< css::frame::XDesktop2 > m_xDesktop;
+
+ /** @short provides read access to the underlying configuration. */
+ css::uno::Reference< css::container::XNameAccess > m_xConfig;
+
+ /** @short knows the current locale of this office session,
+ which is needed to build complete help URLs.
+ */
+ OUString m_sLocale;
+
+ /** @short knows the current operating system of this office session,
+ which is needed to build complete help URLs.
+ */
+ OUString m_sSystem;
+
+ // native interface
+ public:
+
+ /** @short create new instance of this class.
+
+ @param xContext
+ reference to the uno service manager, which created this instance.
+ Can be used later to create own needed uno resources on demand.
+ */
+ HelpOnStartup(const css::uno::Reference< css::uno::XComponentContext >& xContext);
+
+ /** @short does nothing real ...
+
+ @descr But it should exists as virtual function,
+ so this class can't make trouble
+ related to inline/symbols etcpp.!
+ */
+ virtual ~HelpOnStartup() override;
+
+ // uno interface
+ public:
+
+ // css.lang.XServiceInfo
+ DECLARE_XSERVICEINFO_NOFACTORY
+ /* Helper for registry */
+ /// @throws css::uno::Exception
+ static css::uno::Reference< css::uno::XInterface > SAL_CALL impl_createInstance ( const css::uno::Reference< css::lang::XMultiServiceFactory >& xServiceManager );
+ static css::uno::Reference< css::lang::XSingleServiceFactory > impl_createFactory ( const css::uno::Reference< css::lang::XMultiServiceFactory >& xServiceManager );
+
+ // css.task.XJob
+ virtual css::uno::Any SAL_CALL execute(const css::uno::Sequence< css::beans::NamedValue >& lArguments) override;
+
+ // css.lang.XEventListener
+ virtual void SAL_CALL disposing(const css::lang::EventObject& aEvent) override;
+
+ // helper
+ private:
+
+ /** @short analyze the given job arguments, try to locate a model reference
+ and try to classify this model.
+
+ @descr As a result of this operation a module identifier will be returned.
+ It can be used against the module configuration then to retrieve further information.
+
+ @param lArguments
+ the list of job arguments which is given on our interface method execute().
+
+ @return [string]
+ a module identifier ... or an empty value if no model could be located ...
+ or if it could not be classified successfully.
+ */
+ OUString its_getModuleIdFromEnv(const css::uno::Sequence< css::beans::NamedValue >& lArguments);
+
+ /** @short tries to locate the open help module and return
+ the url of the currently shown help content.
+
+ @descr It returns an empty string, if the help isn't still
+ open at calling time.
+
+ @return The URL of the current shown help content;
+ or an empty value if the help isn't still open.
+ */
+ OUString its_getCurrentHelpURL();
+
+ /** @short checks if the given help url match to a default help url
+ of any office module.
+
+ @param sHelpURL
+ the help url for checking.
+
+ @return [bool]
+ sal_True if the given URL is any default one ...
+ sal_False otherwise.
+ */
+ bool its_isHelpUrlADefaultOne(const OUString& sHelpURL);
+
+ /** @short checks, if the help module should be shown automatically for the
+ currently opened office module.
+
+ @descr This value is read from the module configuration.
+ In case the help should be shown, this method returns
+ a help URL, which can be used to show the right help content.
+
+ @param sModule
+ identifies the used office module.
+
+ @return [string]
+ A valid help URL in case the help content should be shown;
+ an empty value if such automatism was disabled for the specified office module.
+ */
+ OUString its_checkIfHelpEnabledAndGetURL(const OUString& sModule);
+
+ /** @short create a help URL for the given parameters.
+
+ @param sBaseURL
+ must be the base URL for a requested help content
+ e.g. "vnd.sun.star.help://swriter/"
+ or "vnd.sun.star.help://swriter/67351"
+
+ @param sLocale
+ the current office locale
+ e.g. "en-US"
+
+ @param sSystem
+ the current operating system
+ e.g. "WIN"
+
+ @return The URL which was generated.
+ e.g.
+ e.g. "vnd.sun.star.help://swriter/?Language=en-US&System=WIN"
+ or "vnd.sun.star.help://swriter/67351?Language=en-US&System=WIN"
+ */
+ static OUString ist_createHelpURL(const OUString& sBaseURL,
+ const OUString& sLocale ,
+ const OUString& sSystem );
+};
+
+} // namespace framework
+
+#endif // INCLUDED_FRAMEWORK_INC_JOBS_HELPONSTARTUP_HXX
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/framework/inc/jobs/job.hxx b/framework/inc/jobs/job.hxx
new file mode 100644
index 000000000..a4e2e472c
--- /dev/null
+++ b/framework/inc/jobs/job.hxx
@@ -0,0 +1,205 @@
+/* -*- 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_JOB_HXX
+#define INCLUDED_FRAMEWORK_INC_JOBS_JOB_HXX
+
+#include <jobs/jobdata.hxx>
+
+#include <com/sun/star/frame/XFrame.hpp>
+#include <com/sun/star/frame/XDesktop2.hpp>
+#include <com/sun/star/frame/XDispatchResultListener.hpp>
+#include <com/sun/star/task/XJobListener.hpp>
+#include <com/sun/star/util/XCloseListener.hpp>
+
+#include <cppuhelper/implbase.hxx>
+#include <osl/conditn.hxx>
+
+namespace framework{
+
+/**
+ @short it represent a job; execute it and control its lifetime
+
+ @descr This implementation can be used to wrap jobs, execute it
+ synchronously or asynchronous, control its lifetime
+ and differe between jobs with and without configuration.
+ */
+class Job final : public ::cppu::WeakImplHelper<
+ css::task::XJobListener
+ , css::frame::XTerminateListener
+ , css::util::XCloseListener >
+{
+
+ // structs
+
+ private:
+
+ /** different possible states for the internal wrapped job.
+ It can be started, stopped by a queryClosing() request or
+ disposed() by a notifyClosing() request ...
+ */
+ enum ERunState
+ {
+ E_NEW,
+ E_RUNNING,
+ E_STOPPED_OR_FINISHED,
+ E_DISPOSED
+ };
+
+ // member
+
+ private:
+
+ /**
+ hold all necessary information about this job.
+ It can be used for both modes: with and without configuration.
+ */
+ JobData m_aJobCfg;
+
+ /**
+ We need it to create own services on demand.
+ */
+ css::uno::Reference< css::uno::XComponentContext > m_xContext;
+
+ /**
+ Hold the (may asynchronous) job alive.
+ */
+ css::uno::Reference< css::uno::XInterface > m_xJob;
+
+ /**
+ Used to wait for finishing of asynchronous started jobs.
+ */
+ ::osl::Condition m_aAsyncWait;
+
+ /**
+ For some special cases we must know the environment, in which
+ this job runs. Means the frame inside which we may was triggered.
+ We use it too, to listen for closing events of this resource.
+
+ Please note: If m_xFrame is set - m_xModel should be NULL.
+ Only one environment can be supported really.
+ */
+ css::uno::Reference< css::frame::XFrame > m_xFrame;
+
+ /**
+ For some special cases we must know the environment, in which
+ this job runs. Means the document inside which we may was triggered.
+ We use it too, to listen for closing events of this resource.
+
+ Please note: If m_xModel is set - m_xFrame should be NULL.
+ Only one environment can be supported really.
+ */
+ css::uno::Reference< css::frame::XModel > m_xModel;
+
+ /**
+ We are registered at this instance to listen for office shutdown events.
+ It's necessary suppress it (if possible) or to react in the right way.
+ */
+ css::uno::Reference< css::frame::XDesktop2 > m_xDesktop;
+
+ /**
+ A job can return a dispatch result event after finishing its work.
+ We have to transport it to any outside interested listener then.
+ (see m_xResultSourceFake for further information too!)
+ */
+ css::uno::Reference< css::frame::XDispatchResultListener > m_xResultListener;
+
+ /**
+ We can't set ourself as source of a dispatch result event ... nor our job.
+ Because the listener (set as m_xResultListener) expect the original instance,
+ where it was registered. This original instance is the user of this class.
+ It must be set explicitly and will be used to fake the source of the event!
+ */
+ css::uno::Reference< css::uno::XInterface > m_xResultSourceFake;
+
+ /**
+ Holds the state, if we are listen for desktop/frame or model closing events or not.
+ The used references are not really enough to detect a valid listener connection.
+ That's why we use this additional information here too.
+ */
+ bool m_bListenOnDesktop;
+ bool m_bListenOnFrame;
+ bool m_bListenOnModel;
+
+ /**
+ In case we got a close request from our desktop/frame/model (on which we listen) ... and
+ the ownership was delivered there ... we have to close ourself and this object
+ in case the internal wrapped and running job finish his work.
+ */
+ bool m_bPendingCloseFrame;
+ bool m_bPendingCloseModel;
+
+ /**
+ indicates in which state the internal job currently exist.
+
+ We can use this information to throw any suitable veto exception
+ to prevent the environment against dying or suppress superfluous dispose()
+ calls at the job.
+ */
+ ERunState m_eRunState;
+
+ // native interface
+
+ public:
+
+ Job( const css::uno::Reference< css::uno::XComponentContext >& xContext ,
+ const css::uno::Reference< css::frame::XFrame >& xFrame );
+ Job( const css::uno::Reference< css::uno::XComponentContext >& xContext ,
+ const css::uno::Reference< css::frame::XModel >& xModel );
+ virtual ~Job( ) override;
+
+ void setDispatchResultFake( const css::uno::Reference< css::frame::XDispatchResultListener >& xListener ,
+ const css::uno::Reference< css::uno::XInterface >& xSourceFake );
+ void setJobData ( const JobData& aData );
+ void execute ( const css::uno::Sequence< css::beans::NamedValue >& lDynamicArgs );
+ void die ( );
+
+ private:
+
+ css::uno::Sequence< css::beans::NamedValue > impl_generateJobArgs ( const css::uno::Sequence< css::beans::NamedValue >& lDynamicArgs );
+ void impl_reactForJobResult( const css::uno::Any& aResult );
+ void impl_startListening ( );
+ void impl_stopListening ( );
+
+ // uno interface
+
+ public:
+
+ // XJobListener
+ virtual void SAL_CALL jobFinished( const css::uno::Reference< css::task::XAsyncJob >& xJob,
+ const css::uno::Any& aResult ) override;
+
+ // XTerminateListener
+ virtual void SAL_CALL queryTermination ( const css::lang::EventObject& aEvent ) override;
+ virtual void SAL_CALL notifyTermination( const css::lang::EventObject& aEvent ) override;
+
+ // XCloseListener
+ virtual void SAL_CALL queryClosing ( const css::lang::EventObject& aEvent ,
+ sal_Bool bGetsOwnership ) override;
+ virtual void SAL_CALL notifyClosing( const css::lang::EventObject& aEvent ) override;
+
+ // XEventListener
+ virtual void SAL_CALL disposing( const css::lang::EventObject& aEvent ) override;
+};
+
+} // namespace framework
+
+#endif // INCLUDED_FRAMEWORK_INC_JOBS_JOB_HXX
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/framework/inc/jobs/jobconst.hxx b/framework/inc/jobs/jobconst.hxx
new file mode 100644
index 000000000..80e78f4d9
--- /dev/null
+++ b/framework/inc/jobs/jobconst.hxx
@@ -0,0 +1,48 @@
+/* -*- 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_JOBCONST_HXX
+#define INCLUDED_FRAMEWORK_INC_JOBS_JOBCONST_HXX
+
+#include <rtl/ustring.hxx>
+#include <fwidllapi.h>
+
+namespace framework{
+
+/**
+ @short defines all constant values used within a job environment.
+
+ @descr The protocol between job executor/dispatch and jobs is fix and well defined.
+ But why every implemented job should write such constant values directly into
+ it's code. Typos can occur or code will be changed by new developers ...
+ Shared set of constant values can help to improve the maintenance of this code.
+ */
+class FWI_DLLPUBLIC JobConst
+{
+ public:
+ static const OUString ANSWER_DEACTIVATE_JOB;
+ static const OUString ANSWER_SAVE_ARGUMENTS;
+ static const OUString ANSWER_SEND_DISPATCHRESULT;
+};
+
+} // namespace framework
+
+#endif // INCLUDED_FRAMEWORK_INC_JOBS_JOBCONST_HXX
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/framework/inc/jobs/jobdata.hxx b/framework/inc/jobs/jobdata.hxx
new file mode 100644
index 000000000..5d64bcb8c
--- /dev/null
+++ b/framework/inc/jobs/jobdata.hxx
@@ -0,0 +1,210 @@
+/* -*- 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_JOBDATA_HXX
+#define INCLUDED_FRAMEWORK_INC_JOBS_JOBDATA_HXX
+
+#include <com/sun/star/uno/XComponentContext.hpp>
+#include <com/sun/star/beans/NamedValue.hpp>
+
+#include <rtl/ustring.hxx>
+
+#include <vector>
+
+namespace framework{
+
+/**
+ @short holds all necessary information about a job and
+ handle it's configuration (if any exist!)
+ @descr It can be used from different use cases as a container
+ (or proxy) for all config data of a registered job.
+ But it doesn't implement any execute functionality!
+ */
+class JobData final
+{
+ public:
+
+ /** These values can be used to differe between jobs with and jobs without
+ a configuration. Of course an "unknown state" should be available too,
+ to detect a missing initialization.
+ */
+ enum EMode
+ {
+ /// indicates a missing initialization
+ E_UNKNOWN_MODE,
+ /// indicates a job with configuration (They alias represent the config key name.)
+ E_ALIAS,
+ /// indicates a job without configuration (The pure UNO implementation is used only.)
+ E_SERVICE,
+ /// indicates a job with configuration, which was triggered by an event
+ E_EVENT
+ };
+
+ /** These values represent the environment type, in which a job can run.
+ A job must known, from which binding it will be started. Because
+ it's initialization data depends from that!
+ */
+ enum EEnvironment
+ {
+ /// indicates a missing initialization
+ E_UNKNOWN_ENVIRONMENT,
+ /// this job is used by the global JobExecutor service
+ E_EXECUTION,
+ /// this job is used by the global dispatch framework
+ E_DISPATCH,
+ /// this job is used by the global event broadcaster
+ E_DOCUMENTEVENT
+ };
+
+ /** Some jobs can be registered to "logical events", which are generated on demand if another document event
+ occurs. E.g. "onDocumentOpened" in case "OnNew" or "OnLoad" was notified to the JobExecutor instance.
+ And normally the original event is transported as parameter set to the executed job. But then such job
+ can't differ between e.g. "OnNew" and "onDocumentOpened".
+ That's why we must know, for which type of event the job was really triggered .-)
+
+ The information "sDocEvent" from this struct must be set on the member JobData::m_sEvent from outside
+ user of such Jobdata structure.
+ */
+ struct TJob2DocEventBinding
+ {
+ OUString m_sJobName;
+ OUString m_sDocEvent;
+
+ TJob2DocEventBinding(const OUString& sJobName ,
+ const OUString& sDocEvent)
+ : m_sJobName (sJobName )
+ , m_sDocEvent(sDocEvent)
+ {}
+ };
+
+ // member
+
+ private:
+
+ /**
+ reference to the uno service manager.
+ We need it for creating of own uno services ... e.g. for
+ opening the configuration.
+ */
+ css::uno::Reference< css::uno::XComponentContext > m_xContext;
+
+ /**
+ An instance of this class can be used in two different modes:
+ - as a configured job
+ - as a job without any configuration
+ First mode is triggered by an alias, which points to the
+ configuration entries. Second mode is specified by a uno service
+ or implementation name. Then we do the same things (use the same interfaces)
+ but don't handle any configuration data.
+ The effect: This mode can be detected by this member.
+ */
+ EMode m_eMode;
+
+ /**
+ Because jobs can be bind to different mechanism inside office, a job
+ should know inside which environment it runs. E.g. a job can be executed
+ by the global JobExecutor service (triggered by an event) or e.g. as part
+ of the global dispatch framework (triggered by an UI control e.g. a menu entry).
+ */
+ EEnvironment m_eEnvironment;
+
+ /**
+ the alias name of this job.
+ Is used as entry of configuration set for job registration, to find all
+ necessary properties of it...
+ */
+ OUString m_sAlias;
+
+ /**
+ the uno implementation name of this job.
+ It's read from the configuration. Don't set it from outside!
+ */
+ OUString m_sService;
+
+ /**
+ the module context list of this job.
+ It's read from the configuration. Don't set it from outside!
+ */
+ OUString m_sContext;
+
+ /**
+ a job can be registered for an event.
+ It can be an empty value! But it will be set from outside any times.
+ Because it's not clear which job this instance should represent if an event
+ (instead of an alias) comes in. Because there can be multiple registrations
+ for this event. We use this information only, to merge it with the job specific
+ arguments. A job can be called so, with a) its own config data and b) some dynamic
+ environment data.
+ */
+ OUString m_sEvent;
+
+ /**
+ job specific configuration items... unknown for us!
+ It's read from the configuration. Don't set it from outside!
+ */
+ std::vector< css::beans::NamedValue > m_lArguments;
+
+ // native interface
+
+ public:
+
+ JobData( const css::uno::Reference< css::uno::XComponentContext >& rxContext );
+ JobData( const JobData& rCopy );
+ ~JobData( );
+
+ JobData& operator=( const JobData& rCopy );
+
+ EMode getMode () const;
+ EEnvironment getEnvironment () const;
+ OUString getEnvironmentDescriptor() const;
+ OUString getService () const;
+ OUString getEvent () const;
+ css::uno::Sequence< css::beans::NamedValue > getConfig () const;
+ std::vector< css::beans::NamedValue > getJobConfig () const;
+
+ bool hasConfig () const;
+ bool hasCorrectContext ( const OUString& rModuleIdent ) const;
+
+ void setEnvironment ( EEnvironment eEnvironment );
+ void setAlias ( const OUString& sAlias );
+ void setService ( const OUString& sService );
+ void setEvent ( const OUString& sEvent ,
+ const OUString& sAlias );
+ void setJobConfig ( const std::vector< css::beans::NamedValue >& lArguments );
+ void disableJob ( );
+
+ static std::vector< OUString > getEnabledJobsForEvent( const css::uno::Reference< css::uno::XComponentContext >& rxContext,
+ const OUString& sEvent );
+
+ static void appendEnabledJobsForEvent( const css::uno::Reference< css::uno::XComponentContext >& rxContext,
+ const OUString& sEvent ,
+ ::std::vector< JobData::TJob2DocEventBinding >& lJobs );
+
+ // private helper
+
+ private:
+
+ void impl_reset();
+};
+
+} // namespace framework
+
+#endif // INCLUDED_FRAMEWORK_INC_JOBS_JOBDATA_HXX
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/framework/inc/jobs/jobresult.hxx b/framework/inc/jobs/jobresult.hxx
new file mode 100644
index 000000000..2178a541a
--- /dev/null
+++ b/framework/inc/jobs/jobresult.hxx
@@ -0,0 +1,106 @@
+/* -*- 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_JOBRESULT_HXX
+#define INCLUDED_FRAMEWORK_INC_JOBS_JOBRESULT_HXX
+
+#include <com/sun/star/beans/NamedValue.hpp>
+#include <com/sun/star/frame/DispatchResultEvent.hpp>
+
+#include <vector>
+
+namespace framework{
+
+/**
+ @short represent a result of a finished job execution
+ @descr Such result instance transport all necessary
+ data from the code place where the job was finished
+ to the outside code, where e.g. listener must be notified.
+ */
+class JobResult final
+{
+
+ // types
+
+ public:
+
+ /**
+ These enum values are used to build a flag mask of possible set
+ parts of an analyzed pure job execution result.
+ An user of this class can decide, if a member of us can be valid
+ or not. So it can indicate, if a job used the special part inside
+ its returned result protocol.
+ To be usable as flags - it must be values of set {0,1,2,4,8,16 ...}!
+ */
+ enum EParts
+ {
+ E_NOPART = 0,
+ E_ARGUMENTS = 1,
+ E_DEACTIVATE = 2,
+ E_DISPATCHRESULT = 4
+ };
+
+ // member
+
+ private:
+
+ /**
+ an user of us must know, which (possible) parts of
+ a "pure result" was really set by an executed job.
+ Means which other members of this class are valid.
+ This mask can be used to find it out.
+ */
+ sal_uInt32 m_eParts;
+
+ /**
+ a job can have persistent data
+ They are part of the pure result and will be used to
+ write it to the configuration. But that's part of any
+ user of us. We provide this information here only.
+ */
+ std::vector< css::beans::NamedValue > m_lArguments;
+
+ /**
+ represent the part "DispatchResult"
+ It's a fulfilled event type, which was given
+ back by the executed job. Any user of us can send
+ it to its registered result listener directly.
+ */
+ css::frame::DispatchResultEvent m_aDispatchResult;
+
+ // native interface
+
+ public:
+
+ JobResult( const css::uno::Any& aResult );
+ JobResult( const JobResult& rCopy );
+ ~JobResult( );
+
+ JobResult& operator=( const JobResult& rCopy );
+
+ bool existPart ( sal_uInt32 eParts ) const;
+ std::vector< css::beans::NamedValue > getArguments ( ) const;
+ css::frame::DispatchResultEvent getDispatchResult( ) const;
+};
+
+} // namespace framework
+
+#endif // INCLUDED_FRAMEWORK_INC_JOBS_JOBRESULT_HXX
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/framework/inc/jobs/joburl.hxx b/framework/inc/jobs/joburl.hxx
new file mode 100644
index 000000000..32c2fc809
--- /dev/null
+++ b/framework/inc/jobs/joburl.hxx
@@ -0,0 +1,111 @@
+/* -*- 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_JOBURL_HXX
+#define INCLUDED_FRAMEWORK_INC_JOBS_JOBURL_HXX
+
+#include <rtl/ustring.hxx>
+
+namespace framework{
+
+#define JOBURL_EVENT_STR "event="
+#define JOBURL_EVENT_LEN 6
+
+#define JOBURL_ALIAS_STR "alias="
+#define JOBURL_ALIAS_LEN 6
+
+#define JOBURL_SERVICE_STR "service="
+#define JOBURL_SERVICE_LEN 8
+
+#define JOBURL_PART_SEPARATOR ';'
+#define JOBURL_PARTARGS_SEPARATOR ','
+
+/**
+ @short can be used to parse, validate and work with job URL's
+ @descr Job URLs are specified by the following syntax:
+ vnd.sun.star.job:{[event=<name>]|[alias=<name>]|[service=<name>]}
+ This class can analyze this structure and separate it into his different parts.
+ After doing that these parts are accessible by the methods of this class.
+ */
+class JobURL
+{
+
+ // types
+
+ private:
+
+ /**
+ possible states of a job URL
+ Note: These values are used in combination. So they must be
+ values in form 2^n.
+ */
+ enum ERequest
+ {
+ /// mark a job URL as not valid
+ E_UNKNOWN = 0,
+ /// it's an event
+ E_EVENT = 1,
+ /// it's an alias
+ E_ALIAS = 2,
+ /// it's a service
+ E_SERVICE = 4
+ };
+
+ // types
+
+ private:
+
+ /** knows the state of this URL instance */
+ sal_uInt32 m_eRequest;
+
+ /** holds the event part of a job URL */
+ OUString m_sEvent;
+
+ /** holds the alias part of a job URL */
+ OUString m_sAlias;
+
+ /** holds the service part of a job URL */
+ OUString m_sService;
+
+ // native interface
+
+ public:
+
+ JobURL ( const OUString& sURL );
+ bool isValid ( ) const;
+ bool getEvent ( OUString& sEvent ) const;
+ bool getAlias ( OUString& sAlias ) const;
+ bool getService ( OUString& sService ) const;
+
+ // private helper
+
+ private:
+
+ static bool implst_split( const OUString& sPart ,
+ const char* pPartIdentifier ,
+ sal_Int32 nPartLength ,
+ OUString& rPartValue ,
+ OUString& rPartArguments );
+};
+
+} // namespace framework
+
+#endif // INCLUDED_FRAMEWORK_INC_JOBS_JOBURL_HXX
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/framework/inc/jobs/shelljob.hxx b/framework/inc/jobs/shelljob.hxx
new file mode 100644
index 000000000..387e3d142
--- /dev/null
+++ b/framework/inc/jobs/shelljob.hxx
@@ -0,0 +1,130 @@
+/* -*- 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_SHELLJOB_HXX
+#define INCLUDED_FRAMEWORK_INC_JOBS_SHELLJOB_HXX
+
+#include <macros/xserviceinfo.hxx>
+
+#include <cppuhelper/implbase.hxx>
+
+#include <com/sun/star/task/XJob.hpp>
+
+namespace framework{
+
+/** @short implements a job component which can be used
+ to execute system shell commands.
+
+ @descr Because the job will be implemented generic
+ it can be bound to any event where jobs can be
+ registered for. Further there is a generic
+ way to configure the shell command and it's list
+ of arguments.
+ */
+class ShellJob final : public ::cppu::WeakImplHelper< css::lang::XServiceInfo,css::task::XJob >
+{
+
+ // member
+ private:
+
+ /** @short reference to a uno service manager. */
+ css::uno::Reference< css::uno::XComponentContext > m_xContext;
+
+ // native interface
+ public:
+
+ /** @short create new instance of this class.
+
+ @param xContext
+ reference to the uno service manager, which created this instance.
+ Can be used later to create own needed uno resources on demand.
+ */
+ ShellJob(const css::uno::Reference< css::uno::XComponentContext >& xContext);
+
+ /** @short does nothing real ...
+
+ @descr But it should exists as virtual function,
+ so this class can't make trouble
+ related to inline/symbols etcpp.!
+ */
+ virtual ~ShellJob() override;
+
+ // uno interface
+ public:
+
+ // css.lang.XServiceInfo
+ DECLARE_XSERVICEINFO_NOFACTORY
+ /* Helper for registry */
+ /// @throws css::uno::Exception
+ static css::uno::Reference< css::uno::XInterface > SAL_CALL impl_createInstance ( const css::uno::Reference< css::lang::XMultiServiceFactory >& xServiceManager );
+ static css::uno::Reference< css::lang::XSingleServiceFactory > impl_createFactory ( const css::uno::Reference< css::lang::XMultiServiceFactory >& xServiceManager );
+
+ // css.task.XJob
+ virtual css::uno::Any SAL_CALL execute(const css::uno::Sequence< css::beans::NamedValue >& lArguments) override;
+
+ // helper
+ private:
+
+ /** generate a return value for method execute()
+ which will force deactivation of this job for further requests.
+
+ @return an Any following the job protocol for deactivation.
+ */
+ static css::uno::Any impl_generateAnswer4Deactivation();
+
+ /** substitute all might existing placeholder variables
+ within the configured command.
+
+ The command is part of the job configuration.
+ These will make changes more easy (no code changes required).
+ Further the command can use placeholder as they are supported
+ by the global substitution service (e.g. $(prog) etcpp)
+
+ @param sCommand
+ the command containing placeholder variables.
+
+ @return the substituted command.
+ */
+ OUString impl_substituteCommandVariables(const OUString& sCommand);
+
+ /** executes the command.
+
+ @param sCommand
+ the absolute command as URL or system path (without any argument !).
+
+ @param lArguments
+ the complete list of arguments configured for these job.
+
+ @param bCheckExitCode
+ bind the execution result to the exit code of the started process.
+ If it's set to false we return false only in case executable couldn't be found
+ or couldn't be started.
+
+ @return sal_True if command was executed successfully; sal_False otherwise.
+ */
+ bool impl_execute(const OUString& sCommand ,
+ const css::uno::Sequence< OUString >& lArguments ,
+ bool bCheckExitCode);
+};
+
+} // namespace framework
+
+#endif // INCLUDED_FRAMEWORK_INC_JOBS_SHELLJOB_HXX
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */