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_SERVICEHANDLER_HXX_
29 #define __FRAMEWORK_DISPATCH_SERVICEHANDLER_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 "service:*" 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                     His job is to create any registered uno components which must be coded inside
79                     dispatched URL (may with some optional given parameters). After that such created
80                     service must be hold his self alive. Such mechanism can be usefull for UI components
81                     (e.g. Dialogs, Wizards) only.
82 
83     @base           ThreadHelpBase
84                         exports a lock member to guarantee right initialize value of it
85     @base           OWeakObject
86                         provides XWeak and ref count mechanism
87 
88 	@devstatus		ready to use
89 
90     @modified       02.05.2002 08:13, as96863
91 */
92 class ServiceHandler : // interfaces
93                        public  css::lang::XTypeProvider      ,
94                        public  css::lang::XServiceInfo       ,
95                        public  css::frame::XDispatchProvider ,
96                        public  css::frame::XNotifyingDispatch, // => XDispatch
97                        // baseclasses
98                        // Order is neccessary for right initialization!
99                        private ThreadHelpBase                ,
100                        public  cppu::OWeakObject
101 {
102     /* member */
103     private:
104 
105         /// reference to global uno service manager which had created us
106         css::uno::Reference< css::lang::XMultiServiceFactory > m_xFactory;
107 
108     /* interface */
109 	public:
110 
111         // ctor/dtor
112                  ServiceHandler( const css::uno::Reference< css::lang::XMultiServiceFactory >& xFactory );
113         virtual ~ServiceHandler(                                                                        );
114 
115         // XInterface, XTypeProvider, XServiceInfo
116         FWK_DECLARE_XINTERFACE
117         FWK_DECLARE_XTYPEPROVIDER
118         DECLARE_XSERVICEINFO
119 
120         // XDispatchProvider
121         virtual css::uno::Reference< css::frame::XDispatch > SAL_CALL                       queryDispatch  ( const css::util::URL&                                       aURL        ,
122                                                                                                              const ::rtl::OUString&                                      sTarget     ,
123                                                                                                                    sal_Int32                                             nFlags      ) throw( css::uno::RuntimeException );
124         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 );
125 
126         // XNotifyingDispatch
127         virtual void SAL_CALL dispatchWithNotification( const css::util::URL&                                             aURL      ,
128                                                         const css::uno::Sequence< css::beans::PropertyValue >&            lArguments,
129                                                         const css::uno::Reference< css::frame::XDispatchResultListener >& xListener ) throw( css::uno::RuntimeException );
130 
131         // XDispatch
132         virtual void SAL_CALL dispatch            ( const css::util::URL&                                     aURL       ,
133                                                     const css::uno::Sequence< css::beans::PropertyValue >&    lArguments ) throw( css::uno::RuntimeException );
134         virtual void SAL_CALL addStatusListener   ( const css::uno::Reference< css::frame::XStatusListener >& xListener  ,
135                                                     const css::util::URL&                                     aURL       ) throw( css::uno::RuntimeException );
136         virtual void SAL_CALL removeStatusListener( const css::uno::Reference< css::frame::XStatusListener >& xListener  ,
137                                                     const css::util::URL&                                     aURL       ) throw( css::uno::RuntimeException );
138 
139     /* internal */
140     private:
141 
142         css::uno::Reference< css::uno::XInterface > implts_dispatch( const css::util::URL&                                  aURL       ,
143                                                                      const css::uno::Sequence< css::beans::PropertyValue >& lArguments ) throw( css::uno::RuntimeException );
144 
145 };      //  class ServiceHandler
146 
147 }		//	namespace framework
148 
149 #endif  //  #ifndef __FRAMEWORK_DISPATCH_SERVICEHANDLER_HXX_
150