update dev300-m58
[ooovba.git] / framework / inc / helper / opluginframedispatcher.hxx
blobc3000e67a40bb75ca5415752cac3d08b8f0bf47f
1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: opluginframedispatcher.hxx,v $
10 * $Revision: 1.8 $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
31 #ifndef __FRAMEWORK_HELPER_OPLUGINFRAMEDISPATCHER_HXX_
32 #define __FRAMEWORK_HELPER_OPLUGINFRAMEDISPATCHER_HXX_
34 //_________________________________________________________________________________________________________________
35 // my own includes
36 //_________________________________________________________________________________________________________________
38 #include <threadhelp/threadhelpbase.hxx>
39 #include <macros/generic.hxx>
40 #include <macros/xinterface.hxx>
41 #include <macros/debug.hxx>
42 #include <general.h>
44 //_________________________________________________________________________________________________________________
45 // interface includes
46 //_________________________________________________________________________________________________________________
47 #include <com/sun/star/frame/XFrame.hpp>
48 #include <com/sun/star/frame/XDispatch.hpp>
49 #include <com/sun/star/frame/XDispatchProvider.hpp>
50 #include <com/sun/star/mozilla/XPluginInstance.hpp>
51 #include <com/sun/star/mozilla/XPluginInstancePeer.hpp>
52 #include <com/sun/star/mozilla/XPluginInstanceNotifySink.hpp>
53 #include <com/sun/star/util/URL.hpp>
54 #include <com/sun/star/frame/DispatchDescriptor.hpp>
55 #include <com/sun/star/io/XInputStream.hpp>
56 #include <com/sun/star/beans/PROPERTYVALUE.hpp>
58 //_________________________________________________________________________________________________________________
59 // other includes
60 //_________________________________________________________________________________________________________________
61 #include <cppuhelper/implbase3.hxx>
62 #include <cppuhelper/weakref.hxx>
63 #include <cppuhelper/interfacecontainer.hxx>
65 //_________________________________________________________________________________________________________________
66 // namespace
67 //_________________________________________________________________________________________________________________
69 namespace framework{
71 //_________________________________________________________________________________________________________________
72 // exported const
73 //_________________________________________________________________________________________________________________
75 //_________________________________________________________________________________________________________________
76 // exported definitions
77 //_________________________________________________________________________________________________________________
79 /*-************************************************************************************************************//**
80 Use OMultiTypeInterfaceContainerHelperVar-template to create new class to get a container
81 to combine string values with listeners.
82 *//*-*************************************************************************************************************/
84 struct IMPL_hashCode
86 size_t operator()(const ::rtl::OUString& sString) const
88 return sString.hashCode();
92 typedef ::cppu::OMultiTypeInterfaceContainerHelperVar< ::rtl::OUString ,
93 IMPL_hashCode ,
94 ::std::equal_to< ::rtl::OUString > > IMPL_ListenerContainerHelper ;
96 /*-************************************************************************************************************//**
97 @short -
98 @descr -
100 @implements XInterface
101 XDispatchProvider
102 XDispatch
103 XPluginInstanceNotifySink
104 @base OWeakObject
106 @devstatus ready to use
107 *//*-*************************************************************************************************************/
109 class OPlugInFrameDispatcher : private ThreadHelpBase ,
110 public ::cppu::WeakImplHelper3< ::com::sun::star::frame::XDispatchProvider, ::com::sun::star::frame::XDispatch, ::com::sun::star::mozilla::XPluginInstanceNotifySink >
112 //-------------------------------------------------------------------------------------------------------------
113 // public methods
114 //-------------------------------------------------------------------------------------------------------------
116 public:
118 static void AddArguments ( const css::uno::Sequence< css::beans::PropertyValue > & rArgs ,
119 const ::rtl::OUString& rURL );
120 static const css::uno::Sequence < css::beans::PropertyValue >* GetArguments ( const ::rtl::OUString& rURL );
121 static void RemoveArguments ( const ::rtl::OUString& rURL );
123 //---------------------------------------------------------------------------------------------------------
124 // constructor / destructor
125 //---------------------------------------------------------------------------------------------------------
127 /*-****************************************************************************************************//**
128 @short standard ctor
129 @descr These initialize a new instance of ths class with needed informations for work.
131 @seealso using at owner
133 @param -
134 @return -
136 @onerror -
137 *//*-*****************************************************************************************************/
139 OPlugInFrameDispatcher( const css::uno::Reference< css::lang::XMultiServiceFactory >& xFactory ,
140 const css::uno::Reference< css::mozilla::XPluginInstance >& xOwner ,
141 const css::uno::Reference< css::mozilla::XPluginInstancePeer >& xPlugInDLL );
143 //---------------------------------------------------------------------------------------------------------
144 // XDispatchProvider
145 //---------------------------------------------------------------------------------------------------------
147 /*-****************************************************************************************************//**
148 @short search a dispatcher for given URL
149 @descr If no interceptor is set on owner, we search for right frame and dispatch URL to it.
150 If no frame was found, we do nothing.
152 @seealso -
154 @param "aURL" , URL to dispatch.
155 @param "sTargetFrameName" , name of searched frame.
156 @param "nSearchFlags" , flags for searching.
157 @return A reference a dispatcher for these URL (if someone was found!).
159 @onerror We return a NULL-reference.
160 *//*-*****************************************************************************************************/
162 virtual css::uno::Reference< css::frame::XDispatch > SAL_CALL queryDispatch( const css::util::URL& aURL ,
163 const ::rtl::OUString& sTargetFrameName ,
164 sal_Int32 nSearchFlags ) throw( css::uno::RuntimeException );
166 /*-****************************************************************************************************//**
167 @short search dispatcher for more the one URL
168 @descr Call this method, if you search dispatcher for more then one URL at the same time.
169 ( But these mode is not supported yet! )
171 @seealso -
173 @param "seqDescripts", descriptor to search more then one dispatcher.
174 @return A list of founded dispatcher. (if somewhere exist!)
176 @onerror An empty list is returned.
177 *//*-*****************************************************************************************************/
179 virtual css::uno::Sequence< css::uno::Reference< css::frame::XDispatch > > SAL_CALL queryDispatches( const css::uno::Sequence< css::frame::DispatchDescriptor >& seqDescripts ) throw( css::uno::RuntimeException );
181 //---------------------------------------------------------------------------------------------------------
182 // XDispatch
183 //---------------------------------------------------------------------------------------------------------
185 /*-****************************************************************************************************//**
186 @short dispatch URL with arguments
187 @descr This class implement XDispatch interface to. We use the implementation of ouer owner
188 directly to do this. He must support a function impl_loadComponent().
190 @seealso methode <owner>::impl_loadComponent()
192 @param "aURL" , URL to dispatch.
193 @param "seqArguments" , list of optional arguments.
194 @return -
196 @onerror -
197 *//*-*****************************************************************************************************/
199 virtual void SAL_CALL dispatch( const css::util::URL& aURL ,
200 const css::uno::Sequence< css::beans::PropertyValue >& seqArguments) throw( css::uno::RuntimeException );
202 /*-****************************************************************************************************//**
203 @short add listener for state events
204 @descr -
206 @seealso -
208 @param "xControl" , reference to a valid listener for state events.
209 @param "aURL" , URL about listener will be informed, if something occured.
210 @return -
212 @onerror -
213 *//*-*****************************************************************************************************/
215 virtual void SAL_CALL addStatusListener( const css::uno::Reference< css::frame::XStatusListener >& xControl,
216 const css::util::URL& aURL ) throw( css::uno::RuntimeException );
218 /*-****************************************************************************************************//**
219 @short remove listener
220 @descr -
222 @seealso -
224 @param "xControl" , reference to a valid listener.
225 @param "aURL" , URL on which listener has registered.
226 @return -
228 @onerror -
229 *//*-*****************************************************************************************************/
231 virtual void SAL_CALL removeStatusListener( const css::uno::Reference< css::frame::XStatusListener >& xControl,
232 const css::util::URL& aURL ) throw( css::uno::RuntimeException );
234 //---------------------------------------------------------------------------------------------------------
235 // XPluginInstanceNotifySink
236 //---------------------------------------------------------------------------------------------------------
238 /*-****************************************************************************************************//**
239 @short -
240 @descr -
242 @seealso -
244 @param -
245 @param -
246 @return -
248 @onerror -
249 *//*-*****************************************************************************************************/
251 void SAL_CALL notifyURL( const ::rtl::OUString& sURL ) throw( css::uno::RuntimeException );
253 //-------------------------------------------------------------------------------------------------------------
254 // protected methods
255 //-------------------------------------------------------------------------------------------------------------
257 protected:
259 /*-****************************************************************************************************//**
260 @short standard destructor
261 @descr This method destruct an instance of this class and clear some member.
262 This method is protected, because its not allowed to use an instance of this class as a member!
263 You MUST use a pointer.
265 @seealso -
267 @param -
268 @return -
270 @onerror -
271 *//*-*****************************************************************************************************/
273 virtual ~OPlugInFrameDispatcher();
275 //-------------------------------------------------------------------------------------------------------------
276 // private methods
277 //-------------------------------------------------------------------------------------------------------------
279 private:
281 /*-****************************************************************************************************//**
282 @short -
283 @descr -
285 @seealso -
287 @param -
288 @return -
290 @onerror -
291 *//*-*****************************************************************************************************/
293 void impl_sendStatusEvent( const ::rtl::OUString& sURL ,
294 sal_Bool bLoadingSuccessful );
296 //-------------------------------------------------------------------------------------------------------------
297 // debug methods
298 // (should be private everyway!)
299 //-------------------------------------------------------------------------------------------------------------
301 /*-****************************************************************************************************//**
302 @short debug-method to check incoming parameter of some other mehods of this class
303 @descr The following methods are used to check parameters for other methods
304 of this class. The return value is used directly for an ASSERT(...).
306 @seealso ASSERTs in implementation!
308 @param references to checking variables
309 @return sal_False on invalid parameter<BR>
310 sal_True otherway
312 @onerror -
313 *//*-*****************************************************************************************************/
315 #ifdef ENABLE_ASSERTIONS
317 private:
319 static sal_Bool impldbg_checkParameter_OPlugInFrameDispatcherCtor ( const css::uno::Reference< css::lang::XMultiServiceFactory >& xFactory ,
320 const css::uno::Reference< css::mozilla::XPluginInstance >& xOwner ,
321 const css::uno::Reference< css::mozilla::XPluginInstancePeer >& xPlugInDLL );
322 static sal_Bool impldbg_checkParameter_queryDispatch ( const css::util::URL& aURL ,
323 const ::rtl::OUString& sTargetFrameName ,
324 sal_Int32 nSearchFlags );
325 static sal_Bool impldbg_checkParameter_queryDispatches ( const css::uno::Sequence< css::frame::DispatchDescriptor >& seqDescriptor );
326 static sal_Bool impldbg_checkParameter_dispatch ( const css::util::URL& aURL ,
327 const css::uno::Sequence< css::beans::PropertyValue >& seqArguments );
328 static sal_Bool impldbg_checkParameter_addStatusListener ( const css::uno::Reference< css::frame::XStatusListener >& xControl ,
329 const css::util::URL& aURL );
330 static sal_Bool impldbg_checkParameter_removeStatusListener ( const css::uno::Reference< css::frame::XStatusListener >& xControl ,
331 const css::util::URL& aURL );
332 static sal_Bool impldbg_checkParameter_notifyURL ( const ::rtl::OUString& sURL );
334 #endif // #ifdef ENABLE_ASSERTIONS
336 //-------------------------------------------------------------------------------------------------------------
337 // variables
338 // (should be private everyway!)
339 //-------------------------------------------------------------------------------------------------------------
341 private:
343 css::uno::Reference< css::lang::XMultiServiceFactory > m_xFactory ; /// servicemanager to create uno services
344 css::uno::WeakReference< css::mozilla::XPluginInstance > m_xOwnerWeak ; /// weakreference to owner (Don't use a hard reference. Owner can't delete us then!)
345 css::uno::Reference< css::mozilla::XPluginInstancePeer > m_xPlugInDLL ; /// Interface for communication with browser.
346 ::rtl::OUString m_sTargetFrameName ; /// We need it as target for get/postURL.
347 IMPL_ListenerContainerHelper m_aListenerContainer ; /// Container to combine listeners and URLs.
349 }; // class OPlugInFrameDispatcher
351 } // namespace framework
353 #endif // #ifndef __FRAMEWORK_HELPER_OPLUGINFRAMEDISPATCHER_HXX_