1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: pluginframe.hxx,v $
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_SERVICES_PLUGINFRAME_HXX_
32 #define __FRAMEWORK_SERVICES_PLUGINFRAME_HXX_
34 //_________________________________________________________________________________________________________________
36 //_________________________________________________________________________________________________________________
38 #include <services/frame.hxx>
40 //_________________________________________________________________________________________________________________
42 //_________________________________________________________________________________________________________________
43 #include <com/sun/star/mozilla/XPluginInstance.hpp>
44 #include <com/sun/star/mozilla/XPluginInstancePeer.hpp>
45 #include <com/sun/star/mozilla/XPluginWindowPeer.hpp>
46 #include <com/sun/star/io/XInputStream.hpp>
47 #include <com/sun/star/lang/XInitialization.hpp>
48 #include <com/sun/star/awt/XWindow.hpp>
49 #include <com/sun/star/frame/XDispatchResultListener.hpp>
50 #include <com/sun/star/frame/FeatureStateEvent.hpp>
51 #include <com/sun/star/lang/EventObject.hpp>
53 //_________________________________________________________________________________________________________________
55 //_________________________________________________________________________________________________________________
58 #include <vcl/threadex.hxx>
60 #include <svtools/cmdoptions.hxx>
63 //_________________________________________________________________________________________________________________
65 //_________________________________________________________________________________________________________________
69 //_________________________________________________________________________________________________________________
71 //_________________________________________________________________________________________________________________
73 //_________________________________________________________________________________________________________________
74 // exported definitions
75 //_________________________________________________________________________________________________________________
77 /*-************************************************************************************************************//**
78 @short implements an special frame - a plugin frame
81 @implements XInitialization
83 XDispatchResultListener
85 *//*-*************************************************************************************************************/
87 class PlugInFrame
: public css::lang::XInitialization
,
88 public css::mozilla::XPluginInstance
,
89 public css::frame::XDispatchResultListener
, // => XEVENTLISTENER
90 public Frame
// Order of baseclasses is neccessary for right initialization!
92 //-------------------------------------------------------------------------------------------------------------
94 //-------------------------------------------------------------------------------------------------------------
98 //---------------------------------------------------------------------------------------------------------
99 // constructor / destructor
100 //---------------------------------------------------------------------------------------------------------
102 /*-****************************************************************************************************//**
103 @short standard constructor to create instance
104 @descr This constructor initialize a new instance of this class,
105 and will be set valid values on his member and baseclasses.
113 *//*-*****************************************************************************************************/
115 PlugInFrame( const css::uno::Reference
< css::lang::XMultiServiceFactory
>& xFactory
);
117 /*-****************************************************************************************************//**
118 @short standard destructor
119 @descr This method destruct an instance of this class and clear some member.
127 *//*-*****************************************************************************************************/
129 virtual ~PlugInFrame();
131 //---------------------------------------------------------------------------------------------------------
132 // XInterface, XTypeProvider, XServiceInfo
133 //---------------------------------------------------------------------------------------------------------
136 DECLARE_XTYPEPROVIDER
139 //---------------------------------------------------------------------------------------------------------
141 //---------------------------------------------------------------------------------------------------------
143 void SAL_CALL
initialize( const css::uno::Sequence
< css::uno::Any
>& seqArguments
) throw( css::uno::Exception
,
144 css::uno::RuntimeException
);
146 //---------------------------------------------------------------------------------------------------------
148 //---------------------------------------------------------------------------------------------------------
150 void SAL_CALL
start () throw( css::uno::RuntimeException
);
151 void SAL_CALL
implcb_start () throw( css::uno::RuntimeException
);
152 void SAL_CALL
stop () throw( css::uno::RuntimeException
);
153 void SAL_CALL
implcb_stop () throw( css::uno::RuntimeException
);
154 void SAL_CALL
destroy () throw( css::uno::RuntimeException
);
155 void SAL_CALL
implcb_destroy() throw( css::uno::RuntimeException
);
156 void SAL_CALL
createWindow ( const css::uno::Any
& aPlatformWindowHandle
,
157 sal_Bool bEmbedded
) throw( css::uno::RuntimeException
);
158 void SAL_CALL
implcb_createWindow ( const css::uno::Any
& aPlatformWindowHandle
,
159 sal_Bool bEmbedded
) throw( css::uno::RuntimeException
);
160 void SAL_CALL
newStream ( const ::rtl::OUString
& sMIMEDescription
,
161 const ::rtl::OUString
& sURL
,
162 const ::rtl::OUString
& sFilter
,
163 const css::uno::Reference
< css::io::XInputStream
>& xStream
,
164 const css::uno::Any
& aSessionId
) throw( css::uno::RuntimeException
);
165 void SAL_CALL implcb_newStream
166 ( const ::rtl::OUString
& sMIMEDescription
,
167 const ::rtl::OUString
& sURL
,
168 const ::rtl::OUString
& sFilter
,
169 const css::uno::Reference
< css::io::XInputStream
>& xStream
,
170 const css::uno::Any
& aSessionId
) throw( css::uno::RuntimeException
);
171 void SAL_CALL
newURL ( const ::rtl::OUString
& sMIMEDescription
,
172 const ::rtl::OUString
& sURL
,
173 const ::rtl::OUString
& sFilter
,
174 const css::uno::Any
& aSessionId
) throw( css::uno::RuntimeException
);
175 void SAL_CALL
implcb_newURL ( const ::rtl::OUString
& sMIMEDescription
,
176 const ::rtl::OUString
& sURL
,
177 const ::rtl::OUString
& sFilter
,
178 const css::uno::Any
& aSessionId
) throw( css::uno::RuntimeException
);
179 virtual void SAL_CALL
getHttpServerURL( ::rtl::OUString
& sHost
,
181 ::rtl::OUString
& sPrefix
) throw( css::uno::RuntimeException
);
183 //---------------------------------------------------------------------------------------------------------
185 //---------------------------------------------------------------------------------------------------------
187 virtual css::uno::Reference
< css::frame::XDispatch
> SAL_CALL
queryDispatch( const css::util::URL
& aURL
,
188 const ::rtl::OUString
& sTargetFrameName
,
189 sal_Int32 nSearchFlags
) throw( css::uno::RuntimeException
);
190 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
);
192 //---------------------------------------------------------------------------------------------------------
193 // XDispatchResultListener
194 //---------------------------------------------------------------------------------------------------------
196 virtual void SAL_CALL
dispatchFinished ( const css::frame::DispatchResultEvent
& aEvent
) throw( css::uno::RuntimeException
);
198 //---------------------------------------------------------------------------------------------------------
200 //---------------------------------------------------------------------------------------------------------
202 void SAL_CALL
disposing( const css::lang::EventObject
& aEvent
) throw( css::uno::RuntimeException
);
204 //-------------------------------------------------------------------------------------------------------------
206 //-------------------------------------------------------------------------------------------------------------
210 //-------------------------------------------------------------------------------------------------------------
212 //-------------------------------------------------------------------------------------------------------------
216 void impl_tryToLoadDocument();
217 sal_Bool
impl_registerRemoteFactories( const css::uno::Reference
< css::lang::XMultiServiceFactory
>& xRemoteServiceManager
);
219 //-------------------------------------------------------------------------------------------------------------
221 // (should be private everyway!)
222 //-------------------------------------------------------------------------------------------------------------
224 /*-****************************************************************************************************//**
225 @short debug-method to check incoming parameter of some other mehods of this class
226 @descr The following methods are used to check parameters for other methods
227 of this class. The return value is used directly for an ASSERT(...).
229 @seealso ASSERTs in implementation!
231 @param references to checking variables
232 @return sal_False on invalid parameter<BR>
236 *//*-*****************************************************************************************************/
238 #ifdef ENABLE_ASSERTIONS
242 static sal_Bool
impldbg_checkParameter_initialize ( const css::uno::Sequence
< css::uno::Any
>& seqArguments
);
243 static sal_Bool
impldbg_checkParameter_createWindow ( const css::uno::Any
& aPlatformWindowHandle
,
244 sal_Bool bEmbedded
);
245 static sal_Bool
impldbg_checkParameter_newStream ( const ::rtl::OUString
& sMIMEDescription
,
246 const ::rtl::OUString
& sURL
,
247 const ::rtl::OUString
& sFilter
,
248 const css::uno::Reference
< css::io::XInputStream
>& xStream
);
249 static sal_Bool
impldbg_checkParameter_newURL ( const ::rtl::OUString
& sMIMEDescription
,
250 const ::rtl::OUString
& sURL
,
251 const ::rtl::OUString
& sFilter
);
252 static sal_Bool
impldbg_checkParameter_getHttpServerURL ( ::rtl::OUString
& sHost
,
254 ::rtl::OUString
& sPrefix
);
255 static sal_Bool
impldbg_checkParameter_queryDispatch ( const css::util::URL
& aURL
,
256 const ::rtl::OUString
& sTargetFrameName
,
257 sal_Int32 nSearchFlags
);
258 static sal_Bool
impldbg_checkParameter_queryDispatches ( const css::uno::Sequence
< css::frame::DispatchDescriptor
>& seqDescripts
);
259 static sal_Bool
impldbg_checkParameter_statusChanged ( const css::frame::FeatureStateEvent
& aEvent
);
260 static sal_Bool
impldbg_checkParameter_disposing ( const css::lang::EventObject
& aEvent
);
262 #endif // #ifdef ENABLE_ASSERTIONS
264 //-------------------------------------------------------------------------------------------------------------
266 // (should be private everyway!)
267 //-------------------------------------------------------------------------------------------------------------
271 css::uno::Reference
< css::mozilla::XPluginInstancePeer
> m_xPlugInInstancePeer
; /// Reference to UNO interface of PlugIn dll for communication with browser
272 css::uno::Reference
< css::mozilla::XPluginWindowPeer
> m_xPlugInWindowPeer
; /// Reference to set child window at plugin window
273 css::uno::Sequence
< css::beans::PropertyValue
> m_seqProperties
; /// Sequence of properties as arguments for load document
274 css::util::URL m_aURL
; /// URL for document to load
275 sal_Bool m_bILoad
; /// PlugInFrame has a valid loader which load the document and wait for finished/cancelled
276 sal_Bool m_bIHaveDocument
; /// We have a document loaded successful.
277 css::uno::Reference
< css::frame::XDispatchProvider
> m_xPlugInDispatcher
; /// Dispatcher to forward dispatches to browser
278 static sal_Bool m_bRemoteFactoriesExist
; /// indicates, if remote factories was already registered (neccessary one times only!)
279 SvtCommandOptions m_aCommandOptions
; /// ref counted class to support disabling commands defined by configuration file
281 }; // class PlugInFrame
283 /*-************************************************************************************************************//**
284 @short used to forward all asynchronous calls which use VCL internal to the main thread
285 @descr We need this asynchronous mechanism to prevent us against dead locks. Sometimes our main thread
286 can call us for event handling like FOCUS, ACTIVATE and something else. But at the same time we will call
287 the main thread to CREATE A WINDOW, SET IT VISIBLE ... Then we have a problem. We must send us himself a event
288 to run our code synchronized with our main thread!
292 *//*-*************************************************************************************************************/
294 enum eIMPL_PluginCommand
304 class cIMPL_MainThreadExecutorRequest
307 cIMPL_MainThreadExecutorRequest( eIMPL_PluginCommand eCommand
,
308 PlugInFrame
* pPluginInstance
);
310 cIMPL_MainThreadExecutorRequest( eIMPL_PluginCommand eCommand
,
311 PlugInFrame
* pPluginInstance
,
312 const css::uno::Any
& aPlatformWindowHandle
,
313 sal_Bool bEmbedded
);
315 cIMPL_MainThreadExecutorRequest( eIMPL_PluginCommand eCommand
,
316 PlugInFrame
* pPluginInstance
,
317 const ::rtl::OUString
& sMIMEDescription
,
318 const ::rtl::OUString
& sURL
,
319 const ::rtl::OUString
& sFilter
,
320 const css::uno::Reference
< css::io::XInputStream
>& xStream
,
321 const css::uno::Any
& aSessionId
);
323 /*-****************************************************************************************************//**
333 *//*-*****************************************************************************************************/
337 //-------------------------------------------------------------------------------------------------------------
339 //-------------------------------------------------------------------------------------------------------------
342 eIMPL_PluginCommand m_eCommand
; /// switch to specify forward function
343 PlugInFrame
* m_pPluginInstance
; /// instance wich has started this swicth mechanism and wish to called back from us
344 css::uno::Reference
< css::uno::XInterface
> m_xPluginInstance
; /// reference to our plugin frame to prevent that plugin frame dies before we call back
345 css::uno::Any m_aPlatformWindowHandle
; /// parameter for XPluginInstance->createWindow()
346 sal_Bool m_bEmbedded
; /// parameter for XPluginInstance->createWindow()
347 ::rtl::OUString m_sMIMEDescription
; /// parameter for XPluginInstance->newStream()/newURL()
348 ::rtl::OUString m_sURL
; /// parameter for XPluginInstance->newStream()/newURL()
349 ::rtl::OUString m_sFilter
; /// parameter for XPluginInstance->newStream()/newURL()
350 css::uno::Reference
< css::io::XInputStream
> m_xStream
; /// parameter for XPluginInstance->newStream()/newURL()
351 css::uno::Any m_aSessionId
; /// parameter for XPluginInstance->newStream()/newURL()
354 class cIMPL_MainThreadExecutor
356 //-------------------------------------------------------------------------------------------------------------
358 //-------------------------------------------------------------------------------------------------------------
360 static void execute( cIMPL_MainThreadExecutorRequest
* pRequest
);
362 /*-****************************************************************************************************//**
372 *//*-*****************************************************************************************************/
373 DECL_STATIC_LINK( cIMPL_MainThreadExecutor
, worker
, cIMPL_MainThreadExecutorRequest
* );
376 } // namespace framework
378 #endif // #ifndef __FRAMEWORK_SERVICES_PLUGINFRAME_HXX_