LibreOffice Module framework (master) 1
|
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. More...
#include <jobdata.hxx>
Classes | |
struct | TJob2DocEventBinding |
Some jobs can be registered to "logical events", which are generated on demand if another document event occurs. More... | |
Public Types | |
enum | EMode { E_UNKNOWN_MODE , E_ALIAS , E_SERVICE , E_EVENT } |
These values can be used to differe between jobs with and jobs without a configuration. More... | |
enum | EEnvironment { E_UNKNOWN_ENVIRONMENT , E_EXECUTION , E_DISPATCH , E_DOCUMENTEVENT } |
These values represent the environment type, in which a job can run. More... | |
Public Member Functions | |
JobData (css::uno::Reference< css::uno::XComponentContext > xContext) | |
standard ctor @descr It initialize this new instance. More... | |
JobData (const JobData &rCopy) | |
copy ctor @descr Sometimes such job data container must be moved from one using place to another one. More... | |
~JobData () | |
let this instance die @descr There is no chance any longer to work. More... | |
JobData & | operator= (const JobData &rCopy) |
operator for copying JobData instances @descr Sometimes such job data container must be moved from one using place to another one. More... | |
EMode | getMode () const |
these functions provides access to our internal members @descr These member represent any information about the job and can be used from outside to e.g. More... | |
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 |
return information, if this job is part of the global configuration package org.openoffice.Office.Jobs @descr Because jobs can be executed by the dispatch framework using a uno service name directly - an executed job must not have any configuration really. More... | |
bool | hasCorrectContext (std::u16string_view rModuleIdent) const |
void | setEnvironment (EEnvironment eEnvironment) |
set a new environment descriptor for this job @descr It must(!) be done every time this container is initialized with new job data e.g. More... | |
void | setAlias (const OUString &sAlias) |
initialize this instance as a job with configuration @descr They given alias can be used to address some configuration data. More... | |
void | setService (const OUString &sService) |
initialize this instance as a job without configuration @descr This job has no configuration data. More... | |
void | setEvent (const OUString &sEvent, const OUString &sAlias) |
initialize this instance with new job values. More... | |
void | setJobConfig (std::vector< css::beans::NamedValue > &&lArguments) |
set the new job specific arguments @descr If a job finish his work, it can give us a new list of arguments (which will not interpreted by us). More... | |
void | disableJob () |
mark a job as non startable for further requests @descr We don't remove the configuration entry! We set a timestamp value only. More... | |
Static Public Member Functions | |
static std::vector< OUString > | getEnabledJobsForEvent (const css::uno::Reference< css::uno::XComponentContext > &rxContext, std::u16string_view sEvent) |
static void | appendEnabledJobsForEvent (const css::uno::Reference< css::uno::XComponentContext > &rxContext, const OUString &sEvent, ::std::vector< JobData::TJob2DocEventBinding > &lJobs) |
Private Member Functions | |
void | impl_reset () |
reset all internal structures @descr If someone recycles this instance, he can switch from one using mode to another one. More... | |
Private Attributes | |
css::uno::Reference< css::uno::XComponentContext > | m_xContext |
reference to the uno service manager. More... | |
EMode | m_eMode |
An instance of this class can be used in two different modes: More... | |
EEnvironment | m_eEnvironment |
Because jobs can be bind to different mechanism inside office, a job should know inside which environment it runs. More... | |
OUString | m_sAlias |
the alias name of this job. More... | |
OUString | m_sService |
the uno implementation name of this job. More... | |
OUString | m_sContext |
the module context list of this job. More... | |
OUString | m_sEvent |
a job can be registered for an event. More... | |
std::vector< css::beans::NamedValue > | m_lArguments |
job specific configuration items... unknown for us! It's read from the configuration. More... | |
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!
Definition at line 40 of file jobdata.hxx.
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!
Definition at line 64 of file jobdata.hxx.
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.
Definition at line 48 of file jobdata.hxx.
framework::JobData::JobData | ( | css::uno::Reference< css::uno::XComponentContext > | xContext | ) |
standard ctor @descr It initialize this new instance.
But for real working it's necessary to call setAlias() or setService() later. Because we need the job data ...
rxContext | reference to the uno service manager |
Definition at line 49 of file jobdata.cxx.
References impl_reset().
framework::JobData::JobData | ( | const JobData & | rCopy | ) |
copy ctor @descr Sometimes such job data container must be moved from one using place to another one.
Then a copy ctor and copy operator must be available.
rCopy | the original instance, from which we must copy all data |
Definition at line 64 of file jobdata.cxx.
framework::JobData::~JobData | ( | ) |
let this instance die @descr There is no chance any longer to work.
We have to release all used resources and free used memory.
Definition at line 97 of file jobdata.cxx.
References impl_reset().
|
static |
Definition at line 419 of file jobdata.cxx.
References getEnabledJobsForEvent(), and i.
void framework::JobData::disableJob | ( | ) |
mark a job as non startable for further requests @descr We don't remove the configuration entry! We set a timestamp value only.
And there exist two of them: one for an administrator... and one for the current user. We change it for the user layer only. So this JobDispatch can't be started any more... till the administrator change his timestamp. That can be useful for post setup scenarios, which must run one time only.
Note: This method don't do anything, if this represented job doesn't have a configuration!
Definition at line 366 of file jobdata.cxx.
References framework::ConfigAccess::cfg(), framework::ConfigAccess::close(), framework::Converter::convert_DateTime2ISO8601(), framework::ConfigAccess::E_CLOSED, E_EVENT, framework::ConfigAccess::E_READWRITE, framework::ConfigAccess::getMode(), m_eMode, m_sAlias, m_sEvent, m_xContext, framework::ConfigAccess::open(), DateTime::SYSTEM, and utl::wrapConfigurationElementName().
css::uno::Sequence< css::beans::NamedValue > framework::JobData::getConfig | ( | ) | const |
Definition at line 328 of file jobdata.cxx.
References E_ALIAS, m_eMode, m_sAlias, m_sContext, and m_sService.
|
static |
Definition at line 455 of file jobdata.cxx.
References framework::ConfigAccess::cfg(), framework::ConfigAccess::close(), d, framework::ConfigAccess::E_CLOSED, framework::ConfigAccess::E_READONLY, framework::ConfigAccess::getMode(), framework::isEnabled(), and framework::ConfigAccess::open().
Referenced by appendEnabledJobsForEvent().
JobData::EEnvironment framework::JobData::getEnvironment | ( | ) | const |
Definition at line 286 of file jobdata.cxx.
References m_eEnvironment.
OUString framework::JobData::getEnvironmentDescriptor | ( | ) | const |
Definition at line 291 of file jobdata.cxx.
References E_DISPATCH, E_DOCUMENTEVENT, E_EXECUTION, and m_eEnvironment.
OUString framework::JobData::getEvent | ( | ) | const |
Definition at line 318 of file jobdata.cxx.
References m_sEvent.
std::vector< css::beans::NamedValue > framework::JobData::getJobConfig | ( | ) | const |
Definition at line 323 of file jobdata.cxx.
References m_lArguments.
JobData::EMode framework::JobData::getMode | ( | ) | const |
these functions provides access to our internal members @descr These member represent any information about the job and can be used from outside to e.g.
start a job.
Definition at line 281 of file jobdata.cxx.
References m_eMode.
OUString framework::JobData::getService | ( | ) | const |
Definition at line 313 of file jobdata.cxx.
References m_sService.
bool framework::JobData::hasConfig | ( | ) | const |
return information, if this job is part of the global configuration package org.openoffice.Office.Jobs @descr Because jobs can be executed by the dispatch framework using a uno service name directly - an executed job must not have any configuration really.
Such jobs must provide the right interfaces only! But after finishing jobs can return some information (e.g. for updating her configuration ...). We must know if such request is valid or not then.
Definition at line 351 of file jobdata.cxx.
bool framework::JobData::hasCorrectContext | ( | std::u16string_view | rModuleIdent | ) | const |
Definition at line 434 of file jobdata.cxx.
References m_sContext, and nIndex.
|
private |
reset all internal structures @descr If someone recycles this instance, he can switch from one using mode to another one.
But then we have to reset all currently used information. Otherwise we mix it and they can make trouble.
But note: that does not set defaults for internal used members, which does not relate to any job property! e.g. the reference to the global uno service manager. Such information is used for internal processes only and are necessary for our work.
Definition at line 532 of file jobdata.cxx.
References E_UNKNOWN_ENVIRONMENT, E_UNKNOWN_MODE, m_eEnvironment, m_eMode, m_lArguments, m_sAlias, m_sContext, m_sEvent, and m_sService.
Referenced by JobData(), setAlias(), setService(), and ~JobData().
operator for copying JobData instances @descr Sometimes such job data container must be moved from one using place to another one.
Then a copy ctor and copy operator must be available.
rCopy | the original instance, from which we must copy all data |
Definition at line 78 of file jobdata.cxx.
References m_eEnvironment, m_eMode, m_lArguments, m_sAlias, m_sContext, m_sEvent, and m_sService.
void framework::JobData::setAlias | ( | const OUString & | sAlias | ) |
initialize this instance as a job with configuration @descr They given alias can be used to address some configuration data.
We read it and fill our internal structures. Of course old information will be lost doing so.
sAlias | the alias name of this job, used to locate job properties inside cfg |
Definition at line 111 of file jobdata.cxx.
References framework::ConfigAccess::cfg(), framework::ConfigAccess::close(), E_ALIAS, framework::ConfigAccess::E_CLOSED, framework::ConfigAccess::E_READONLY, framework::ConfigAccess::getMode(), i, impl_reset(), m_eMode, m_lArguments, m_sAlias, m_sContext, m_sService, m_xContext, Name, nCount, framework::ConfigAccess::open(), and utl::wrapConfigurationElementName().
Referenced by setEvent().
void framework::JobData::setEnvironment | ( | EEnvironment | eEnvironment | ) |
set a new environment descriptor for this job @descr It must(!) be done every time this container is initialized with new job data e.g.
: setAlias()/setEvent()/setService() ... Otherwise the environment will be unknown!
Definition at line 271 of file jobdata.cxx.
References m_eEnvironment.
void framework::JobData::setEvent | ( | const OUString & | sEvent, |
const OUString & | sAlias | ||
) |
initialize this instance with new job values.
@descr It reads automatically all properties of the specified job (using it's alias name) and "register it" for the given event. This registration will not be validated against the underlying configuration! (That must be done from outside. Because the caller must have the configuration already open to get the values for sEvent and sAlias! And doing so it can perform only, if the time stamp values are read outside too. Further it makes no sense to initialize and start a disabled job. So this initialization method will be called for enabled jobs only.)
sEvent | the triggered event, for which this job should be started |
sAlias | mark the required job inside event registration list |
Definition at line 203 of file jobdata.cxx.
References E_EVENT, m_eMode, m_sEvent, and setAlias().
void framework::JobData::setJobConfig | ( | std::vector< css::beans::NamedValue > && | lArguments | ) |
set the new job specific arguments @descr If a job finish his work, it can give us a new list of arguments (which will not interpreted by us).
We write it back to the configuration only (if this job has its own configuration!). So a job can have persistent data without implementing anything or define own config areas for that.
lArguments | list of arguments, which should be set for this job |
Definition at line 225 of file jobdata.cxx.
References framework::ConfigAccess::cfg(), framework::ConfigAccess::close(), E_ALIAS, framework::ConfigAccess::E_CLOSED, framework::ConfigAccess::E_READWRITE, framework::ConfigAccess::getMode(), i, m_eMode, m_lArguments, m_sAlias, m_xContext, nCount, framework::ConfigAccess::open(), and utl::wrapConfigurationElementName().
void framework::JobData::setService | ( | const OUString & | sService | ) |
initialize this instance as a job without configuration @descr This job has no configuration data.
We have to forget all old information and set only some of them new, so this instance can work.
sService | the uno service name of this "non configured" job |
Definition at line 176 of file jobdata.cxx.
References E_SERVICE, impl_reset(), m_eMode, and m_sService.
|
private |
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).
Definition at line 126 of file jobdata.hxx.
Referenced by getEnvironment(), getEnvironmentDescriptor(), impl_reset(), operator=(), and setEnvironment().
|
private |
An instance of this class can be used in two different modes:
Definition at line 118 of file jobdata.hxx.
Referenced by disableJob(), getConfig(), getMode(), hasConfig(), impl_reset(), operator=(), setAlias(), setEvent(), setJobConfig(), and setService().
|
private |
job specific configuration items... unknown for us! It's read from the configuration.
Don't set it from outside!
Definition at line 162 of file jobdata.hxx.
Referenced by getJobConfig(), impl_reset(), operator=(), setAlias(), and setJobConfig().
|
private |
the alias name of this job.
Is used as entry of configuration set for job registration, to find all necessary properties of it...
Definition at line 133 of file jobdata.hxx.
Referenced by disableJob(), getConfig(), impl_reset(), operator=(), setAlias(), and setJobConfig().
|
private |
the module context list of this job.
It's read from the configuration. Don't set it from outside!
Definition at line 145 of file jobdata.hxx.
Referenced by getConfig(), hasCorrectContext(), impl_reset(), operator=(), and setAlias().
|
private |
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.
Definition at line 156 of file jobdata.hxx.
Referenced by disableJob(), getEvent(), impl_reset(), operator=(), and setEvent().
|
private |
the uno implementation name of this job.
It's read from the configuration. Don't set it from outside!
Definition at line 139 of file jobdata.hxx.
Referenced by getConfig(), getService(), impl_reset(), operator=(), setAlias(), and setService().
|
private |
reference to the uno service manager.
We need it for creating of own uno services ... e.g. for opening the configuration.
Definition at line 106 of file jobdata.hxx.
Referenced by disableJob(), setAlias(), and setJobConfig().