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_DISPATCH_STARTMODULEDISPATCHER_HXX_
25 #define __FRAMEWORK_DISPATCH_STARTMODULEDISPATCHER_HXX_
26 
27 //_______________________________________________
28 // my own includes
29 
30 #include <threadhelp/threadhelpbase.hxx>
31 #include <macros/xinterface.hxx>
32 #include <macros/xtypeprovider.hxx>
33 #include <macros/debug.hxx>
34 #include <macros/generic.hxx>
35 #include <stdtypes.h>
36 #include <general.h>
37 
38 //_______________________________________________
39 // interface includes
40 #include <com/sun/star/lang/XTypeProvider.hpp>
41 #include <com/sun/star/frame/XFrame.hpp>
42 #include <com/sun/star/frame/XStatusListener.hpp>
43 #include <com/sun/star/frame/XNotifyingDispatch.hpp>
44 #include <com/sun/star/frame/XDispatchInformationProvider.hpp>
45 #include <com/sun/star/util/URL.hpp>
46 #include <com/sun/star/frame/XDispatchResultListener.hpp>
47 #include <com/sun/star/lang/XMultiServiceFactory.hpp>
48 #include <com/sun/star/frame/DispatchResultState.hpp>
49 
50 //_______________________________________________
51 // other includes
52 #include <cppuhelper/weak.hxx>
53 #include <vcl/evntpost.hxx>
54 
55 //_______________________________________________
56 // namespace
57 
58 namespace framework{
59 
60 //-----------------------------------------------
61 /**
62     @short          helper to handle all URLs related to the StartModule
63  */
64 class StartModuleDispatcher : public css::lang::XTypeProvider
65                             , public css::frame::XNotifyingDispatch             // => XDispatch
66                             , public css::frame::XDispatchInformationProvider
67                             // baseclasses ... order is neccessary for right initialization!
68                             , private ThreadHelpBase
69                             , public  ::cppu::OWeakObject
70 {
71     //-------------------------------------------
72     // member
73 
74     private:
75 
76         //---------------------------------------
77         /** @short reference to an uno service manager,
78                    which can be used to create own needed
79                    uno resources. */
80         css::uno::Reference< css::lang::XMultiServiceFactory > m_xSMGR;
81 
82         //---------------------------------------
83         /** @short  our "context" frame. */
84         css::uno::WeakReference< css::frame::XFrame > m_xOwner;
85 
86         //---------------------------------------
87         /** @short  the original queryDispatch() target. */
88         ::rtl::OUString m_sDispatchTarget;
89 
90         //---------------------------------------
91         /** @short  list of registered status listener */
92         ListenerHash m_lStatusListener;
93 
94     //-------------------------------------------
95     // native interface
96 
97 	public:
98 
99         //---------------------------------------
100         /** @short  connect a new StartModuleDispatcher instance to its "owner frame".
101 
102             @descr  Such "owner frame" is used as context for all related operations.
103 
104             @param  xSMGR
105                     an uno service manager, which is needed to create uno resource
106                     internaly.
107 
108             @param  xFrame
109                     the frame where the corresponding dispatch was started.
110 
111             @param  sTarget
112                     the original target information used for the related queryDispatch() call.
113          */
114         StartModuleDispatcher(const css::uno::Reference< css::lang::XMultiServiceFactory >& xSMGR  ,
115                               const css::uno::Reference< css::frame::XFrame >&              xFrame ,
116                               const ::rtl::OUString&                                        sTarget);
117 
118         //---------------------------------------
119         /** @short  does nothing real. */
120         virtual ~StartModuleDispatcher();
121 
122     //-------------------------------------------
123     // uno interface
124 
125     public:
126 
127         //---------------------------------------
128         FWK_DECLARE_XINTERFACE
129         FWK_DECLARE_XTYPEPROVIDER
130 
131         //---------------------------------------
132         // XNotifyingDispatch
133         virtual void SAL_CALL dispatchWithNotification( const css::util::URL&                                             aURL      ,
134                                                         const css::uno::Sequence< css::beans::PropertyValue >&            lArguments,
135                                                         const css::uno::Reference< css::frame::XDispatchResultListener >& xListener ) throw(css::uno::RuntimeException);
136 
137         //---------------------------------------
138         // XDispatch
139         virtual void SAL_CALL dispatch            ( const css::util::URL&                                     aURL      ,
140                                                     const css::uno::Sequence< css::beans::PropertyValue >&    lArguments) throw(css::uno::RuntimeException);
141         virtual void SAL_CALL addStatusListener   ( const css::uno::Reference< css::frame::XStatusListener >& xListener ,
142                                                     const css::util::URL&                                     aURL      ) throw(css::uno::RuntimeException);
143         virtual void SAL_CALL removeStatusListener( const css::uno::Reference< css::frame::XStatusListener >& xListener ,
144                                                     const css::util::URL&                                     aURL      ) throw(css::uno::RuntimeException);
145 
146         //---------------------------------------
147         // XDispatchInformationProvider
148         virtual css::uno::Sequence< sal_Int16 >                       SAL_CALL getSupportedCommandGroups         (                         ) throw (css::uno::RuntimeException);
149         virtual css::uno::Sequence< css::frame::DispatchInformation > SAL_CALL getConfigurableDispatchInformation( sal_Int16 nCommandGroup ) throw (css::uno::RuntimeException);
150 
151     //-------------------------------------------
152     // internal helper
153 
154     private:
155 
156         //---------------------------------------
157         /** @short  check if StartModule can be shown.
158          */
159         ::sal_Bool implts_isBackingModePossible();
160 
161         //---------------------------------------
162         /** @short  open the special BackingComponent (now StartModule)
163 
164             @return [bool]
165                     sal_True if operation was successfully.
166          */
167         ::sal_Bool implts_establishBackingMode();
168 
169         //---------------------------------------
170         /** @short  notify a DispatchResultListener.
171 
172             @descr  We check the listener reference before we use it.
173                     So this method can be called everytimes!
174 
175             @parama xListener
176                     the listener, which should be notified.
177                     Can be null!
178 
179             @param  nState
180                     directly used as css::frame::DispatchResultState value.
181 
182             @param  aResult
183                     not used yet realy ...
184          */
185         void implts_notifyResultListener(const css::uno::Reference< css::frame::XDispatchResultListener >& xListener,
186                                                sal_Int16                                                   nState   ,
187                                          const css::uno::Any&                                              aResult  );
188 
189 }; // class StartModuleDispatcher
190 
191 } // namespace framework
192 
193 #endif // #ifndef __FRAMEWORK_DISPATCH_STARTMODULEDISPATCHER_HXX_
194