xref: /trunk/main/framework/inc/jobs/jobexecutor.hxx (revision cdf0e10c)
1 /*************************************************************************
2  *
3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4  *
5  * Copyright 2000, 2010 Oracle and/or its affiliates.
6  *
7  * OpenOffice.org - a multi-platform office productivity suite
8  *
9  * This file is part of OpenOffice.org.
10  *
11  * OpenOffice.org is free software: you can redistribute it and/or modify
12  * it under the terms of the GNU Lesser General Public License version 3
13  * only, as published by the Free Software Foundation.
14  *
15  * OpenOffice.org is distributed in the hope that it will be useful,
16  * but WITHOUT ANY WARRANTY; without even the implied warranty of
17  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
18  * GNU Lesser General Public License version 3 for more details
19  * (a copy is included in the LICENSE file that accompanied this code).
20  *
21  * You should have received a copy of the GNU Lesser General Public License
22  * version 3 along with OpenOffice.org.  If not, see
23  * <http://www.openoffice.org/license.html>
24  * for a copy of the LGPLv3 License.
25  *
26  ************************************************************************/
27 
28 #ifndef __FRAMEWORK_JOBS_JOBEXECUTOR_HXX_
29 #define __FRAMEWORK_JOBS_JOBEXECUTOR_HXX_
30 
31 //_______________________________________
32 // my own includes
33 
34 #include <jobs/configaccess.hxx>
35 #include <threadhelp/threadhelpbase.hxx>
36 #include <macros/xinterface.hxx>
37 #include <macros/xtypeprovider.hxx>
38 #include <macros/xserviceinfo.hxx>
39 #include <macros/debug.hxx>
40 #include <stdtypes.h>
41 #include <general.h>
42 
43 //_______________________________________
44 // interface includes
45 #include <com/sun/star/lang/XMultiServiceFactory.hpp>
46 #include <com/sun/star/task/XJobExecutor.hpp>
47 #include <com/sun/star/lang/XComponent.hpp>
48 #include <com/sun/star/container/XContainerListener.hpp>
49 #include <com/sun/star/lang/XEventListener.hpp>
50 #include <com/sun/star/document/XEventListener.hpp>
51 #include <com/sun/star/frame/XModuleManager.hpp>
52 
53 //_______________________________________
54 // other includes
55 #include <cppuhelper/weak.hxx>
56 #include <rtl/ustring.hxx>
57 
58 //_______________________________________
59 // namespace
60 
61 namespace framework{
62 
63 //_______________________________________
64 // public const
65 
66 //_______________________________________
67 /**
68     @short  implements a job executor, which can be triggered from any code
69     @descr  It uses the given trigger event to locate any registered job service
70             inside the configuration and execute it. Of course it controls the
71             liftime of such jobs too.
72  */
73 class JobExecutor : public  css::lang::XTypeProvider
74                   , public  css::lang::XServiceInfo
75                   , public  css::task::XJobExecutor
76                   , public  css::container::XContainerListener // => lang.XEventListener
77                   , public  css::document::XEventListener
78                   , private ThreadHelpBase
79                   , public  ::cppu::OWeakObject
80 {
81     //___________________________________
82     // member
83 
84     private:
85 
86         /** reference to the uno service manager */
87         css::uno::Reference< css::lang::XMultiServiceFactory > m_xSMGR;
88 
89         /** reference to the module info service */
90         css::uno::Reference< css::frame::XModuleManager > m_xModuleManager;
91 
92         /** cached list of all registered event names of cfg for call optimization. */
93         OUStringList m_lEvents;
94 
95         /** we listen at the configuration for changes at the event list. */
96         ConfigAccess m_aConfig;
97 
98     //___________________________________
99     // native interface methods
100 
101     public:
102 
103                   JobExecutor( const css::uno::Reference< css::lang::XMultiServiceFactory >& xSMGR );
104          virtual ~JobExecutor(                                                                     );
105 
106     //___________________________________
107     // uno interface methods
108 
109     public:
110 
111         // XInterface, XTypeProvider, XServiceInfo
112         FWK_DECLARE_XINTERFACE
113         FWK_DECLARE_XTYPEPROVIDER
114         DECLARE_XSERVICEINFO
115 
116         // task.XJobExecutor
117         virtual void SAL_CALL trigger( const ::rtl::OUString& sEvent ) throw(css::uno::RuntimeException);
118 
119         // document.XEventListener
120         virtual void SAL_CALL notifyEvent( const css::document::EventObject& aEvent ) throw(css::uno::RuntimeException);
121 
122         // container.XContainerListener
123         virtual void SAL_CALL elementInserted( const css::container::ContainerEvent& aEvent ) throw(css::uno::RuntimeException);
124         virtual void SAL_CALL elementRemoved ( const css::container::ContainerEvent& aEvent ) throw(css::uno::RuntimeException);
125         virtual void SAL_CALL elementReplaced( const css::container::ContainerEvent& aEvent ) throw(css::uno::RuntimeException);
126 
127         // lang.XEventListener
128         virtual void SAL_CALL disposing( const css::lang::EventObject& aEvent ) throw(css::uno::RuntimeException);
129 };
130 
131 } // namespace framework
132 
133 #endif // __FRAMEWORK_JOBS_JOBEXECUTOR_HXX_
134