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_SERVICES_DISPATCHHELPER_HXX_
25 #define __FRAMEWORK_SERVICES_DISPATCHHELPER_HXX_
26 
27 //_______________________________________________
28 // my own includes
29 
30 #include <threadhelp/threadhelpbase.hxx>
31 #include <macros/generic.hxx>
32 #include <macros/debug.hxx>
33 #include <macros/xinterface.hxx>
34 #include <macros/xtypeprovider.hxx>
35 #include <macros/xserviceinfo.hxx>
36 #include <general.h>
37 
38 //_______________________________________________
39 // interface includes
40 #include <com/sun/star/lang/XMultiServiceFactory.hpp>
41 #include <com/sun/star/frame/XDispatchHelper.hpp>
42 #include <com/sun/star/frame/XDispatchResultListener.hpp>
43 #include <com/sun/star/frame/DispatchResultEvent.hpp>
44 
45 //_______________________________________________
46 // other includes
47 #include <cppuhelper/implbase3.hxx>
48 #include <osl/conditn.hxx>
49 
50 //_______________________________________________
51 // namespace
52 
53 namespace framework{
54 
55 //_______________________________________________
56 // exported const
57 
58 //_______________________________________________
59 // exported definitions
60 
61 /**
62     @short      implements an easy way for dispatches
63     @descr      Dispatches are splitted into different parts:
64                     - parsing of the URL
65                     - searching for a dispatcgh object
66                     - dispatching of the URL
67                 All these steps are done inside one method call here.
68 */
69 
70 class DispatchHelper : public ThreadHelpBase                      // must be the first base class!
71                       ,public ::cppu::WeakImplHelper3< ::com::sun::star::lang::XServiceInfo,::com::sun::star::frame::XDispatchHelper,::com::sun::star::frame::XDispatchResultListener >
72 {
73 
74     //-------------------------------------------
75     // member
76 
77     private:
78 
79         /** global uno service manager.
80             Can be used to create own needed services. */
81         css::uno::Reference< css::lang::XMultiServiceFactory > m_xSMGR;
82 
83         /** used to wait for asynchronous listener callbacks. */
84         ::osl::Condition m_aBlock;
85 
86         css::uno::Any m_aResult;
87 
88         css::uno::Reference< css::uno::XInterface > m_xBroadcaster;
89 
90     //-------------------------------------------
91     // interface
92 
93 	public:
94 
95         //---------------------------------------
96         // ctor/dtor
97 
98                  DispatchHelper( const css::uno::Reference< css::lang::XMultiServiceFactory >& xSMGR );
99         virtual ~DispatchHelper(                                                                     );
100 
101         //---------------------------------------
102         // XInterface, XTypeProvider, XServiceInfo
103 
104 		DECLARE_XSERVICEINFO
105 
106         //---------------------------------------
107         // XDispatchHelper
108         virtual css::uno::Any SAL_CALL executeDispatch(
109                                         const css::uno::Reference< css::frame::XDispatchProvider >& xDispatchProvider ,
110                                         const ::rtl::OUString&                                      sURL              ,
111                                         const ::rtl::OUString&                                      sTargetFrameName  ,
112                                               sal_Int32                                             nSearchFlags      ,
113                                         const css::uno::Sequence< css::beans::PropertyValue >&      lArguments        )
114         throw(css::uno::RuntimeException);
115 
116         //---------------------------------------
117         // XDispatchResultListener
118         virtual void SAL_CALL dispatchFinished(
119                                 const css::frame::DispatchResultEvent& aResult )
120         throw(css::uno::RuntimeException);
121 
122         //---------------------------------------
123         // XEventListener
124         virtual void SAL_CALL disposing(
125                                 const css::lang::EventObject& aEvent )
126         throw(css::uno::RuntimeException);
127 };
128 
129 }
130 
131 #endif
132