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_SERVICEHANDLER_HXX_
25 #define __FRAMEWORK_DISPATCH_SERVICEHANDLER_HXX_
26 
27 //_________________________________________________________________________________________________________________
28 //	my own includes
29 //_________________________________________________________________________________________________________________
30 
31 #include <macros/generic.hxx>
32 #include <macros/xinterface.hxx>
33 #include <macros/xtypeprovider.hxx>
34 #include <macros/xserviceinfo.hxx>
35 #include <macros/debug.hxx>
36 #include <threadhelp/threadhelpbase.hxx>
37 #include <general.h>
38 #include <stdtypes.h>
39 
40 //_________________________________________________________________________________________________________________
41 //	interface includes
42 //_________________________________________________________________________________________________________________
43 #include <com/sun/star/lang/XTypeProvider.hpp>
44 #include <com/sun/star/frame/XNotifyingDispatch.hpp>
45 #include <com/sun/star/frame/XDispatch.hpp>
46 #include <com/sun/star/frame/XDispatchProvider.hpp>
47 #include <com/sun/star/util/URL.hpp>
48 #include <com/sun/star/beans/PropertyValue.hpp>
49 #include <com/sun/star/frame/XStatusListener.hpp>
50 
51 //_________________________________________________________________________________________________________________
52 //	other includes
53 //_________________________________________________________________________________________________________________
54 #include <cppuhelper/weak.hxx>
55 
56 //_________________________________________________________________________________________________________________
57 //	namespace
58 //_________________________________________________________________________________________________________________
59 
60 namespace framework{
61 
62 //_________________________________________________________________________________________________________________
63 //	exported const
64 //_________________________________________________________________________________________________________________
65 
66 //_________________________________________________________________________________________________________________
67 //	exported definitions
68 //_________________________________________________________________________________________________________________
69 
70 /**
71     @short          protocol handler for "service:*" URLs
72     @descr          It's a special dispatch/provider object which is registered for such URL pattern and will
73                     be automaticly used by the framework dispatch mechanism if such URL occured.
74                     His job is to create any registered uno components which must be coded inside
75                     dispatched URL (may with some optional given parameters). After that such created
76                     service must be hold his self alive. Such mechanism can be usefull for UI components
77                     (e.g. Dialogs, Wizards) only.
78 
79     @base           ThreadHelpBase
80                         exports a lock member to guarantee right initialize value of it
81     @base           OWeakObject
82                         provides XWeak and ref count mechanism
83 
84 	@devstatus		ready to use
85 
86     @modified       02.05.2002 08:13, as96863
87 */
88 class ServiceHandler : // 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                  ServiceHandler( const css::uno::Reference< css::lang::XMultiServiceFactory >& xFactory );
109         virtual ~ServiceHandler(                                                                        );
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         css::uno::Reference< css::uno::XInterface > implts_dispatch( const css::util::URL&                                  aURL       ,
139                                                                      const css::uno::Sequence< css::beans::PropertyValue >& lArguments ) throw( css::uno::RuntimeException );
140 
141 };      //  class ServiceHandler
142 
143 }		//	namespace framework
144 
145 #endif  //  #ifndef __FRAMEWORK_DISPATCH_SERVICEHANDLER_HXX_
146