1f8e07b45SAndrew Rist /**************************************************************
2cdf0e10cSrcweir  *
3f8e07b45SAndrew Rist  * Licensed to the Apache Software Foundation (ASF) under one
4f8e07b45SAndrew Rist  * or more contributor license agreements.  See the NOTICE file
5f8e07b45SAndrew Rist  * distributed with this work for additional information
6f8e07b45SAndrew Rist  * regarding copyright ownership.  The ASF licenses this file
7f8e07b45SAndrew Rist  * to you under the Apache License, Version 2.0 (the
8f8e07b45SAndrew Rist  * "License"); you may not use this file except in compliance
9f8e07b45SAndrew Rist  * with the License.  You may obtain a copy of the License at
10f8e07b45SAndrew Rist  *
11f8e07b45SAndrew Rist  *   http://www.apache.org/licenses/LICENSE-2.0
12f8e07b45SAndrew Rist  *
13f8e07b45SAndrew Rist  * Unless required by applicable law or agreed to in writing,
14f8e07b45SAndrew Rist  * software distributed under the License is distributed on an
15f8e07b45SAndrew Rist  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16f8e07b45SAndrew Rist  * KIND, either express or implied.  See the License for the
17f8e07b45SAndrew Rist  * specific language governing permissions and limitations
18f8e07b45SAndrew Rist  * under the License.
19f8e07b45SAndrew Rist  *
20f8e07b45SAndrew Rist  *************************************************************/
21f8e07b45SAndrew Rist 
22f8e07b45SAndrew Rist 
23cdf0e10cSrcweir 
24cdf0e10cSrcweir #ifndef __FRAMEWORK_DISPATCH_STARTMODULEDISPATCHER_HXX_
25cdf0e10cSrcweir #define __FRAMEWORK_DISPATCH_STARTMODULEDISPATCHER_HXX_
26cdf0e10cSrcweir 
27cdf0e10cSrcweir //_______________________________________________
28cdf0e10cSrcweir // my own includes
29cdf0e10cSrcweir 
30cdf0e10cSrcweir #include <threadhelp/threadhelpbase.hxx>
31cdf0e10cSrcweir #include <macros/xinterface.hxx>
32cdf0e10cSrcweir #include <macros/xtypeprovider.hxx>
33cdf0e10cSrcweir #include <macros/debug.hxx>
34cdf0e10cSrcweir #include <macros/generic.hxx>
35cdf0e10cSrcweir #include <stdtypes.h>
36cdf0e10cSrcweir #include <general.h>
37cdf0e10cSrcweir 
38cdf0e10cSrcweir //_______________________________________________
39cdf0e10cSrcweir // interface includes
40cdf0e10cSrcweir #include <com/sun/star/lang/XTypeProvider.hpp>
41cdf0e10cSrcweir #include <com/sun/star/frame/XFrame.hpp>
42cdf0e10cSrcweir #include <com/sun/star/frame/XStatusListener.hpp>
43cdf0e10cSrcweir #include <com/sun/star/frame/XNotifyingDispatch.hpp>
44cdf0e10cSrcweir #include <com/sun/star/frame/XDispatchInformationProvider.hpp>
45cdf0e10cSrcweir #include <com/sun/star/util/URL.hpp>
46cdf0e10cSrcweir #include <com/sun/star/frame/XDispatchResultListener.hpp>
47cdf0e10cSrcweir #include <com/sun/star/lang/XMultiServiceFactory.hpp>
48cdf0e10cSrcweir #include <com/sun/star/frame/DispatchResultState.hpp>
49cdf0e10cSrcweir 
50cdf0e10cSrcweir //_______________________________________________
51cdf0e10cSrcweir // other includes
52cdf0e10cSrcweir #include <cppuhelper/weak.hxx>
53cdf0e10cSrcweir #include <vcl/evntpost.hxx>
54cdf0e10cSrcweir 
55cdf0e10cSrcweir //_______________________________________________
56cdf0e10cSrcweir // namespace
57cdf0e10cSrcweir 
58cdf0e10cSrcweir namespace framework{
59cdf0e10cSrcweir 
60cdf0e10cSrcweir //-----------------------------------------------
61cdf0e10cSrcweir /**
62cdf0e10cSrcweir     @short          helper to handle all URLs related to the StartModule
63cdf0e10cSrcweir  */
64cdf0e10cSrcweir class StartModuleDispatcher : public css::lang::XTypeProvider
65cdf0e10cSrcweir                             , public css::frame::XNotifyingDispatch             // => XDispatch
66cdf0e10cSrcweir                             , public css::frame::XDispatchInformationProvider
67*07a3d7f1SPedro Giffuni                             // baseclasses ... order is necessary for right initialization!
68cdf0e10cSrcweir                             , private ThreadHelpBase
69cdf0e10cSrcweir                             , public  ::cppu::OWeakObject
70cdf0e10cSrcweir {
71cdf0e10cSrcweir     //-------------------------------------------
72cdf0e10cSrcweir     // member
73cdf0e10cSrcweir 
74cdf0e10cSrcweir     private:
75cdf0e10cSrcweir 
76cdf0e10cSrcweir         //---------------------------------------
77cdf0e10cSrcweir         /** @short reference to an uno service manager,
78cdf0e10cSrcweir                    which can be used to create own needed
79cdf0e10cSrcweir                    uno resources. */
80cdf0e10cSrcweir         css::uno::Reference< css::lang::XMultiServiceFactory > m_xSMGR;
81cdf0e10cSrcweir 
82cdf0e10cSrcweir         //---------------------------------------
83cdf0e10cSrcweir         /** @short  our "context" frame. */
84cdf0e10cSrcweir         css::uno::WeakReference< css::frame::XFrame > m_xOwner;
85cdf0e10cSrcweir 
86cdf0e10cSrcweir         //---------------------------------------
87cdf0e10cSrcweir         /** @short  the original queryDispatch() target. */
88cdf0e10cSrcweir         ::rtl::OUString m_sDispatchTarget;
89cdf0e10cSrcweir 
90cdf0e10cSrcweir         //---------------------------------------
91cdf0e10cSrcweir         /** @short  list of registered status listener */
92cdf0e10cSrcweir         ListenerHash m_lStatusListener;
93cdf0e10cSrcweir 
94cdf0e10cSrcweir     //-------------------------------------------
95cdf0e10cSrcweir     // native interface
96cdf0e10cSrcweir 
97cdf0e10cSrcweir 	public:
98cdf0e10cSrcweir 
99cdf0e10cSrcweir         //---------------------------------------
100cdf0e10cSrcweir         /** @short  connect a new StartModuleDispatcher instance to its "owner frame".
101cdf0e10cSrcweir 
102cdf0e10cSrcweir             @descr  Such "owner frame" is used as context for all related operations.
103cdf0e10cSrcweir 
104cdf0e10cSrcweir             @param  xSMGR
105cdf0e10cSrcweir                     an uno service manager, which is needed to create uno resource
106cdf0e10cSrcweir                     internaly.
107cdf0e10cSrcweir 
108cdf0e10cSrcweir             @param  xFrame
109cdf0e10cSrcweir                     the frame where the corresponding dispatch was started.
110cdf0e10cSrcweir 
111cdf0e10cSrcweir             @param  sTarget
112cdf0e10cSrcweir                     the original target information used for the related queryDispatch() call.
113cdf0e10cSrcweir          */
114cdf0e10cSrcweir         StartModuleDispatcher(const css::uno::Reference< css::lang::XMultiServiceFactory >& xSMGR  ,
115cdf0e10cSrcweir                               const css::uno::Reference< css::frame::XFrame >&              xFrame ,
116cdf0e10cSrcweir                               const ::rtl::OUString&                                        sTarget);
117cdf0e10cSrcweir 
118cdf0e10cSrcweir         //---------------------------------------
119cdf0e10cSrcweir         /** @short  does nothing real. */
120cdf0e10cSrcweir         virtual ~StartModuleDispatcher();
121cdf0e10cSrcweir 
122cdf0e10cSrcweir     //-------------------------------------------
123cdf0e10cSrcweir     // uno interface
124cdf0e10cSrcweir 
125cdf0e10cSrcweir     public:
126cdf0e10cSrcweir 
127cdf0e10cSrcweir         //---------------------------------------
128cdf0e10cSrcweir         FWK_DECLARE_XINTERFACE
129cdf0e10cSrcweir         FWK_DECLARE_XTYPEPROVIDER
130cdf0e10cSrcweir 
131cdf0e10cSrcweir         //---------------------------------------
132cdf0e10cSrcweir         // XNotifyingDispatch
133cdf0e10cSrcweir         virtual void SAL_CALL dispatchWithNotification( const css::util::URL&                                             aURL      ,
134cdf0e10cSrcweir                                                         const css::uno::Sequence< css::beans::PropertyValue >&            lArguments,
135cdf0e10cSrcweir                                                         const css::uno::Reference< css::frame::XDispatchResultListener >& xListener ) throw(css::uno::RuntimeException);
136cdf0e10cSrcweir 
137cdf0e10cSrcweir         //---------------------------------------
138cdf0e10cSrcweir         // XDispatch
139cdf0e10cSrcweir         virtual void SAL_CALL dispatch            ( const css::util::URL&                                     aURL      ,
140cdf0e10cSrcweir                                                     const css::uno::Sequence< css::beans::PropertyValue >&    lArguments) throw(css::uno::RuntimeException);
141cdf0e10cSrcweir         virtual void SAL_CALL addStatusListener   ( const css::uno::Reference< css::frame::XStatusListener >& xListener ,
142cdf0e10cSrcweir                                                     const css::util::URL&                                     aURL      ) throw(css::uno::RuntimeException);
143cdf0e10cSrcweir         virtual void SAL_CALL removeStatusListener( const css::uno::Reference< css::frame::XStatusListener >& xListener ,
144cdf0e10cSrcweir                                                     const css::util::URL&                                     aURL      ) throw(css::uno::RuntimeException);
145cdf0e10cSrcweir 
146cdf0e10cSrcweir         //---------------------------------------
147cdf0e10cSrcweir         // XDispatchInformationProvider
148cdf0e10cSrcweir         virtual css::uno::Sequence< sal_Int16 >                       SAL_CALL getSupportedCommandGroups         (                         ) throw (css::uno::RuntimeException);
149cdf0e10cSrcweir         virtual css::uno::Sequence< css::frame::DispatchInformation > SAL_CALL getConfigurableDispatchInformation( sal_Int16 nCommandGroup ) throw (css::uno::RuntimeException);
150cdf0e10cSrcweir 
151cdf0e10cSrcweir     //-------------------------------------------
152cdf0e10cSrcweir     // internal helper
153cdf0e10cSrcweir 
154cdf0e10cSrcweir     private:
155cdf0e10cSrcweir 
156cdf0e10cSrcweir         //---------------------------------------
157cdf0e10cSrcweir         /** @short  check if StartModule can be shown.
158cdf0e10cSrcweir          */
159cdf0e10cSrcweir         ::sal_Bool implts_isBackingModePossible();
160cdf0e10cSrcweir 
161cdf0e10cSrcweir         //---------------------------------------
162cdf0e10cSrcweir         /** @short  open the special BackingComponent (now StartModule)
163cdf0e10cSrcweir 
164cdf0e10cSrcweir             @return [bool]
165cdf0e10cSrcweir                     sal_True if operation was successfully.
166cdf0e10cSrcweir          */
167cdf0e10cSrcweir         ::sal_Bool implts_establishBackingMode();
168cdf0e10cSrcweir 
169cdf0e10cSrcweir         //---------------------------------------
170cdf0e10cSrcweir         /** @short  notify a DispatchResultListener.
171cdf0e10cSrcweir 
172cdf0e10cSrcweir             @descr  We check the listener reference before we use it.
173cdf0e10cSrcweir                     So this method can be called everytimes!
174cdf0e10cSrcweir 
175cdf0e10cSrcweir             @parama xListener
176cdf0e10cSrcweir                     the listener, which should be notified.
177cdf0e10cSrcweir                     Can be null!
178cdf0e10cSrcweir 
179cdf0e10cSrcweir             @param  nState
180cdf0e10cSrcweir                     directly used as css::frame::DispatchResultState value.
181cdf0e10cSrcweir 
182cdf0e10cSrcweir             @param  aResult
183*07a3d7f1SPedro Giffuni                     not used yet really ...
184cdf0e10cSrcweir          */
185cdf0e10cSrcweir         void implts_notifyResultListener(const css::uno::Reference< css::frame::XDispatchResultListener >& xListener,
186cdf0e10cSrcweir                                                sal_Int16                                                   nState   ,
187cdf0e10cSrcweir                                          const css::uno::Any&                                              aResult  );
188cdf0e10cSrcweir 
189cdf0e10cSrcweir }; // class StartModuleDispatcher
190cdf0e10cSrcweir 
191cdf0e10cSrcweir } // namespace framework
192cdf0e10cSrcweir 
193cdf0e10cSrcweir #endif // #ifndef __FRAMEWORK_DISPATCH_STARTMODULEDISPATCHER_HXX_
194