1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
3 * This file is part of the LibreOffice project.
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/.
9 * This file incorporates work covered by the following license notice:
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 .
20 #ifndef __FRAMEWORK_JOBS_JOBEXECUTOR_HXX_
21 #define __FRAMEWORK_JOBS_JOBEXECUTOR_HXX_
23 #include <jobs/configaccess.hxx>
24 #include <threadhelp/threadhelpbase.hxx>
25 #include <macros/xinterface.hxx>
26 #include <macros/xtypeprovider.hxx>
27 #include <macros/xserviceinfo.hxx>
28 #include <macros/debug.hxx>
32 #include <com/sun/star/lang/XMultiServiceFactory.hpp>
33 #include <com/sun/star/task/XJobExecutor.hpp>
34 #include <com/sun/star/lang/XComponent.hpp>
35 #include <com/sun/star/container/XContainerListener.hpp>
36 #include <com/sun/star/lang/XEventListener.hpp>
37 #include <com/sun/star/document/XEventListener.hpp>
38 #include <com/sun/star/frame/XModuleManager2.hpp>
40 #include <cppuhelper/weak.hxx>
41 #include <rtl/ustring.hxx>
47 //_______________________________________
49 @short implements a job executor, which can be triggered from any code
50 @descr It uses the given trigger event to locate any registered job service
51 inside the configuration and execute it. Of course it controls the
52 liftime of such jobs too.
54 class JobExecutor
: public css::lang::XTypeProvider
55 , public css::lang::XServiceInfo
56 , public css::task::XJobExecutor
57 , public css::container::XContainerListener
// => lang.XEventListener
58 , public css::document::XEventListener
59 , private ThreadHelpBase
60 , public ::cppu::OWeakObject
62 //___________________________________
67 /** reference to the uno service manager */
68 css::uno::Reference
< css::lang::XMultiServiceFactory
> m_xSMGR
;
70 /** reference to the module info service */
71 css::uno::Reference
< css::frame::XModuleManager2
> m_xModuleManager
;
73 /** cached list of all registered event names of cfg for call optimization. */
74 OUStringList m_lEvents
;
76 /** we listen at the configuration for changes at the event list. */
77 ConfigAccess m_aConfig
;
79 /** helper to allow us listen to the configuration without a cyclic dependency */
80 com::sun::star::uno::Reference
<com::sun::star::container::XContainerListener
> m_xConfigListener
;
82 //___________________________________
83 // native interface methods
87 JobExecutor( const css::uno::Reference
< css::lang::XMultiServiceFactory
>& xSMGR
);
88 virtual ~JobExecutor( );
90 //___________________________________
91 // uno interface methods
95 // XInterface, XTypeProvider, XServiceInfo
96 FWK_DECLARE_XINTERFACE
97 FWK_DECLARE_XTYPEPROVIDER
101 virtual void SAL_CALL
trigger( const OUString
& sEvent
) throw(css::uno::RuntimeException
);
103 // document.XEventListener
104 virtual void SAL_CALL
notifyEvent( const css::document::EventObject
& aEvent
) throw(css::uno::RuntimeException
);
106 // container.XContainerListener
107 virtual void SAL_CALL
elementInserted( const css::container::ContainerEvent
& aEvent
) throw(css::uno::RuntimeException
);
108 virtual void SAL_CALL
elementRemoved ( const css::container::ContainerEvent
& aEvent
) throw(css::uno::RuntimeException
);
109 virtual void SAL_CALL
elementReplaced( const css::container::ContainerEvent
& aEvent
) throw(css::uno::RuntimeException
);
111 // lang.XEventListener
112 virtual void SAL_CALL
disposing( const css::lang::EventObject
& aEvent
) throw(css::uno::RuntimeException
);
115 } // namespace framework
117 #endif // __FRAMEWORK_JOBS_JOBEXECUTOR_HXX_
119 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */