LibreOffice Module framework (master) 1
job.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 <jobs/jobdata.hxx>
23
24#include <com/sun/star/frame/XFrame.hpp>
25#include <com/sun/star/frame/XDesktop2.hpp>
26#include <com/sun/star/frame/XDispatchResultListener.hpp>
27#include <com/sun/star/task/XJobListener.hpp>
28#include <com/sun/star/util/XCloseListener.hpp>
29
31#include <osl/conditn.hxx>
32
33namespace framework{
34
42class Job final : public ::cppu::WeakImplHelper<
43 css::task::XJobListener
44 , css::frame::XTerminateListener
45 , css::util::XCloseListener >
46{
47
48 // structs
49
50 private:
51
57 {
62 };
63
64 // member
65
66 private:
67
73
77 css::uno::Reference< css::uno::XComponentContext > m_xContext;
78
82 css::uno::Reference< css::uno::XInterface > m_xJob;
83
87 ::osl::Condition m_aAsyncWait;
88
97 css::uno::Reference< css::frame::XFrame > m_xFrame;
98
107 css::uno::Reference< css::frame::XModel > m_xModel;
108
113 css::uno::Reference< css::frame::XDesktop2 > m_xDesktop;
114
120 css::uno::Reference< css::frame::XDispatchResultListener > m_xResultListener;
121
128 css::uno::Reference< css::uno::XInterface > m_xResultSourceFake;
129
138
146
155
156 // native interface
157
158 public:
159
160 Job( const css::uno::Reference< css::uno::XComponentContext >& xContext ,
161 css::uno::Reference< css::frame::XFrame > xFrame );
162 Job( const css::uno::Reference< css::uno::XComponentContext >& xContext ,
163 css::uno::Reference< css::frame::XModel > xModel );
164 virtual ~Job( ) override;
165
166 void setDispatchResultFake( const css::uno::Reference< css::frame::XDispatchResultListener >& xListener ,
167 const css::uno::Reference< css::uno::XInterface >& xSourceFake );
168 void setJobData ( const JobData& aData );
169 void execute ( const css::uno::Sequence< css::beans::NamedValue >& lDynamicArgs );
170 void die ( );
171
172 private:
173
174 css::uno::Sequence< css::beans::NamedValue > impl_generateJobArgs ( const css::uno::Sequence< css::beans::NamedValue >& lDynamicArgs );
175 void impl_reactForJobResult( const css::uno::Any& aResult );
178
179 // uno interface
180
181 public:
182
183 // XJobListener
184 virtual void SAL_CALL jobFinished( const css::uno::Reference< css::task::XAsyncJob >& xJob,
185 const css::uno::Any& aResult ) override;
186
187 // XTerminateListener
188 virtual void SAL_CALL queryTermination ( const css::lang::EventObject& aEvent ) override;
189 virtual void SAL_CALL notifyTermination( const css::lang::EventObject& aEvent ) override;
190
191 // XCloseListener
192 virtual void SAL_CALL queryClosing ( const css::lang::EventObject& aEvent ,
193 sal_Bool bGetsOwnership ) override;
194 virtual void SAL_CALL notifyClosing( const css::lang::EventObject& aEvent ) override;
195
196 // XEventListener
197 virtual void SAL_CALL disposing( const css::lang::EventObject& aEvent ) override;
198};
199
200} // namespace framework
201
202/* 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
it represent a job; execute it and control its lifetime
Definition: job.hxx:46
virtual void SAL_CALL queryClosing(const css::lang::EventObject &aEvent, sal_Bool bGetsOwnership) override
virtual void SAL_CALL jobFinished(const css::uno::Reference< css::task::XAsyncJob > &xJob, const css::uno::Any &aResult) override
virtual void SAL_CALL queryTermination(const css::lang::EventObject &aEvent) override
void execute(const css::uno::Sequence< css::beans::NamedValue > &lDynamicArgs)
void impl_stopListening()
ERunState m_eRunState
indicates in which state the internal job currently exist.
Definition: job.hxx:154
virtual void SAL_CALL notifyTermination(const css::lang::EventObject &aEvent) override
void setDispatchResultFake(const css::uno::Reference< css::frame::XDispatchResultListener > &xListener, const css::uno::Reference< css::uno::XInterface > &xSourceFake)
virtual void SAL_CALL disposing(const css::lang::EventObject &aEvent) override
css::uno::Reference< css::frame::XDispatchResultListener > m_xResultListener
A job can return a dispatch result event after finishing its work.
Definition: job.hxx:120
bool m_bPendingCloseFrame
In case we got a close request from our desktop/frame/model (on which we listen) ....
Definition: job.hxx:144
bool m_bPendingCloseModel
Definition: job.hxx:145
JobData m_aJobCfg
hold all necessary information about this job.
Definition: job.hxx:72
void impl_reactForJobResult(const css::uno::Any &aResult)
bool m_bListenOnFrame
Definition: job.hxx:136
void impl_startListening()
css::uno::Reference< css::frame::XFrame > m_xFrame
For some special cases we must know the environment, in which this job runs.
Definition: job.hxx:97
Job(const css::uno::Reference< css::uno::XComponentContext > &xContext, css::uno::Reference< css::frame::XFrame > xFrame)
virtual ~Job() override
ERunState
different possible states for the internal wrapped job.
Definition: job.hxx:57
@ E_STOPPED_OR_FINISHED
Definition: job.hxx:60
@ E_DISPOSED
Definition: job.hxx:61
void setJobData(const JobData &aData)
Job(const css::uno::Reference< css::uno::XComponentContext > &xContext, css::uno::Reference< css::frame::XModel > xModel)
virtual void SAL_CALL notifyClosing(const css::lang::EventObject &aEvent) override
css::uno::Reference< css::frame::XModel > m_xModel
For some special cases we must know the environment, in which this job runs.
Definition: job.hxx:107
css::uno::Reference< css::frame::XDesktop2 > m_xDesktop
We are registered at this instance to listen for office shutdown events.
Definition: job.hxx:113
css::uno::Reference< css::uno::XInterface > m_xJob
Hold the (may asynchronous) job alive.
Definition: job.hxx:82
bool m_bListenOnModel
Definition: job.hxx:137
bool m_bListenOnDesktop
Holds the state, if we are listen for desktop/frame or model closing events or not.
Definition: job.hxx:135
css::uno::Sequence< css::beans::NamedValue > impl_generateJobArgs(const css::uno::Sequence< css::beans::NamedValue > &lDynamicArgs)
::osl::Condition m_aAsyncWait
Used to wait for finishing of asynchronous started jobs.
Definition: job.hxx:87
css::uno::Reference< css::uno::XComponentContext > m_xContext
We need it to create own services on demand.
Definition: job.hxx:77
css::uno::Reference< css::uno::XInterface > m_xResultSourceFake
We can't set ourself as source of a dispatch result event ... nor our job.
Definition: job.hxx:128
unsigned char sal_Bool