LibreOffice Module framework (master) 1
Public Member Functions | Private Types | Private Member Functions | Private Attributes | List of all members
framework::Job Class Referencefinal

it represent a job; execute it and control its lifetime More...

#include <job.hxx>

Inheritance diagram for framework::Job:
[legend]
Collaboration diagram for framework::Job:
[legend]

Public Member Functions

 Job (const css::uno::Reference< css::uno::XComponentContext > &xContext, css::uno::Reference< css::frame::XFrame > xFrame)
 
 Job (const css::uno::Reference< css::uno::XComponentContext > &xContext, css::uno::Reference< css::frame::XModel > xModel)
 
virtual ~Job () override
 
void setDispatchResultFake (const css::uno::Reference< css::frame::XDispatchResultListener > &xListener, const css::uno::Reference< css::uno::XInterface > &xSourceFake)
 
void setJobData (const JobData &aData)
 
void execute (const css::uno::Sequence< css::beans::NamedValue > &lDynamicArgs)
 
void die ()
 
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
 
virtual void SAL_CALL notifyTermination (const css::lang::EventObject &aEvent) override
 
virtual void SAL_CALL queryClosing (const css::lang::EventObject &aEvent, sal_Bool bGetsOwnership) override
 
virtual void SAL_CALL notifyClosing (const css::lang::EventObject &aEvent) override
 
virtual void SAL_CALL disposing (const css::lang::EventObject &aEvent) override
 

Private Types

enum  ERunState {
  E_NEW ,
  E_RUNNING ,
  E_STOPPED_OR_FINISHED ,
  E_DISPOSED
}
 different possible states for the internal wrapped job. More...
 

Private Member Functions

css::uno::Sequence< css::beans::NamedValue > impl_generateJobArgs (const css::uno::Sequence< css::beans::NamedValue > &lDynamicArgs)
 
void impl_reactForJobResult (const css::uno::Any &aResult)
 
void impl_startListening ()
 
void impl_stopListening ()
 

Private Attributes

JobData m_aJobCfg
 hold all necessary information about this job. More...
 
css::uno::Reference< css::uno::XComponentContext > m_xContext
 We need it to create own services on demand. More...
 
css::uno::Reference< css::uno::XInterface > m_xJob
 Hold the (may asynchronous) job alive. More...
 
::osl::Condition m_aAsyncWait
 Used to wait for finishing of asynchronous started jobs. More...
 
css::uno::Reference< css::frame::XFrame > m_xFrame
 For some special cases we must know the environment, in which this job runs. More...
 
css::uno::Reference< css::frame::XModel > m_xModel
 For some special cases we must know the environment, in which this job runs. More...
 
css::uno::Reference< css::frame::XDesktop2 > m_xDesktop
 We are registered at this instance to listen for office shutdown events. More...
 
css::uno::Reference< css::frame::XDispatchResultListener > m_xResultListener
 A job can return a dispatch result event after finishing its work. More...
 
css::uno::Reference< css::uno::XInterface > m_xResultSourceFake
 We can't set ourself as source of a dispatch result event ... nor our job. More...
 
bool m_bListenOnDesktop
 Holds the state, if we are listen for desktop/frame or model closing events or not. More...
 
bool m_bListenOnFrame
 
bool m_bListenOnModel
 
bool m_bPendingCloseFrame
 In case we got a close request from our desktop/frame/model (on which we listen) ... and the ownership was delivered there ... we have to close ourself and this object in case the internal wrapped and running job finish his work. More...
 
bool m_bPendingCloseModel
 
ERunState m_eRunState
 indicates in which state the internal job currently exist. More...
 

Detailed Description

it represent a job; execute it and control its lifetime

@descr This implementation can be used to wrap jobs, execute it synchronously or asynchronous, control its lifetime and differe between jobs with and without configuration.

Definition at line 42 of file job.hxx.

Member Enumeration Documentation

◆ ERunState

different possible states for the internal wrapped job.

It can be started, stopped by a queryClosing() request or disposed() by a notifyClosing() request ...

Enumerator
E_NEW 
E_RUNNING 
E_STOPPED_OR_FINISHED 
E_DISPOSED 

Definition at line 56 of file job.hxx.

Constructor & Destructor Documentation

◆ Job() [1/2]

framework::Job::Job ( const css::uno::Reference< css::uno::XComponentContext > &  xContext,
css::uno::Reference< css::frame::XFrame >  xFrame 
)

◆ Job() [2/2]

framework::Job::Job ( const css::uno::Reference< css::uno::XComponentContext > &  xContext,
css::uno::Reference< css::frame::XModel >  xModel 
)

◆ ~Job()

virtual framework::Job::~Job ( )
overridevirtual

Member Function Documentation

◆ die()

void framework::Job::die ( )

◆ disposing()

virtual void SAL_CALL framework::Job::disposing ( const css::lang::EventObject &  aEvent)
overridevirtual

◆ execute()

void framework::Job::execute ( const css::uno::Sequence< css::beans::NamedValue > &  lDynamicArgs)

◆ impl_generateJobArgs()

css::uno::Sequence< css::beans::NamedValue > framework::Job::impl_generateJobArgs ( const css::uno::Sequence< css::beans::NamedValue > &  lDynamicArgs)
private

◆ impl_reactForJobResult()

void framework::Job::impl_reactForJobResult ( const css::uno::Any &  aResult)
private

◆ impl_startListening()

void framework::Job::impl_startListening ( )
private

◆ impl_stopListening()

void framework::Job::impl_stopListening ( )
private

◆ jobFinished()

virtual void SAL_CALL framework::Job::jobFinished ( const css::uno::Reference< css::task::XAsyncJob > &  xJob,
const css::uno::Any &  aResult 
)
overridevirtual

◆ notifyClosing()

virtual void SAL_CALL framework::Job::notifyClosing ( const css::lang::EventObject &  aEvent)
overridevirtual

◆ notifyTermination()

virtual void SAL_CALL framework::Job::notifyTermination ( const css::lang::EventObject &  aEvent)
overridevirtual

◆ queryClosing()

virtual void SAL_CALL framework::Job::queryClosing ( const css::lang::EventObject &  aEvent,
sal_Bool  bGetsOwnership 
)
overridevirtual

◆ queryTermination()

virtual void SAL_CALL framework::Job::queryTermination ( const css::lang::EventObject &  aEvent)
overridevirtual

◆ setDispatchResultFake()

void framework::Job::setDispatchResultFake ( const css::uno::Reference< css::frame::XDispatchResultListener > &  xListener,
const css::uno::Reference< css::uno::XInterface > &  xSourceFake 
)

◆ setJobData()

void framework::Job::setJobData ( const JobData aData)

Member Data Documentation

◆ m_aAsyncWait

::osl::Condition framework::Job::m_aAsyncWait
private

Used to wait for finishing of asynchronous started jobs.

Definition at line 87 of file job.hxx.

◆ m_aJobCfg

JobData framework::Job::m_aJobCfg
private

hold all necessary information about this job.

It can be used for both modes: with and without configuration.

Definition at line 72 of file job.hxx.

◆ m_bListenOnDesktop

bool framework::Job::m_bListenOnDesktop
private

Holds the state, if we are listen for desktop/frame or model closing events or not.

The used references are not really enough to detect a valid listener connection. That's why we use this additional information here too.

Definition at line 135 of file job.hxx.

◆ m_bListenOnFrame

bool framework::Job::m_bListenOnFrame
private

Definition at line 136 of file job.hxx.

◆ m_bListenOnModel

bool framework::Job::m_bListenOnModel
private

Definition at line 137 of file job.hxx.

◆ m_bPendingCloseFrame

bool framework::Job::m_bPendingCloseFrame
private

In case we got a close request from our desktop/frame/model (on which we listen) ... and the ownership was delivered there ... we have to close ourself and this object in case the internal wrapped and running job finish his work.

Definition at line 144 of file job.hxx.

◆ m_bPendingCloseModel

bool framework::Job::m_bPendingCloseModel
private

Definition at line 145 of file job.hxx.

◆ m_eRunState

ERunState framework::Job::m_eRunState
private

indicates in which state the internal job currently exist.

We can use this information to throw any suitable veto exception to prevent the environment against dying or suppress superfluous dispose() calls at the job.

Definition at line 154 of file job.hxx.

◆ m_xContext

css::uno::Reference< css::uno::XComponentContext > framework::Job::m_xContext
private

We need it to create own services on demand.

Definition at line 77 of file job.hxx.

◆ m_xDesktop

css::uno::Reference< css::frame::XDesktop2 > framework::Job::m_xDesktop
private

We are registered at this instance to listen for office shutdown events.

It's necessary suppress it (if possible) or to react in the right way.

Definition at line 113 of file job.hxx.

◆ m_xFrame

css::uno::Reference< css::frame::XFrame > framework::Job::m_xFrame
private

For some special cases we must know the environment, in which this job runs.

Means the frame inside which we may was triggered. We use it too, to listen for closing events of this resource.

Please note: If m_xFrame is set - m_xModel should be NULL. Only one environment can be supported really.

Definition at line 97 of file job.hxx.

◆ m_xJob

css::uno::Reference< css::uno::XInterface > framework::Job::m_xJob
private

Hold the (may asynchronous) job alive.

Definition at line 82 of file job.hxx.

◆ m_xModel

css::uno::Reference< css::frame::XModel > framework::Job::m_xModel
private

For some special cases we must know the environment, in which this job runs.

Means the document inside which we may was triggered. We use it too, to listen for closing events of this resource.

Please note: If m_xModel is set - m_xFrame should be NULL. Only one environment can be supported really.

Definition at line 107 of file job.hxx.

◆ m_xResultListener

css::uno::Reference< css::frame::XDispatchResultListener > framework::Job::m_xResultListener
private

A job can return a dispatch result event after finishing its work.

We have to transport it to any outside interested listener then. (see m_xResultSourceFake for further information too!)

Definition at line 120 of file job.hxx.

◆ m_xResultSourceFake

css::uno::Reference< css::uno::XInterface > framework::Job::m_xResultSourceFake
private

We can't set ourself as source of a dispatch result event ... nor our job.

Because the listener (set as m_xResultListener) expect the original instance, where it was registered. This original instance is the user of this class. It must be set explicitly and will be used to fake the source of the event!

Definition at line 128 of file job.hxx.


The documentation for this class was generated from the following file: