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_DISPATCH_SYSTEMEXEC_HXX_
29 #define __FRAMEWORK_DISPATCH_SYSTEMEXEC_HXX_
30 
31 //_________________________________________________________________________________________________________________
32 //	my own includes
33 //_________________________________________________________________________________________________________________
34 
35 #include <macros/generic.hxx>
36 #include <macros/xinterface.hxx>
37 #include <macros/xtypeprovider.hxx>
38 #include <macros/xserviceinfo.hxx>
39 #include <macros/debug.hxx>
40 #include <threadhelp/threadhelpbase.hxx>
41 #include <general.h>
42 #include <stdtypes.h>
43 
44 //_________________________________________________________________________________________________________________
45 //	interface includes
46 //_________________________________________________________________________________________________________________
47 #include <com/sun/star/lang/XTypeProvider.hpp>
48 #include <com/sun/star/frame/XNotifyingDispatch.hpp>
49 #include <com/sun/star/frame/XDispatch.hpp>
50 #include <com/sun/star/frame/XDispatchProvider.hpp>
51 #include <com/sun/star/util/URL.hpp>
52 #include <com/sun/star/beans/PropertyValue.hpp>
53 #include <com/sun/star/frame/XStatusListener.hpp>
54 
55 //_________________________________________________________________________________________________________________
56 //	other includes
57 //_________________________________________________________________________________________________________________
58 #include <cppuhelper/weak.hxx>
59 
60 //_________________________________________________________________________________________________________________
61 //	namespace
62 //_________________________________________________________________________________________________________________
63 
64 namespace framework{
65 
66 //_________________________________________________________________________________________________________________
67 //	exported const
68 //_________________________________________________________________________________________________________________
69 
70 //_________________________________________________________________________________________________________________
71 //	exported definitions
72 //_________________________________________________________________________________________________________________
73 
74 /**
75     @short          protocol handler for "systemexec:*" URLs
76     @descr          It's a special dispatch/provider object which is registered for such URL pattern and will
77                     be automaticly used by the framework dispatch mechanism if such URL occured.
78                     It forwards all URL's to the underlying operating system.
79                     So it would e.g. be possible to open HTML files outside the office within a web browser.
80 
81     @base           ThreadHelpBase
82                         exports a lock member to guarantee right initialize value of it
83     @base           OWeakObject
84                         provides XWeak and ref count mechanism
85 
86 	@devstatus		ready to use
87 */
88 class SystemExec : // interfaces
89                        public  css::lang::XTypeProvider      ,
90                        public  css::lang::XServiceInfo       ,
91                        public  css::frame::XDispatchProvider ,
92                        public  css::frame::XNotifyingDispatch, // => XDispatch
93                        // baseclasses
94                        // Order is neccessary for right initialization!
95                        private ThreadHelpBase                ,
96                        public  cppu::OWeakObject
97 {
98     /* member */
99     private:
100 
101         /// reference to global uno service manager which had created us
102         css::uno::Reference< css::lang::XMultiServiceFactory > m_xFactory;
103 
104     /* interface */
105 	public:
106 
107         // ctor/dtor
108                  SystemExec( const css::uno::Reference< css::lang::XMultiServiceFactory >& xFactory );
109         virtual ~SystemExec(                                                                        );
110 
111         // XInterface, XTypeProvider, XServiceInfo
112         FWK_DECLARE_XINTERFACE
113 		FWK_DECLARE_XTYPEPROVIDER
114         DECLARE_XSERVICEINFO
115 
116         // XDispatchProvider
117         virtual css::uno::Reference< css::frame::XDispatch > SAL_CALL                       queryDispatch  ( const css::util::URL&                                       aURL        ,
118                                                                                                              const ::rtl::OUString&                                      sTarget     ,
119                                                                                                                    sal_Int32                                             nFlags      ) throw( css::uno::RuntimeException );
120         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 );
121 
122         // XNotifyingDispatch
123         virtual void SAL_CALL dispatchWithNotification( const css::util::URL&                                             aURL      ,
124                                                         const css::uno::Sequence< css::beans::PropertyValue >&            lArguments,
125                                                         const css::uno::Reference< css::frame::XDispatchResultListener >& xListener ) throw( css::uno::RuntimeException );
126 
127         // XDispatch
128         virtual void SAL_CALL dispatch            ( const css::util::URL&                                     aURL       ,
129                                                     const css::uno::Sequence< css::beans::PropertyValue >&    lArguments ) throw( css::uno::RuntimeException );
130         virtual void SAL_CALL addStatusListener   ( const css::uno::Reference< css::frame::XStatusListener >& xListener  ,
131                                                     const css::util::URL&                                     aURL       ) throw( css::uno::RuntimeException );
132         virtual void SAL_CALL removeStatusListener( const css::uno::Reference< css::frame::XStatusListener >& xListener  ,
133                                                     const css::util::URL&                                     aURL       ) throw( css::uno::RuntimeException );
134 
135     /* internal */
136     private:
137 
138         void impl_notifyResultListener(const css::uno::Reference< css::frame::XDispatchResultListener >& xListener,
139                                        const sal_Int16                                                   nState   );
140 
141 };      //  class SystemExec
142 
143 }		//	namespace framework
144 
145 #endif  //  #ifndef __FRAMEWORK_DISPATCH_SYSTEMEXEC_HXX_
146