1*cdf0e10cSrcweir /*************************************************************************
2*cdf0e10cSrcweir  *
3*cdf0e10cSrcweir  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4*cdf0e10cSrcweir  *
5*cdf0e10cSrcweir  * Copyright 2000, 2010 Oracle and/or its affiliates.
6*cdf0e10cSrcweir  *
7*cdf0e10cSrcweir  * OpenOffice.org - a multi-platform office productivity suite
8*cdf0e10cSrcweir  *
9*cdf0e10cSrcweir  * This file is part of OpenOffice.org.
10*cdf0e10cSrcweir  *
11*cdf0e10cSrcweir  * OpenOffice.org is free software: you can redistribute it and/or modify
12*cdf0e10cSrcweir  * it under the terms of the GNU Lesser General Public License version 3
13*cdf0e10cSrcweir  * only, as published by the Free Software Foundation.
14*cdf0e10cSrcweir  *
15*cdf0e10cSrcweir  * OpenOffice.org is distributed in the hope that it will be useful,
16*cdf0e10cSrcweir  * but WITHOUT ANY WARRANTY; without even the implied warranty of
17*cdf0e10cSrcweir  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
18*cdf0e10cSrcweir  * GNU Lesser General Public License version 3 for more details
19*cdf0e10cSrcweir  * (a copy is included in the LICENSE file that accompanied this code).
20*cdf0e10cSrcweir  *
21*cdf0e10cSrcweir  * You should have received a copy of the GNU Lesser General Public License
22*cdf0e10cSrcweir  * version 3 along with OpenOffice.org.  If not, see
23*cdf0e10cSrcweir  * <http://www.openoffice.org/license.html>
24*cdf0e10cSrcweir  * for a copy of the LGPLv3 License.
25*cdf0e10cSrcweir  *
26*cdf0e10cSrcweir  ************************************************************************/
27*cdf0e10cSrcweir 
28*cdf0e10cSrcweir // MARKER(update_precomp.py): autogen include statement, do not remove
29*cdf0e10cSrcweir #include "precompiled_framework.hxx"
30*cdf0e10cSrcweir 
31*cdf0e10cSrcweir //_________________________________________________________________________________________________________________
32*cdf0e10cSrcweir //	my own includes
33*cdf0e10cSrcweir //_________________________________________________________________________________________________________________
34*cdf0e10cSrcweir #include <loadenv/loadenv.hxx>
35*cdf0e10cSrcweir 
36*cdf0e10cSrcweir #ifndef __FRAMEWORK_LOADENV_TARGETHELPER_HXX_
37*cdf0e10cSrcweir #include <loadenv/targethelper.hxx>
38*cdf0e10cSrcweir #endif
39*cdf0e10cSrcweir 
40*cdf0e10cSrcweir #ifndef __FRAMEWORK_DESKTOP_HXX_
41*cdf0e10cSrcweir #include <services/desktop.hxx>
42*cdf0e10cSrcweir #endif
43*cdf0e10cSrcweir #include <helper/ocomponentaccess.hxx>
44*cdf0e10cSrcweir #include <dispatch/dispatchprovider.hxx>
45*cdf0e10cSrcweir 
46*cdf0e10cSrcweir #ifndef __FRAMEWORK_DISPATCH_INTERCEPTIONHELPER_HXX_
47*cdf0e10cSrcweir #include <dispatch/interceptionhelper.hxx>
48*cdf0e10cSrcweir #endif
49*cdf0e10cSrcweir #include <classes/taskcreator.hxx>
50*cdf0e10cSrcweir #include <threadhelp/transactionguard.hxx>
51*cdf0e10cSrcweir #include <threadhelp/writeguard.hxx>
52*cdf0e10cSrcweir #include <threadhelp/readguard.hxx>
53*cdf0e10cSrcweir #include <services.h>
54*cdf0e10cSrcweir #include <general.h>
55*cdf0e10cSrcweir #include <properties.h>
56*cdf0e10cSrcweir 
57*cdf0e10cSrcweir #include <classes/resource.hrc>
58*cdf0e10cSrcweir #include <classes/fwkresid.hxx>
59*cdf0e10cSrcweir 
60*cdf0e10cSrcweir //_________________________________________________________________________________________________________________
61*cdf0e10cSrcweir //	interface includes
62*cdf0e10cSrcweir //_________________________________________________________________________________________________________________
63*cdf0e10cSrcweir #include <com/sun/star/beans/PropertyAttribute.hpp>
64*cdf0e10cSrcweir #include <com/sun/star/frame/FrameSearchFlag.hpp>
65*cdf0e10cSrcweir #include <com/sun/star/awt/XToolkit.hpp>
66*cdf0e10cSrcweir #include <com/sun/star/awt/XWindow.hpp>
67*cdf0e10cSrcweir #include <com/sun/star/awt/XWindowPeer.hpp>
68*cdf0e10cSrcweir #include <com/sun/star/awt/WindowDescriptor.hpp>
69*cdf0e10cSrcweir #include <com/sun/star/awt/WindowAttribute.hpp>
70*cdf0e10cSrcweir #include <com/sun/star/awt/PosSize.hpp>
71*cdf0e10cSrcweir #include <com/sun/star/util/XURLTransformer.hpp>
72*cdf0e10cSrcweir #include <com/sun/star/task/XInteractionAbort.hpp>
73*cdf0e10cSrcweir #include <com/sun/star/task/XInteractionApprove.hpp>
74*cdf0e10cSrcweir #include <com/sun/star/document/XInteractionFilterSelect.hpp>
75*cdf0e10cSrcweir #include <com/sun/star/document/AmbigousFilterRequest.hpp>
76*cdf0e10cSrcweir #include <com/sun/star/task/ErrorCodeRequest.hpp>
77*cdf0e10cSrcweir #include <com/sun/star/ucb/InteractiveIOException.hpp>
78*cdf0e10cSrcweir #include <com/sun/star/ucb/InteractiveAugmentedIOException.hpp>
79*cdf0e10cSrcweir #include <com/sun/star/frame/XNotifyingDispatch.hpp>
80*cdf0e10cSrcweir #include <com/sun/star/frame/DispatchResultState.hpp>
81*cdf0e10cSrcweir #include <com/sun/star/lang/IllegalArgumentException.hpp>
82*cdf0e10cSrcweir #include <com/sun/star/lang/DisposedException.hpp>
83*cdf0e10cSrcweir #include <com/sun/star/util/XCloseable.hpp>
84*cdf0e10cSrcweir #include <com/sun/star/document/MacroExecMode.hpp>
85*cdf0e10cSrcweir #include <com/sun/star/document/UpdateDocMode.hpp>
86*cdf0e10cSrcweir #include <com/sun/star/frame/XTerminateListener2.hpp>
87*cdf0e10cSrcweir 
88*cdf0e10cSrcweir //_________________________________________________________________________________________________________________
89*cdf0e10cSrcweir //	includes of other projects
90*cdf0e10cSrcweir //_________________________________________________________________________________________________________________
91*cdf0e10cSrcweir #include <cppuhelper/queryinterface.hxx>
92*cdf0e10cSrcweir #include <cppuhelper/typeprovider.hxx>
93*cdf0e10cSrcweir #include <cppuhelper/factory.hxx>
94*cdf0e10cSrcweir #include <cppuhelper/proptypehlp.hxx>
95*cdf0e10cSrcweir #include <rtl/ustrbuf.hxx>
96*cdf0e10cSrcweir #include <rtl/logfile.hxx>
97*cdf0e10cSrcweir #include <vcl/svapp.hxx>
98*cdf0e10cSrcweir 
99*cdf0e10cSrcweir #ifndef __RSC
100*cdf0e10cSrcweir #include <tools/errinf.hxx>
101*cdf0e10cSrcweir #endif
102*cdf0e10cSrcweir #include <comphelper/extract.hxx>
103*cdf0e10cSrcweir 
104*cdf0e10cSrcweir #include <fwkdllapi.h>
105*cdf0e10cSrcweir 
106*cdf0e10cSrcweir //_________________________________________________________________________________________________________________
107*cdf0e10cSrcweir //	namespace
108*cdf0e10cSrcweir //_________________________________________________________________________________________________________________
109*cdf0e10cSrcweir 
110*cdf0e10cSrcweir namespace framework{
111*cdf0e10cSrcweir 
112*cdf0e10cSrcweir //_________________________________________________________________________________________________________________
113*cdf0e10cSrcweir //	non exported const
114*cdf0e10cSrcweir //_________________________________________________________________________________________________________________
115*cdf0e10cSrcweir 
116*cdf0e10cSrcweir //_________________________________________________________________________________________________________________
117*cdf0e10cSrcweir //	non exported definitions
118*cdf0e10cSrcweir //_________________________________________________________________________________________________________________
119*cdf0e10cSrcweir 
120*cdf0e10cSrcweir //_________________________________________________________________________________________________________________
121*cdf0e10cSrcweir //	declarations
122*cdf0e10cSrcweir //_________________________________________________________________________________________________________________
123*cdf0e10cSrcweir 
124*cdf0e10cSrcweir //*****************************************************************************************************************
125*cdf0e10cSrcweir //	XInterface, XTypeProvider, XServiceInfo
126*cdf0e10cSrcweir //*****************************************************************************************************************
127*cdf0e10cSrcweir DEFINE_XINTERFACE_15                    (   Desktop                                                  ,
128*cdf0e10cSrcweir                                             OWeakObject                                              ,
129*cdf0e10cSrcweir                                             DIRECT_INTERFACE( css::lang::XTypeProvider              ),
130*cdf0e10cSrcweir                                             DIRECT_INTERFACE( css::lang::XServiceInfo               ),
131*cdf0e10cSrcweir                                             DIRECT_INTERFACE( css::frame::XDesktop                  ),
132*cdf0e10cSrcweir                                             DIRECT_INTERFACE( css::frame::XComponentLoader          ),
133*cdf0e10cSrcweir                                             DIRECT_INTERFACE( css::frame::XTasksSupplier            ),
134*cdf0e10cSrcweir                                             DIRECT_INTERFACE( css::frame::XDispatchProvider         ),
135*cdf0e10cSrcweir                                             DIRECT_INTERFACE( css::frame::XDispatchProviderInterception),
136*cdf0e10cSrcweir                                             DIRECT_INTERFACE( css::frame::XFramesSupplier           ),
137*cdf0e10cSrcweir                                             DIRECT_INTERFACE( css::frame::XFrame                    ),
138*cdf0e10cSrcweir                                             DIRECT_INTERFACE( css::lang::XComponent                 ),
139*cdf0e10cSrcweir                                             DIRECT_INTERFACE( css::frame::XDispatchResultListener   ),
140*cdf0e10cSrcweir                                             DIRECT_INTERFACE( css::lang::XEventListener             ),
141*cdf0e10cSrcweir                                             DIRECT_INTERFACE( css::task::XInteractionHandler        ),
142*cdf0e10cSrcweir                                             DIRECT_INTERFACE( css::beans::XPropertySet				),
143*cdf0e10cSrcweir                                             DIRECT_INTERFACE( css::frame::XUntitledNumbers          )
144*cdf0e10cSrcweir 										)
145*cdf0e10cSrcweir 
146*cdf0e10cSrcweir DEFINE_XTYPEPROVIDER_15                 (   Desktop                                                 ,
147*cdf0e10cSrcweir                                             css::lang::XTypeProvider                                ,
148*cdf0e10cSrcweir                                             css::lang::XServiceInfo                                 ,
149*cdf0e10cSrcweir                                             css::frame::XDesktop                                    ,
150*cdf0e10cSrcweir                                             css::frame::XComponentLoader                            ,
151*cdf0e10cSrcweir                                             css::frame::XTasksSupplier                              ,
152*cdf0e10cSrcweir                                             css::frame::XDispatchProvider                           ,
153*cdf0e10cSrcweir                                             css::frame::XDispatchProviderInterception               ,
154*cdf0e10cSrcweir                                             css::frame::XFramesSupplier                             ,
155*cdf0e10cSrcweir                                             css::frame::XFrame                                      ,
156*cdf0e10cSrcweir                                             css::lang::XComponent                                   ,
157*cdf0e10cSrcweir                                             css::frame::XDispatchResultListener                     ,
158*cdf0e10cSrcweir                                             css::lang::XEventListener                               ,
159*cdf0e10cSrcweir                                             css::task::XInteractionHandler                          ,
160*cdf0e10cSrcweir                                             css::beans::XPropertySet                                ,
161*cdf0e10cSrcweir                                             css::frame::XUntitledNumbers
162*cdf0e10cSrcweir 										)
163*cdf0e10cSrcweir 
164*cdf0e10cSrcweir DEFINE_XSERVICEINFO_ONEINSTANCESERVICE  (   Desktop                                                 ,
165*cdf0e10cSrcweir                                             ::cppu::OWeakObject                                     ,
166*cdf0e10cSrcweir                                             SERVICENAME_DESKTOP                                     ,
167*cdf0e10cSrcweir 											IMPLEMENTATIONNAME_DESKTOP
168*cdf0e10cSrcweir 										)
169*cdf0e10cSrcweir 
170*cdf0e10cSrcweir DEFINE_INIT_SERVICE                     (   Desktop,
171*cdf0e10cSrcweir                                             {
172*cdf0e10cSrcweir                                                 /*Attention
173*cdf0e10cSrcweir                                                     I think we don't need any mutex or lock here ... because we are called by our own static method impl_createInstance()
174*cdf0e10cSrcweir                                                     to create a new instance of this class by our own supported service factory.
175*cdf0e10cSrcweir                                                     see macro DEFINE_XSERVICEINFO_MULTISERVICE and "impl_initService()" for further informations!
176*cdf0e10cSrcweir                                                 */
177*cdf0e10cSrcweir 
178*cdf0e10cSrcweir                                                 //-------------------------------------------------------------------------------------------------------------
179*cdf0e10cSrcweir                                                 // Initialize a new XFrames-helper-object to handle XIndexAccess and XElementAccess.
180*cdf0e10cSrcweir                                                 // We hold member as reference ... not as pointer too!
181*cdf0e10cSrcweir                                                 // Attention: We share our frame container with this helper. Container is threadsafe himself ... So I think we can do that.
182*cdf0e10cSrcweir                                                 // But look on dispose() for right order of deinitialization.
183*cdf0e10cSrcweir                                                 OFrames* pFramesHelper = new OFrames( m_xFactory, this, &m_aChildTaskContainer );
184*cdf0e10cSrcweir                                                 m_xFramesHelper = css::uno::Reference< css::frame::XFrames >( static_cast< ::cppu::OWeakObject* >(pFramesHelper), css::uno::UNO_QUERY );
185*cdf0e10cSrcweir 
186*cdf0e10cSrcweir                                                 //-------------------------------------------------------------------------------------------------------------
187*cdf0e10cSrcweir                                                 // Initialize a new dispatchhelper-object to handle dispatches.
188*cdf0e10cSrcweir                                                 // We use these helper as slave for our interceptor helper ... not directly!
189*cdf0e10cSrcweir                                                 // But he is event listener on THIS instance!
190*cdf0e10cSrcweir                                                 DispatchProvider* pDispatchHelper = new DispatchProvider( m_xFactory, this );
191*cdf0e10cSrcweir                                                 css::uno::Reference< css::frame::XDispatchProvider > xDispatchProvider( static_cast< ::cppu::OWeakObject* >(pDispatchHelper), css::uno::UNO_QUERY );
192*cdf0e10cSrcweir 
193*cdf0e10cSrcweir                                                 //-------------------------------------------------------------------------------------------------------------
194*cdf0e10cSrcweir                                                 // Initialize a new interception helper object to handle dispatches and implement an interceptor mechanism.
195*cdf0e10cSrcweir                                                 // Set created dispatch provider as slowest slave of it.
196*cdf0e10cSrcweir                                                 // Hold interception helper by reference only - not by pointer!
197*cdf0e10cSrcweir                                                 // So it's easiear to destroy it.
198*cdf0e10cSrcweir                                                 InterceptionHelper* pInterceptionHelper = new InterceptionHelper( this, xDispatchProvider );
199*cdf0e10cSrcweir                                                 m_xDispatchHelper = css::uno::Reference< css::frame::XDispatchProvider >( static_cast< ::cppu::OWeakObject* >(pInterceptionHelper), css::uno::UNO_QUERY );
200*cdf0e10cSrcweir 
201*cdf0e10cSrcweir                                                 ::rtl::OUStringBuffer sUntitledPrefix (256);
202*cdf0e10cSrcweir                                                 sUntitledPrefix.append      (::rtl::OUString( String( FwkResId( STR_UNTITLED_DOCUMENT ))));
203*cdf0e10cSrcweir                                                 sUntitledPrefix.appendAscii (" ");
204*cdf0e10cSrcweir 
205*cdf0e10cSrcweir                                                 ::comphelper::NumberedCollection* pNumbers = new ::comphelper::NumberedCollection ();
206*cdf0e10cSrcweir                                                 m_xTitleNumberGenerator = css::uno::Reference< css::frame::XUntitledNumbers >(static_cast< ::cppu::OWeakObject* >(pNumbers), css::uno::UNO_QUERY_THROW);
207*cdf0e10cSrcweir                                                 pNumbers->setOwner          ( static_cast< ::cppu::OWeakObject* >(this) );
208*cdf0e10cSrcweir                                                 pNumbers->setUntitledPrefix ( sUntitledPrefix.makeStringAndClear ()     );
209*cdf0e10cSrcweir 
210*cdf0e10cSrcweir                                                 // Safe impossible cases
211*cdf0e10cSrcweir                                                 // We can't work without this helper!
212*cdf0e10cSrcweir                                                 LOG_ASSERT2( m_xFramesHelper.is  ()==sal_False, "Desktop::Desktop()", "Frames helper is not valid. XFrames, XIndexAccess and XElementAcces are not supported!\n")
213*cdf0e10cSrcweir                                                 LOG_ASSERT2( m_xDispatchHelper.is()==sal_False, "Desktop::Desktop()", "Dispatch helper is not valid. XDispatch will not work correctly!\n"                      )
214*cdf0e10cSrcweir 
215*cdf0e10cSrcweir                                                 // Enable object for real working!
216*cdf0e10cSrcweir                                                 // Otherwise all calls will be rejected ...
217*cdf0e10cSrcweir                                                 m_aTransactionManager.setWorkingMode( E_WORK );
218*cdf0e10cSrcweir                                             }
219*cdf0e10cSrcweir                                         )
220*cdf0e10cSrcweir 
221*cdf0e10cSrcweir /*-************************************************************************************************************//**
222*cdf0e10cSrcweir     @short      standard constructor to create instance by factory
223*cdf0e10cSrcweir     @descr      This constructor initialize a new instance of this class by valid factory,
224*cdf0e10cSrcweir                 and will be set valid values on his member and baseclasses.
225*cdf0e10cSrcweir 
226*cdf0e10cSrcweir     @attention  a)  Don't use your own reference during an UNO-Service-ctor! There is no guarantee, that you
227*cdf0e10cSrcweir                     will get over this. (e.g. using of your reference as parameter to initialize some member)
228*cdf0e10cSrcweir                     Do such things in DEFINE_INIT_SERVICE() method, which is called automaticly after your ctor!!!
229*cdf0e10cSrcweir                 b)  Baseclass OBroadcastHelper is a typedef in namespace cppu!
230*cdf0e10cSrcweir                     The microsoft compiler has some problems to handle it right BY using namespace explicitly ::cppu::OBroadcastHelper.
231*cdf0e10cSrcweir                     If we write it without a namespace or expand the typedef to OBrodcastHelperVar<...> -> it will be OK!?
232*cdf0e10cSrcweir                     I don't know why! (other compiler not tested .. but it works!)
233*cdf0e10cSrcweir 
234*cdf0e10cSrcweir     @seealso    method DEFINE_INIT_SERVICE()
235*cdf0e10cSrcweir 
236*cdf0e10cSrcweir     @param      "xFactory" is the multi service manager, which create this instance.
237*cdf0e10cSrcweir                 The value must be different from NULL!
238*cdf0e10cSrcweir     @return     -
239*cdf0e10cSrcweir 
240*cdf0e10cSrcweir     @onerror    We throw an ASSERT in debug version or do nothing in relaese version.
241*cdf0e10cSrcweir *//*-*************************************************************************************************************/
242*cdf0e10cSrcweir Desktop::Desktop( const css::uno::Reference< css::lang::XMultiServiceFactory >& xFactory )
243*cdf0e10cSrcweir 		//	Init baseclasses first
244*cdf0e10cSrcweir         //  Attention: Don't change order of initialization!
245*cdf0e10cSrcweir         //      ThreadHelpBase is a struct with a lock as member. We can't use a lock as direct member!
246*cdf0e10cSrcweir         //      We must garant right initialization and a valid value of this to initialize other baseclasses!
247*cdf0e10cSrcweir         :   ThreadHelpBase          ( &Application::GetSolarMutex()                 )
248*cdf0e10cSrcweir         ,   TransactionBase         (                                               )
249*cdf0e10cSrcweir         ,   ::cppu::OBroadcastHelperVar< ::cppu::OMultiTypeInterfaceContainerHelper, ::cppu::OMultiTypeInterfaceContainerHelper::keyType >           ( m_aLock.getShareableOslMutex()         )
250*cdf0e10cSrcweir         ,   ::cppu::OPropertySetHelper  ( *(static_cast< ::cppu::OBroadcastHelper* >(this)) )
251*cdf0e10cSrcweir         ,   ::cppu::OWeakObject     (                                               )
252*cdf0e10cSrcweir 		// Init member
253*cdf0e10cSrcweir 		#ifdef ENABLE_ASSERTIONS
254*cdf0e10cSrcweir         ,   m_bIsTerminated         ( sal_False                                     )   // see dispose() for further informations!
255*cdf0e10cSrcweir 		#endif
256*cdf0e10cSrcweir         ,   m_xFactory              ( xFactory                                      )
257*cdf0e10cSrcweir         ,   m_aChildTaskContainer   (                                               )
258*cdf0e10cSrcweir         ,   m_aListenerContainer    ( m_aLock.getShareableOslMutex()                )
259*cdf0e10cSrcweir         ,   m_xFramesHelper         (                                               )
260*cdf0e10cSrcweir         ,   m_xDispatchHelper       (                                               )
261*cdf0e10cSrcweir         ,   m_eLoadState            ( E_NOTSET                                      )
262*cdf0e10cSrcweir         ,   m_xLastFrame            (                                               )
263*cdf0e10cSrcweir         ,   m_aInteractionRequest   (                                               )
264*cdf0e10cSrcweir         ,   m_bSuspendQuickstartVeto( sal_False										)
265*cdf0e10cSrcweir         ,   m_aCommandOptions       (                                               )
266*cdf0e10cSrcweir         ,   m_sName                 (                                               )
267*cdf0e10cSrcweir         ,   m_sTitle                (                                               )
268*cdf0e10cSrcweir         ,   m_xDispatchRecorderSupplier(                                            )
269*cdf0e10cSrcweir         ,   m_xPipeTerminator       (                                               )
270*cdf0e10cSrcweir         ,   m_xQuickLauncher        (                                               )
271*cdf0e10cSrcweir         ,   m_xSWThreadManager      (                                               )
272*cdf0e10cSrcweir         ,   m_xSfxTerminator        (                                               )
273*cdf0e10cSrcweir         ,   m_xTitleNumberGenerator (                                               )
274*cdf0e10cSrcweir {
275*cdf0e10cSrcweir 	// Safe impossible cases
276*cdf0e10cSrcweir 	// We don't accept all incoming parameter.
277*cdf0e10cSrcweir     LOG_ASSERT2( implcp_ctor( xFactory ), "Desktop::Desktop()", "Invalid parameter detected!")
278*cdf0e10cSrcweir }
279*cdf0e10cSrcweir 
280*cdf0e10cSrcweir /*-************************************************************************************************************//**
281*cdf0e10cSrcweir 	@short		standard destructor
282*cdf0e10cSrcweir 	@descr		This one do NOTHING! Use dispose() instaed of this.
283*cdf0e10cSrcweir 
284*cdf0e10cSrcweir 	@seealso	method dispose()
285*cdf0e10cSrcweir 
286*cdf0e10cSrcweir 	@param		-
287*cdf0e10cSrcweir 	@return		-
288*cdf0e10cSrcweir 
289*cdf0e10cSrcweir 	@onerror	-
290*cdf0e10cSrcweir *//*-*************************************************************************************************************/
291*cdf0e10cSrcweir Desktop::~Desktop()
292*cdf0e10cSrcweir {
293*cdf0e10cSrcweir     LOG_ASSERT2( m_bIsTerminated                       ==sal_False, "Desktop::~Desktop()", "Who forgot to terminate the desktop service?" )
294*cdf0e10cSrcweir     LOG_ASSERT2( m_aTransactionManager.getWorkingMode()!=E_CLOSE  , "Desktop::~Desktop()", "Who forgot to dispose this service?"          )
295*cdf0e10cSrcweir }
296*cdf0e10cSrcweir 
297*cdf0e10cSrcweir //=============================================================================
298*cdf0e10cSrcweir sal_Bool SAL_CALL Desktop::terminate()
299*cdf0e10cSrcweir     throw( css::uno::RuntimeException )
300*cdf0e10cSrcweir {
301*cdf0e10cSrcweir     TransactionGuard aTransaction( m_aTransactionManager, E_HARDEXCEPTIONS );
302*cdf0e10cSrcweir 
303*cdf0e10cSrcweir     SYNCHRONIZED_START
304*cdf0e10cSrcweir         ReadGuard aReadLock( m_aLock );
305*cdf0e10cSrcweir 
306*cdf0e10cSrcweir         css::uno::Reference< css::frame::XTerminateListener > xPipeTerminator    = m_xPipeTerminator;
307*cdf0e10cSrcweir         css::uno::Reference< css::frame::XTerminateListener > xQuickLauncher     = m_xQuickLauncher;
308*cdf0e10cSrcweir         css::uno::Reference< css::frame::XTerminateListener > xSWThreadManager   = m_xSWThreadManager;
309*cdf0e10cSrcweir         css::uno::Reference< css::frame::XTerminateListener > xSfxTerminator     = m_xSfxTerminator;
310*cdf0e10cSrcweir 
311*cdf0e10cSrcweir         css::lang::EventObject                                aEvent             ( static_cast< ::cppu::OWeakObject* >(this) );
312*cdf0e10cSrcweir         ::sal_Bool											  bAskQuickStart     = !m_bSuspendQuickstartVeto                  ;
313*cdf0e10cSrcweir 
314*cdf0e10cSrcweir         aReadLock.unlock();
315*cdf0e10cSrcweir     SYNCHRONIZED_END
316*cdf0e10cSrcweir 
317*cdf0e10cSrcweir     //-------------------------------------------------------------------------------------------------------------
318*cdf0e10cSrcweir     // Ask normal terminate listener. They could stop terminate without closing any open document.
319*cdf0e10cSrcweir     Desktop::TTerminateListenerList lCalledTerminationListener;
320*cdf0e10cSrcweir     ::sal_Bool                      bVeto = sal_False;
321*cdf0e10cSrcweir     impl_sendQueryTerminationEvent(lCalledTerminationListener, bVeto);
322*cdf0e10cSrcweir     if ( bVeto )
323*cdf0e10cSrcweir     {
324*cdf0e10cSrcweir         impl_sendCancelTerminationEvent(lCalledTerminationListener);
325*cdf0e10cSrcweir         return sal_False;
326*cdf0e10cSrcweir     }
327*cdf0e10cSrcweir 
328*cdf0e10cSrcweir     //-------------------------------------------------------------------------------------------------------------
329*cdf0e10cSrcweir     // try to close all open frames.
330*cdf0e10cSrcweir     // Allow using of any UI ... because Desktop.terminate() was designed as UI functionality in the past.
331*cdf0e10cSrcweir     ::sal_Bool bAllowUI      = sal_True;
332*cdf0e10cSrcweir     ::sal_Bool bFramesClosed = impl_closeFrames(bAllowUI);
333*cdf0e10cSrcweir     if ( ! bFramesClosed )
334*cdf0e10cSrcweir     {
335*cdf0e10cSrcweir         impl_sendCancelTerminationEvent(lCalledTerminationListener);
336*cdf0e10cSrcweir         return sal_False;
337*cdf0e10cSrcweir     }
338*cdf0e10cSrcweir 
339*cdf0e10cSrcweir     //-------------------------------------------------------------------------------------------------------------
340*cdf0e10cSrcweir     // Normal listener had no problem ...
341*cdf0e10cSrcweir     // all frames was closed ...
342*cdf0e10cSrcweir     // now it's time to ask our specialized listener.
343*cdf0e10cSrcweir     // They are handled these way because they wish to hinder the office on termination
344*cdf0e10cSrcweir     // but they wish also closing of all frames.
345*cdf0e10cSrcweir 
346*cdf0e10cSrcweir 	// Note further:
347*cdf0e10cSrcweir     //    We shouldn't ask quicklauncher in case it was allowed from outside only.
348*cdf0e10cSrcweir     //    This is special trick to "ignore existing quick starter" for debug purposes.
349*cdf0e10cSrcweir 
350*cdf0e10cSrcweir     // Attention:
351*cdf0e10cSrcweir     // Order of alled listener is important !
352*cdf0e10cSrcweir     // some of them are harmless .-)
353*cdf0e10cSrcweir     // But some of them can be dangerous. E.g. it would be dangerous if we close our pipe
354*cdf0e10cSrcweir     // and dont terminate in real because another listener throws a veto exception .-)
355*cdf0e10cSrcweir 
356*cdf0e10cSrcweir     ::sal_Bool bTerminate = sal_False;
357*cdf0e10cSrcweir     try
358*cdf0e10cSrcweir     {
359*cdf0e10cSrcweir         if(
360*cdf0e10cSrcweir             ( bAskQuickStart      ) &&
361*cdf0e10cSrcweir             ( xQuickLauncher.is() )
362*cdf0e10cSrcweir           )
363*cdf0e10cSrcweir         {
364*cdf0e10cSrcweir             xQuickLauncher->queryTermination( aEvent );
365*cdf0e10cSrcweir             lCalledTerminationListener.push_back( xQuickLauncher );
366*cdf0e10cSrcweir         }
367*cdf0e10cSrcweir 
368*cdf0e10cSrcweir         if ( xSWThreadManager.is() )
369*cdf0e10cSrcweir         {
370*cdf0e10cSrcweir             xSWThreadManager->queryTermination( aEvent );
371*cdf0e10cSrcweir             lCalledTerminationListener.push_back( xSWThreadManager );
372*cdf0e10cSrcweir         }
373*cdf0e10cSrcweir 
374*cdf0e10cSrcweir         if ( xPipeTerminator.is() )
375*cdf0e10cSrcweir         {
376*cdf0e10cSrcweir             xPipeTerminator->queryTermination( aEvent );
377*cdf0e10cSrcweir             lCalledTerminationListener.push_back( xPipeTerminator );
378*cdf0e10cSrcweir         }
379*cdf0e10cSrcweir 
380*cdf0e10cSrcweir         if ( xSfxTerminator.is() )
381*cdf0e10cSrcweir         {
382*cdf0e10cSrcweir             xSfxTerminator->queryTermination( aEvent );
383*cdf0e10cSrcweir             lCalledTerminationListener.push_back( xSfxTerminator );
384*cdf0e10cSrcweir         }
385*cdf0e10cSrcweir 
386*cdf0e10cSrcweir         bTerminate = sal_True;
387*cdf0e10cSrcweir     }
388*cdf0e10cSrcweir     catch(const css::frame::TerminationVetoException&)
389*cdf0e10cSrcweir     {
390*cdf0e10cSrcweir         bTerminate = sal_False;
391*cdf0e10cSrcweir     }
392*cdf0e10cSrcweir 
393*cdf0e10cSrcweir     if ( ! bTerminate )
394*cdf0e10cSrcweir         impl_sendCancelTerminationEvent(lCalledTerminationListener);
395*cdf0e10cSrcweir     else
396*cdf0e10cSrcweir     {
397*cdf0e10cSrcweir         #ifdef ENABLE_ASSERTIONS
398*cdf0e10cSrcweir             // "Protect" us against dispose before terminate calls!
399*cdf0e10cSrcweir             // see dispose() for further informations.
400*cdf0e10cSrcweir             /* SAFE AREA --------------------------------------------------------------------------------------- */
401*cdf0e10cSrcweir             WriteGuard aWriteLock( m_aLock );
402*cdf0e10cSrcweir             m_bIsTerminated = sal_True;
403*cdf0e10cSrcweir             aWriteLock.unlock();
404*cdf0e10cSrcweir             /* UNSAFE AREA ------------------------------------------------------------------------------------- */
405*cdf0e10cSrcweir         #endif
406*cdf0e10cSrcweir 
407*cdf0e10cSrcweir         impl_sendNotifyTerminationEvent();
408*cdf0e10cSrcweir 
409*cdf0e10cSrcweir         if(
410*cdf0e10cSrcweir             ( bAskQuickStart      ) &&
411*cdf0e10cSrcweir             ( xQuickLauncher.is() )
412*cdf0e10cSrcweir           )
413*cdf0e10cSrcweir         {
414*cdf0e10cSrcweir             xQuickLauncher->notifyTermination( aEvent );
415*cdf0e10cSrcweir         }
416*cdf0e10cSrcweir 
417*cdf0e10cSrcweir         if ( xSWThreadManager.is() )
418*cdf0e10cSrcweir             xSWThreadManager->notifyTermination( aEvent );
419*cdf0e10cSrcweir 
420*cdf0e10cSrcweir         if ( xPipeTerminator.is() )
421*cdf0e10cSrcweir             xPipeTerminator->notifyTermination( aEvent );
422*cdf0e10cSrcweir 
423*cdf0e10cSrcweir         // Must be realy the last listener to be called.
424*cdf0e10cSrcweir         // Because it shutdown the whole process asynchronous !
425*cdf0e10cSrcweir         if ( xSfxTerminator.is() )
426*cdf0e10cSrcweir             xSfxTerminator->notifyTermination( aEvent );
427*cdf0e10cSrcweir     }
428*cdf0e10cSrcweir 
429*cdf0e10cSrcweir     return bTerminate;
430*cdf0e10cSrcweir }
431*cdf0e10cSrcweir 
432*cdf0e10cSrcweir 
433*cdf0e10cSrcweir //=============================================================================
434*cdf0e10cSrcweir void SAL_CALL Desktop::addTerminateListener( const css::uno::Reference< css::frame::XTerminateListener >& xListener )
435*cdf0e10cSrcweir     throw( css::uno::RuntimeException )
436*cdf0e10cSrcweir {
437*cdf0e10cSrcweir     TransactionGuard aTransaction( m_aTransactionManager, E_HARDEXCEPTIONS );
438*cdf0e10cSrcweir 
439*cdf0e10cSrcweir     css::uno::Reference< css::lang::XServiceInfo > xInfo( xListener, css::uno::UNO_QUERY );
440*cdf0e10cSrcweir     if ( xInfo.is() )
441*cdf0e10cSrcweir     {
442*cdf0e10cSrcweir         ::rtl::OUString sImplementationName = xInfo->getImplementationName();
443*cdf0e10cSrcweir 
444*cdf0e10cSrcweir         // SYCNHRONIZED ->
445*cdf0e10cSrcweir         WriteGuard aWriteLock( m_aLock );
446*cdf0e10cSrcweir 
447*cdf0e10cSrcweir         if( sImplementationName.equals(IMPLEMENTATIONNAME_SFXTERMINATOR) )
448*cdf0e10cSrcweir         {
449*cdf0e10cSrcweir             m_xSfxTerminator = xListener;
450*cdf0e10cSrcweir             return;
451*cdf0e10cSrcweir         }
452*cdf0e10cSrcweir         if( sImplementationName.equals(IMPLEMENTATIONNAME_PIPETERMINATOR) )
453*cdf0e10cSrcweir         {
454*cdf0e10cSrcweir             m_xPipeTerminator = xListener;
455*cdf0e10cSrcweir             return;
456*cdf0e10cSrcweir         }
457*cdf0e10cSrcweir         if( sImplementationName.equals(IMPLEMENTATIONNAME_QUICKLAUNCHER) )
458*cdf0e10cSrcweir         {
459*cdf0e10cSrcweir             m_xQuickLauncher = xListener;
460*cdf0e10cSrcweir             return;
461*cdf0e10cSrcweir         }
462*cdf0e10cSrcweir         if( sImplementationName.equals(IMPLEMENTATIONNAME_SWTHREADMANAGER) )
463*cdf0e10cSrcweir         {
464*cdf0e10cSrcweir             m_xSWThreadManager = xListener;
465*cdf0e10cSrcweir             return;
466*cdf0e10cSrcweir         }
467*cdf0e10cSrcweir 
468*cdf0e10cSrcweir         aWriteLock.unlock();
469*cdf0e10cSrcweir         // <- SYCNHRONIZED
470*cdf0e10cSrcweir     }
471*cdf0e10cSrcweir 
472*cdf0e10cSrcweir     // No lock required ... container is threadsafe by itself.
473*cdf0e10cSrcweir     m_aListenerContainer.addInterface( ::getCppuType( ( const css::uno::Reference< css::frame::XTerminateListener >*) NULL ), xListener );
474*cdf0e10cSrcweir }
475*cdf0e10cSrcweir 
476*cdf0e10cSrcweir //=============================================================================
477*cdf0e10cSrcweir void SAL_CALL Desktop::removeTerminateListener( const css::uno::Reference< css::frame::XTerminateListener >& xListener )
478*cdf0e10cSrcweir     throw( css::uno::RuntimeException )
479*cdf0e10cSrcweir {
480*cdf0e10cSrcweir     TransactionGuard aTransaction( m_aTransactionManager, E_SOFTEXCEPTIONS );
481*cdf0e10cSrcweir 
482*cdf0e10cSrcweir     css::uno::Reference< css::lang::XServiceInfo > xInfo( xListener, css::uno::UNO_QUERY );
483*cdf0e10cSrcweir     if ( xInfo.is() )
484*cdf0e10cSrcweir     {
485*cdf0e10cSrcweir         ::rtl::OUString sImplementationName = xInfo->getImplementationName();
486*cdf0e10cSrcweir 
487*cdf0e10cSrcweir         // SYCNHRONIZED ->
488*cdf0e10cSrcweir         WriteGuard aWriteLock( m_aLock );
489*cdf0e10cSrcweir 
490*cdf0e10cSrcweir         if( sImplementationName.equals(IMPLEMENTATIONNAME_SFXTERMINATOR) )
491*cdf0e10cSrcweir         {
492*cdf0e10cSrcweir             m_xSfxTerminator.clear();
493*cdf0e10cSrcweir             return;
494*cdf0e10cSrcweir         }
495*cdf0e10cSrcweir 
496*cdf0e10cSrcweir         if( sImplementationName.equals(IMPLEMENTATIONNAME_PIPETERMINATOR) )
497*cdf0e10cSrcweir         {
498*cdf0e10cSrcweir             m_xPipeTerminator.clear();
499*cdf0e10cSrcweir             return;
500*cdf0e10cSrcweir         }
501*cdf0e10cSrcweir 
502*cdf0e10cSrcweir         if( sImplementationName.equals(IMPLEMENTATIONNAME_QUICKLAUNCHER) )
503*cdf0e10cSrcweir         {
504*cdf0e10cSrcweir             m_xQuickLauncher.clear();
505*cdf0e10cSrcweir             return;
506*cdf0e10cSrcweir         }
507*cdf0e10cSrcweir 
508*cdf0e10cSrcweir         if( sImplementationName.equals(IMPLEMENTATIONNAME_SWTHREADMANAGER) )
509*cdf0e10cSrcweir         {
510*cdf0e10cSrcweir             m_xSWThreadManager.clear();
511*cdf0e10cSrcweir             return;
512*cdf0e10cSrcweir         }
513*cdf0e10cSrcweir 
514*cdf0e10cSrcweir         aWriteLock.unlock();
515*cdf0e10cSrcweir         // <- SYCNHRONIZED
516*cdf0e10cSrcweir     }
517*cdf0e10cSrcweir 
518*cdf0e10cSrcweir     // No lock required ... container is threadsafe by itself.
519*cdf0e10cSrcweir     m_aListenerContainer.removeInterface( ::getCppuType( ( const css::uno::Reference< css::frame::XTerminateListener >*) NULL ), xListener );
520*cdf0e10cSrcweir }
521*cdf0e10cSrcweir 
522*cdf0e10cSrcweir /*-************************************************************************************************************//**
523*cdf0e10cSrcweir     @interface  XDesktop
524*cdf0e10cSrcweir     @short      get access to create enumerations of all current components
525*cdf0e10cSrcweir     @descr      You will be the owner of the returned object and must delete it if you don't use it again.
526*cdf0e10cSrcweir 
527*cdf0e10cSrcweir     @seealso    class TasksAccess
528*cdf0e10cSrcweir     @seealso    class TasksEnumeration
529*cdf0e10cSrcweir 
530*cdf0e10cSrcweir     @param      -
531*cdf0e10cSrcweir     @return     A reference to an XEnumerationAccess-object.
532*cdf0e10cSrcweir 
533*cdf0e10cSrcweir     @onerror    We return a null-reference.
534*cdf0e10cSrcweir     @threadsafe yes
535*cdf0e10cSrcweir *//*-*************************************************************************************************************/
536*cdf0e10cSrcweir css::uno::Reference< css::container::XEnumerationAccess > SAL_CALL Desktop::getComponents() throw( css::uno::RuntimeException )
537*cdf0e10cSrcweir {
538*cdf0e10cSrcweir 	/* UNSAFE AREA --------------------------------------------------------------------------------------------- */
539*cdf0e10cSrcweir     // Register transaction and reject wrong calls.
540*cdf0e10cSrcweir     TransactionGuard aTransaction( m_aTransactionManager, E_HARDEXCEPTIONS );
541*cdf0e10cSrcweir 
542*cdf0e10cSrcweir 	// We use a helper class OComponentAccess to have access on all child components.
543*cdf0e10cSrcweir     // Create it on demand and return it as a reference.
544*cdf0e10cSrcweir     OComponentAccess* pAccess = new OComponentAccess( this );
545*cdf0e10cSrcweir     css::uno::Reference< css::container::XEnumerationAccess > xAccess( static_cast< ::cppu::OWeakObject* >(pAccess), css::uno::UNO_QUERY );
546*cdf0e10cSrcweir     return xAccess;
547*cdf0e10cSrcweir }
548*cdf0e10cSrcweir 
549*cdf0e10cSrcweir /*-************************************************************************************************************//**
550*cdf0e10cSrcweir     @interface  XDesktop
551*cdf0e10cSrcweir     @short      return the current active component
552*cdf0e10cSrcweir     @descr      The most current component is the window, model or the controller of the current active frame.
553*cdf0e10cSrcweir 
554*cdf0e10cSrcweir     @seealso    method getCurrentFrame()
555*cdf0e10cSrcweir     @seealso    method impl_getFrameComponent()
556*cdf0e10cSrcweir 
557*cdf0e10cSrcweir     @param      -
558*cdf0e10cSrcweir     @return     A reference to the component.
559*cdf0e10cSrcweir 
560*cdf0e10cSrcweir     @onerror    We return a null-reference.
561*cdf0e10cSrcweir     @threadsafe yes
562*cdf0e10cSrcweir *//*-*************************************************************************************************************/
563*cdf0e10cSrcweir css::uno::Reference< css::lang::XComponent > SAL_CALL Desktop::getCurrentComponent() throw( css::uno::RuntimeException )
564*cdf0e10cSrcweir {
565*cdf0e10cSrcweir 	/* UNSAFE AREA --------------------------------------------------------------------------------------------- */
566*cdf0e10cSrcweir     // Register transaction and reject wrong calls.
567*cdf0e10cSrcweir     TransactionGuard aTransaction( m_aTransactionManager, E_HARDEXCEPTIONS );
568*cdf0e10cSrcweir 
569*cdf0e10cSrcweir 	// Set return value if method failed.
570*cdf0e10cSrcweir     css::uno::Reference< css::lang::XComponent > xComponent;
571*cdf0e10cSrcweir 
572*cdf0e10cSrcweir 	// Get reference to current frame ...
573*cdf0e10cSrcweir 	// ... get component of this frame ... (It can be the window, the model or the controller.)
574*cdf0e10cSrcweir     // ... and return the result.
575*cdf0e10cSrcweir     css::uno::Reference< css::frame::XFrame > xCurrentFrame = getCurrentFrame();
576*cdf0e10cSrcweir 	if( xCurrentFrame.is() == sal_True )
577*cdf0e10cSrcweir 	{
578*cdf0e10cSrcweir 		xComponent = impl_getFrameComponent( xCurrentFrame );
579*cdf0e10cSrcweir 	}
580*cdf0e10cSrcweir 	return xComponent;
581*cdf0e10cSrcweir }
582*cdf0e10cSrcweir 
583*cdf0e10cSrcweir /*-************************************************************************************************************//**
584*cdf0e10cSrcweir     @interface  XDesktop
585*cdf0e10cSrcweir     @short      return the current active frame in hierarchy
586*cdf0e10cSrcweir     @descr      There can be more then one different active pathes in our frame hierarchy. But only one of them
587*cdf0e10cSrcweir                 could be the most active frame (normal he has the focus).
588*cdf0e10cSrcweir                 Don't mix it with getActiveFrame()! That will return our current active frame, which must be
589*cdf0e10cSrcweir                 a direct child of us and should be a part(!) of an active path.
590*cdf0e10cSrcweir 
591*cdf0e10cSrcweir     @seealso    method getActiveFrame()
592*cdf0e10cSrcweir 
593*cdf0e10cSrcweir     @param      -
594*cdf0e10cSrcweir     @return     A valid reference, if there is an active frame.
595*cdf0e10cSrcweir                 A null reference , otherwise.
596*cdf0e10cSrcweir 
597*cdf0e10cSrcweir     @onerror    We return a null reference.
598*cdf0e10cSrcweir     @threadsafe yes
599*cdf0e10cSrcweir *//*-*************************************************************************************************************/
600*cdf0e10cSrcweir css::uno::Reference< css::frame::XFrame > SAL_CALL Desktop::getCurrentFrame() throw( css::uno::RuntimeException )
601*cdf0e10cSrcweir {
602*cdf0e10cSrcweir 	/* UNSAFE AREA --------------------------------------------------------------------------------------------- */
603*cdf0e10cSrcweir     // Register transaction and reject wrong calls.
604*cdf0e10cSrcweir     TransactionGuard aTransaction( m_aTransactionManager, E_HARDEXCEPTIONS );
605*cdf0e10cSrcweir 
606*cdf0e10cSrcweir 	// Start search with ouer direct active frame (if it exist!).
607*cdf0e10cSrcweir     // Search on his children for other active frames too.
608*cdf0e10cSrcweir     // Stop if no one could be found and return last of found ones.
609*cdf0e10cSrcweir     css::uno::Reference< css::frame::XFramesSupplier > xLast = css::uno::Reference< css::frame::XFramesSupplier >( getActiveFrame(), css::uno::UNO_QUERY );
610*cdf0e10cSrcweir     if( xLast.is() == sal_True )
611*cdf0e10cSrcweir 	{
612*cdf0e10cSrcweir         css::uno::Reference< css::frame::XFramesSupplier > xNext = css::uno::Reference< css::frame::XFramesSupplier >( xLast->getActiveFrame(), css::uno::UNO_QUERY );
613*cdf0e10cSrcweir         while( xNext.is() == sal_True )
614*cdf0e10cSrcweir 		{
615*cdf0e10cSrcweir             xLast = xNext;
616*cdf0e10cSrcweir             xNext = css::uno::Reference< css::frame::XFramesSupplier >( xNext->getActiveFrame(), css::uno::UNO_QUERY );
617*cdf0e10cSrcweir 		}
618*cdf0e10cSrcweir 	}
619*cdf0e10cSrcweir     return css::uno::Reference< css::frame::XFrame >( xLast, css::uno::UNO_QUERY );
620*cdf0e10cSrcweir }
621*cdf0e10cSrcweir 
622*cdf0e10cSrcweir /*-************************************************************************************************************//**
623*cdf0e10cSrcweir     @interface  XComponentLoader
624*cdf0e10cSrcweir     @short      try to load given URL into a task
625*cdf0e10cSrcweir     @descr      You can give us some informations about the content, which you will load into a frame.
626*cdf0e10cSrcweir                 We search or create this target for you, make a type detection of given URL and try to load it.
627*cdf0e10cSrcweir                 As result of this operation we return the new created component or nothing, if loading failed.
628*cdf0e10cSrcweir 
629*cdf0e10cSrcweir     @seealso    -
630*cdf0e10cSrcweir 
631*cdf0e10cSrcweir     @param      "sURL"              , URL, which represant the content
632*cdf0e10cSrcweir     @param      "sTargetFrameName"  , name of target frame or special value like "_self", "_blank" ...
633*cdf0e10cSrcweir     @param      "nSearchFlags"      , optional arguments for frame search, if target isn't a special one
634*cdf0e10cSrcweir     @param      "lArguments"        , optional arguments for loading
635*cdf0e10cSrcweir     @return     A valid component reference, if loading was successfully.
636*cdf0e10cSrcweir                 A null reference otherwise.
637*cdf0e10cSrcweir 
638*cdf0e10cSrcweir     @onerror    We return a null reference.
639*cdf0e10cSrcweir     @threadsafe yes
640*cdf0e10cSrcweir *//*-*************************************************************************************************************/
641*cdf0e10cSrcweir css::uno::Reference< css::lang::XComponent > SAL_CALL Desktop::loadComponentFromURL( const ::rtl::OUString&                                 sURL            ,
642*cdf0e10cSrcweir                                                                                      const ::rtl::OUString&                                 sTargetFrameName,
643*cdf0e10cSrcweir                                                                                            sal_Int32                                        nSearchFlags    ,
644*cdf0e10cSrcweir                                                                                      const css::uno::Sequence< css::beans::PropertyValue >& lArguments      ) throw(    css::io::IOException                ,
645*cdf0e10cSrcweir                                                                                                                                                                         css::lang::IllegalArgumentException ,
646*cdf0e10cSrcweir                                                                                                                                                                         css::uno::RuntimeException          )
647*cdf0e10cSrcweir {
648*cdf0e10cSrcweir     /* UNSAFE AREA --------------------------------------------------------------------------------------------- */
649*cdf0e10cSrcweir     // Register transaction and reject wrong calls.
650*cdf0e10cSrcweir     TransactionGuard aTransaction( m_aTransactionManager, E_HARDEXCEPTIONS );
651*cdf0e10cSrcweir     RTL_LOGFILE_CONTEXT( aLog, "framework (as96863) ::Desktop::loadComponentFromURL" );
652*cdf0e10cSrcweir 
653*cdf0e10cSrcweir     ReadGuard aReadLock(m_aLock);
654*cdf0e10cSrcweir     css::uno::Reference< css::frame::XComponentLoader > xThis(static_cast< css::frame::XComponentLoader* >(this), css::uno::UNO_QUERY);
655*cdf0e10cSrcweir     css::uno::Reference< css::lang::XMultiServiceFactory > xSMGR = m_xFactory;
656*cdf0e10cSrcweir     aReadLock.unlock();
657*cdf0e10cSrcweir 
658*cdf0e10cSrcweir     RTL_LOGFILE_PRODUCT_CONTEXT( aLog2, "PERFORMANCE - Desktop::loadComponentFromURL()" );
659*cdf0e10cSrcweir     return LoadEnv::loadComponentFromURL(xThis, xSMGR, sURL, sTargetFrameName, nSearchFlags, lArguments);
660*cdf0e10cSrcweir }
661*cdf0e10cSrcweir 
662*cdf0e10cSrcweir /*-************************************************************************************************************//**
663*cdf0e10cSrcweir     @interface  XTasksSupplier
664*cdf0e10cSrcweir     @short      get access to create enumerations of ouer taskchilds
665*cdf0e10cSrcweir     @descr      Direct childs of desktop are tasks everytime.
666*cdf0e10cSrcweir                 Call these method to could create enumerations of it.
667*cdf0e10cSrcweir 
668*cdf0e10cSrcweir But; Don't forget - you will be the owner of returned object and must release it!
669*cdf0e10cSrcweir                 We use a helper class to implement the access interface. They hold a weakreference to us.
670*cdf0e10cSrcweir                 It can be, that the desktop is dead - but not your tasksaccess-object! Then they will do nothing!
671*cdf0e10cSrcweir                 You can't create enumerations then.
672*cdf0e10cSrcweir 
673*cdf0e10cSrcweir     @attention  Normaly we don't need any lock here. We don't work on internal member!
674*cdf0e10cSrcweir 
675*cdf0e10cSrcweir     @seealso    class TasksAccess
676*cdf0e10cSrcweir 
677*cdf0e10cSrcweir     @param      -
678*cdf0e10cSrcweir     @return     A reference to an accessobject, which can create enumerations of ouer childtasks.
679*cdf0e10cSrcweir 
680*cdf0e10cSrcweir     @onerror    A null reference is returned.
681*cdf0e10cSrcweir     @threadsafe yes
682*cdf0e10cSrcweir *//*-*************************************************************************************************************/
683*cdf0e10cSrcweir css::uno::Reference< css::container::XEnumerationAccess > SAL_CALL Desktop::getTasks() throw( css::uno::RuntimeException )
684*cdf0e10cSrcweir {
685*cdf0e10cSrcweir     LOG_WARNING("Desktop::getTasks()", "Use of obsolete interface XTaskSupplier")
686*cdf0e10cSrcweir     return NULL;
687*cdf0e10cSrcweir     /*
688*cdf0e10cSrcweir     TransactionGuard aTransaction( m_aTransactionManager, E_HARDEXCEPTIONS );
689*cdf0e10cSrcweir 
690*cdf0e10cSrcweir     OTasksAccess* pTasksAccess = new OTasksAccess( this, &m_aChildTaskContainer );
691*cdf0e10cSrcweir     css::uno::Reference< css::container::XEnumerationAccess > xAccess( static_cast< ::cppu::OWeakObject* >(pTasksAccess), css::uno::UNO_QUERY );
692*cdf0e10cSrcweir 	return xAccess;
693*cdf0e10cSrcweir     */
694*cdf0e10cSrcweir }
695*cdf0e10cSrcweir 
696*cdf0e10cSrcweir /*-************************************************************************************************************//**
697*cdf0e10cSrcweir     @interface  XTasksSupplier
698*cdf0e10cSrcweir     @short      return current active task of ouer direct childs
699*cdf0e10cSrcweir     @descr      Desktop childs are tasks only ! If we have an active path from desktop
700*cdf0e10cSrcweir                 as top to any frame on bottom, we must have an active direct child. His reference is returned here.
701*cdf0e10cSrcweir 
702*cdf0e10cSrcweir     @attention  a)  Do not confuse it with getCurrentFrame()! The current frame don't must one of ouer direct childs.
703*cdf0e10cSrcweir                     It can be every frame in subtree and must have the focus (Is the last one of an active path!).
704*cdf0e10cSrcweir                 b)  We don't need any lock here. Our container is threadsafe himself and live, if we live!
705*cdf0e10cSrcweir 
706*cdf0e10cSrcweir     @seealso    method getCurrentFrame()
707*cdf0e10cSrcweir 
708*cdf0e10cSrcweir     @param      -
709*cdf0e10cSrcweir     @return     A reference to ouer current active taskchild.
710*cdf0e10cSrcweir 
711*cdf0e10cSrcweir     @onerror    A null reference is returned.
712*cdf0e10cSrcweir     @threadsafe yes
713*cdf0e10cSrcweir *//*-*************************************************************************************************************/
714*cdf0e10cSrcweir css::uno::Reference< css::frame::XTask > SAL_CALL Desktop::getActiveTask() throw( css::uno::RuntimeException )
715*cdf0e10cSrcweir {
716*cdf0e10cSrcweir     /*
717*cdf0e10cSrcweir     TransactionGuard aTransaction( m_aTransactionManager, E_HARDEXCEPTIONS );
718*cdf0e10cSrcweir 
719*cdf0e10cSrcweir     return css::uno::Reference< css::frame::XTask >( m_aChildTaskContainer.getActive(), css::uno::UNO_QUERY );
720*cdf0e10cSrcweir     */
721*cdf0e10cSrcweir     LOG_WARNING("Desktop::getActiveTask()", "Use of obsolete interface XTaskSupplier")
722*cdf0e10cSrcweir     return NULL;
723*cdf0e10cSrcweir }
724*cdf0e10cSrcweir 
725*cdf0e10cSrcweir /*-************************************************************************************************************//**
726*cdf0e10cSrcweir     @interface  XDispatchProvider
727*cdf0e10cSrcweir     @short      search a dispatcher for given URL
728*cdf0e10cSrcweir     @descr      We use a helper implementation (class DispatchProvider) to do so.
729*cdf0e10cSrcweir                 So we don't must implement this algorithm twice!
730*cdf0e10cSrcweir 
731*cdf0e10cSrcweir     @attention  We don't need any lock here. Our helper is threadsafe himself and live, if we live!
732*cdf0e10cSrcweir 
733*cdf0e10cSrcweir     @seealso    class DispatchProvider
734*cdf0e10cSrcweir 
735*cdf0e10cSrcweir     @param      "aURL"              , URL to dispatch
736*cdf0e10cSrcweir     @param      "sTargetFrameName"  , name of target frame, who should dispatch these URL
737*cdf0e10cSrcweir     @param      "nSearchFlags"      , flags to regulate the search
738*cdf0e10cSrcweir     @param      "lQueries"          , list of queryDispatch() calls!
739*cdf0e10cSrcweir     @return     A reference or list of founded dispatch objects for these URL.
740*cdf0e10cSrcweir 
741*cdf0e10cSrcweir     @onerror    A null reference is returned.
742*cdf0e10cSrcweir     @threadsafe yes
743*cdf0e10cSrcweir *//*-*************************************************************************************************************/
744*cdf0e10cSrcweir css::uno::Reference< css::frame::XDispatch > SAL_CALL Desktop::queryDispatch( const css::util::URL&  aURL             ,
745*cdf0e10cSrcweir                                                                               const ::rtl::OUString& sTargetFrameName ,
746*cdf0e10cSrcweir                                                                                     sal_Int32        nSearchFlags     ) throw( css::uno::RuntimeException )
747*cdf0e10cSrcweir {
748*cdf0e10cSrcweir 	const char UNO_PROTOCOL[] = ".uno:";
749*cdf0e10cSrcweir 
750*cdf0e10cSrcweir 	/* UNSAFE AREA --------------------------------------------------------------------------------------------- */
751*cdf0e10cSrcweir     // Register transaction and reject wrong calls.
752*cdf0e10cSrcweir     TransactionGuard aTransaction( m_aTransactionManager, E_HARDEXCEPTIONS );
753*cdf0e10cSrcweir 
754*cdf0e10cSrcweir 	// Remove uno and cmd protocol part as we want to support both of them. We store only the command part
755*cdf0e10cSrcweir 	// in our hash map. All other protocols are stored with the protocol part.
756*cdf0e10cSrcweir 	String aCommand( aURL.Main );
757*cdf0e10cSrcweir 	if ( aURL.Protocol.equalsIgnoreAsciiCaseAsciiL( UNO_PROTOCOL, sizeof( UNO_PROTOCOL )-1 ))
758*cdf0e10cSrcweir 		aCommand = aURL.Path;
759*cdf0e10cSrcweir 
760*cdf0e10cSrcweir 	// Make hash_map lookup if the current URL is in the disabled list
761*cdf0e10cSrcweir 	if ( m_aCommandOptions.Lookup( SvtCommandOptions::CMDOPTION_DISABLED, aCommand ) )
762*cdf0e10cSrcweir 		return css::uno::Reference< css::frame::XDispatch >();
763*cdf0e10cSrcweir 	else
764*cdf0e10cSrcweir 	{
765*cdf0e10cSrcweir 		// We use a helper to support these interface and an interceptor mechanism.
766*cdf0e10cSrcweir 		// Our helper is threadsafe by himself!
767*cdf0e10cSrcweir 		return m_xDispatchHelper->queryDispatch( aURL, sTargetFrameName, nSearchFlags );
768*cdf0e10cSrcweir 	}
769*cdf0e10cSrcweir }
770*cdf0e10cSrcweir 
771*cdf0e10cSrcweir //*****************************************************************************************************************
772*cdf0e10cSrcweir css::uno::Sequence< css::uno::Reference< css::frame::XDispatch > > SAL_CALL Desktop::queryDispatches( const css::uno::Sequence< css::frame::DispatchDescriptor >& lQueries ) throw( css::uno::RuntimeException )
773*cdf0e10cSrcweir {
774*cdf0e10cSrcweir 	/* UNSAFE AREA --------------------------------------------------------------------------------------------- */
775*cdf0e10cSrcweir     // Register transaction and reject wrong calls.
776*cdf0e10cSrcweir     TransactionGuard aTransaction( m_aTransactionManager, E_HARDEXCEPTIONS );
777*cdf0e10cSrcweir 
778*cdf0e10cSrcweir     return m_xDispatchHelper->queryDispatches( lQueries );
779*cdf0e10cSrcweir }
780*cdf0e10cSrcweir 
781*cdf0e10cSrcweir /*-************************************************************************************************************//**
782*cdf0e10cSrcweir     @interface  XDipsatchProviderInterception
783*cdf0e10cSrcweir     @short      supports registration/deregistration of interception objects, which
784*cdf0e10cSrcweir                 are interested on special dispatches.
785*cdf0e10cSrcweir 
786*cdf0e10cSrcweir     @descr      Its realy provided by an internal helper, which is used inside the dispatch api too.
787*cdf0e10cSrcweir     @param      xInterceptor
788*cdf0e10cSrcweir                 the interceptor object, which wish to be (de)registered.
789*cdf0e10cSrcweir 
790*cdf0e10cSrcweir     @threadsafe yes
791*cdf0e10cSrcweir *//*-*************************************************************************************************************/
792*cdf0e10cSrcweir void SAL_CALL Desktop::registerDispatchProviderInterceptor( const css::uno::Reference< css::frame::XDispatchProviderInterceptor >& xInterceptor)
793*cdf0e10cSrcweir     throw( css::uno::RuntimeException)
794*cdf0e10cSrcweir {
795*cdf0e10cSrcweir     TransactionGuard aTransaction( m_aTransactionManager, E_HARDEXCEPTIONS );
796*cdf0e10cSrcweir 
797*cdf0e10cSrcweir     css::uno::Reference< css::frame::XDispatchProviderInterception > xInterceptionHelper( m_xDispatchHelper, css::uno::UNO_QUERY );
798*cdf0e10cSrcweir     xInterceptionHelper->registerDispatchProviderInterceptor( xInterceptor );
799*cdf0e10cSrcweir }
800*cdf0e10cSrcweir 
801*cdf0e10cSrcweir //*****************************************************************************************************************
802*cdf0e10cSrcweir void SAL_CALL Desktop::releaseDispatchProviderInterceptor ( const css::uno::Reference< css::frame::XDispatchProviderInterceptor >& xInterceptor)
803*cdf0e10cSrcweir     throw( css::uno::RuntimeException)
804*cdf0e10cSrcweir {
805*cdf0e10cSrcweir     TransactionGuard aTransaction( m_aTransactionManager, E_SOFTEXCEPTIONS );
806*cdf0e10cSrcweir 
807*cdf0e10cSrcweir     css::uno::Reference< css::frame::XDispatchProviderInterception > xInterceptionHelper( m_xDispatchHelper, css::uno::UNO_QUERY );
808*cdf0e10cSrcweir     xInterceptionHelper->releaseDispatchProviderInterceptor( xInterceptor );
809*cdf0e10cSrcweir }
810*cdf0e10cSrcweir 
811*cdf0e10cSrcweir /*-************************************************************************************************************//**
812*cdf0e10cSrcweir     @interface  XFramesSupplier
813*cdf0e10cSrcweir     @short      return access to append or remove childs on desktop
814*cdf0e10cSrcweir     @descr      We don't implement these interface directly. We use a helper class to do this.
815*cdf0e10cSrcweir                 If you wish to add or delete childs to/from the container, call these method to get
816*cdf0e10cSrcweir                 a reference to the helper.
817*cdf0e10cSrcweir 
818*cdf0e10cSrcweir     @attention  Helper is threadsafe himself. So we don't need any lock here.
819*cdf0e10cSrcweir 
820*cdf0e10cSrcweir     @seealso    class OFrames
821*cdf0e10cSrcweir 
822*cdf0e10cSrcweir     @param      -
823*cdf0e10cSrcweir     @return     A reference to the helper.
824*cdf0e10cSrcweir 
825*cdf0e10cSrcweir     @onerror    A null reference is returned.
826*cdf0e10cSrcweir     @threadsafe yes
827*cdf0e10cSrcweir *//*-*************************************************************************************************************/
828*cdf0e10cSrcweir css::uno::Reference< css::frame::XFrames > SAL_CALL Desktop::getFrames() throw( css::uno::RuntimeException )
829*cdf0e10cSrcweir {
830*cdf0e10cSrcweir 	/* UNSAFE AREA --------------------------------------------------------------------------------------------- */
831*cdf0e10cSrcweir     // Register transaction and reject wrong calls.
832*cdf0e10cSrcweir     TransactionGuard aTransaction( m_aTransactionManager, E_HARDEXCEPTIONS );
833*cdf0e10cSrcweir 
834*cdf0e10cSrcweir     return m_xFramesHelper;
835*cdf0e10cSrcweir }
836*cdf0e10cSrcweir 
837*cdf0e10cSrcweir /*-************************************************************************************************************//**
838*cdf0e10cSrcweir     @interface  XFramesSupplier
839*cdf0e10cSrcweir     @short      set/get the current active child frame
840*cdf0e10cSrcweir     @descr      It must be a task. Direct childs of desktop are tasks only! No frames are accepted.
841*cdf0e10cSrcweir                 We don't save this information directly in this class. We use ouer container-helper
842*cdf0e10cSrcweir                 to do that.
843*cdf0e10cSrcweir 
844*cdf0e10cSrcweir     @attention  Helper is threadsafe himself. So we don't need any lock here.
845*cdf0e10cSrcweir 
846*cdf0e10cSrcweir     @seealso    class OFrameContainer
847*cdf0e10cSrcweir 
848*cdf0e10cSrcweir     @param      "xFrame", new active frame (must be valid!)
849*cdf0e10cSrcweir     @return     A reference to ouer current active childtask, if anyone exist.
850*cdf0e10cSrcweir 
851*cdf0e10cSrcweir     @onerror    A null reference is returned.
852*cdf0e10cSrcweir     @threadsafe yes
853*cdf0e10cSrcweir *//*-*************************************************************************************************************/
854*cdf0e10cSrcweir void SAL_CALL Desktop::setActiveFrame( const css::uno::Reference< css::frame::XFrame >& xFrame ) throw( css::uno::RuntimeException )
855*cdf0e10cSrcweir {
856*cdf0e10cSrcweir 	/* UNSAFE AREA --------------------------------------------------------------------------------------------- */
857*cdf0e10cSrcweir     // Register transaction and reject wrong calls.
858*cdf0e10cSrcweir     TransactionGuard aTransaction( m_aTransactionManager, E_HARDEXCEPTIONS );
859*cdf0e10cSrcweir 
860*cdf0e10cSrcweir     // Get old active frame first.
861*cdf0e10cSrcweir     // If nothing will change - do nothing!
862*cdf0e10cSrcweir     // Otherwise set new active frame ...
863*cdf0e10cSrcweir     // and deactivate last frame.
864*cdf0e10cSrcweir     // It's neccessary for our FrameActionEvent listener on a frame!
865*cdf0e10cSrcweir     css::uno::Reference< css::frame::XFrame > xLastActiveChild = m_aChildTaskContainer.getActive();
866*cdf0e10cSrcweir     if( xLastActiveChild != xFrame )
867*cdf0e10cSrcweir 	{
868*cdf0e10cSrcweir         m_aChildTaskContainer.setActive( xFrame );
869*cdf0e10cSrcweir         if( xLastActiveChild.is() == sal_True )
870*cdf0e10cSrcweir         {
871*cdf0e10cSrcweir             xLastActiveChild->deactivate();
872*cdf0e10cSrcweir         }
873*cdf0e10cSrcweir     }
874*cdf0e10cSrcweir }
875*cdf0e10cSrcweir 
876*cdf0e10cSrcweir //*****************************************************************************************************************
877*cdf0e10cSrcweir css::uno::Reference< css::frame::XFrame > SAL_CALL Desktop::getActiveFrame() throw( css::uno::RuntimeException )
878*cdf0e10cSrcweir {
879*cdf0e10cSrcweir 	/* UNSAFE AREA --------------------------------------------------------------------------------------------- */
880*cdf0e10cSrcweir     // Register transaction and reject wrong calls.
881*cdf0e10cSrcweir     TransactionGuard aTransaction( m_aTransactionManager, E_HARDEXCEPTIONS );
882*cdf0e10cSrcweir 
883*cdf0e10cSrcweir 	return m_aChildTaskContainer.getActive();
884*cdf0e10cSrcweir }
885*cdf0e10cSrcweir 
886*cdf0e10cSrcweir /*-************************************************************************************************************//**
887*cdf0e10cSrcweir     @interface  XFrame
888*cdf0e10cSrcweir     @short      non implemented methods!
889*cdf0e10cSrcweir     @descr      Some method make no sense for our desktop! He has no window or parent or ...
890*cdf0e10cSrcweir                 So we should implement it empty and warn programmer, if he use it!
891*cdf0e10cSrcweir 
892*cdf0e10cSrcweir     @seealso    -
893*cdf0e10cSrcweir 
894*cdf0e10cSrcweir     @param      -
895*cdf0e10cSrcweir     @return     -
896*cdf0e10cSrcweir 
897*cdf0e10cSrcweir     @onerror    -
898*cdf0e10cSrcweir     @threadsafe -
899*cdf0e10cSrcweir *//*-*************************************************************************************************************/
900*cdf0e10cSrcweir void SAL_CALL Desktop::initialize( const css::uno::Reference< css::awt::XWindow >& ) throw( css::uno::RuntimeException )
901*cdf0e10cSrcweir {
902*cdf0e10cSrcweir }
903*cdf0e10cSrcweir 
904*cdf0e10cSrcweir //*****************************************************************************************************************
905*cdf0e10cSrcweir css::uno::Reference< css::awt::XWindow > SAL_CALL Desktop::getContainerWindow() throw( css::uno::RuntimeException )
906*cdf0e10cSrcweir {
907*cdf0e10cSrcweir     return css::uno::Reference< css::awt::XWindow >();
908*cdf0e10cSrcweir }
909*cdf0e10cSrcweir 
910*cdf0e10cSrcweir //*****************************************************************************************************************
911*cdf0e10cSrcweir void SAL_CALL Desktop::setCreator( const css::uno::Reference< css::frame::XFramesSupplier >& /*xCreator*/ ) throw( css::uno::RuntimeException )
912*cdf0e10cSrcweir {
913*cdf0e10cSrcweir }
914*cdf0e10cSrcweir 
915*cdf0e10cSrcweir //*****************************************************************************************************************
916*cdf0e10cSrcweir css::uno::Reference< css::frame::XFramesSupplier > SAL_CALL Desktop::getCreator() throw( css::uno::RuntimeException )
917*cdf0e10cSrcweir {
918*cdf0e10cSrcweir     return css::uno::Reference< css::frame::XFramesSupplier >();
919*cdf0e10cSrcweir }
920*cdf0e10cSrcweir 
921*cdf0e10cSrcweir //*****************************************************************************************************************
922*cdf0e10cSrcweir ::rtl::OUString SAL_CALL Desktop::getName() throw( css::uno::RuntimeException )
923*cdf0e10cSrcweir {
924*cdf0e10cSrcweir     /* SAFE { */
925*cdf0e10cSrcweir     ReadGuard aReadLock( m_aLock );
926*cdf0e10cSrcweir     return m_sName;
927*cdf0e10cSrcweir     /* } SAFE */
928*cdf0e10cSrcweir }
929*cdf0e10cSrcweir 
930*cdf0e10cSrcweir //*****************************************************************************************************************
931*cdf0e10cSrcweir void SAL_CALL Desktop::setName( const ::rtl::OUString& sName ) throw( css::uno::RuntimeException )
932*cdf0e10cSrcweir {
933*cdf0e10cSrcweir     /* SAFE { */
934*cdf0e10cSrcweir     WriteGuard aWriteLock( m_aLock );
935*cdf0e10cSrcweir     m_sName = sName;
936*cdf0e10cSrcweir     aWriteLock.unlock();
937*cdf0e10cSrcweir     /* } SAFE */
938*cdf0e10cSrcweir }
939*cdf0e10cSrcweir 
940*cdf0e10cSrcweir //*****************************************************************************************************************
941*cdf0e10cSrcweir sal_Bool SAL_CALL Desktop::isTop() throw( css::uno::RuntimeException )
942*cdf0e10cSrcweir {
943*cdf0e10cSrcweir 	return sal_True;
944*cdf0e10cSrcweir }
945*cdf0e10cSrcweir 
946*cdf0e10cSrcweir //*****************************************************************************************************************
947*cdf0e10cSrcweir void SAL_CALL Desktop::activate() throw( css::uno::RuntimeException )
948*cdf0e10cSrcweir {
949*cdf0e10cSrcweir     // Desktop is activae always ... but sometimes our frames try to activate
950*cdf0e10cSrcweir     // the complete path from bottom to top ... And our desktop is the topest frame :-(
951*cdf0e10cSrcweir     // So - please don't show any assertions here. Do nothing!
952*cdf0e10cSrcweir }
953*cdf0e10cSrcweir 
954*cdf0e10cSrcweir //*****************************************************************************************************************
955*cdf0e10cSrcweir void SAL_CALL Desktop::deactivate() throw( css::uno::RuntimeException )
956*cdf0e10cSrcweir {
957*cdf0e10cSrcweir     // Desktop is activae always ... but sometimes our frames try to deactivate
958*cdf0e10cSrcweir     // the complete path from bottom to top ... And our desktop is the topest frame :-(
959*cdf0e10cSrcweir     // So - please don't show any assertions here. Do nothing!
960*cdf0e10cSrcweir }
961*cdf0e10cSrcweir 
962*cdf0e10cSrcweir //*****************************************************************************************************************
963*cdf0e10cSrcweir sal_Bool SAL_CALL Desktop::isActive() throw( css::uno::RuntimeException )
964*cdf0e10cSrcweir {
965*cdf0e10cSrcweir 	return sal_True;
966*cdf0e10cSrcweir }
967*cdf0e10cSrcweir 
968*cdf0e10cSrcweir //*****************************************************************************************************************
969*cdf0e10cSrcweir sal_Bool SAL_CALL Desktop::setComponent( const css::uno::Reference< css::awt::XWindow >&       /*xComponentWindow*/ ,
970*cdf0e10cSrcweir                                          const css::uno::Reference< css::frame::XController >& /*xController*/      ) throw( css::uno::RuntimeException )
971*cdf0e10cSrcweir {
972*cdf0e10cSrcweir 	return sal_False;
973*cdf0e10cSrcweir }
974*cdf0e10cSrcweir 
975*cdf0e10cSrcweir //*****************************************************************************************************************
976*cdf0e10cSrcweir css::uno::Reference< css::awt::XWindow > SAL_CALL Desktop::getComponentWindow() throw( css::uno::RuntimeException )
977*cdf0e10cSrcweir {
978*cdf0e10cSrcweir     return css::uno::Reference< css::awt::XWindow >();
979*cdf0e10cSrcweir }
980*cdf0e10cSrcweir 
981*cdf0e10cSrcweir //*****************************************************************************************************************
982*cdf0e10cSrcweir css::uno::Reference< css::frame::XController > SAL_CALL Desktop::getController() throw( css::uno::RuntimeException )
983*cdf0e10cSrcweir {
984*cdf0e10cSrcweir     return css::uno::Reference< css::frame::XController >();
985*cdf0e10cSrcweir }
986*cdf0e10cSrcweir 
987*cdf0e10cSrcweir //*****************************************************************************************************************
988*cdf0e10cSrcweir void SAL_CALL Desktop::contextChanged() throw( css::uno::RuntimeException )
989*cdf0e10cSrcweir {
990*cdf0e10cSrcweir }
991*cdf0e10cSrcweir 
992*cdf0e10cSrcweir //*****************************************************************************************************************
993*cdf0e10cSrcweir void SAL_CALL Desktop::addFrameActionListener( const css::uno::Reference< css::frame::XFrameActionListener >& ) throw( css::uno::RuntimeException )
994*cdf0e10cSrcweir {
995*cdf0e10cSrcweir }
996*cdf0e10cSrcweir 
997*cdf0e10cSrcweir //*****************************************************************************************************************
998*cdf0e10cSrcweir //   css::frame::XFrame
999*cdf0e10cSrcweir //*****************************************************************************************************************
1000*cdf0e10cSrcweir void SAL_CALL Desktop::removeFrameActionListener( const css::uno::Reference< css::frame::XFrameActionListener >& ) throw( css::uno::RuntimeException )
1001*cdf0e10cSrcweir {
1002*cdf0e10cSrcweir }
1003*cdf0e10cSrcweir 
1004*cdf0e10cSrcweir /*-************************************************************************************************************//**
1005*cdf0e10cSrcweir     @interface  XFrame
1006*cdf0e10cSrcweir     @short      try to find a frame with special parameters
1007*cdf0e10cSrcweir     @descr      This method searches for a frame with the specified name.
1008*cdf0e10cSrcweir                 Frames may contain other frames (e.g. a frameset) and may
1009*cdf0e10cSrcweir                 be contained in other frames. This hierarchie ist searched by
1010*cdf0e10cSrcweir                 this method.
1011*cdf0e10cSrcweir                 First some special names are taken into account, i.e. "",
1012*cdf0e10cSrcweir                 "_self", "_top", "_parent" etc. The FrameSearchFlags are ignored
1013*cdf0e10cSrcweir                 when comparing these names with aTargetFrameName, further steps are
1014*cdf0e10cSrcweir                 controlled by the FrameSearchFlags. If allowed, the name of the frame
1015*cdf0e10cSrcweir                 itself is compared with the desired one, then ( again if allowed )
1016*cdf0e10cSrcweir                 the method findFrame is called for all children of the frame.
1017*cdf0e10cSrcweir                 If no Frame with the given name is found until the top frames container,
1018*cdf0e10cSrcweir                 a new top Frame is created, if this is allowed by a special
1019*cdf0e10cSrcweir                 FrameSearchFlag. The new Frame also gets the desired name.
1020*cdf0e10cSrcweir                 We use a helper to get right search direction and react in a right manner.
1021*cdf0e10cSrcweir 
1022*cdf0e10cSrcweir     @seealso    class TargetFinder
1023*cdf0e10cSrcweir 
1024*cdf0e10cSrcweir     @param      "sTargetFrameName"  , name of searched frame
1025*cdf0e10cSrcweir     @param      "nSearchFlags"      , flags to regulate search
1026*cdf0e10cSrcweir     @return     A reference to an existing frame in hierarchy, if it exist.
1027*cdf0e10cSrcweir 
1028*cdf0e10cSrcweir     @onerror    A null reference is returned.
1029*cdf0e10cSrcweir     @threadsafe yes
1030*cdf0e10cSrcweir *//*-*************************************************************************************************************/
1031*cdf0e10cSrcweir css::uno::Reference< css::frame::XFrame > SAL_CALL Desktop::findFrame( const ::rtl::OUString& sTargetFrameName ,
1032*cdf0e10cSrcweir                                                                              sal_Int32        nSearchFlags     ) throw( css::uno::RuntimeException )
1033*cdf0e10cSrcweir {
1034*cdf0e10cSrcweir     css::uno::Reference< css::frame::XFrame > xTarget;
1035*cdf0e10cSrcweir 
1036*cdf0e10cSrcweir     //-----------------------------------------------------------------------------------------------------
1037*cdf0e10cSrcweir     // 0) Ignore wrong parameter!
1038*cdf0e10cSrcweir     //    We doesn't support search for following special targets.
1039*cdf0e10cSrcweir     //    If we reject this requests - we mustnt check for such names
1040*cdf0e10cSrcweir     //    in following code again and again. If we do not so -wrong
1041*cdf0e10cSrcweir     //    search results can occure!
1042*cdf0e10cSrcweir     //-----------------------------------------------------------------------------------------------------
1043*cdf0e10cSrcweir     if (
1044*cdf0e10cSrcweir         (sTargetFrameName==SPECIALTARGET_DEFAULT  )   ||    // valid for dispatches - not for findFrame()!
1045*cdf0e10cSrcweir         (sTargetFrameName==SPECIALTARGET_MENUBAR  )   ||    // valid for dispatches - not for findFrame()!
1046*cdf0e10cSrcweir         (sTargetFrameName==SPECIALTARGET_HELPAGENT)   ||    // valid for dispatches - not for findFrame()!
1047*cdf0e10cSrcweir         (sTargetFrameName==SPECIALTARGET_PARENT   )   ||    // we have no parent by definition
1048*cdf0e10cSrcweir         (sTargetFrameName==SPECIALTARGET_BEAMER   )         // beamer frames are allowed as child of tasks only -
1049*cdf0e10cSrcweir                                                             // and they exist more then ones. We have no idea which our sub tasks is the right one
1050*cdf0e10cSrcweir        )
1051*cdf0e10cSrcweir     {
1052*cdf0e10cSrcweir         return NULL;
1053*cdf0e10cSrcweir     }
1054*cdf0e10cSrcweir 
1055*cdf0e10cSrcweir     //-----------------------------------------------------------------------------------------------------
1056*cdf0e10cSrcweir     // I) check for special defined targets first which must be handled exclusive.
1057*cdf0e10cSrcweir     //    force using of "if() else if() ..."
1058*cdf0e10cSrcweir     //-----------------------------------------------------------------------------------------------------
1059*cdf0e10cSrcweir 
1060*cdf0e10cSrcweir     // get threadsafe some neccessary member which are neccessary for following functionality
1061*cdf0e10cSrcweir     /* SAFE { */
1062*cdf0e10cSrcweir     ReadGuard aReadLock( m_aLock );
1063*cdf0e10cSrcweir     css::uno::Reference< css::lang::XMultiServiceFactory > xFactory = m_xFactory;
1064*cdf0e10cSrcweir     aReadLock.unlock();
1065*cdf0e10cSrcweir     /* } SAFE */
1066*cdf0e10cSrcweir 
1067*cdf0e10cSrcweir     //-----------------------------------------------------------------------------------------------------
1068*cdf0e10cSrcweir     // I.I) "_blank"
1069*cdf0e10cSrcweir     //  create a new task as child of this desktop instance
1070*cdf0e10cSrcweir     //  Note: Used helper TaskCreator use us automaticly ...
1071*cdf0e10cSrcweir     //-----------------------------------------------------------------------------------------------------
1072*cdf0e10cSrcweir     if ( sTargetFrameName==SPECIALTARGET_BLANK )
1073*cdf0e10cSrcweir     {
1074*cdf0e10cSrcweir         TaskCreator aCreator(xFactory);
1075*cdf0e10cSrcweir         xTarget = aCreator.createTask(sTargetFrameName,sal_False);
1076*cdf0e10cSrcweir     }
1077*cdf0e10cSrcweir 
1078*cdf0e10cSrcweir     //-----------------------------------------------------------------------------------------------------
1079*cdf0e10cSrcweir     // I.II) "_top"
1080*cdf0e10cSrcweir     //  We are top by definition
1081*cdf0e10cSrcweir     //-----------------------------------------------------------------------------------------------------
1082*cdf0e10cSrcweir     else
1083*cdf0e10cSrcweir     if ( sTargetFrameName==SPECIALTARGET_TOP )
1084*cdf0e10cSrcweir     {
1085*cdf0e10cSrcweir         xTarget = this;
1086*cdf0e10cSrcweir     }
1087*cdf0e10cSrcweir 
1088*cdf0e10cSrcweir     //-----------------------------------------------------------------------------------------------------
1089*cdf0e10cSrcweir     // I.III) "_self", ""
1090*cdf0e10cSrcweir     //  This mean this "frame" in every case.
1091*cdf0e10cSrcweir     //-----------------------------------------------------------------------------------------------------
1092*cdf0e10cSrcweir     else
1093*cdf0e10cSrcweir     if (
1094*cdf0e10cSrcweir         ( sTargetFrameName==SPECIALTARGET_SELF ) ||
1095*cdf0e10cSrcweir         ( sTargetFrameName.getLength()<1       )
1096*cdf0e10cSrcweir        )
1097*cdf0e10cSrcweir     {
1098*cdf0e10cSrcweir         xTarget = this;
1099*cdf0e10cSrcweir     }
1100*cdf0e10cSrcweir 
1101*cdf0e10cSrcweir     else
1102*cdf0e10cSrcweir     {
1103*cdf0e10cSrcweir         //-------------------------------------------------------------------------------------------------
1104*cdf0e10cSrcweir         // II) otherwhise use optional given search flags
1105*cdf0e10cSrcweir         //  force using of combinations of such flags. means no "else" part of use if() statements.
1106*cdf0e10cSrcweir         //  But we ust break further searches if target was already found.
1107*cdf0e10cSrcweir         //  Order of using flags is fix: SELF - CHILDREN - SIBLINGS - PARENT
1108*cdf0e10cSrcweir         //  TASK and CREATE are handled special.
1109*cdf0e10cSrcweir         //  But note: Such flags are not valid for the desktop - especialy SIBLINGS or PARENT.
1110*cdf0e10cSrcweir         //-------------------------------------------------------------------------------------------------
1111*cdf0e10cSrcweir 
1112*cdf0e10cSrcweir         // get threadsafe some neccessary member which are neccessary for following functionality
1113*cdf0e10cSrcweir         /* SAFE { */
1114*cdf0e10cSrcweir         aReadLock.lock();
1115*cdf0e10cSrcweir         ::rtl::OUString sOwnName = m_sName;
1116*cdf0e10cSrcweir         aReadLock.unlock();
1117*cdf0e10cSrcweir         /* } SAFE */
1118*cdf0e10cSrcweir 
1119*cdf0e10cSrcweir         //-------------------------------------------------------------------------------------------------
1120*cdf0e10cSrcweir         // II.I) SELF
1121*cdf0e10cSrcweir         //  Check for right name. If it's the searched one return ourself - otherwhise
1122*cdf0e10cSrcweir         //  ignore this flag.
1123*cdf0e10cSrcweir         //-------------------------------------------------------------------------------------------------
1124*cdf0e10cSrcweir         if (
1125*cdf0e10cSrcweir             (nSearchFlags &  css::frame::FrameSearchFlag::SELF)  &&
1126*cdf0e10cSrcweir             (sOwnName     == sTargetFrameName                 )
1127*cdf0e10cSrcweir            )
1128*cdf0e10cSrcweir         {
1129*cdf0e10cSrcweir             xTarget = this;
1130*cdf0e10cSrcweir         }
1131*cdf0e10cSrcweir 
1132*cdf0e10cSrcweir         //-------------------------------------------------------------------------------------------------
1133*cdf0e10cSrcweir         // II.II) TASKS
1134*cdf0e10cSrcweir         //  This is a special flag. Normaly it regulate search inside tasks and forbid access to parent trees.
1135*cdf0e10cSrcweir         //  But the desktop exists outside such task trees. They are our sub trees. So the desktop implement
1136*cdf0e10cSrcweir         //  a special feature: We use it to start search on our direct childrens only. That means we supress
1137*cdf0e10cSrcweir         //  search on ALL child frames. May that can be usefull to get access on opened document tasks
1138*cdf0e10cSrcweir         //  only without filter out all non realy required sub frames ...
1139*cdf0e10cSrcweir         //  Used helper method on our container doesn't create any frame - its a search only.
1140*cdf0e10cSrcweir         //-------------------------------------------------------------------------------------------------
1141*cdf0e10cSrcweir         if (
1142*cdf0e10cSrcweir             ( ! xTarget.is()                                  ) &&
1143*cdf0e10cSrcweir             (nSearchFlags & css::frame::FrameSearchFlag::TASKS)
1144*cdf0e10cSrcweir            )
1145*cdf0e10cSrcweir         {
1146*cdf0e10cSrcweir             xTarget = m_aChildTaskContainer.searchOnDirectChildrens(sTargetFrameName);
1147*cdf0e10cSrcweir         }
1148*cdf0e10cSrcweir 
1149*cdf0e10cSrcweir         //-------------------------------------------------------------------------------------------------
1150*cdf0e10cSrcweir         // II.III) CHILDREN
1151*cdf0e10cSrcweir         //  Search on all children for the given target name.
1152*cdf0e10cSrcweir         //  An empty name value can't occure here - because it must be already handled as "_self"
1153*cdf0e10cSrcweir         //  before. Used helper function of container doesn't create any frame.
1154*cdf0e10cSrcweir         //  It makes a deep search only.
1155*cdf0e10cSrcweir         //-------------------------------------------------------------------------------------------------
1156*cdf0e10cSrcweir         if (
1157*cdf0e10cSrcweir             ( ! xTarget.is()                                     ) &&
1158*cdf0e10cSrcweir             (nSearchFlags & css::frame::FrameSearchFlag::CHILDREN)
1159*cdf0e10cSrcweir            )
1160*cdf0e10cSrcweir         {
1161*cdf0e10cSrcweir             xTarget = m_aChildTaskContainer.searchOnAllChildrens(sTargetFrameName);
1162*cdf0e10cSrcweir         }
1163*cdf0e10cSrcweir 
1164*cdf0e10cSrcweir         //-------------------------------------------------------------------------------------------------
1165*cdf0e10cSrcweir         // II.IV) CREATE
1166*cdf0e10cSrcweir         //  If we haven't found any valid target frame by using normal flags - but user allowed us to create
1167*cdf0e10cSrcweir         //  a new one ... we should do that. Used TaskCreator use us automaticly as parent!
1168*cdf0e10cSrcweir         //-------------------------------------------------------------------------------------------------
1169*cdf0e10cSrcweir         if (
1170*cdf0e10cSrcweir             ( ! xTarget.is()                                   )    &&
1171*cdf0e10cSrcweir             (nSearchFlags & css::frame::FrameSearchFlag::CREATE)
1172*cdf0e10cSrcweir            )
1173*cdf0e10cSrcweir         {
1174*cdf0e10cSrcweir             TaskCreator aCreator(xFactory);
1175*cdf0e10cSrcweir             xTarget = aCreator.createTask(sTargetFrameName,sal_False);
1176*cdf0e10cSrcweir         }
1177*cdf0e10cSrcweir     }
1178*cdf0e10cSrcweir 
1179*cdf0e10cSrcweir     return xTarget;
1180*cdf0e10cSrcweir }
1181*cdf0e10cSrcweir 
1182*cdf0e10cSrcweir //=============================================================================
1183*cdf0e10cSrcweir void SAL_CALL Desktop::dispose()
1184*cdf0e10cSrcweir     throw( css::uno::RuntimeException )
1185*cdf0e10cSrcweir {
1186*cdf0e10cSrcweir 	// Safe impossible cases
1187*cdf0e10cSrcweir 	// It's an programming error if dispose is called before terminate!
1188*cdf0e10cSrcweir     LOG_ASSERT2( m_bIsTerminated==sal_False, "Desktop::dispose()", "It's not allowed to dispose the desktop before terminate() is called!" )
1189*cdf0e10cSrcweir 
1190*cdf0e10cSrcweir     SYNCHRONIZED_START
1191*cdf0e10cSrcweir         WriteGuard aWriteLock( m_aLock );
1192*cdf0e10cSrcweir 
1193*cdf0e10cSrcweir         // Look for multiple calls of this method!
1194*cdf0e10cSrcweir         // If somewhere call dispose() twice - he will be stopped here realy!!!
1195*cdf0e10cSrcweir         TransactionGuard aTransaction( m_aTransactionManager, E_HARDEXCEPTIONS );
1196*cdf0e10cSrcweir 
1197*cdf0e10cSrcweir         // Now - we are alone and its the first call of this method ...
1198*cdf0e10cSrcweir         // otherwise call before had thrown a DisposedException / hopefully .-)
1199*cdf0e10cSrcweir         // But we dont use the transaction object created before ... we reset it immediatly ...
1200*cdf0e10cSrcweir         // two lines of code ... for what ?
1201*cdf0e10cSrcweir         // The answer: We wished to synchronize concurrent dispose() calls -> OK
1202*cdf0e10cSrcweir         // But next line will wait for all currently running transaction (even if they
1203*cdf0e10cSrcweir         // are running within the same thread!) So we would block ourself there if aTransaction
1204*cdf0e10cSrcweir         // will stay registered .-)
1205*cdf0e10cSrcweir         aTransaction.stop();
1206*cdf0e10cSrcweir 
1207*cdf0e10cSrcweir         // Disable this instance for further work.
1208*cdf0e10cSrcweir         // This will wait for all current running transactions ...
1209*cdf0e10cSrcweir         // and reject all new incoming requests!
1210*cdf0e10cSrcweir         m_aTransactionManager.setWorkingMode( E_BEFORECLOSE );
1211*cdf0e10cSrcweir 
1212*cdf0e10cSrcweir         aWriteLock.unlock();
1213*cdf0e10cSrcweir     SYNCHRONIZED_END
1214*cdf0e10cSrcweir 
1215*cdf0e10cSrcweir     // Following lines of code can be called outside a synchronized block ...
1216*cdf0e10cSrcweir     // Because our transaction manager will block all new requests to this object.
1217*cdf0e10cSrcweir     // So nobody can use us any longer.
1218*cdf0e10cSrcweir     // Exception: Only removing of listener will work ... and this code cant be dangerous.
1219*cdf0e10cSrcweir 
1220*cdf0e10cSrcweir     // First we has to kill all listener connections.
1221*cdf0e10cSrcweir     // They might rely on our member and can hinder us on releasing them.
1222*cdf0e10cSrcweir     css::uno::Reference< css::uno::XInterface > xThis ( static_cast< ::cppu::OWeakObject* >(this), css::uno::UNO_QUERY );
1223*cdf0e10cSrcweir     css::lang::EventObject                      aEvent( xThis );
1224*cdf0e10cSrcweir     m_aListenerContainer.disposeAndClear( aEvent );
1225*cdf0e10cSrcweir 
1226*cdf0e10cSrcweir     // Clear our child task container and forget all task references hardly.
1227*cdf0e10cSrcweir     // Normaly all open document was already closed by our terminate() function before ...
1228*cdf0e10cSrcweir     // New opened frames will have a problem now .-)
1229*cdf0e10cSrcweir     m_aChildTaskContainer.clear();
1230*cdf0e10cSrcweir 
1231*cdf0e10cSrcweir     // Dispose our helper too.
1232*cdf0e10cSrcweir     css::uno::Reference< css::lang::XEventListener > xFramesHelper( m_xFramesHelper, css::uno::UNO_QUERY );
1233*cdf0e10cSrcweir     if( xFramesHelper.is() )
1234*cdf0e10cSrcweir         xFramesHelper->disposing( aEvent );
1235*cdf0e10cSrcweir 
1236*cdf0e10cSrcweir     // At least clean up other member references.
1237*cdf0e10cSrcweir     m_xDispatchHelper.clear();
1238*cdf0e10cSrcweir     m_xFramesHelper.clear();
1239*cdf0e10cSrcweir     m_xLastFrame.clear();
1240*cdf0e10cSrcweir     m_xFactory.clear();
1241*cdf0e10cSrcweir 
1242*cdf0e10cSrcweir     m_xPipeTerminator.clear();
1243*cdf0e10cSrcweir     m_xQuickLauncher.clear();
1244*cdf0e10cSrcweir     m_xSWThreadManager.clear();
1245*cdf0e10cSrcweir     m_xSfxTerminator.clear();
1246*cdf0e10cSrcweir 
1247*cdf0e10cSrcweir     // From this point nothing will work further on this object ...
1248*cdf0e10cSrcweir     // excepting our dtor() .-)
1249*cdf0e10cSrcweir     m_aTransactionManager.setWorkingMode( E_CLOSE );
1250*cdf0e10cSrcweir }
1251*cdf0e10cSrcweir 
1252*cdf0e10cSrcweir /*-************************************************************************************************************//**
1253*cdf0e10cSrcweir     @interface  XComponent
1254*cdf0e10cSrcweir     @short      add/remove listener for dispose events
1255*cdf0e10cSrcweir     @descr      Add an event listener to this object, if you whish to get informations
1256*cdf0e10cSrcweir                 about our dieing!
1257*cdf0e10cSrcweir                 You must releas ethis listener reference during your own disposing() method.
1258*cdf0e10cSrcweir 
1259*cdf0e10cSrcweir     @attention  Our container is threadsafe himeslf. So we doesn't need any lock here.
1260*cdf0e10cSrcweir 
1261*cdf0e10cSrcweir     @seealso    -
1262*cdf0e10cSrcweir 
1263*cdf0e10cSrcweir     @param      "xListener", reference to valid listener. We don't accept invalid values!
1264*cdf0e10cSrcweir     @return     -
1265*cdf0e10cSrcweir 
1266*cdf0e10cSrcweir     @onerror    -
1267*cdf0e10cSrcweir     @threadsafe yes
1268*cdf0e10cSrcweir *//*-*************************************************************************************************************/
1269*cdf0e10cSrcweir void SAL_CALL Desktop::addEventListener( const css::uno::Reference< css::lang::XEventListener >& xListener ) throw( css::uno::RuntimeException )
1270*cdf0e10cSrcweir {
1271*cdf0e10cSrcweir 	/* UNSAFE AREA --------------------------------------------------------------------------------------------- */
1272*cdf0e10cSrcweir 	// Safe impossible cases
1273*cdf0e10cSrcweir 	// Method not defined for all incoming parameter.
1274*cdf0e10cSrcweir     LOG_ASSERT2( implcp_addEventListener( xListener ), "Desktop::addEventListener()", "Invalid parameter detected!" )
1275*cdf0e10cSrcweir     // Register transaction and reject wrong calls.
1276*cdf0e10cSrcweir     TransactionGuard aTransaction( m_aTransactionManager, E_HARDEXCEPTIONS );
1277*cdf0e10cSrcweir 
1278*cdf0e10cSrcweir     m_aListenerContainer.addInterface( ::getCppuType( ( const css::uno::Reference< css::lang::XEventListener >*) NULL ), xListener );
1279*cdf0e10cSrcweir }
1280*cdf0e10cSrcweir 
1281*cdf0e10cSrcweir //*****************************************************************************************************************
1282*cdf0e10cSrcweir void SAL_CALL Desktop::removeEventListener( const css::uno::Reference< css::lang::XEventListener >& xListener ) throw( css::uno::RuntimeException )
1283*cdf0e10cSrcweir {
1284*cdf0e10cSrcweir 	/* UNSAFE AREA --------------------------------------------------------------------------------------------- */
1285*cdf0e10cSrcweir 	// Safe impossible cases
1286*cdf0e10cSrcweir 	// Method not defined for all incoming parameter.
1287*cdf0e10cSrcweir     LOG_ASSERT2( implcp_removeEventListener( xListener ), "Desktop::removeEventListener()", "Invalid parameter detected!" )
1288*cdf0e10cSrcweir     // Register transaction and reject wrong calls.
1289*cdf0e10cSrcweir     TransactionGuard aTransaction( m_aTransactionManager, E_SOFTEXCEPTIONS );
1290*cdf0e10cSrcweir 
1291*cdf0e10cSrcweir     m_aListenerContainer.removeInterface( ::getCppuType( ( const css::uno::Reference< css::lang::XEventListener >*) NULL ), xListener );
1292*cdf0e10cSrcweir }
1293*cdf0e10cSrcweir 
1294*cdf0e10cSrcweir /*-************************************************************************************************************//**
1295*cdf0e10cSrcweir     @interface  XDispatchResultListener
1296*cdf0e10cSrcweir     @short      callback for dispatches
1297*cdf0e10cSrcweir     @descr      To support our method "loadComponentFromURL()" we are listener on temp. created dispatcher.
1298*cdf0e10cSrcweir                 They call us back in this method "statusChanged()". As source of given state event, they give us a
1299*cdf0e10cSrcweir                 reference to the target frame, in which dispatch was loaded! So we can use it to return his component
1300*cdf0e10cSrcweir                 to caller! If no target exist ... ??!!
1301*cdf0e10cSrcweir 
1302*cdf0e10cSrcweir     @seealso    method loadComponentFromURL()
1303*cdf0e10cSrcweir 
1304*cdf0e10cSrcweir     @param      "aEvent", state event which (hopefully) valid informations
1305*cdf0e10cSrcweir     @return     -
1306*cdf0e10cSrcweir 
1307*cdf0e10cSrcweir     @onerror    -
1308*cdf0e10cSrcweir     @threadsafe yes
1309*cdf0e10cSrcweir *//*-*************************************************************************************************************/
1310*cdf0e10cSrcweir void SAL_CALL Desktop::dispatchFinished( const css::frame::DispatchResultEvent& aEvent ) throw( css::uno::RuntimeException )
1311*cdf0e10cSrcweir {
1312*cdf0e10cSrcweir 	/* UNSAFE AREA --------------------------------------------------------------------------------------------- */
1313*cdf0e10cSrcweir     // Register transaction and reject wrong calls.
1314*cdf0e10cSrcweir     TransactionGuard aTransaction( m_aTransactionManager, E_HARDEXCEPTIONS );
1315*cdf0e10cSrcweir 
1316*cdf0e10cSrcweir     /* SAFE AREA ------------------------------------------------------------------------------------------- */
1317*cdf0e10cSrcweir     WriteGuard aWriteLock( m_aLock );
1318*cdf0e10cSrcweir     if( m_eLoadState != E_INTERACTION )
1319*cdf0e10cSrcweir     {
1320*cdf0e10cSrcweir         m_xLastFrame = css::uno::Reference< css::frame::XFrame >();
1321*cdf0e10cSrcweir         m_eLoadState = E_FAILED                                   ;
1322*cdf0e10cSrcweir         if( aEvent.State == css::frame::DispatchResultState::SUCCESS )
1323*cdf0e10cSrcweir         {
1324*cdf0e10cSrcweir             css::uno::Reference < css::frame::XFrame > xFrame;
1325*cdf0e10cSrcweir             if ( aEvent.Result >>= m_xLastFrame )
1326*cdf0e10cSrcweir                 m_eLoadState = E_SUCCESSFUL;
1327*cdf0e10cSrcweir         }
1328*cdf0e10cSrcweir     }
1329*cdf0e10cSrcweir     /* UNSAFE AREA ----------------------------------------------------------------------------------------- */
1330*cdf0e10cSrcweir }
1331*cdf0e10cSrcweir 
1332*cdf0e10cSrcweir /*-************************************************************************************************************//**
1333*cdf0e10cSrcweir     @interface  XEventListener
1334*cdf0e10cSrcweir     @short      not implemented!
1335*cdf0e10cSrcweir     @descr      We are a status listener ... and so we must be an event listener too ... But we doesn't need it realy!
1336*cdf0e10cSrcweir                 We are a temp. listener only and our lifetime isn't smaller then of our temp. used dispatcher.
1337*cdf0e10cSrcweir 
1338*cdf0e10cSrcweir     @seealso    method loadComponentFromURL()
1339*cdf0e10cSrcweir 
1340*cdf0e10cSrcweir     @param      -
1341*cdf0e10cSrcweir     @return     -
1342*cdf0e10cSrcweir 
1343*cdf0e10cSrcweir     @onerror    -
1344*cdf0e10cSrcweir     @threadsafe -
1345*cdf0e10cSrcweir *//*-*************************************************************************************************************/
1346*cdf0e10cSrcweir void SAL_CALL Desktop::disposing( const css::lang::EventObject& ) throw( css::uno::RuntimeException )
1347*cdf0e10cSrcweir {
1348*cdf0e10cSrcweir     LOG_ERROR( "Desktop::disposing()", "Algorithm error! Normaly desktop is temp. listener ... not all the time. So this method shouldn't be called." )
1349*cdf0e10cSrcweir }
1350*cdf0e10cSrcweir 
1351*cdf0e10cSrcweir /*-************************************************************************************************************//**
1352*cdf0e10cSrcweir     @interface  XInteractionHandler
1353*cdf0e10cSrcweir     @short      callback for loadComponentFromURL for detected exceptions during load proccess
1354*cdf0e10cSrcweir     @descr      In this case we must cancel loading and throw these detected exception again as result
1355*cdf0e10cSrcweir                 of our own called method.
1356*cdf0e10cSrcweir 
1357*cdf0e10cSrcweir     @attention  a)
1358*cdf0e10cSrcweir                 Normal loop in loadComponentFromURL() breaks on setted member m_eLoadState during callback statusChanged().
1359*cdf0e10cSrcweir                 But these interaction feature implements second way to do so! So we must look on different callbacks
1360*cdf0e10cSrcweir                 for same operation ... and live with it.
1361*cdf0e10cSrcweir                 b)
1362*cdf0e10cSrcweir                 Search for given continuations too. If any XInteractionAbort exist ... use it to abort further operations
1363*cdf0e10cSrcweir                 for currently running operation!
1364*cdf0e10cSrcweir 
1365*cdf0e10cSrcweir     @seealso    method loadComponentFromURL()
1366*cdf0e10cSrcweir     @seealso    member m_eLoadState
1367*cdf0e10cSrcweir 
1368*cdf0e10cSrcweir     @param      "xRequest", request for interaction - normal a wrapped target exception from bottom services
1369*cdf0e10cSrcweir     @return     -
1370*cdf0e10cSrcweir 
1371*cdf0e10cSrcweir     @onerror    -
1372*cdf0e10cSrcweir     @threadsafe yes
1373*cdf0e10cSrcweir *//*-*************************************************************************************************************/
1374*cdf0e10cSrcweir void SAL_CALL Desktop::handle( const css::uno::Reference< css::task::XInteractionRequest >& xRequest ) throw( css::uno::RuntimeException )
1375*cdf0e10cSrcweir {
1376*cdf0e10cSrcweir 	/* UNSAFE AREA --------------------------------------------------------------------------------------------- */
1377*cdf0e10cSrcweir     // Register transaction and reject wrong calls.
1378*cdf0e10cSrcweir     TransactionGuard aTransaction( m_aTransactionManager, E_HARDEXCEPTIONS );
1379*cdf0e10cSrcweir 
1380*cdf0e10cSrcweir     // Don't check incoming request!
1381*cdf0e10cSrcweir     // If somewhere starts interaction without right parameter - he maked something wrong.
1382*cdf0e10cSrcweir     // loadComponentFromURL() waits for thjese event - otherwise it yield for ever!
1383*cdf0e10cSrcweir 
1384*cdf0e10cSrcweir     // get packed request and work on it first
1385*cdf0e10cSrcweir     // Attention: Don't set it on internal member BEFORE interaction is finished - because
1386*cdf0e10cSrcweir     // "loadComponentFromURL()" yield tills this member is changed. If we do it before
1387*cdf0e10cSrcweir     // interaction finish we can't guarantee right functionality. May be we cancel load process to erliear ...
1388*cdf0e10cSrcweir     css::uno::Any aRequest = xRequest->getRequest();
1389*cdf0e10cSrcweir 
1390*cdf0e10cSrcweir     // extract continuations from request
1391*cdf0e10cSrcweir     css::uno::Sequence< css::uno::Reference< css::task::XInteractionContinuation > > lContinuations = xRequest->getContinuations();
1392*cdf0e10cSrcweir     css::uno::Reference< css::task::XInteractionAbort >                              xAbort         ;
1393*cdf0e10cSrcweir     css::uno::Reference< css::task::XInteractionApprove >                            xApprove       ;
1394*cdf0e10cSrcweir     css::uno::Reference< css::document::XInteractionFilterSelect >                   xFilterSelect  ;
1395*cdf0e10cSrcweir     sal_Bool                                                                         bAbort         = sal_False;
1396*cdf0e10cSrcweir 
1397*cdf0e10cSrcweir     sal_Int32 nCount=lContinuations.getLength();
1398*cdf0e10cSrcweir     for( sal_Int32 nStep=0; nStep<nCount; ++nStep )
1399*cdf0e10cSrcweir     {
1400*cdf0e10cSrcweir         if( ! xAbort.is() )
1401*cdf0e10cSrcweir             xAbort  = css::uno::Reference< css::task::XInteractionAbort >( lContinuations[nStep], css::uno::UNO_QUERY );
1402*cdf0e10cSrcweir 
1403*cdf0e10cSrcweir         if( ! xApprove.is() )
1404*cdf0e10cSrcweir             xApprove  = css::uno::Reference< css::task::XInteractionApprove >( lContinuations[nStep], css::uno::UNO_QUERY );
1405*cdf0e10cSrcweir 
1406*cdf0e10cSrcweir         if( ! xFilterSelect.is() )
1407*cdf0e10cSrcweir             xFilterSelect = css::uno::Reference< css::document::XInteractionFilterSelect >( lContinuations[nStep], css::uno::UNO_QUERY );
1408*cdf0e10cSrcweir     }
1409*cdf0e10cSrcweir 
1410*cdf0e10cSrcweir     // differ between abortable interactions (error, unknown filter ...)
1411*cdf0e10cSrcweir     // and other ones (ambigous but not unknown filter ...)
1412*cdf0e10cSrcweir     css::task::ErrorCodeRequest          aErrorCodeRequest     ;
1413*cdf0e10cSrcweir     css::document::AmbigousFilterRequest aAmbigousFilterRequest;
1414*cdf0e10cSrcweir     if( aRequest >>= aAmbigousFilterRequest )
1415*cdf0e10cSrcweir     {
1416*cdf0e10cSrcweir         if( xFilterSelect.is() )
1417*cdf0e10cSrcweir         {
1418*cdf0e10cSrcweir             xFilterSelect->setFilter( aAmbigousFilterRequest.SelectedFilter ); // user selected filter wins!
1419*cdf0e10cSrcweir             xFilterSelect->select();
1420*cdf0e10cSrcweir         }
1421*cdf0e10cSrcweir     }
1422*cdf0e10cSrcweir     else
1423*cdf0e10cSrcweir     if( aRequest >>= aErrorCodeRequest )
1424*cdf0e10cSrcweir     {
1425*cdf0e10cSrcweir         sal_Bool bWarning = ((aErrorCodeRequest.ErrCode & ERRCODE_WARNING_MASK) == ERRCODE_WARNING_MASK);
1426*cdf0e10cSrcweir         if (xApprove.is() && bWarning)
1427*cdf0e10cSrcweir             xApprove->select();
1428*cdf0e10cSrcweir         else
1429*cdf0e10cSrcweir         if (xAbort.is())
1430*cdf0e10cSrcweir         {
1431*cdf0e10cSrcweir             xAbort->select();
1432*cdf0e10cSrcweir             bAbort = sal_True;
1433*cdf0e10cSrcweir         }
1434*cdf0e10cSrcweir     }
1435*cdf0e10cSrcweir     else
1436*cdf0e10cSrcweir     if( xAbort.is() )
1437*cdf0e10cSrcweir     {
1438*cdf0e10cSrcweir         xAbort->select();
1439*cdf0e10cSrcweir         bAbort = sal_True;
1440*cdf0e10cSrcweir     }
1441*cdf0e10cSrcweir 
1442*cdf0e10cSrcweir     /* SAFE AREA ------------------------------------------------------------------------------------------- */
1443*cdf0e10cSrcweir     // Ok now it's time to break yield loop of loadComponentFromURL().
1444*cdf0e10cSrcweir     // But only for realy aborted requests!
1445*cdf0e10cSrcweir     // For example warnings will be approved and we wait for any success story ...
1446*cdf0e10cSrcweir     if (bAbort)
1447*cdf0e10cSrcweir     {
1448*cdf0e10cSrcweir         WriteGuard aWriteLock( m_aLock );
1449*cdf0e10cSrcweir         m_eLoadState          = E_INTERACTION;
1450*cdf0e10cSrcweir         m_aInteractionRequest = aRequest     ;
1451*cdf0e10cSrcweir         aWriteLock.unlock();
1452*cdf0e10cSrcweir     }
1453*cdf0e10cSrcweir     /* UNSAFE AREA ----------------------------------------------------------------------------------------- */
1454*cdf0e10cSrcweir }
1455*cdf0e10cSrcweir 
1456*cdf0e10cSrcweir //-----------------------------------------------------------------------------
1457*cdf0e10cSrcweir ::sal_Int32 SAL_CALL Desktop::leaseNumber( const css::uno::Reference< css::uno::XInterface >& xComponent )
1458*cdf0e10cSrcweir     throw (css::lang::IllegalArgumentException,
1459*cdf0e10cSrcweir            css::uno::RuntimeException         )
1460*cdf0e10cSrcweir {
1461*cdf0e10cSrcweir     TransactionGuard aTransaction( m_aTransactionManager, E_HARDEXCEPTIONS );
1462*cdf0e10cSrcweir     return m_xTitleNumberGenerator->leaseNumber (xComponent);
1463*cdf0e10cSrcweir }
1464*cdf0e10cSrcweir 
1465*cdf0e10cSrcweir //-----------------------------------------------------------------------------
1466*cdf0e10cSrcweir void SAL_CALL Desktop::releaseNumber( ::sal_Int32 nNumber )
1467*cdf0e10cSrcweir     throw (css::lang::IllegalArgumentException,
1468*cdf0e10cSrcweir            css::uno::RuntimeException         )
1469*cdf0e10cSrcweir {
1470*cdf0e10cSrcweir     TransactionGuard aTransaction( m_aTransactionManager, E_HARDEXCEPTIONS );
1471*cdf0e10cSrcweir     m_xTitleNumberGenerator->releaseNumber (nNumber);
1472*cdf0e10cSrcweir }
1473*cdf0e10cSrcweir 
1474*cdf0e10cSrcweir //-----------------------------------------------------------------------------
1475*cdf0e10cSrcweir void SAL_CALL Desktop::releaseNumberForComponent( const css::uno::Reference< css::uno::XInterface >& xComponent )
1476*cdf0e10cSrcweir     throw (css::lang::IllegalArgumentException,
1477*cdf0e10cSrcweir            css::uno::RuntimeException         )
1478*cdf0e10cSrcweir {
1479*cdf0e10cSrcweir     TransactionGuard aTransaction( m_aTransactionManager, E_HARDEXCEPTIONS );
1480*cdf0e10cSrcweir     m_xTitleNumberGenerator->releaseNumberForComponent (xComponent);
1481*cdf0e10cSrcweir }
1482*cdf0e10cSrcweir 
1483*cdf0e10cSrcweir //-----------------------------------------------------------------------------
1484*cdf0e10cSrcweir ::rtl::OUString SAL_CALL Desktop::getUntitledPrefix()
1485*cdf0e10cSrcweir     throw (css::uno::RuntimeException)
1486*cdf0e10cSrcweir {
1487*cdf0e10cSrcweir     TransactionGuard aTransaction( m_aTransactionManager, E_HARDEXCEPTIONS );
1488*cdf0e10cSrcweir     return m_xTitleNumberGenerator->getUntitledPrefix ();
1489*cdf0e10cSrcweir }
1490*cdf0e10cSrcweir 
1491*cdf0e10cSrcweir /*-************************************************************************************************************//**
1492*cdf0e10cSrcweir     @short      try to convert a property value
1493*cdf0e10cSrcweir     @descr      This method is called from helperclass "OPropertySetHelper".
1494*cdf0e10cSrcweir                 Don't use this directly!
1495*cdf0e10cSrcweir                 You must try to convert the value of given DESKTOP_PROPHANDLE and
1496*cdf0e10cSrcweir                 return results of this operation. This will be used to ask vetoable
1497*cdf0e10cSrcweir                 listener. If no listener has a veto, we will change value realy!
1498*cdf0e10cSrcweir                 ( in method setFastPropertyValue_NoBroadcast(...) )
1499*cdf0e10cSrcweir 
1500*cdf0e10cSrcweir     @attention  Methods of OPropertySethelper are safed by using our shared osl mutex! (see ctor!)
1501*cdf0e10cSrcweir                 So we must use different locks to make our implementation threadsafe.
1502*cdf0e10cSrcweir 
1503*cdf0e10cSrcweir     @seealso    class OPropertySetHelper
1504*cdf0e10cSrcweir     @seealso    method setFastPropertyValue_NoBroadcast()
1505*cdf0e10cSrcweir 
1506*cdf0e10cSrcweir     @param      "aConvertedValue"   new converted value of property
1507*cdf0e10cSrcweir     @param      "aOldValue"         old value of property
1508*cdf0e10cSrcweir     @param      "nHandle"           handle of property
1509*cdf0e10cSrcweir     @param      "aValue"            new value of property
1510*cdf0e10cSrcweir     @return     sal_True if value will be changed, sal_FALSE otherway
1511*cdf0e10cSrcweir 
1512*cdf0e10cSrcweir     @onerror    IllegalArgumentException, if you call this with an invalid argument
1513*cdf0e10cSrcweir     @threadsafe yes
1514*cdf0e10cSrcweir *//*-*************************************************************************************************************/
1515*cdf0e10cSrcweir sal_Bool SAL_CALL Desktop::convertFastPropertyValue(       css::uno::Any&   aConvertedValue ,
1516*cdf0e10cSrcweir                                                            css::uno::Any&   aOldValue       ,
1517*cdf0e10cSrcweir                                                            sal_Int32        nHandle         ,
1518*cdf0e10cSrcweir                                                      const css::uno::Any&   aValue          ) throw( css::lang::IllegalArgumentException )
1519*cdf0e10cSrcweir {
1520*cdf0e10cSrcweir 	/* UNSAFE AREA --------------------------------------------------------------------------------------------- */
1521*cdf0e10cSrcweir     // Register transaction and reject wrong calls.
1522*cdf0e10cSrcweir     TransactionGuard aTransaction( m_aTransactionManager, E_HARDEXCEPTIONS );
1523*cdf0e10cSrcweir 
1524*cdf0e10cSrcweir 	//	Initialize state with sal_False !!!
1525*cdf0e10cSrcweir 	//	(Handle can be invalid)
1526*cdf0e10cSrcweir 	sal_Bool bReturn = sal_False;
1527*cdf0e10cSrcweir 
1528*cdf0e10cSrcweir     switch( nHandle )
1529*cdf0e10cSrcweir 	{
1530*cdf0e10cSrcweir         case DESKTOP_PROPHANDLE_SUSPENDQUICKSTARTVETO:
1531*cdf0e10cSrcweir                 bReturn = PropHelper::willPropertyBeChanged(
1532*cdf0e10cSrcweir                     css::uno::makeAny(m_bSuspendQuickstartVeto),
1533*cdf0e10cSrcweir                     aValue,
1534*cdf0e10cSrcweir                     aOldValue,
1535*cdf0e10cSrcweir                     aConvertedValue);
1536*cdf0e10cSrcweir                 break;
1537*cdf0e10cSrcweir         case DESKTOP_PROPHANDLE_DISPATCHRECORDERSUPPLIER :
1538*cdf0e10cSrcweir                 bReturn = PropHelper::willPropertyBeChanged(
1539*cdf0e10cSrcweir                     css::uno::makeAny(m_xDispatchRecorderSupplier),
1540*cdf0e10cSrcweir                     aValue,
1541*cdf0e10cSrcweir                     aOldValue,
1542*cdf0e10cSrcweir                     aConvertedValue);
1543*cdf0e10cSrcweir                 break;
1544*cdf0e10cSrcweir         case DESKTOP_PROPHANDLE_TITLE :
1545*cdf0e10cSrcweir                 bReturn = PropHelper::willPropertyBeChanged(
1546*cdf0e10cSrcweir                     css::uno::makeAny(m_sTitle),
1547*cdf0e10cSrcweir                     aValue,
1548*cdf0e10cSrcweir                     aOldValue,
1549*cdf0e10cSrcweir                     aConvertedValue);
1550*cdf0e10cSrcweir                 break;
1551*cdf0e10cSrcweir 	}
1552*cdf0e10cSrcweir 
1553*cdf0e10cSrcweir 	// Return state of operation.
1554*cdf0e10cSrcweir 	return bReturn ;
1555*cdf0e10cSrcweir }
1556*cdf0e10cSrcweir 
1557*cdf0e10cSrcweir /*-************************************************************************************************************//**
1558*cdf0e10cSrcweir     @short      set value of a transient property
1559*cdf0e10cSrcweir     @descr      This method is calling from helperclass "OPropertySetHelper".
1560*cdf0e10cSrcweir                 Don't use this directly!
1561*cdf0e10cSrcweir                 Handle and value are valid everyway! You must set the new value only.
1562*cdf0e10cSrcweir                 After this, baseclass send messages to all listener automaticly.
1563*cdf0e10cSrcweir 
1564*cdf0e10cSrcweir     @seealso    class OPropertySetHelper
1565*cdf0e10cSrcweir 
1566*cdf0e10cSrcweir     @param      "nHandle"   handle of property to change
1567*cdf0e10cSrcweir     @param      "aValue"    new value of property
1568*cdf0e10cSrcweir     @return     -
1569*cdf0e10cSrcweir 
1570*cdf0e10cSrcweir     @onerror    An exception is thrown.
1571*cdf0e10cSrcweir     @threadsafe yes
1572*cdf0e10cSrcweir *//*-*************************************************************************************************************/
1573*cdf0e10cSrcweir void SAL_CALL Desktop::setFastPropertyValue_NoBroadcast(       sal_Int32        nHandle ,
1574*cdf0e10cSrcweir                                                          const css::uno::Any&   aValue  ) throw( css::uno::Exception )
1575*cdf0e10cSrcweir {
1576*cdf0e10cSrcweir 	/* UNSAFE AREA --------------------------------------------------------------------------------------------- */
1577*cdf0e10cSrcweir     // Register transaction and reject wrong calls.
1578*cdf0e10cSrcweir     TransactionGuard aTransaction( m_aTransactionManager, E_HARDEXCEPTIONS );
1579*cdf0e10cSrcweir 
1580*cdf0e10cSrcweir     switch( nHandle )
1581*cdf0e10cSrcweir 	{
1582*cdf0e10cSrcweir         case DESKTOP_PROPHANDLE_SUSPENDQUICKSTARTVETO:    aValue >>= m_bSuspendQuickstartVeto;
1583*cdf0e10cSrcweir 													break;
1584*cdf0e10cSrcweir         case DESKTOP_PROPHANDLE_DISPATCHRECORDERSUPPLIER:    aValue >>= m_xDispatchRecorderSupplier;
1585*cdf0e10cSrcweir                                                     break;
1586*cdf0e10cSrcweir         case DESKTOP_PROPHANDLE_TITLE:    aValue >>= m_sTitle;
1587*cdf0e10cSrcweir                                                     break;
1588*cdf0e10cSrcweir 	}
1589*cdf0e10cSrcweir }
1590*cdf0e10cSrcweir 
1591*cdf0e10cSrcweir /*-************************************************************************************************************//**
1592*cdf0e10cSrcweir     @short      get value of a transient property
1593*cdf0e10cSrcweir     @descr      This method is calling from helperclass "OPropertySetHelper".
1594*cdf0e10cSrcweir                 Don't use this directly!
1595*cdf0e10cSrcweir 
1596*cdf0e10cSrcweir     @attention  We don't need any mutex or lock here ... We use threadsafe container or methods here only!
1597*cdf0e10cSrcweir 
1598*cdf0e10cSrcweir     @seealso    class OPropertySetHelper
1599*cdf0e10cSrcweir 
1600*cdf0e10cSrcweir     @param      "nHandle"   handle of property to change
1601*cdf0e10cSrcweir     @param      "aValue"    current value of property
1602*cdf0e10cSrcweir     @return     -
1603*cdf0e10cSrcweir 
1604*cdf0e10cSrcweir     @onerror    -
1605*cdf0e10cSrcweir     @threadsafe yes
1606*cdf0e10cSrcweir *//*-*************************************************************************************************************/
1607*cdf0e10cSrcweir void SAL_CALL Desktop::getFastPropertyValue( css::uno::Any& aValue  ,
1608*cdf0e10cSrcweir                                              sal_Int32      nHandle ) const
1609*cdf0e10cSrcweir {
1610*cdf0e10cSrcweir 	/* UNSAFE AREA --------------------------------------------------------------------------------------------- */
1611*cdf0e10cSrcweir     // Register transaction and reject wrong calls.
1612*cdf0e10cSrcweir     TransactionGuard aTransaction( m_aTransactionManager, E_HARDEXCEPTIONS );
1613*cdf0e10cSrcweir 
1614*cdf0e10cSrcweir     switch( nHandle )
1615*cdf0e10cSrcweir 	{
1616*cdf0e10cSrcweir         case DESKTOP_PROPHANDLE_ACTIVEFRAME           :   aValue <<= m_aChildTaskContainer.getActive();
1617*cdf0e10cSrcweir 													break;
1618*cdf0e10cSrcweir         case DESKTOP_PROPHANDLE_ISPLUGGED           :   aValue <<= sal_False;
1619*cdf0e10cSrcweir 													break;
1620*cdf0e10cSrcweir         case DESKTOP_PROPHANDLE_SUSPENDQUICKSTARTVETO:    aValue <<= m_bSuspendQuickstartVeto;
1621*cdf0e10cSrcweir 													break;
1622*cdf0e10cSrcweir         case DESKTOP_PROPHANDLE_DISPATCHRECORDERSUPPLIER:    aValue <<= m_xDispatchRecorderSupplier;
1623*cdf0e10cSrcweir                                                     break;
1624*cdf0e10cSrcweir         case DESKTOP_PROPHANDLE_TITLE:    aValue <<= m_sTitle;
1625*cdf0e10cSrcweir                                                     break;
1626*cdf0e10cSrcweir 	}
1627*cdf0e10cSrcweir }
1628*cdf0e10cSrcweir 
1629*cdf0e10cSrcweir /*-************************************************************************************************************//**
1630*cdf0e10cSrcweir     @short      return structure and information about transient properties
1631*cdf0e10cSrcweir     @descr      This method is calling from helperclass "OPropertySetHelper".
1632*cdf0e10cSrcweir                 Don't use this directly!
1633*cdf0e10cSrcweir 
1634*cdf0e10cSrcweir     @attention  You must use global lock (method use static variable) ... and it must be the shareable osl mutex of it.
1635*cdf0e10cSrcweir                 Because; our baseclass use this mutex to make his code threadsafe. We use our lock!
1636*cdf0e10cSrcweir                 So we could have two different mutex/lock mechanism at the same object.
1637*cdf0e10cSrcweir 
1638*cdf0e10cSrcweir     @seealso    class OPropertySetHelper
1639*cdf0e10cSrcweir 
1640*cdf0e10cSrcweir     @param      -
1641*cdf0e10cSrcweir     @return     structure with property-informations
1642*cdf0e10cSrcweir 
1643*cdf0e10cSrcweir     @onerror    -
1644*cdf0e10cSrcweir     @threadsafe yes
1645*cdf0e10cSrcweir *//*-*************************************************************************************************************/
1646*cdf0e10cSrcweir ::cppu::IPropertyArrayHelper& SAL_CALL Desktop::getInfoHelper()
1647*cdf0e10cSrcweir {
1648*cdf0e10cSrcweir 	/* UNSAFE AREA --------------------------------------------------------------------------------------------- */
1649*cdf0e10cSrcweir     // Register transaction and reject wrong calls.
1650*cdf0e10cSrcweir     TransactionGuard aTransaction( m_aTransactionManager, E_HARDEXCEPTIONS );
1651*cdf0e10cSrcweir 
1652*cdf0e10cSrcweir 	// Optimize this method !
1653*cdf0e10cSrcweir 	// We initialize a static variable only one time. And we don't must use a mutex at every call!
1654*cdf0e10cSrcweir 	// For the first call; pInfoHelper is NULL - for the second call pInfoHelper is different from NULL!
1655*cdf0e10cSrcweir     static ::cppu::OPropertyArrayHelper* pInfoHelper = NULL;
1656*cdf0e10cSrcweir 
1657*cdf0e10cSrcweir     if( pInfoHelper == NULL )
1658*cdf0e10cSrcweir 	{
1659*cdf0e10cSrcweir 		// Ready for multithreading
1660*cdf0e10cSrcweir         ::osl::MutexGuard aGuard( LockHelper::getGlobalLock().getShareableOslMutex() );
1661*cdf0e10cSrcweir 		// Control this pointer again, another instance can be faster then these!
1662*cdf0e10cSrcweir         if( pInfoHelper == NULL )
1663*cdf0e10cSrcweir 		{
1664*cdf0e10cSrcweir 			// Define static member to give structure of properties to baseclass "OPropertySetHelper".
1665*cdf0e10cSrcweir 			// "impl_getStaticPropertyDescriptor" is a non exported and static funtion, who will define a static propertytable.
1666*cdf0e10cSrcweir 			// "sal_True" say: Table is sorted by name.
1667*cdf0e10cSrcweir             static ::cppu::OPropertyArrayHelper aInfoHelper( impl_getStaticPropertyDescriptor(), sal_True );
1668*cdf0e10cSrcweir 			pInfoHelper = &aInfoHelper;
1669*cdf0e10cSrcweir 		}
1670*cdf0e10cSrcweir 	}
1671*cdf0e10cSrcweir 
1672*cdf0e10cSrcweir     return(*pInfoHelper);
1673*cdf0e10cSrcweir }
1674*cdf0e10cSrcweir 
1675*cdf0e10cSrcweir /*-************************************************************************************************************//**
1676*cdf0e10cSrcweir     @short      return propertysetinfo
1677*cdf0e10cSrcweir     @descr      You can call this method to get information about transient properties
1678*cdf0e10cSrcweir                 of this object.
1679*cdf0e10cSrcweir 
1680*cdf0e10cSrcweir     @attention  You must use global lock (method use static variable) ... and it must be the shareable osl mutex of it.
1681*cdf0e10cSrcweir                 Because; our baseclass use this mutex to make his code threadsafe. We use our lock!
1682*cdf0e10cSrcweir                 So we could have two different mutex/lock mechanism at the same object.
1683*cdf0e10cSrcweir 
1684*cdf0e10cSrcweir     @seealso    class OPropertySetHelper
1685*cdf0e10cSrcweir     @seealso    interface XPropertySet
1686*cdf0e10cSrcweir     @seealso    interface XMultiPropertySet
1687*cdf0e10cSrcweir 
1688*cdf0e10cSrcweir     @param      -
1689*cdf0e10cSrcweir     @return     reference to object with information [XPropertySetInfo]
1690*cdf0e10cSrcweir 
1691*cdf0e10cSrcweir     @onerror    -
1692*cdf0e10cSrcweir     @threadsafe yes
1693*cdf0e10cSrcweir *//*-*************************************************************************************************************/
1694*cdf0e10cSrcweir css::uno::Reference< css::beans::XPropertySetInfo > SAL_CALL Desktop::getPropertySetInfo() throw (::com::sun::star::uno::RuntimeException)
1695*cdf0e10cSrcweir {
1696*cdf0e10cSrcweir 	/* UNSAFE AREA --------------------------------------------------------------------------------------------- */
1697*cdf0e10cSrcweir     // Register transaction and reject wrong calls.
1698*cdf0e10cSrcweir     TransactionGuard aTransaction( m_aTransactionManager, E_HARDEXCEPTIONS );
1699*cdf0e10cSrcweir 
1700*cdf0e10cSrcweir 	// Optimize this method !
1701*cdf0e10cSrcweir 	// We initialize a static variable only one time. And we don't must use a mutex at every call!
1702*cdf0e10cSrcweir 	// For the first call; pInfo is NULL - for the second call pInfo is different from NULL!
1703*cdf0e10cSrcweir     static css::uno::Reference< css::beans::XPropertySetInfo >* pInfo = NULL;
1704*cdf0e10cSrcweir 
1705*cdf0e10cSrcweir     if( pInfo == NULL )
1706*cdf0e10cSrcweir 	{
1707*cdf0e10cSrcweir 		// Ready for multithreading
1708*cdf0e10cSrcweir         ::osl::MutexGuard aGuard( LockHelper::getGlobalLock().getShareableOslMutex() );
1709*cdf0e10cSrcweir 		// Control this pointer again, another instance can be faster then these!
1710*cdf0e10cSrcweir         if( pInfo == NULL )
1711*cdf0e10cSrcweir 		{
1712*cdf0e10cSrcweir 			// Create structure of propertysetinfo for baseclass "OPropertySetHelper".
1713*cdf0e10cSrcweir 			// (Use method "getInfoHelper()".)
1714*cdf0e10cSrcweir             static css::uno::Reference< css::beans::XPropertySetInfo > xInfo( createPropertySetInfo( getInfoHelper() ) );
1715*cdf0e10cSrcweir 			pInfo = &xInfo;
1716*cdf0e10cSrcweir 		}
1717*cdf0e10cSrcweir 	}
1718*cdf0e10cSrcweir 
1719*cdf0e10cSrcweir 	return (*pInfo);
1720*cdf0e10cSrcweir }
1721*cdf0e10cSrcweir 
1722*cdf0e10cSrcweir /*-************************************************************************************************************//**
1723*cdf0e10cSrcweir     @short      return current component of current frame
1724*cdf0e10cSrcweir     @descr      The desktop himself has no component. But every frame in subtree.
1725*cdf0e10cSrcweir                 If somewhere call getCurrentComponent() at this class, we try to find the right frame and
1726*cdf0e10cSrcweir                 then we try to become his component. It can be a VCL-component, the model or the controller
1727*cdf0e10cSrcweir                 of founded frame.
1728*cdf0e10cSrcweir 
1729*cdf0e10cSrcweir     @attention  We don't work on internal member ... so we doesn't need any lock here.
1730*cdf0e10cSrcweir 
1731*cdf0e10cSrcweir     @seealso    method getCurrentComponent();
1732*cdf0e10cSrcweir 
1733*cdf0e10cSrcweir     @param      "xFrame", reference to valid frame in hierarchy. Method is not defined for invalid values.
1734*cdf0e10cSrcweir                 But we don't check these. Its an IMPL-method and caller must use it right!
1735*cdf0e10cSrcweir     @return     A reference to found component.
1736*cdf0e10cSrcweir 
1737*cdf0e10cSrcweir     @onerror    A null reference is returned.
1738*cdf0e10cSrcweir     @threadsafe yes
1739*cdf0e10cSrcweir *//*-*************************************************************************************************************/
1740*cdf0e10cSrcweir css::uno::Reference< css::lang::XComponent > Desktop::impl_getFrameComponent( const css::uno::Reference< css::frame::XFrame >& xFrame ) const
1741*cdf0e10cSrcweir {
1742*cdf0e10cSrcweir 	/* UNSAFE AREA --------------------------------------------------------------------------------------------- */
1743*cdf0e10cSrcweir     // Register transaction and reject wrong calls.
1744*cdf0e10cSrcweir     TransactionGuard aTransaction( m_aTransactionManager, E_HARDEXCEPTIONS );
1745*cdf0e10cSrcweir 
1746*cdf0e10cSrcweir 	// Set default return value, if method failed.
1747*cdf0e10cSrcweir     css::uno::Reference< css::lang::XComponent > xComponent;
1748*cdf0e10cSrcweir 	// Does no controller exists?
1749*cdf0e10cSrcweir     css::uno::Reference< css::frame::XController > xController = xFrame->getController();
1750*cdf0e10cSrcweir     if( xController.is() == sal_False )
1751*cdf0e10cSrcweir 	{
1752*cdf0e10cSrcweir 		// Controller not exist - use the VCL-component.
1753*cdf0e10cSrcweir         xComponent = css::uno::Reference< css::lang::XComponent >( xFrame->getComponentWindow(), css::uno::UNO_QUERY );
1754*cdf0e10cSrcweir 	}
1755*cdf0e10cSrcweir 	else
1756*cdf0e10cSrcweir 	{
1757*cdf0e10cSrcweir 		// Does no model exists?
1758*cdf0e10cSrcweir         css::uno::Reference< css::frame::XModel > xModel( xController->getModel(), css::uno::UNO_QUERY );
1759*cdf0e10cSrcweir         if( xModel.is() == sal_True )
1760*cdf0e10cSrcweir 		{
1761*cdf0e10cSrcweir 			// Model exist - use the model as component.
1762*cdf0e10cSrcweir             xComponent = css::uno::Reference< css::lang::XComponent >( xModel, css::uno::UNO_QUERY );
1763*cdf0e10cSrcweir 		}
1764*cdf0e10cSrcweir 		else
1765*cdf0e10cSrcweir 		{
1766*cdf0e10cSrcweir 			// Model not exist - use the controller as component.
1767*cdf0e10cSrcweir             xComponent = css::uno::Reference< css::lang::XComponent >( xController, css::uno::UNO_QUERY );
1768*cdf0e10cSrcweir 		}
1769*cdf0e10cSrcweir 	}
1770*cdf0e10cSrcweir 
1771*cdf0e10cSrcweir 	return xComponent;
1772*cdf0e10cSrcweir }
1773*cdf0e10cSrcweir 
1774*cdf0e10cSrcweir /*-************************************************************************************************************//**
1775*cdf0e10cSrcweir     @short      create table with information about properties
1776*cdf0e10cSrcweir     @descr      We use a helper class to support properties. These class need some information about this.
1777*cdf0e10cSrcweir                 These method create a new static description table with name, type, r/w-flags and so on ...
1778*cdf0e10cSrcweir 
1779*cdf0e10cSrcweir     @seealso    class OPropertySetHelper
1780*cdf0e10cSrcweir     @seealso    method getInfoHelper()
1781*cdf0e10cSrcweir 
1782*cdf0e10cSrcweir     @param      -
1783*cdf0e10cSrcweir     @return     Static table with information about properties.
1784*cdf0e10cSrcweir 
1785*cdf0e10cSrcweir     @onerror    -
1786*cdf0e10cSrcweir     @threadsafe yes
1787*cdf0e10cSrcweir *//*-*************************************************************************************************************/
1788*cdf0e10cSrcweir const css::uno::Sequence< css::beans::Property > Desktop::impl_getStaticPropertyDescriptor()
1789*cdf0e10cSrcweir {
1790*cdf0e10cSrcweir 	// Create a new static property array to initialize sequence!
1791*cdf0e10cSrcweir 	// Table of all predefined properties of this class. Its used from OPropertySetHelper-class!
1792*cdf0e10cSrcweir 	// Don't forget to change the defines (see begin of this file), if you add, change or delete a property in this list!!!
1793*cdf0e10cSrcweir 	// It's necessary for methods of OPropertySetHelper.
1794*cdf0e10cSrcweir 	// ATTENTION:
1795*cdf0e10cSrcweir     //      YOU MUST SORT FOLLOW TABLE BY NAME ALPHABETICAL !!!
1796*cdf0e10cSrcweir 
1797*cdf0e10cSrcweir     static const css::beans::Property pProperties[] =
1798*cdf0e10cSrcweir 	{
1799*cdf0e10cSrcweir         css::beans::Property( DESKTOP_PROPNAME_ACTIVEFRAME              , DESKTOP_PROPHANDLE_ACTIVEFRAME             , ::getCppuType((const css::uno::Reference< css::lang::XComponent >*)NULL)                , css::beans::PropertyAttribute::TRANSIENT | css::beans::PropertyAttribute::READONLY ),
1800*cdf0e10cSrcweir         css::beans::Property( DESKTOP_PROPNAME_DISPATCHRECORDERSUPPLIER , DESKTOP_PROPHANDLE_DISPATCHRECORDERSUPPLIER, ::getCppuType((const css::uno::Reference< css::frame::XDispatchRecorderSupplier >*)NULL), css::beans::PropertyAttribute::TRANSIENT ),
1801*cdf0e10cSrcweir         css::beans::Property( DESKTOP_PROPNAME_ISPLUGGED                , DESKTOP_PROPHANDLE_ISPLUGGED               , ::getBooleanCppuType()                                                                  , css::beans::PropertyAttribute::TRANSIENT | css::beans::PropertyAttribute::READONLY ),
1802*cdf0e10cSrcweir         css::beans::Property( DESKTOP_PROPNAME_SUSPENDQUICKSTARTVETO    , DESKTOP_PROPHANDLE_SUSPENDQUICKSTARTVETO   , ::getBooleanCppuType()                                                                  , css::beans::PropertyAttribute::TRANSIENT ),
1803*cdf0e10cSrcweir         css::beans::Property( DESKTOP_PROPNAME_TITLE                    , DESKTOP_PROPHANDLE_TITLE                   , ::getCppuType((const ::rtl::OUString*)NULL)                                             , css::beans::PropertyAttribute::TRANSIENT ),
1804*cdf0e10cSrcweir 	};
1805*cdf0e10cSrcweir 	// Use it to initialize sequence!
1806*cdf0e10cSrcweir     static const css::uno::Sequence< css::beans::Property > lPropertyDescriptor( pProperties, DESKTOP_PROPCOUNT );
1807*cdf0e10cSrcweir 	// Return static "PropertyDescriptor"
1808*cdf0e10cSrcweir     return lPropertyDescriptor;
1809*cdf0e10cSrcweir }
1810*cdf0e10cSrcweir 
1811*cdf0e10cSrcweir //=============================================================================
1812*cdf0e10cSrcweir void Desktop::impl_sendQueryTerminationEvent(Desktop::TTerminateListenerList& lCalledListener,
1813*cdf0e10cSrcweir                                              ::sal_Bool&                      bVeto          )
1814*cdf0e10cSrcweir {
1815*cdf0e10cSrcweir     bVeto = sal_False;
1816*cdf0e10cSrcweir 
1817*cdf0e10cSrcweir     TransactionGuard aTransaction( m_aTransactionManager, E_HARDEXCEPTIONS );
1818*cdf0e10cSrcweir 
1819*cdf0e10cSrcweir     ::cppu::OInterfaceContainerHelper* pContainer = m_aListenerContainer.getContainer( ::getCppuType( ( const css::uno::Reference< css::frame::XTerminateListener >*) NULL ) );
1820*cdf0e10cSrcweir 	if ( ! pContainer )
1821*cdf0e10cSrcweir         return;
1822*cdf0e10cSrcweir 
1823*cdf0e10cSrcweir     css::lang::EventObject aEvent( static_cast< ::cppu::OWeakObject* >(this) );
1824*cdf0e10cSrcweir 
1825*cdf0e10cSrcweir     ::cppu::OInterfaceIteratorHelper aIterator( *pContainer );
1826*cdf0e10cSrcweir     while ( aIterator.hasMoreElements() )
1827*cdf0e10cSrcweir     {
1828*cdf0e10cSrcweir         try
1829*cdf0e10cSrcweir         {
1830*cdf0e10cSrcweir             css::uno::Reference< css::frame::XTerminateListener > xListener(aIterator.next(), css::uno::UNO_QUERY);
1831*cdf0e10cSrcweir             if ( ! xListener.is() )
1832*cdf0e10cSrcweir                 continue;
1833*cdf0e10cSrcweir             xListener->queryTermination( aEvent );
1834*cdf0e10cSrcweir             lCalledListener.push_back(xListener);
1835*cdf0e10cSrcweir         }
1836*cdf0e10cSrcweir         catch( const css::frame::TerminationVetoException& )
1837*cdf0e10cSrcweir         {
1838*cdf0e10cSrcweir             // first veto will stop notification loop.
1839*cdf0e10cSrcweir             bVeto = sal_True;
1840*cdf0e10cSrcweir             return;
1841*cdf0e10cSrcweir         }
1842*cdf0e10cSrcweir         catch( const css::uno::Exception& )
1843*cdf0e10cSrcweir         {
1844*cdf0e10cSrcweir             // clean up container.
1845*cdf0e10cSrcweir             // E.g. dead remote listener objects can make trouble otherwise.
1846*cdf0e10cSrcweir             // Iterator implementation allows removing objects during it's used !
1847*cdf0e10cSrcweir             aIterator.remove();
1848*cdf0e10cSrcweir         }
1849*cdf0e10cSrcweir     }
1850*cdf0e10cSrcweir }
1851*cdf0e10cSrcweir 
1852*cdf0e10cSrcweir //=============================================================================
1853*cdf0e10cSrcweir void Desktop::impl_sendCancelTerminationEvent(const Desktop::TTerminateListenerList& lCalledListener)
1854*cdf0e10cSrcweir {
1855*cdf0e10cSrcweir     TransactionGuard aTransaction( m_aTransactionManager, E_HARDEXCEPTIONS );
1856*cdf0e10cSrcweir 
1857*cdf0e10cSrcweir     css::lang::EventObject                          aEvent( static_cast< ::cppu::OWeakObject* >(this) );
1858*cdf0e10cSrcweir     Desktop::TTerminateListenerList::const_iterator pIt;
1859*cdf0e10cSrcweir     for (  pIt  = lCalledListener.begin();
1860*cdf0e10cSrcweir            pIt != lCalledListener.end  ();
1861*cdf0e10cSrcweir          ++pIt                           )
1862*cdf0e10cSrcweir     {
1863*cdf0e10cSrcweir         try
1864*cdf0e10cSrcweir         {
1865*cdf0e10cSrcweir             // Note: cancelTermination() is a new and optional interface method !
1866*cdf0e10cSrcweir             css::uno::Reference< css::frame::XTerminateListener  > xListener           = *pIt;
1867*cdf0e10cSrcweir             css::uno::Reference< css::frame::XTerminateListener2 > xListenerGeneration2(xListener, css::uno::UNO_QUERY);
1868*cdf0e10cSrcweir             if ( ! xListenerGeneration2.is() )
1869*cdf0e10cSrcweir                 continue;
1870*cdf0e10cSrcweir             xListenerGeneration2->cancelTermination( aEvent );
1871*cdf0e10cSrcweir         }
1872*cdf0e10cSrcweir         catch( const css::uno::Exception& )
1873*cdf0e10cSrcweir         {}
1874*cdf0e10cSrcweir     }
1875*cdf0e10cSrcweir }
1876*cdf0e10cSrcweir 
1877*cdf0e10cSrcweir //=============================================================================
1878*cdf0e10cSrcweir void Desktop::impl_sendNotifyTerminationEvent()
1879*cdf0e10cSrcweir {
1880*cdf0e10cSrcweir     TransactionGuard aTransaction( m_aTransactionManager, E_HARDEXCEPTIONS );
1881*cdf0e10cSrcweir 
1882*cdf0e10cSrcweir     ::cppu::OInterfaceContainerHelper* pContainer = m_aListenerContainer.getContainer( ::getCppuType( ( const css::uno::Reference< css::frame::XTerminateListener >*) NULL ) );
1883*cdf0e10cSrcweir 	if ( ! pContainer )
1884*cdf0e10cSrcweir         return;
1885*cdf0e10cSrcweir 
1886*cdf0e10cSrcweir     css::lang::EventObject aEvent( static_cast< ::cppu::OWeakObject* >(this) );
1887*cdf0e10cSrcweir 
1888*cdf0e10cSrcweir     ::cppu::OInterfaceIteratorHelper aIterator( *pContainer );
1889*cdf0e10cSrcweir     while ( aIterator.hasMoreElements() )
1890*cdf0e10cSrcweir     {
1891*cdf0e10cSrcweir         try
1892*cdf0e10cSrcweir         {
1893*cdf0e10cSrcweir             css::uno::Reference< css::frame::XTerminateListener > xListener(aIterator.next(), css::uno::UNO_QUERY);
1894*cdf0e10cSrcweir             if ( ! xListener.is() )
1895*cdf0e10cSrcweir                 continue;
1896*cdf0e10cSrcweir             xListener->notifyTermination( aEvent );
1897*cdf0e10cSrcweir         }
1898*cdf0e10cSrcweir         catch( const css::uno::Exception& )
1899*cdf0e10cSrcweir         {
1900*cdf0e10cSrcweir             // clean up container.
1901*cdf0e10cSrcweir             // E.g. dead remote listener objects can make trouble otherwise.
1902*cdf0e10cSrcweir             // Iterator implementation allows removing objects during it's used !
1903*cdf0e10cSrcweir             aIterator.remove();
1904*cdf0e10cSrcweir         }
1905*cdf0e10cSrcweir     }
1906*cdf0e10cSrcweir }
1907*cdf0e10cSrcweir 
1908*cdf0e10cSrcweir //=============================================================================
1909*cdf0e10cSrcweir ::sal_Bool Desktop::impl_closeFrames(::sal_Bool bAllowUI)
1910*cdf0e10cSrcweir {
1911*cdf0e10cSrcweir     SYNCHRONIZED_START
1912*cdf0e10cSrcweir         ReadGuard aReadLock( m_aLock );
1913*cdf0e10cSrcweir         css::uno::Sequence< css::uno::Reference< css::frame::XFrame > > lFrames = m_aChildTaskContainer.getAllElements();
1914*cdf0e10cSrcweir         aReadLock.unlock();
1915*cdf0e10cSrcweir     SYNCHRONIZED_END
1916*cdf0e10cSrcweir 
1917*cdf0e10cSrcweir     ::sal_Int32 c                = lFrames.getLength();
1918*cdf0e10cSrcweir     ::sal_Int32 i                = 0;
1919*cdf0e10cSrcweir     ::sal_Int32 nNonClosedFrames = 0;
1920*cdf0e10cSrcweir 
1921*cdf0e10cSrcweir     for( i=0; i<c; ++i )
1922*cdf0e10cSrcweir     {
1923*cdf0e10cSrcweir         try
1924*cdf0e10cSrcweir         {
1925*cdf0e10cSrcweir             css::uno::Reference< css::frame::XFrame > xFrame = lFrames[i];
1926*cdf0e10cSrcweir 
1927*cdf0e10cSrcweir             // XController.suspend() will show an UI ...
1928*cdf0e10cSrcweir             // Use it in case it was allowed from outside only.
1929*cdf0e10cSrcweir             sal_Bool                                       bSuspended = sal_False;
1930*cdf0e10cSrcweir             css::uno::Reference< css::frame::XController > xController( xFrame->getController(), css::uno::UNO_QUERY );
1931*cdf0e10cSrcweir             if (
1932*cdf0e10cSrcweir                 ( bAllowUI         ) &&
1933*cdf0e10cSrcweir                 ( xController.is() )
1934*cdf0e10cSrcweir                )
1935*cdf0e10cSrcweir             {
1936*cdf0e10cSrcweir                 bSuspended = xController->suspend( sal_True );
1937*cdf0e10cSrcweir                 if ( ! bSuspended )
1938*cdf0e10cSrcweir                 {
1939*cdf0e10cSrcweir                     ++nNonClosedFrames;
1940*cdf0e10cSrcweir                     continue;
1941*cdf0e10cSrcweir                 }
1942*cdf0e10cSrcweir             }
1943*cdf0e10cSrcweir 
1944*cdf0e10cSrcweir             // Try to close frame (in case no UI was allowed without calling XController->suspend() before!)
1945*cdf0e10cSrcweir             // But don't deliver ownership to any other one!
1946*cdf0e10cSrcweir             // This method can be called again.
1947*cdf0e10cSrcweir             css::uno::Reference< css::util::XCloseable > xClose( xFrame, css::uno::UNO_QUERY );
1948*cdf0e10cSrcweir             if ( xClose.is() )
1949*cdf0e10cSrcweir             {
1950*cdf0e10cSrcweir                 try
1951*cdf0e10cSrcweir                 {
1952*cdf0e10cSrcweir                     xClose->close(sal_False);
1953*cdf0e10cSrcweir                 }
1954*cdf0e10cSrcweir                 catch(const css::util::CloseVetoException&)
1955*cdf0e10cSrcweir                 {
1956*cdf0e10cSrcweir                     // Any internal process of this frame disagree with our request.
1957*cdf0e10cSrcweir                     // Safe this state but dont break these loop. Other frames has to be closed!
1958*cdf0e10cSrcweir                     ++nNonClosedFrames;
1959*cdf0e10cSrcweir 
1960*cdf0e10cSrcweir                     // Reactivate controller.
1961*cdf0e10cSrcweir                     // It can happen that XController.suspend() returned true ... but a registered close listener
1962*cdf0e10cSrcweir                     // throwed these veto exception. Then the controller has to be reactivated. Otherwise
1963*cdf0e10cSrcweir                     // these document doesnt work any more.
1964*cdf0e10cSrcweir                     if (
1965*cdf0e10cSrcweir                         (bSuspended      ) &&
1966*cdf0e10cSrcweir                         (xController.is())
1967*cdf0e10cSrcweir                        )
1968*cdf0e10cSrcweir                         xController->suspend(sal_False);
1969*cdf0e10cSrcweir                 }
1970*cdf0e10cSrcweir 
1971*cdf0e10cSrcweir                 // If interface XClosable interface exists and was used ...
1972*cdf0e10cSrcweir                 // it's not allowed to use XComponent->dispose() also !
1973*cdf0e10cSrcweir                 continue;
1974*cdf0e10cSrcweir             }
1975*cdf0e10cSrcweir 
1976*cdf0e10cSrcweir             // XClosable not supported ?
1977*cdf0e10cSrcweir             // Then we have to dispose these frame hardly.
1978*cdf0e10cSrcweir             css::uno::Reference< css::lang::XComponent > xDispose( xFrame, css::uno::UNO_QUERY );
1979*cdf0e10cSrcweir             if ( xDispose.is() )
1980*cdf0e10cSrcweir                 xDispose->dispose();
1981*cdf0e10cSrcweir 
1982*cdf0e10cSrcweir             // Don't remove these frame from our child container!
1983*cdf0e10cSrcweir             // A frame do it by itself inside close()/dispose() method.
1984*cdf0e10cSrcweir         }
1985*cdf0e10cSrcweir         catch(const css::lang::DisposedException&)
1986*cdf0e10cSrcweir         {
1987*cdf0e10cSrcweir             // Dispose frames are closed frames.
1988*cdf0e10cSrcweir             // So we can count it here .-)
1989*cdf0e10cSrcweir         }
1990*cdf0e10cSrcweir     }
1991*cdf0e10cSrcweir 
1992*cdf0e10cSrcweir     return (nNonClosedFrames < 1);
1993*cdf0e10cSrcweir }
1994*cdf0e10cSrcweir 
1995*cdf0e10cSrcweir //_________________________________________________________________________________________________________________
1996*cdf0e10cSrcweir //	debug methods
1997*cdf0e10cSrcweir //_________________________________________________________________________________________________________________
1998*cdf0e10cSrcweir 
1999*cdf0e10cSrcweir /*-----------------------------------------------------------------------------------------------------------------
2000*cdf0e10cSrcweir 	The follow methods checks the parameter for other functions. If a parameter or his value is non valid,
2001*cdf0e10cSrcweir     we return "sal_True". (otherwise sal_False) This mechanism is used to throw an ASSERT!
2002*cdf0e10cSrcweir -----------------------------------------------------------------------------------------------------------------*/
2003*cdf0e10cSrcweir 
2004*cdf0e10cSrcweir #ifdef ENABLE_ASSERTIONS
2005*cdf0e10cSrcweir 
2006*cdf0e10cSrcweir //*****************************************************************************************************************
2007*cdf0e10cSrcweir //	We work with valid servicemanager only.
2008*cdf0e10cSrcweir sal_Bool Desktop::implcp_ctor( const css::uno::Reference< css::lang::XMultiServiceFactory >& xFactory )
2009*cdf0e10cSrcweir {
2010*cdf0e10cSrcweir     return(
2011*cdf0e10cSrcweir 			( &xFactory		==	NULL		)	||
2012*cdf0e10cSrcweir 			( xFactory.is()	==	sal_False	)
2013*cdf0e10cSrcweir           );
2014*cdf0e10cSrcweir }
2015*cdf0e10cSrcweir 
2016*cdf0e10cSrcweir //*****************************************************************************************************************
2017*cdf0e10cSrcweir //	We work with valid listener only.
2018*cdf0e10cSrcweir sal_Bool Desktop::implcp_addEventListener( const css::uno::Reference< css::lang::XEventListener >& xListener )
2019*cdf0e10cSrcweir {
2020*cdf0e10cSrcweir     return(
2021*cdf0e10cSrcweir 			( &xListener		==	NULL		)	||
2022*cdf0e10cSrcweir 			( xListener.is()	==	sal_False	)
2023*cdf0e10cSrcweir           );
2024*cdf0e10cSrcweir }
2025*cdf0e10cSrcweir 
2026*cdf0e10cSrcweir //*****************************************************************************************************************
2027*cdf0e10cSrcweir //	We work with valid listener only.
2028*cdf0e10cSrcweir sal_Bool Desktop::implcp_removeEventListener( const css::uno::Reference< css::lang::XEventListener >& xListener )
2029*cdf0e10cSrcweir {
2030*cdf0e10cSrcweir     return(
2031*cdf0e10cSrcweir 			( &xListener		==	NULL		)	||
2032*cdf0e10cSrcweir 			( xListener.is()	==	sal_False	)
2033*cdf0e10cSrcweir           );
2034*cdf0e10cSrcweir }
2035*cdf0e10cSrcweir 
2036*cdf0e10cSrcweir #endif	// #ifdef ENABLE_ASSERTIONS
2037*cdf0e10cSrcweir 
2038*cdf0e10cSrcweir }	// namespace framework
2039