xref: /aoo41x/main/framework/inc/jobs/jobdispatch.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_JOBDISPATCH_HXX_
29 #define __FRAMEWORK_JOBS_JOBDISPATCH_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/frame/XNotifyingDispatch.hpp>
47 #include <com/sun/star/frame/XDispatch.hpp>
48 #include <com/sun/star/frame/XStatusListener.hpp>
49 #include <com/sun/star/frame/XDispatchResultListener.hpp>
50 #include <com/sun/star/task/XJobListener.hpp>
51 #include <com/sun/star/frame/XTerminateListener.hpp>
52 #include <com/sun/star/frame/XDispatchProvider.hpp>
53 #include <com/sun/star/frame/XDesktop.hpp>
54 #include <com/sun/star/uno/XInterface.hpp>
55 #include <com/sun/star/beans/NamedValue.hpp>
56 #include <com/sun/star/frame/FeatureStateEvent.hpp>
57 #include <com/sun/star/frame/DispatchResultEvent.hpp>
58 #include <com/sun/star/lang/XInitialization.hpp>
59 
60 //_______________________________________
61 // other includes
62 #include <unotools/configpathes.hxx>
63 #include <cppuhelper/weak.hxx>
64 #include <rtl/ustring.hxx>
65 
66 //_______________________________________
67 // namespace
68 
69 namespace framework{
70 
71 //_______________________________________
72 // public const
73 
74 //_______________________________________
75 /**
76     @short  implements a dispatch object for jobs
77     @descr  Such dispatch object will be used by the generic dispatch mechanism if
78             an URL "vnd.sun.star.job:alias=<name>" occures.
79             Then an instance of this class will be created and used.
80             This new instance will be called within his method
81             dispatch() or dispatchWithNotification() for executing the
82             real job. We do it, control the life cycle of this internal
83             wrapped job and inform any interested listener if it finish.
84  */
85 class JobDispatch : public  css::lang::XTypeProvider
86                   , public  css::lang::XServiceInfo
87                   , public  css::lang::XInitialization
88                   , public  css::frame::XDispatchProvider
89                   , public  css::frame::XNotifyingDispatch      // => XDispatch
90                   , private ThreadHelpBase
91                   , public  ::cppu::OWeakObject
92 {
93     //___________________________________
94     // member
95 
96     private:
97 
98         /** reference to the uno service manager */
99         css::uno::Reference< css::lang::XMultiServiceFactory > m_xSMGR;
100 
101         /** reference to the frame, inside which this dispatch is used */
102         css::uno::Reference< css::frame::XFrame > m_xFrame;
103 
104         /** name of module (writer, impress etc.) the frame is for */
105         ::rtl::OUString m_sModuleIdentifier;
106 
107     //___________________________________
108     // native interface methods
109 
110     public:
111 
112                   JobDispatch( const css::uno::Reference< css::lang::XMultiServiceFactory >& xSMGR );
113          virtual ~JobDispatch(                                                                     );
114 
115         void impl_dispatchEvent  ( const ::rtl::OUString&                                            sEvent    ,
116                                    const css::uno::Sequence< css::beans::PropertyValue >&            lArgs     ,
117                                    const css::uno::Reference< css::frame::XDispatchResultListener >& xListener );
118         void impl_dispatchService( const ::rtl::OUString&                                            sService  ,
119                                    const css::uno::Sequence< css::beans::PropertyValue >&            lArgs     ,
120                                    const css::uno::Reference< css::frame::XDispatchResultListener >& xListener );
121         void impl_dispatchAlias  ( const ::rtl::OUString&                                            sAlias    ,
122                                    const css::uno::Sequence< css::beans::PropertyValue >&            lArgs     ,
123                                    const css::uno::Reference< css::frame::XDispatchResultListener >& xListener );
124 
125     //___________________________________
126     // uno interface methods
127 
128     public:
129 
130         // XInterface, XTypeProvider, XServiceInfo
131         FWK_DECLARE_XINTERFACE
132         FWK_DECLARE_XTYPEPROVIDER
133         DECLARE_XSERVICEINFO
134 
135         // Xinitialization
136         virtual void SAL_CALL initialize( const css::uno::Sequence< css::uno::Any >& lArguments ) throw(css::uno::Exception       ,
137                                                                                                         css::uno::RuntimeException);
138 
139         // XDispatchProvider
140         virtual css::uno::Reference< css::frame::XDispatch > SAL_CALL                       queryDispatch  ( const css::util::URL&                                       aURL             ,
141                                                                                                              const ::rtl::OUString&                                      sTargetFrameName ,
142                                                                                                                    sal_Int32                                             nSearchFlags     ) throw(css::uno::RuntimeException);
143         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);
144 
145         // XNotifyingDispatch
146         virtual void SAL_CALL dispatchWithNotification( const css::util::URL&                                             aURL      ,
147                                                         const css::uno::Sequence< css::beans::PropertyValue >&            lArgs     ,
148                                                         const css::uno::Reference< css::frame::XDispatchResultListener >& xListener ) throw(css::uno::RuntimeException);
149 
150         // XDispatch
151         virtual void SAL_CALL dispatch            ( const css::util::URL&                                     aURL      ,
152                                                     const css::uno::Sequence< css::beans::PropertyValue >&    lArgs     ) throw(css::uno::RuntimeException);
153         virtual void SAL_CALL addStatusListener   ( const css::uno::Reference< css::frame::XStatusListener >& xListener ,
154                                                     const css::util::URL&                                     aURL      ) throw(css::uno::RuntimeException);
155         virtual void SAL_CALL removeStatusListener( const css::uno::Reference< css::frame::XStatusListener >& xListener ,
156                                                     const css::util::URL&                                     aURL      ) throw(css::uno::RuntimeException);
157 };
158 
159 } // namespace framework
160 
161 #endif // __FRAMEWORK_JOBS_JOBDISPATCH_HXX_
162