xref: /aoo42x/main/framework/inc/jobs/jobdispatch.hxx (revision 30acf5e8)
1 /**************************************************************
2  *
3  * Licensed to the Apache Software Foundation (ASF) under one
4  * or more contributor license agreements.  See the NOTICE file
5  * distributed with this work for additional information
6  * regarding copyright ownership.  The ASF licenses this file
7  * to you under the Apache License, Version 2.0 (the
8  * "License"); you may not use this file except in compliance
9  * with the License.  You may obtain a copy of the License at
10  *
11  *   http://www.apache.org/licenses/LICENSE-2.0
12  *
13  * Unless required by applicable law or agreed to in writing,
14  * software distributed under the License is distributed on an
15  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16  * KIND, either express or implied.  See the License for the
17  * specific language governing permissions and limitations
18  * under the License.
19  *
20  *************************************************************/
21 
22 
23 
24 #ifndef __FRAMEWORK_JOBS_JOBDISPATCH_HXX_
25 #define __FRAMEWORK_JOBS_JOBDISPATCH_HXX_
26 
27 //_______________________________________
28 // my own includes
29 
30 #include <jobs/configaccess.hxx>
31 #include <threadhelp/threadhelpbase.hxx>
32 #include <macros/xinterface.hxx>
33 #include <macros/xtypeprovider.hxx>
34 #include <macros/xserviceinfo.hxx>
35 #include <macros/debug.hxx>
36 #include <stdtypes.h>
37 #include <general.h>
38 
39 //_______________________________________
40 // interface includes
41 #include <com/sun/star/lang/XMultiServiceFactory.hpp>
42 #include <com/sun/star/frame/XNotifyingDispatch.hpp>
43 #include <com/sun/star/frame/XDispatch.hpp>
44 #include <com/sun/star/frame/XStatusListener.hpp>
45 #include <com/sun/star/frame/XDispatchResultListener.hpp>
46 #include <com/sun/star/task/XJobListener.hpp>
47 #include <com/sun/star/frame/XTerminateListener.hpp>
48 #include <com/sun/star/frame/XDispatchProvider.hpp>
49 #include <com/sun/star/frame/XDesktop.hpp>
50 #include <com/sun/star/uno/XInterface.hpp>
51 #include <com/sun/star/beans/NamedValue.hpp>
52 #include <com/sun/star/frame/FeatureStateEvent.hpp>
53 #include <com/sun/star/frame/DispatchResultEvent.hpp>
54 #include <com/sun/star/lang/XInitialization.hpp>
55 
56 //_______________________________________
57 // other includes
58 #include <unotools/configpathes.hxx>
59 #include <cppuhelper/weak.hxx>
60 #include <rtl/ustring.hxx>
61 
62 //_______________________________________
63 // namespace
64 
65 namespace framework{
66 
67 //_______________________________________
68 // public const
69 
70 //_______________________________________
71 /**
72     @short  implements a dispatch object for jobs
73     @descr  Such dispatch object will be used by the generic dispatch mechanism if
74             an URL "vnd.sun.star.job:alias=<name>" occurs.
75             Then an instance of this class will be created and used.
76             This new instance will be called within his method
77             dispatch() or dispatchWithNotification() for executing the
78             real job. We do it, control the life cycle of this internal
79             wrapped job and inform any interested listener if it finish.
80  */
81 class JobDispatch : public  css::lang::XTypeProvider
82                   , public  css::lang::XServiceInfo
83                   , public  css::lang::XInitialization
84                   , public  css::frame::XDispatchProvider
85                   , public  css::frame::XNotifyingDispatch      // => XDispatch
86                   , private ThreadHelpBase
87                   , public  ::cppu::OWeakObject
88 {
89     //___________________________________
90     // member
91 
92     private:
93 
94         /** reference to the uno service manager */
95         css::uno::Reference< css::lang::XMultiServiceFactory > m_xSMGR;
96 
97         /** reference to the frame, inside which this dispatch is used */
98         css::uno::Reference< css::frame::XFrame > m_xFrame;
99 
100         /** name of module (writer, impress etc.) the frame is for */
101         ::rtl::OUString m_sModuleIdentifier;
102 
103     //___________________________________
104     // native interface methods
105 
106     public:
107 
108                   JobDispatch( const css::uno::Reference< css::lang::XMultiServiceFactory >& xSMGR );
109          virtual ~JobDispatch(                                                                     );
110 
111         void impl_dispatchEvent  ( const ::rtl::OUString&                                            sEvent    ,
112                                    const css::uno::Sequence< css::beans::PropertyValue >&            lArgs     ,
113                                    const css::uno::Reference< css::frame::XDispatchResultListener >& xListener );
114         void impl_dispatchService( const ::rtl::OUString&                                            sService  ,
115                                    const css::uno::Sequence< css::beans::PropertyValue >&            lArgs     ,
116                                    const css::uno::Reference< css::frame::XDispatchResultListener >& xListener );
117         void impl_dispatchAlias  ( const ::rtl::OUString&                                            sAlias    ,
118                                    const css::uno::Sequence< css::beans::PropertyValue >&            lArgs     ,
119                                    const css::uno::Reference< css::frame::XDispatchResultListener >& xListener );
120 
121     //___________________________________
122     // uno interface methods
123 
124     public:
125 
126         // XInterface, XTypeProvider, XServiceInfo
127         FWK_DECLARE_XINTERFACE
128         FWK_DECLARE_XTYPEPROVIDER
129         DECLARE_XSERVICEINFO
130 
131         // Xinitialization
132         virtual void SAL_CALL initialize( const css::uno::Sequence< css::uno::Any >& lArguments ) throw(css::uno::Exception       ,
133                                                                                                         css::uno::RuntimeException);
134 
135         // XDispatchProvider
136         virtual css::uno::Reference< css::frame::XDispatch > SAL_CALL                       queryDispatch  ( const css::util::URL&                                       aURL             ,
137                                                                                                              const ::rtl::OUString&                                      sTargetFrameName ,
138                                                                                                                    sal_Int32                                             nSearchFlags     ) throw(css::uno::RuntimeException);
139         virtual css::uno::Sequence< css::uno::Reference< css::frame::XDispatch > > SAL_CALL queryDispatches( const css::uno::Sequence< css::frame::DispatchDescriptor >& lDescriptor      ) throw(css::uno::RuntimeException);
140 
141         // XNotifyingDispatch
142         virtual void SAL_CALL dispatchWithNotification( const css::util::URL&                                             aURL      ,
143                                                         const css::uno::Sequence< css::beans::PropertyValue >&            lArgs     ,
144                                                         const css::uno::Reference< css::frame::XDispatchResultListener >& xListener ) throw(css::uno::RuntimeException);
145 
146         // XDispatch
147         virtual void SAL_CALL dispatch            ( const css::util::URL&                                     aURL      ,
148                                                     const css::uno::Sequence< css::beans::PropertyValue >&    lArgs     ) throw(css::uno::RuntimeException);
149         virtual void SAL_CALL addStatusListener   ( const css::uno::Reference< css::frame::XStatusListener >& xListener ,
150                                                     const css::util::URL&                                     aURL      ) throw(css::uno::RuntimeException);
151         virtual void SAL_CALL removeStatusListener( const css::uno::Reference< css::frame::XStatusListener >& xListener ,
152                                                     const css::util::URL&                                     aURL      ) throw(css::uno::RuntimeException);
153 };
154 
155 } // namespace framework
156 
157 #endif // __FRAMEWORK_JOBS_JOBDISPATCH_HXX_
158