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