LibreOffice Module framework (master) 1
jobdata.hxx
Go to the documentation of this file.
1/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2/*
3 * This file is part of the LibreOffice project.
4 *
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/.
8 *
9 * This file incorporates work covered by the following license notice:
10 *
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 .
18 */
19
20#pragma once
21
22#include <com/sun/star/uno/XComponentContext.hpp>
23#include <com/sun/star/beans/NamedValue.hpp>
24
25#include <rtl/ustring.hxx>
26
27#include <string_view>
28#include <utility>
29#include <vector>
30
31namespace framework{
32
40class JobData final
41{
42 public:
43
48 enum EMode
49 {
58 };
59
65 {
74 };
75
86 {
87 OUString m_sJobName;
88 OUString m_sDocEvent;
89
90 TJob2DocEventBinding(OUString sJobName ,
91 OUString sDocEvent)
92 : m_sJobName (std::move(sJobName ))
93 , m_sDocEvent(std::move(sDocEvent))
94 {}
95 };
96
97 // member
98
99 private:
100
106 css::uno::Reference< css::uno::XComponentContext > m_xContext;
107
119
127
133 OUString m_sAlias;
134
139 OUString m_sService;
140
145 OUString m_sContext;
146
156 OUString m_sEvent;
157
162 std::vector< css::beans::NamedValue > m_lArguments;
163
164 // native interface
165
166 public:
167
168 JobData( css::uno::Reference< css::uno::XComponentContext > xContext );
169 JobData( const JobData& rCopy );
170 ~JobData( );
171
172 JobData& operator=( const JobData& rCopy );
173
174 EMode getMode () const;
176 OUString getEnvironmentDescriptor() const;
177 OUString getService () const;
178 OUString getEvent () const;
179 css::uno::Sequence< css::beans::NamedValue > getConfig () const;
180 std::vector< css::beans::NamedValue > getJobConfig () const;
181
182 bool hasConfig () const;
183 bool hasCorrectContext ( std::u16string_view rModuleIdent ) const;
184
185 void setEnvironment ( EEnvironment eEnvironment );
186 void setAlias ( const OUString& sAlias );
187 void setService ( const OUString& sService );
188 void setEvent ( const OUString& sEvent ,
189 const OUString& sAlias );
190 void setJobConfig ( std::vector< css::beans::NamedValue >&& lArguments );
191 void disableJob ( );
192
193 static std::vector< OUString > getEnabledJobsForEvent( const css::uno::Reference< css::uno::XComponentContext >& rxContext,
194 std::u16string_view sEvent );
195
196 static void appendEnabledJobsForEvent( const css::uno::Reference< css::uno::XComponentContext >& rxContext,
197 const OUString& sEvent ,
198 ::std::vector< JobData::TJob2DocEventBinding >& lJobs );
199
200 // private helper
201
202 private:
203
204 void impl_reset();
205};
206
207} // namespace framework
208
209/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
holds all necessary information about a job and handle it's configuration (if any exist!...
Definition: jobdata.hxx:41
void setEvent(const OUString &sEvent, const OUString &sAlias)
initialize this instance with new job values.
Definition: jobdata.cxx:203
void disableJob()
mark a job as non startable for further requests @descr We don't remove the configuration entry!...
Definition: jobdata.cxx:366
~JobData()
let this instance die @descr There is no chance any longer to work.
Definition: jobdata.cxx:97
css::uno::Reference< css::uno::XComponentContext > m_xContext
reference to the uno service manager.
Definition: jobdata.hxx:106
static void appendEnabledJobsForEvent(const css::uno::Reference< css::uno::XComponentContext > &rxContext, const OUString &sEvent, ::std::vector< JobData::TJob2DocEventBinding > &lJobs)
Definition: jobdata.cxx:419
EEnvironment getEnvironment() const
Definition: jobdata.cxx:286
void setService(const OUString &sService)
initialize this instance as a job without configuration @descr This job has no configuration data.
Definition: jobdata.cxx:176
bool hasCorrectContext(std::u16string_view rModuleIdent) const
Definition: jobdata.cxx:434
JobData(css::uno::Reference< css::uno::XComponentContext > xContext)
standard ctor @descr It initialize this new instance.
Definition: jobdata.cxx:49
bool hasConfig() const
return information, if this job is part of the global configuration package org.openoffice....
Definition: jobdata.cxx:351
EMode getMode() const
these functions provides access to our internal members @descr These member represent any information...
Definition: jobdata.cxx:281
EMode
These values can be used to differe between jobs with and jobs without a configuration.
Definition: jobdata.hxx:49
@ E_EVENT
indicates a job with configuration, which was triggered by an event
Definition: jobdata.hxx:57
@ E_SERVICE
indicates a job without configuration (The pure UNO implementation is used only.)
Definition: jobdata.hxx:55
@ E_UNKNOWN_MODE
indicates a missing initialization
Definition: jobdata.hxx:51
@ E_ALIAS
indicates a job with configuration (They alias represent the config key name.)
Definition: jobdata.hxx:53
OUString getEnvironmentDescriptor() const
Definition: jobdata.cxx:291
OUString getEvent() const
Definition: jobdata.cxx:318
EEnvironment m_eEnvironment
Because jobs can be bind to different mechanism inside office, a job should know inside which environ...
Definition: jobdata.hxx:126
OUString m_sContext
the module context list of this job.
Definition: jobdata.hxx:145
EEnvironment
These values represent the environment type, in which a job can run.
Definition: jobdata.hxx:65
@ E_UNKNOWN_ENVIRONMENT
indicates a missing initialization
Definition: jobdata.hxx:67
@ E_DISPATCH
this job is used by the global dispatch framework
Definition: jobdata.hxx:71
@ E_EXECUTION
this job is used by the global JobExecutor service
Definition: jobdata.hxx:69
@ E_DOCUMENTEVENT
this job is used by the global event broadcaster
Definition: jobdata.hxx:73
css::uno::Sequence< css::beans::NamedValue > getConfig() const
Definition: jobdata.cxx:328
static std::vector< OUString > getEnabledJobsForEvent(const css::uno::Reference< css::uno::XComponentContext > &rxContext, std::u16string_view sEvent)
Definition: jobdata.cxx:455
OUString getService() const
Definition: jobdata.cxx:313
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 argu...
Definition: jobdata.cxx:225
OUString m_sService
the uno implementation name of this job.
Definition: jobdata.hxx:139
std::vector< css::beans::NamedValue > getJobConfig() const
Definition: jobdata.cxx:323
EMode m_eMode
An instance of this class can be used in two different modes:
Definition: jobdata.hxx:118
void setEnvironment(EEnvironment eEnvironment)
set a new environment descriptor for this job @descr It must(!) be done every time this container is ...
Definition: jobdata.cxx:271
JobData & operator=(const JobData &rCopy)
operator for copying JobData instances @descr Sometimes such job data container must be moved from on...
Definition: jobdata.cxx:78
void impl_reset()
reset all internal structures @descr If someone recycles this instance, he can switch from one using ...
Definition: jobdata.cxx:532
std::vector< css::beans::NamedValue > m_lArguments
job specific configuration items... unknown for us! It's read from the configuration.
Definition: jobdata.hxx:162
OUString m_sEvent
a job can be registered for an event.
Definition: jobdata.hxx:156
OUString m_sAlias
the alias name of this job.
Definition: jobdata.hxx:133
void setAlias(const OUString &sAlias)
initialize this instance as a job with configuration @descr They given alias can be used to address s...
Definition: jobdata.cxx:111
Some jobs can be registered to "logical events", which are generated on demand if another document ev...
Definition: jobdata.hxx:86
TJob2DocEventBinding(OUString sJobName, OUString sDocEvent)
Definition: jobdata.hxx:90