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