28#include <com/sun/star/beans/XPropertySet.hpp>
29#include <com/sun/star/beans/XMultiHierarchicalPropertySet.hpp>
30#include <com/sun/star/container/XNameAccess.hpp>
31#include <com/sun/star/container/XHierarchicalNameAccess.hpp>
124 (
"/org.openoffice.Office.Jobs/Jobs/"
133 css::uno::Reference< css::beans::XPropertySet > xJobProperties(aConfig.
cfg(), css::uno::UNO_QUERY);
134 if (xJobProperties.is())
136 css::uno::Any aValue;
139 aValue = xJobProperties->getPropertyValue(
"Service");
143 aValue = xJobProperties->getPropertyValue(
"Context");
147 aValue = xJobProperties->getPropertyValue(
"Arguments");
148 css::uno::Reference< css::container::XNameAccess > xArgumentList;
150 (aValue >>= xArgumentList) &&
151 (xArgumentList.is() )
154 css::uno::Sequence< OUString > lArgumentNames = xArgumentList->getElementNames();
155 sal_Int32
nCount = lArgumentNames.getLength();
204 const OUString& sAlias )
239 (
"/org.openoffice.Office.Jobs/Jobs/"
245 css::uno::Reference< css::beans::XMultiHierarchicalPropertySet > xArgumentList(aConfig.
cfg(), css::uno::UNO_QUERY);
246 if (xArgumentList.is())
249 css::uno::Sequence< OUString > lNames (
nCount);
250 auto lNamesRange = asNonConstRange(lNames);
251 css::uno::Sequence< css::uno::Any > lValues(
nCount);
252 auto lValuesRange = asNonConstRange(lValues);
260 xArgumentList->setHierarchicalPropertyValues(lNames, lValues);
293 OUString sDescriptor;
297 sDescriptor =
"EXECUTOR";
301 sDescriptor =
"DISPATCH";
305 sDescriptor =
"DOCUMENTEVENT";
330 css::uno::Sequence< css::beans::NamedValue > lConfig;
333 lConfig = { {
"Alias", css::uno::Any(
m_sAlias) },
378 (
"/org.openoffice.Office.Jobs/Events/"
385 css::uno::Reference< css::beans::XPropertySet > xPropSet(aConfig.
cfg(), css::uno::UNO_QUERY);
389 css::uno::Any aValue;
391 xPropSet->setPropertyValue(
"UserTime", aValue);
398 std::u16string_view sUserTime )
405 WildCard aISOPattern(
u"\?\?\?\?-\?\?-\?\?*");
407 bool bValidAdmin = aISOPattern.
Matches(sAdminTime);
408 bool bValidUser = aISOPattern.
Matches(sUserTime );
414 (!bValidAdmin && !bValidUser ) ||
415 ( bValidAdmin && bValidUser && sAdminTime>=sUserTime)
420 const OUString& sEvent ,
421 ::std::vector< JobData::TJob2DocEventBinding >& lJobs )
424 sal_Int32 c = lAdditionalJobs.size();
430 lJobs.push_back(aBinding);
436 sal_Int32 nContextLen =
m_sContext.getLength();
437 sal_Int32 nModuleIdLen = rModuleIdent.size();
439 if ( nContextLen == 0 )
442 if ( nModuleIdLen > 0 )
445 if (
nIndex >= 0 && (
nIndex+nModuleIdLen <= nContextLen ))
447 std::u16string_view sContextModule =
m_sContext.subView(
nIndex, nModuleIdLen );
448 return sContextModule == rModuleIdent;
456 std::u16string_view sEvent )
459 ConfigAccess aConfig(rxContext,
"/org.openoffice.Office.Jobs/Events");
462 return std::vector< OUString >();
464 css::uno::Reference< css::container::XHierarchicalNameAccess > xEventRegistry(aConfig.
cfg(), css::uno::UNO_QUERY);
465 if (!xEventRegistry.is())
466 return std::vector< OUString >();
469 OUString sPath(OUString::Concat(sEvent) +
"/JobList");
470 if (!xEventRegistry->hasByHierarchicalName(sPath))
471 return std::vector< OUString >();
475 css::uno::Any aJobList = xEventRegistry->getByHierarchicalName(sPath);
476 css::uno::Reference< css::container::XNameAccess > xJobList;
477 if (!(aJobList >>= xJobList) || !xJobList.is())
478 return std::vector< OUString >();
485 const css::uno::Sequence< OUString > lAllJobs = xJobList->getElementNames();
486 sal_Int32 c = lAllJobs.getLength();
488 std::vector< OUString > lEnabledJobs(c);
491 for (OUString
const & jobName : lAllJobs)
493 css::uno::Reference< css::beans::XPropertySet > xJob;
495 !(xJobList->getByName(jobName) >>= xJob) ||
503 xJob->getPropertyValue(
"AdminTime") >>= sAdminTime;
506 xJob->getPropertyValue(
"UserTime") >>= sUserTime;
511 lEnabledJobs[
d] = jobName;
514 lEnabledJobs.resize(
d);
bool Matches(std::u16string_view rStr) const
implements a simple configuration access @descr Sometimes it's better to have direct config access in...
void open(EOpenMode eMode)
open the configuration access in the specified mode @descr We set the opened configuration access as ...
EOpenMode getMode() const
return the internal mode of this instance @descr May be the outside user need any information about s...
void close()
close the internal opened configuration access and flush all changes @descr It checks,...
const css::uno::Reference< css::uno::XInterface > & cfg()
provides an access to the internal wrapped configuration access @descr It's not allowed to safe this ...
@ E_READONLY
config access is open for reading only
@ E_CLOSED
config isn't used yet
@ E_READWRITE
config access is open for reading/writing data
static OUString convert_DateTime2ISO8601(const DateTime &aSource)
holds all necessary information about a job and handle it's configuration (if any exist!...
void setEvent(const OUString &sEvent, const OUString &sAlias)
initialize this instance with new job values.
void disableJob()
mark a job as non startable for further requests @descr We don't remove the configuration entry!...
~JobData()
let this instance die @descr There is no chance any longer to work.
css::uno::Reference< css::uno::XComponentContext > m_xContext
reference to the uno service manager.
static void appendEnabledJobsForEvent(const css::uno::Reference< css::uno::XComponentContext > &rxContext, const OUString &sEvent, ::std::vector< JobData::TJob2DocEventBinding > &lJobs)
EEnvironment getEnvironment() const
void setService(const OUString &sService)
initialize this instance as a job without configuration @descr This job has no configuration data.
bool hasCorrectContext(std::u16string_view rModuleIdent) const
JobData(css::uno::Reference< css::uno::XComponentContext > xContext)
standard ctor @descr It initialize this new instance.
bool hasConfig() const
return information, if this job is part of the global configuration package org.openoffice....
EMode getMode() const
these functions provides access to our internal members @descr These member represent any information...
EMode
These values can be used to differe between jobs with and jobs without a configuration.
@ E_EVENT
indicates a job with configuration, which was triggered by an event
@ E_SERVICE
indicates a job without configuration (The pure UNO implementation is used only.)
@ E_UNKNOWN_MODE
indicates a missing initialization
@ E_ALIAS
indicates a job with configuration (They alias represent the config key name.)
OUString getEnvironmentDescriptor() const
OUString getEvent() const
EEnvironment m_eEnvironment
Because jobs can be bind to different mechanism inside office, a job should know inside which environ...
OUString m_sContext
the module context list of this job.
EEnvironment
These values represent the environment type, in which a job can run.
@ E_UNKNOWN_ENVIRONMENT
indicates a missing initialization
@ E_DISPATCH
this job is used by the global dispatch framework
@ E_EXECUTION
this job is used by the global JobExecutor service
@ E_DOCUMENTEVENT
this job is used by the global event broadcaster
css::uno::Sequence< css::beans::NamedValue > getConfig() const
static std::vector< OUString > getEnabledJobsForEvent(const css::uno::Reference< css::uno::XComponentContext > &rxContext, std::u16string_view sEvent)
OUString getService() const
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...
OUString m_sService
the uno implementation name of this job.
std::vector< css::beans::NamedValue > getJobConfig() const
EMode m_eMode
An instance of this class can be used in two different modes:
void setEnvironment(EEnvironment eEnvironment)
set a new environment descriptor for this job @descr It must(!) be done every time this container is ...
JobData & operator=(const JobData &rCopy)
operator for copying JobData instances @descr Sometimes such job data container must be moved from on...
void impl_reset()
reset all internal structures @descr If someone recycles this instance, he can switch from one using ...
std::vector< css::beans::NamedValue > m_lArguments
job specific configuration items... unknown for us! It's read from the configuration.
OUString m_sEvent
a job can be registered for an event.
OUString m_sAlias
the alias name of this job.
void setAlias(const OUString &sAlias)
initialize this instance as a job with configuration @descr They given alias can be used to address s...
css::uno::Reference< css::uno::XComponentContext > m_xContext
static bool isEnabled(std::u16string_view sAdminTime, std::u16string_view sUserTime)
OUString wrapConfigurationElementName(std::u16string_view _sElementName)
Some jobs can be registered to "logical events", which are generated on demand if another document ev...