1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
3 * This file is part of the LibreOffice project.
5 * This Source Code Form is subject to the terms of the Mozilla Public
6 * License, v. 2.0. If a copy of the MPL was not distributed with this
7 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
9 * This file incorporates work covered by the following license notice:
11 * Licensed to the Apache Software Foundation (ASF) under one or more
12 * contributor license agreements. See the NOTICE file distributed
13 * with this work for additional information regarding copyright
14 * ownership. The ASF licenses this file to you under the Apache
15 * License, Version 2.0 (the "License"); you may not use this file
16 * except in compliance with the License. You may obtain a copy of
17 * the License at http://www.apache.org/licenses/LICENSE-2.0 .
20 #ifndef INCLUDED_FRAMEWORK_INC_JOBS_JOBDATA_HXX
21 #define INCLUDED_FRAMEWORK_INC_JOBS_JOBDATA_HXX
23 #include <jobs/configaccess.hxx>
24 #include <jobs/jobresult.hxx>
28 #include <com/sun/star/lang/XMultiServiceFactory.hpp>
29 #include <com/sun/star/uno/XComponentContext.hpp>
30 #include <com/sun/star/beans/NamedValue.hpp>
31 #include <com/sun/star/frame/DispatchResultEvent.hpp>
33 #include <rtl/ustring.hxx>
38 @short holds all necessary information about a job and
39 handle it's configuration (if any exist!)
40 @descr It can be used rom different use cases as a container
41 (or proxy) for all config data of a registered job.
42 But it doesn't implement any execute functionality!
48 /** These values can be used to differe between jobs with and jobs without
49 a configuration. Of course an "unknown state" should be available too,
50 to detect a missing initialization.
54 /// indicates a missing initialization
56 /// indicates a job with configuration (They alias represent the config key name.)
58 /// indicates a job without configuration (The pure UNO implementation is used only.)
60 /// indicates a job with configuration, which was triggered by an event
64 /** These values represent the environment type, in which a job can run.
65 A job must known, from which binding it will be started. Because
66 it's initialization data depends from that!
70 /// indicates a missing initialization
71 E_UNKNOWN_ENVIRONMENT
,
72 /// this job is used by the global JobExecutor service
74 /// this job is used by the global dispatch framework
76 /// this job is used by the global event broadcaster
80 /** Some jobs can be registered to "logical events", which are generated on demand if another document event
81 occurs. E.g. "onDocumentOpened" in case "OnNew" or "OnLoad" was notified to the JobExecutor instance.
82 And normally the original event is transported as parameter set to the executed job. But then such job
83 can't differ between e.g. "OnNew" and "onDocumentOpened".
84 That's why we must know, for which type of event the job was really triggered .-)
86 The information "sDocEvent" from this struct must be set on the member JobData::m_sEvent from outside
87 user of such Jobdata structure.
89 struct TJob2DocEventBinding
94 TJob2DocEventBinding(const OUString
& sJobName
,
95 const OUString
& sDocEvent
)
96 : m_sJobName (sJobName
)
97 , m_sDocEvent(sDocEvent
)
106 reference to the uno service manager.
107 We need it for creating of own uno services ... e.g. for
108 opening the configuration.
110 css::uno::Reference
< css::uno::XComponentContext
> m_xContext
;
113 An instance of this class can be used in two different modes:
114 - as a configured job
115 - as a job without any configuration
116 First mode is triggered by an alias, which points to the
117 configuration entries. Second mode is specified by an uno service
118 or implementation name. Then we do the same things (use the same interfaces)
119 but don't handle any configuration data.
120 The effect: This mode can be detected by this member.
125 Because jobs can be bind to different mechanism inside office, a job
126 should know inside which environment it runs. E.g. a job can be executed
127 by the global JobExecutor service (triggered by an event) or e.g. as part
128 of the global dispatch framework (triggered by an UI control e.g. a menu entry).
130 EEnvironment m_eEnvironment
;
133 the alias name of this job.
134 Is used as entry of configuration set for job registration, to find all
135 necessary properties of it..
140 the uno implementation name of this job.
141 It's readed from the configuration. Don't set it from outside!
146 the module context list of this job.
147 It's readed from the configuration. Don't set it from outside!
152 a job can be registered for an event.
153 It can be an empty value! But it will be set from outside any times.
154 Because it's not clear which job this instance should represent if an event
155 (instaed of an alias) comes in. Because there can be multiple registrations
156 for this event. We use this information only, to merge it with the job specific
157 arguments. A job can be called so, with a) it's onw config data and b) some dynamic
163 job specific configuration items ... unknown for us!
164 It's readed from the configuration. Don't set it from outside!
166 css::uno::Sequence
< css::beans::NamedValue
> m_lArguments
;
169 after a job was successfully executed (by any outside code using our
170 information) it can return a result. This member make it part of this
171 container too. So it can be used for further things.
172 We use it also to update our internal state and the configuration
173 of the job. But note: only the last result will be saved here!
175 JobResult m_aLastExecutionResult
;
181 JobData( const css::uno::Reference
< css::uno::XComponentContext
>& rxContext
);
182 JobData( const JobData
& rCopy
);
185 void operator=( const JobData
& rCopy
);
187 EMode
getMode () const;
188 EEnvironment
getEnvironment () const;
189 OUString
getEnvironmentDescriptor() const;
190 OUString
getService () const;
191 OUString
getEvent () const;
192 css::uno::Sequence
< css::beans::NamedValue
> getConfig () const;
193 css::uno::Sequence
< css::beans::NamedValue
> getJobConfig () const;
195 bool hasConfig () const;
196 bool hasCorrectContext ( const OUString
& rModuleIdent
) const;
198 void setEnvironment ( EEnvironment eEnvironment
);
199 void setAlias ( const OUString
& sAlias
);
200 void setService ( const OUString
& sService
);
201 void setEvent ( const OUString
& sEvent
,
202 const OUString
& sAlias
);
203 void setJobConfig ( const css::uno::Sequence
< css::beans::NamedValue
>& lArguments
);
204 void setResult ( const JobResult
& aResult
);
207 static css::uno::Sequence
< OUString
> getEnabledJobsForEvent( const css::uno::Reference
< css::uno::XComponentContext
>& rxContext
,
208 const OUString
& sEvent
);
210 static void appendEnabledJobsForEvent( const css::uno::Reference
< css::uno::XComponentContext
>& rxContext
,
211 const OUString
& sEvent
,
212 ::std::vector
< JobData::TJob2DocEventBinding
>& lJobs
);
221 } // namespace framework
223 #endif // INCLUDED_FRAMEWORK_INC_JOBS_JOBDATA_HXX
225 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */