1 /*************************************************************************
2  *
3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4  *
5  * Copyright 2000, 2010 Oracle and/or its affiliates.
6  *
7  * OpenOffice.org - a multi-platform office productivity suite
8  *
9  * This file is part of OpenOffice.org.
10  *
11  * OpenOffice.org is free software: you can redistribute it and/or modify
12  * it under the terms of the GNU Lesser General Public License version 3
13  * only, as published by the Free Software Foundation.
14  *
15  * OpenOffice.org is distributed in the hope that it will be useful,
16  * but WITHOUT ANY WARRANTY; without even the implied warranty of
17  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
18  * GNU Lesser General Public License version 3 for more details
19  * (a copy is included in the LICENSE file that accompanied this code).
20  *
21  * You should have received a copy of the GNU Lesser General Public License
22  * version 3 along with OpenOffice.org.  If not, see
23  * <http://www.openoffice.org/license.html>
24  * for a copy of the LGPLv3 License.
25  *
26  ************************************************************************/
27 
28 // MARKER(update_precomp.py): autogen include statement, do not remove
29 #include "precompiled_framework.hxx"
30 
31 //_________________________________________________________________________________________________________________
32 //	my own includes
33 //_________________________________________________________________________________________________________________
34 #include <services/frame.hxx>
35 #include <dispatch/dispatchprovider.hxx>
36 
37 #ifndef __FRAMEWORK_DISPATCH_INTERCEPTIONHELPER_HXX_
38 #include <dispatch/interceptionhelper.hxx>
39 #endif
40 #include <dispatch/closedispatcher.hxx>
41 #include <dispatch/windowcommanddispatch.hxx>
42 #include <loadenv/loadenv.hxx>
43 #include <helper/oframes.hxx>
44 #include <helper/statusindicatorfactory.hxx>
45 #include <framework/titlehelper.hxx>
46 #include <classes/droptargetlistener.hxx>
47 #include <classes/taskcreator.hxx>
48 #include <loadenv/targethelper.hxx>
49 #include <framework/framelistanalyzer.hxx>
50 #include <helper/dockingareadefaultacceptor.hxx>
51 #include <dispatch/dispatchinformationprovider.hxx>
52 #include <threadhelp/transactionguard.hxx>
53 #include <pattern/window.hxx>
54 #include <services.h>
55 #include <properties.h>
56 
57 //_________________________________________________________________________________________________________________
58 //	interface includes
59 //_________________________________________________________________________________________________________________
60 #include <com/sun/star/lang/XInitialization.hpp>
61 #include <com/sun/star/lang/DisposedException.hpp>
62 #include <com/sun/star/task/XJobExecutor.hpp>
63 #include <com/sun/star/util/XURLTransformer.hpp>
64 #include <com/sun/star/util/XCloseable.hpp>
65 #include <com/sun/star/awt/XDevice.hpp>
66 #include <com/sun/star/awt/XTopWindow.hpp>
67 #include <com/sun/star/frame/XDesktop.hpp>
68 #include <com/sun/star/awt/PosSize.hpp>
69 #include <com/sun/star/frame/FrameSearchFlag.hpp>
70 #include <com/sun/star/awt/XWindowPeer.hpp>
71 #include <com/sun/star/awt/XVclWindowPeer.hpp>
72 #include <com/sun/star/task/XStatusIndicatorSupplier.hpp>
73 #include <com/sun/star/beans/PropertyAttribute.hpp>
74 #include <com/sun/star/beans/PropertyValue.hpp>
75 #include <com/sun/star/beans/XPropertySet.hpp>
76 #include <com/sun/star/frame/XModel.hpp>
77 #include <com/sun/star/awt/XDataTransferProviderAccess.hpp>
78 #include <com/sun/star/datatransfer/dnd/XDropTarget.hpp>
79 #include <com/sun/star/awt/WindowAttribute.hpp>
80 #include <com/sun/star/container/XIndexAccess.hpp>
81 #include <com/sun/star/beans/XMaterialHolder.hpp>
82 
83 #ifndef _COM_SUN_STAR_FRAME_XTITLECHANGEBROADCASTER_HPP_
84 #include <com/sun/star/frame/XTitleChangeBroadcaster.hpp>
85 #endif
86 
87 //_________________________________________________________________________________________________________________
88 //	includes of other projects
89 //_________________________________________________________________________________________________________________
90 #include <comphelper/sequenceashashmap.hxx>
91 #include <cppuhelper/queryinterface.hxx>
92 #include <cppuhelper/typeprovider.hxx>
93 #include <cppuhelper/factory.hxx>
94 #include <cppuhelper/proptypehlp.hxx>
95 #include <rtl/ustrbuf.hxx>
96 #include <vcl/window.hxx>
97 #include <vcl/wrkwin.hxx>
98 #include <vcl/svapp.hxx>
99 
100 #ifndef _TOOLKIT_HELPER_VCLUNOHELPER_HXX_
101 #include <toolkit/unohlp.hxx>
102 #endif
103 #include <toolkit/awt/vclxwindow.hxx>
104 #include <comphelper/processfactory.hxx>
105 #include <unotools/moduleoptions.hxx>
106 #include <tools/diagnose_ex.h>
107 
108 #ifdef ENABLE_ASSERTIONS
109 	#ifndef _RTL_STRBUF_HXX_
110 	#include <rtl/strbuf.hxx>
111 	#endif
112 #endif
113 
114 #include <vcl/menu.hxx>
115 
116 //_________________________________________________________________________________________________________________
117 //	namespace
118 //_________________________________________________________________________________________________________________
119 
120 namespace framework{
121 
122 //_________________________________________________________________________________________________________________
123 //	non exported const
124 //_________________________________________________________________________________________________________________
125 
126 //_________________________________________________________________________________________________________________
127 //	non exported definitions
128 //_________________________________________________________________________________________________________________
129 
130 css::uno::WeakReference< css::frame::XFrame > Frame::m_xCloserFrame = css::uno::WeakReference< css::frame::XFrame >();
131 
132 //_________________________________________________________________________________________________________________
133 //	declarations
134 //_________________________________________________________________________________________________________________
135 
136 //*****************************************************************************************************************
137 //	XInterface, XTypeProvider, XServiceInfo
138 //*****************************************************************************************************************
139 DEFINE_XINTERFACE_21                (   Frame                                                                   ,
140 										OWeakObject																,
141 										DIRECT_INTERFACE(css::lang::XTypeProvider								),
142 										DIRECT_INTERFACE(css::lang::XServiceInfo								),
143 										DIRECT_INTERFACE(css::frame::XFramesSupplier							),
144 										DIRECT_INTERFACE(css::frame::XFrame										),
145 										DIRECT_INTERFACE(css::lang::XComponent									),
146 										DIRECT_INTERFACE(css::task::XStatusIndicatorFactory						),
147 										DIRECT_INTERFACE(css::frame::XDispatchProvider							),
148 										DIRECT_INTERFACE(css::frame::XDispatchInformationProvider				),
149 										DIRECT_INTERFACE(css::frame::XDispatchProviderInterception				),
150 										DIRECT_INTERFACE(css::beans::XPropertySet								),
151 										DIRECT_INTERFACE(css::beans::XPropertySetInfo   						),
152 										DIRECT_INTERFACE(css::awt::XWindowListener								),
153 										DIRECT_INTERFACE(css::awt::XTopWindowListener							),
154 										DIRECT_INTERFACE(css::awt::XFocusListener								),
155 										DERIVED_INTERFACE(css::lang::XEventListener, css::awt::XWindowListener	),
156                                         DIRECT_INTERFACE(css::document::XActionLockable                         ),
157                                         DIRECT_INTERFACE(css::util::XCloseable                                  ),
158                                         DIRECT_INTERFACE(css::util::XCloseBroadcaster                           ),
159                                         DIRECT_INTERFACE(css::frame::XComponentLoader                           ),
160                                         DIRECT_INTERFACE(css::frame::XTitle                                     ),
161                                         DIRECT_INTERFACE(css::frame::XTitleChangeBroadcaster                    )
162 									)
163 
164 DEFINE_XTYPEPROVIDER_20             (   Frame                                                                   ,
165 										css::lang::XTypeProvider												,
166 										css::lang::XServiceInfo													,
167 										css::frame::XFramesSupplier												,
168 										css::frame::XFrame														,
169 										css::lang::XComponent													,
170 										css::task::XStatusIndicatorFactory										,
171 										css::beans::XPropertySet												,
172 										css::beans::XPropertySetInfo											,
173 										css::frame::XDispatchProvider											,
174 										css::frame::XDispatchInformationProvider								,
175 										css::frame::XDispatchProviderInterception								,
176 										css::awt::XWindowListener								 				,
177 										css::awt::XTopWindowListener											,
178 										css::awt::XFocusListener												,
179                                         css::lang::XEventListener                                               ,
180                                         css::util::XCloseable                                                   ,
181                                         css::util::XCloseBroadcaster                                            ,
182                                         css::frame::XComponentLoader                                            ,
183                                         css::frame::XTitle                                                      ,
184                                         css::frame::XTitleChangeBroadcaster
185 									)
186 
187 DEFINE_XSERVICEINFO_MULTISERVICE	(	Frame																	,
188                                         ::cppu::OWeakObject                                                     ,
189 										SERVICENAME_FRAME														,
190 										IMPLEMENTATIONNAME_FRAME
191 									)
192 
193 DEFINE_INIT_SERVICE                 (   Frame,
194                                         {
195                                             /*Attention
196                                                 I think we don't need any mutex or lock here ... because we are called by our own static method impl_createInstance()
197                                                 to create a new instance of this class by our own supported service factory.
198                                                 see macro DEFINE_XSERVICEINFO_MULTISERVICE and "impl_initService()" for further informations!
199                                             */
200                                             css::uno::Reference< css::uno::XInterface > xThis(static_cast< ::cppu::OWeakObject* >(this), css::uno::UNO_QUERY_THROW);
201 
202                                             //-------------------------------------------------------------------------------------------------------------
203                                             // Initialize a new dispatchhelper-object to handle dispatches.
204                                             // We use these helper as slave for our interceptor helper ... not directly!
205                                             // But he is event listener on THIS instance!
206                                             DispatchProvider* pDispatchHelper = new DispatchProvider( m_xFactory, this );
207                                             css::uno::Reference< css::frame::XDispatchProvider > xDispatchProvider( static_cast< ::cppu::OWeakObject* >(pDispatchHelper), css::uno::UNO_QUERY );
208 
209                                             //-------------------------------------------------------------------------------------------------------------
210                                             DispatchInformationProvider* pInfoHelper = new DispatchInformationProvider(m_xFactory, this);
211                                             m_xDispatchInfoHelper = css::uno::Reference< css::frame::XDispatchInformationProvider >( static_cast< ::cppu::OWeakObject* >(pInfoHelper), css::uno::UNO_QUERY );
212 
213                                             //-------------------------------------------------------------------------------------------------------------
214                                             // Initialize a new interception helper object to handle dispatches and implement an interceptor mechanism.
215                                             // Set created dispatch provider as slowest slave of it.
216                                             // Hold interception helper by reference only - not by pointer!
217                                             // So it's easiear to destroy it.
218                                             InterceptionHelper* pInterceptionHelper = new InterceptionHelper( this, xDispatchProvider );
219                                             m_xDispatchHelper = css::uno::Reference< css::frame::XDispatchProvider >( static_cast< ::cppu::OWeakObject* >(pInterceptionHelper), css::uno::UNO_QUERY );
220 
221                                             //-------------------------------------------------------------------------------------------------------------
222                                             // Initialize a new XFrames-helper-object to handle XIndexAccess and XElementAccess.
223                                             // We hold member as reference ... not as pointer too!
224                                             // Attention: We share our frame container with this helper. Container is threadsafe himself ... So I think we can do that.
225                                             // But look on dispose() for right order of deinitialization.
226                                             OFrames* pFramesHelper = new OFrames( m_xFactory, this, &m_aChildFrameContainer );
227                                             m_xFramesHelper = css::uno::Reference< css::frame::XFrames >( static_cast< ::cppu::OWeakObject* >(pFramesHelper), css::uno::UNO_QUERY );
228 
229                                             //-------------------------------------------------------------------------------------------------------------
230                                             // Initialize a the drop target listener.
231                                             // We hold member as reference ... not as pointer too!
232                                             DropTargetListener* pDropListener = new DropTargetListener( m_xFactory, this );
233                                             m_xDropTargetListener = css::uno::Reference< css::datatransfer::dnd::XDropTargetListener >( static_cast< ::cppu::OWeakObject* >(pDropListener), css::uno::UNO_QUERY );
234 
235                                             // Safe impossible cases
236                                             // We can't work without these helpers!
237                                             LOG_ASSERT2( xDispatchProvider.is    ()==sal_False, "Frame::impl_initService()", "Slowest slave for dispatch- and interception helper isn't valid. XDispatchProvider, XDispatch, XDispatchProviderInterception are not full supported!" )
238                                             LOG_ASSERT2( m_xDispatchHelper.is    ()==sal_False, "Frame::impl_initService()", "Interception helper isn't valid. XDispatchProvider, XDispatch, XDispatchProviderInterception are not full supported!"                                 )
239                                             LOG_ASSERT2( m_xFramesHelper.is      ()==sal_False, "Frame::impl_initService()", "Frames helper isn't valid. XFrames, XIndexAccess and XElementAcces are not supported!"                                                                )
240                                             LOG_ASSERT2( m_xDropTargetListener.is()==sal_False, "Frame::impl_initService()", "DropTarget helper isn't valid. Drag and drop without functionality!"                                                                                  )
241 
242                                             //-------------------------------------------------------------------------------------------------------------
243                                             // establish notifies for changing of "disabled commands" configuration during runtime
244                                             m_aCommandOptions.EstablisFrameCallback(this);
245 
246                                             //-------------------------------------------------------------------------------------------------------------
247                                             // Create an initial layout manager
248                                             // Create layout manager and connect it to the newly created frame
249                                             m_xLayoutManager = css::uno::Reference< css::frame::XLayoutManager >(m_xFactory->createInstance(SERVICENAME_LAYOUTMANAGER), css::uno::UNO_QUERY);
250 
251                                             //-------------------------------------------------------------------------------------------------------------
252                                             // set information about all supported properties at the base class helper PropertySetHelper
253                                             impl_initializePropInfo();
254                                         }
255                                     )
256 
257 /*-****************************************************************************************************//**
258 	@short		standard constructor to create instance by factory
259 	@descr		This constructor initialize a new instance of this class by valid factory,
260 				and will be set valid values on his member and baseclasses.
261 
262     @attention  a)  Don't use your own reference during an UNO-Service-ctor! There is no guarantee, that you
263                     will get over this. (e.g. using of your reference as parameter to initialize some member)
264                     Do such things in DEFINE_INIT_SERVICE() method, which is called automaticly after your ctor!!!
265                 b)  Baseclass OBroadcastHelper is a typedef in namespace cppu!
266                     The microsoft compiler has some problems to handle it right BY using namespace explicitly ::cppu::OBroadcastHelper.
267                     If we write it without a namespace or expand the typedef to OBrodcastHelperVar<...> -> it will be OK!?
268                     I don't know why! (other compiler not tested .. but it works!)
269 
270     @seealso    method DEFINE_INIT_SERVICE()
271 
272 	@param		"xFactory" is the multi service manager, which create this instance.
273 				The value must be different from NULL!
274 	@return		-
275 
276 	@onerror	ASSERT in debug version or nothing in relaese version.
277 *//*-*****************************************************************************************************/
278 Frame::Frame( const css::uno::Reference< css::lang::XMultiServiceFactory >& xFactory )
279         :   ThreadHelpBase              ( &Application::GetSolarMutex()                     )
280         ,   TransactionBase             (                                                   )
281         ,   PropertySetHelper           ( xFactory,
282                                           &m_aLock,
283                                           &m_aTransactionManager,
284                                           sal_False) // sal_False => dont release shared mutex on calling us!
285         ,   ::cppu::OWeakObject         (                                                   )
286 		//	init member
287         ,   m_xFactory                  ( xFactory                                          )
288         ,   m_aListenerContainer        ( m_aLock.getShareableOslMutex()                    )
289         ,   m_xParent                   (                                                   )
290         ,   m_xContainerWindow          (                                                   )
291         ,   m_xComponentWindow          (                                                   )
292         ,   m_xController               (                                                   )
293         ,   m_eActiveState              ( E_INACTIVE                                        )
294         ,   m_sName                     (                                                   )
295         ,   m_bIsFrameTop               ( sal_True                                          ) // I think we are top without a parent ... and there is no parent yet!
296         ,   m_bConnected                ( sal_False                                         ) // There exist no component inside of use => sal_False, we are not connected!
297         ,   m_nExternalLockCount        ( 0                                                 )
298         ,   m_bSelfClose                ( sal_False                                         ) // Important!
299         ,   m_bIsHidden                 ( sal_True                                          )
300         ,   m_xTitleHelper              (                                                   )
301         ,   m_aChildFrameContainer      (                                                   )
302 {
303     // Check incoming parameter to avoid against wrong initialization.
304     LOG_ASSERT2( implcp_ctor( xFactory ), "Frame::Frame()", "Invalid parameter detected!" )
305 
306     /* Please have a look on "@attentions" of description before! */
307 }
308 
309 /*-****************************************************************************************************//**
310 	@short		standard destructor
311 	@descr		This one do NOTHING! Use dispose() instaed of this.
312 
313 	@seealso	method dispose()
314 
315 	@param		-
316 	@return		-
317 
318 	@onerror	-
319 *//*-*****************************************************************************************************/
320 Frame::~Frame()
321 {
322     LOG_ASSERT2( m_aTransactionManager.getWorkingMode()!=E_CLOSE, "Frame::~Frame()", "Who forgot to dispose this service?" )
323 }
324 
325 /*-************************************************************************************************************//**
326     @interface  XComponentLoader
327     @short      try to load given URL into a task
328     @descr      You can give us some informations about the content, which you will load into a frame.
329                 We search or create this target for you, make a type detection of given URL and try to load it.
330                 As result of this operation we return the new created component or nothing, if loading failed.
331 
332     @seealso    -
333 
334     @param      "sURL"              , URL, which represant the content
335     @param      "sTargetFrameName"  , name of target frame or special value like "_self", "_blank" ...
336     @param      "nSearchFlags"      , optional arguments for frame search, if target isn't a special one
337     @param      "lArguments"        , optional arguments for loading
338     @return     A valid component reference, if loading was successfully.
339                 A null reference otherwise.
340 
341     @onerror    We return a null reference.
342     @threadsafe yes
343 *//*-*************************************************************************************************************/
344 css::uno::Reference< css::lang::XComponent > SAL_CALL Frame::loadComponentFromURL( const ::rtl::OUString&                                 sURL            ,
345                                                                                    const ::rtl::OUString&                                 sTargetFrameName,
346                                                                                          sal_Int32                                        nSearchFlags    ,
347                                                                                    const css::uno::Sequence< css::beans::PropertyValue >& lArguments      ) throw( css::io::IOException                ,
348                                                                                                                                                                    css::lang::IllegalArgumentException ,
349                                                                                                                                                                    css::uno::RuntimeException          )
350 {
351     {
352         // If the frame is closed the call might lead to crash even with target "_blank",
353         // so the DisposedException should be thrown in this case
354         // It still looks to be too dangerous to set the transaction for the whole loading process
355         // so the guard is used in scopes to let the standard check be used
356 
357         TransactionGuard aTransaction( m_aTransactionManager, E_HARDEXCEPTIONS );
358     }
359 
360     ReadGuard aReadLock(m_aLock);
361     css::uno::Reference< css::frame::XComponentLoader > xThis(static_cast< css::frame::XComponentLoader* >(this), css::uno::UNO_QUERY);
362     css::uno::Reference< css::lang::XMultiServiceFactory > xSMGR = m_xFactory;
363     aReadLock.unlock();
364 
365     return LoadEnv::loadComponentFromURL(xThis, xSMGR, sURL, sTargetFrameName, nSearchFlags, lArguments);
366 }
367 
368 /*-****************************************************************************************************//**
369 	@short		return access to append or remove childs on desktop
370 	@descr		We don't implement these interface directly. We use a helper class to do this.
371 				If you wish to add or delete childs to/from the container, call these method to get
372 				a reference to the helper.
373 
374 	@seealso	class OFrames
375 
376 	@param		-
377 	@return		A reference to the helper which answer your queries.
378 
379 	@onerror	A null reference is returned.
380 *//*-*****************************************************************************************************/
381 css::uno::Reference< css::frame::XFrames > SAL_CALL Frame::getFrames() throw( css::uno::RuntimeException )
382 {
383 	/* UNSAFE AREA --------------------------------------------------------------------------------------------- */
384     // Register transaction and reject wrong calls.
385 
386 /*TODO
387     This is a temp. HACK!
388     Our parent (a Task!) stand in close/dispose and set working mode to E_BEFOERECLOSE
389     and call dispose on us! We tra to get this xFramesHelper and are reject by an "already closed" pranet instance ....
390     => We use SOFTEXCEPTIONS here ... but we should make it right in further times ....
391  */
392 
393     TransactionGuard aTransaction( m_aTransactionManager, E_SOFTEXCEPTIONS );
394 
395 	/* SAFE AREA ----------------------------------------------------------------------------------------------- */
396     ReadGuard aReadLock( m_aLock );
397 
398     // Return access to all child frames to caller.
399     // Ouer childframe container is implemented in helper class OFrames and used as a reference m_xFramesHelper!
400     return m_xFramesHelper;
401 }
402 
403 /*-****************************************************************************************************//**
404 	@short		get the current active child frame
405 	@descr		It must be a frameto. Direct childs of a frame are frames only! No task or desktop is accepted.
406 				We don't save this information directly in this class. We use ouer container-helper
407 				to do that.
408 
409 	@seealso	class OFrameContainer
410 	@seealso	method setActiveFrame()
411 
412 	@param		-
413 	@return		A reference to ouer current active childframe, if anyone exist.
414 	@return		A null reference, if nobody is active.
415 
416 	@onerror	A null reference is returned.
417 *//*-*****************************************************************************************************/
418 css::uno::Reference< css::frame::XFrame > SAL_CALL Frame::getActiveFrame() throw( css::uno::RuntimeException )
419 {
420 	/* UNSAFE AREA --------------------------------------------------------------------------------------------- */
421     // Register transaction and reject wrong calls.
422     TransactionGuard aTransaction( m_aTransactionManager, E_HARDEXCEPTIONS );
423 
424     /* SAFE AREA ----------------------------------------------------------------------------------------------- */
425     ReadGuard aReadLock( m_aLock );
426 
427 	// Return current active frame.
428 	// This information is avaliable on the container.
429 	return m_aChildFrameContainer.getActive();
430 }
431 
432 /*-****************************************************************************************************//**
433 	@short		set the new active direct child frame
434 	@descr		It must be a frame to. Direct childs of frame are frames only! No task or desktop is accepted.
435 				We don't save this information directly in this class. We use ouer container-helper
436 				to do that.
437 
438 	@seealso	class OFrameContainer
439 	@seealso	method getActiveFrame()
440 
441 	@param		"xFrame", reference to new active child. It must be an already existing child!
442 	@return		-
443 
444 	@onerror    An assertion is thrown and element is ignored, if given frame is'nt already a child of us.
445 *//*-*****************************************************************************************************/
446 void SAL_CALL Frame::setActiveFrame( const css::uno::Reference< css::frame::XFrame >& xFrame ) throw( css::uno::RuntimeException )
447 {
448 	/* UNSAFE AREA --------------------------------------------------------------------------------------------- */
449     // Check incoming parameters.
450     LOG_ASSERT2( implcp_setActiveFrame( xFrame ), "Frame::setActiveFrame()", "Invalid parameter detected!" )
451     // Look for rejected calls!
452     TransactionGuard aTransaction( m_aTransactionManager, E_HARDEXCEPTIONS );
453 
454 	/* SAFE AREA ----------------------------------------------------------------------------------------------- */
455     WriteGuard aWriteLock( m_aLock );
456 
457     // Copy neccessary member for threadsafe access!
458     // m_aChildFrameContainer is threadsafe himself and he live if we live!!!
459     // ...and our transaction is non breakable too ...
460     css::uno::Reference< css::frame::XFrame > xActiveChild = m_aChildFrameContainer.getActive();
461     EActiveState                              eActiveState = m_eActiveState             ;
462 
463     aWriteLock.unlock();
464     /* UNSAFE AREA --------------------------------------------------------------------------------------------- */
465 
466     // Don't work, if "new" active frame is'nt different from current one!
467     // (xFrame==NULL is allowed to UNSET it!)
468     if( xActiveChild != xFrame )
469     {
470         // ... otherwise set new and deactivate old one.
471         m_aChildFrameContainer.setActive( xFrame );
472         if  (
473                 ( eActiveState      !=  E_INACTIVE  )   &&
474                 ( xActiveChild.is() ==  sal_True    )
475             )
476         {
477             xActiveChild->deactivate();
478         }
479     }
480 
481     if( xFrame.is() == sal_True )
482     {
483         // If last active frame had focus ...
484         // ... reset state to ACTIVE and send right FrameActionEvent for focus lost.
485         if( eActiveState == E_FOCUS )
486         {
487             aWriteLock.lock();
488             eActiveState   = E_ACTIVE    ;
489             m_eActiveState = eActiveState;
490             aWriteLock.unlock();
491             implts_sendFrameActionEvent( css::frame::FrameAction_FRAME_UI_DEACTIVATING );
492         }
493 
494         // If last active frame was active ...
495         // but new one isn't it ...
496         // ... set it as active one.
497         if  (
498                 ( eActiveState          ==  E_ACTIVE    )   &&
499                 ( xFrame->isActive()    ==  sal_False   )
500             )
501         {
502             xFrame->activate();
503         }
504     }
505     else
506     // If this frame is active and has no active subframe anymore it is UI active too
507     if( eActiveState == E_ACTIVE )
508     {
509         aWriteLock.lock();
510         eActiveState   = E_FOCUS     ;
511         m_eActiveState = eActiveState;
512         aWriteLock.unlock();
513         implts_sendFrameActionEvent( css::frame::FrameAction_FRAME_UI_ACTIVATED );
514     }
515 }
516 
517 /*-****************************************************************************************************//**
518    initialize new created layout manager
519 **/
520 void lcl_enableLayoutManager(const css::uno::Reference< css::frame::XLayoutManager >& xLayoutManager,
521                              const css::uno::Reference< css::frame::XFrame >&         xFrame        )
522 {
523     // Provide container window to our layout manager implementation
524     xLayoutManager->attachFrame(xFrame);
525 
526     css::uno::Reference< css::frame::XFrameActionListener > xListen(xLayoutManager, css::uno::UNO_QUERY_THROW);
527     xFrame->addFrameActionListener(xListen);
528 
529     DockingAreaDefaultAcceptor* pAcceptor = new DockingAreaDefaultAcceptor(xFrame);
530     css::uno::Reference< css::ui::XDockingAreaAcceptor > xDockingAreaAcceptor( static_cast< ::cppu::OWeakObject* >(pAcceptor), css::uno::UNO_QUERY_THROW);
531     xLayoutManager->setDockingAreaAcceptor(xDockingAreaAcceptor);
532 }
533 
534 /*-****************************************************************************************************//**
535    deinitialize layout manager
536 **/
537 void lcl_disableLayoutManager(const css::uno::Reference< css::frame::XLayoutManager >& xLayoutManager,
538                               const css::uno::Reference< css::frame::XFrame >&         xFrame        )
539 {
540     css::uno::Reference< css::frame::XFrameActionListener > xListen(xLayoutManager, css::uno::UNO_QUERY_THROW);
541     xFrame->removeFrameActionListener(xListen);
542     xLayoutManager->setDockingAreaAcceptor(css::uno::Reference< css::ui::XDockingAreaAcceptor >());
543     xLayoutManager->attachFrame(css::uno::Reference< css::frame::XFrame >());
544 }
545 
546 /*-****************************************************************************************************//**
547 	@short		initialize frame instance
548 	@descr		A frame needs a window. This method set a new one ... but should called one times only!
549 				We use this window to listen for window events and forward it to our set component.
550 				Its used as parent of component window too.
551 
552 	@seealso	method getContainerWindow()
553 	@seealso	method setComponent()
554 	@seealso	member m_xContainerWindow
555 
556 	@param		"xWindow", reference to new container window - must be valid!
557 	@return		-
558 
559 	@onerror	We do nothing.
560 *//*-*****************************************************************************************************/
561 void SAL_CALL Frame::initialize( const css::uno::Reference< css::awt::XWindow >& xWindow ) throw( css::uno::RuntimeException )
562 {
563 	/* UNSAFE AREA --------------------------------------------------------------------------------------------- */
564     if (!xWindow.is())
565         throw css::uno::RuntimeException(
566                     ::rtl::OUString::createFromAscii("Frame::initialize() called without a valid container window reference."),
567                     static_cast< css::frame::XFrame* >(this));
568 
569     /* SAFE AREA ----------------------------------------------------------------------------------------------- */
570     WriteGuard aWriteLock( m_aLock );
571 
572     if ( m_xContainerWindow.is() )
573         throw css::uno::RuntimeException(
574                 ::rtl::OUString::createFromAscii("Frame::initialized() is called more then once, which isnt usefull nor allowed."),
575                 static_cast< css::frame::XFrame* >(this));
576 
577     // Look for rejected calls first!
578     TransactionGuard aTransaction( m_aTransactionManager, E_SOFTEXCEPTIONS );
579 
580     // Enable object for real working ... so follow impl methods don't must handle it special! (e.g. E_SOFTEXCEPTIONS for rejected calls)
581     m_aTransactionManager.setWorkingMode( E_WORK );
582 
583     // This must be the first call of this method!
584     // We should initialize our object and open it for working.
585     // Set the new window.
586     LOG_ASSERT2( m_xContainerWindow.is()==sal_True, "Frame::initialize()", "Leak detected! This state should never occure ..." )
587     m_xContainerWindow = xWindow;
588 
589     // if window is initially visible, we will never get a windowShowing event
590     Window* pWindow = VCLUnoHelper::GetWindow(xWindow);
591     if (pWindow && pWindow->IsVisible())
592         m_bIsHidden = sal_False;
593 
594     css::uno::Reference< css::lang::XMultiServiceFactory > xSMGR          = m_xFactory;
595     css::uno::Reference< css::frame::XLayoutManager >     xLayoutManager = m_xLayoutManager;
596 
597     // Release lock ... because we call some impl methods, which are threadsafe by himself.
598     // If we hold this lock - we will produce our own deadlock!
599     aWriteLock.unlock();
600 	/* UNSAFE AREA --------------------------------------------------------------------------------------------- */
601 
602     if (xLayoutManager.is())
603         lcl_enableLayoutManager(xLayoutManager, this);
604 
605     // create progress helper
606     css::uno::Reference< css::frame::XFrame >                 xThis            (static_cast< css::frame::XFrame* >(this)                        , css::uno::UNO_QUERY_THROW);
607     css::uno::Reference< css::task::XStatusIndicatorFactory > xIndicatorFactory(xSMGR->createInstance(IMPLEMENTATIONNAME_STATUSINDICATORFACTORY), css::uno::UNO_QUERY_THROW);
608     css::uno::Reference< css::lang::XInitialization >         xIndicatorInit   (xIndicatorFactory                                               , css::uno::UNO_QUERY_THROW);
609     css::uno::Sequence< css::uno::Any > lArgs(2);
610     css::beans::NamedValue aArg;
611     aArg.Name    = STATUSINDICATORFACTORY_PROPNAME_FRAME;
612     aArg.Value <<= xThis;
613     lArgs[0]   <<= aArg;
614     aArg.Name    = STATUSINDICATORFACTORY_PROPNAME_ALLOWPARENTSHOW;
615     aArg.Value <<= sal_True;
616     lArgs[1]   <<= aArg;
617     xIndicatorInit->initialize(lArgs);
618 
619     // SAFE -> ----------------------------------
620     aWriteLock.lock();
621     m_xIndicatorFactoryHelper = xIndicatorFactory;
622     aWriteLock.unlock();
623     // <- SAFE ----------------------------------
624 
625     // Start listening for events after setting it on helper class ...
626     // So superflous messages are filtered to NULL :-)
627     implts_startWindowListening();
628 
629     impl_enablePropertySet();
630 
631     // create WindowCommandDispatch; it is supposed to release itself at frame destruction
632     (void)new WindowCommandDispatch(xSMGR, this);
633 
634     // Initialize title functionality
635     TitleHelper* pTitleHelper = new TitleHelper(xSMGR);
636     m_xTitleHelper = css::uno::Reference< css::frame::XTitle >(static_cast< ::cppu::OWeakObject* >(pTitleHelper), css::uno::UNO_QUERY_THROW);
637     pTitleHelper->setOwner(xThis);
638 }
639 
640 /*-****************************************************************************************************//**
641 	@short		returns current set container window
642 	@descr		The ContainerWindow property is used as a container for the component
643 				in this frame. So this object implements a container interface too.
644 				The instantiation of the container window is done by the user of this class.
645 				The frame is the owner of its container window.
646 
647 	@seealso	method initialize()
648 
649 	@param		-
650 	@return		A reference to current set containerwindow.
651 
652 	@onerror	A null reference is returned.
653 *//*-*****************************************************************************************************/
654 css::uno::Reference< css::awt::XWindow > SAL_CALL Frame::getContainerWindow() throw( css::uno::RuntimeException )
655 {
656 	/* UNSAFE AREA --------------------------------------------------------------------------------------------- */
657     // Register transaction and reject wrong calls.
658     TransactionGuard aTransaction( m_aTransactionManager, E_SOFTEXCEPTIONS );
659 
660 	/* SAFE AREA ----------------------------------------------------------------------------------------------- */
661     ReadGuard aReadLock( m_aLock );
662 
663     return m_xContainerWindow;
664 }
665 
666 /*-****************************************************************************************************//**
667 	@short		set parent frame
668 	@descr		We need a parent to support some functionality! e.g. findFrame()
669                 By the way we use the chance to set an internal information about our top state.
670                 So we must not check this information during every isTop() call.
671                 We are top, if our parent is the desktop instance or we havent any parent.
672 
673     @seealso    getCreator()
674     @seealso    findFrame()
675     @seealso    isTop()
676     @seealos    m_bIsFrameTop
677 
678     @param      xCreator
679                     valid reference to our new owner frame, which should implement a supplier interface
680 
681     @threadsafe yes
682     @modified   08.05.2002 09:35, as96863
683 *//*-*****************************************************************************************************/
684 void SAL_CALL Frame::setCreator( const css::uno::Reference< css::frame::XFramesSupplier >& xCreator ) throw( css::uno::RuntimeException )
685 {
686     TransactionGuard aTransaction( m_aTransactionManager, E_HARDEXCEPTIONS );
687 
688     /* SAFE { */
689         WriteGuard aWriteLock( m_aLock );
690             m_xParent = xCreator;
691         aWriteLock.unlock();
692     /* } SAFE */
693 
694     css::uno::Reference< css::frame::XDesktop > xIsDesktop( xCreator, css::uno::UNO_QUERY );
695     m_bIsFrameTop = ( xIsDesktop.is() || ! xCreator.is() );
696 }
697 
698 /*-****************************************************************************************************//**
699 	@short		returns current parent frame
700 	@descr		The Creator is the parent frame container. If it is NULL, the frame is the uppermost one.
701 
702 	@seealso	method setCreator()
703 
704 	@param		-
705 	@return		A reference to current set parent frame container.
706 
707 	@onerror	A null reference is returned.
708 *//*-*****************************************************************************************************/
709 css::uno::Reference< css::frame::XFramesSupplier > SAL_CALL Frame::getCreator() throw( css::uno::RuntimeException )
710 {
711 	/* UNSAFE AREA --------------------------------------------------------------------------------------------- */
712     // Register transaction and reject wrong calls.
713     TransactionGuard aTransaction( m_aTransactionManager, E_HARDEXCEPTIONS );
714 
715 	/* SAFE AREA ----------------------------------------------------------------------------------------------- */
716     ReadGuard aReadLock( m_aLock );
717 
718     return m_xParent;
719 }
720 
721 /*-****************************************************************************************************//**
722 	@short		returns current set name of frame
723 	@descr		This name is used to find target of findFrame() or queryDispatch() calls.
724 
725 	@seealso	method setName()
726 
727 	@param		-
728 	@return		Current set name of frame.
729 
730 	@onerror	An empty string is returned.
731 *//*-*****************************************************************************************************/
732 ::rtl::OUString SAL_CALL Frame::getName() throw( css::uno::RuntimeException )
733 {
734 	/* SAFE { */
735     ReadGuard aReadLock( m_aLock );
736     return m_sName;
737 	/* } SAFE */
738 }
739 
740 /*-****************************************************************************************************//**
741 	@short		set new name for frame
742 	@descr		This name is used to find target of findFrame() or queryDispatch() calls.
743 
744 	@attention	Special names like "_blank", "_self" aren't allowed ...
745 				"_beamer" or "_menubar" excepts this rule!
746 
747 	@seealso	method getName()
748 
749 	@param		"sName", new frame name.
750 	@return		-
751 
752 	@onerror	We do nothing.
753 *//*-*****************************************************************************************************/
754 void SAL_CALL Frame::setName( const ::rtl::OUString& sName ) throw( css::uno::RuntimeException )
755 {
756 	/* SAFE { */
757     WriteGuard aWriteLock( m_aLock );
758     // Set new name ... but look for invalid special target names!
759     // They are not allowed to set.
760     if (TargetHelper::isValidNameForFrame(sName))
761         m_sName = sName;
762 	aWriteLock.unlock();
763 	/* } SAFE */
764 }
765 
766 /*-****************************************************************************************************//**
767 	@short		search for frames
768 	@descr		This method searches for a frame with the specified name.
769 				Frames may contain other frames (e.g. a frameset) and may
770 				be contained in other frames. This hierarchie ist searched by
771 				this method.
772 				First some special names are taken into account, i.e. "",
773                 "_self", "_top", "_blank" etc. The nSearchFlags are ignored
774 				when comparing these names with sTargetFrameName, further steps are
775 				controlled by the search flags. If allowed, the name of the frame
776 				itself is compared with the desired one, then ( again if allowed )
777                 the method findFrame() is called for all children, for siblings
778                 and as last for the parent frame.
779 				If no frame with the given name is found until the top frames container,
780 				a new top one is created, if this is allowed by a special
781 				flag. The new frame also gets the desired name.
782 
783     @param      sTargetFrameName
784                     special names (_blank, _self) or real name of target frame
785     @param      nSearchFlags
786                     optional flags which regulate search for non special target frames
787 
788     @return     A reference to found or may be new created frame.
789     @threadsafe yes
790     @modified   16.05.2002 11:08, as96863
791 *//*-*****************************************************************************************************/
792 css::uno::Reference< css::frame::XFrame > SAL_CALL Frame::findFrame( const ::rtl::OUString&  sTargetFrameName,
793                                                                            sal_Int32         nSearchFlags    ) throw( css::uno::RuntimeException )
794 {
795     css::uno::Reference< css::frame::XFrame > xTarget;
796 
797     //-----------------------------------------------------------------------------------------------------
798     // 0) Ignore wrong parameter!
799     //    We doesn't support search for following special targets.
800     //    If we reject this requests - we mustnt check for such names
801     //    in following code again and again. If we do not so -wrong
802     //    search results can occure!
803     //-----------------------------------------------------------------------------------------------------
804     if (
805         (sTargetFrameName==SPECIALTARGET_DEFAULT  )   ||    // valid for dispatches - not for findFrame()!
806         (sTargetFrameName==SPECIALTARGET_MENUBAR  )   ||    // valid for dispatches - not for findFrame()!
807         (sTargetFrameName==SPECIALTARGET_HELPAGENT)         // valid for dispatches - not for findFrame()!
808        )
809     {
810         return NULL;
811     }
812 
813     //-----------------------------------------------------------------------------------------------------
814     // I) check for special defined targets first which must be handled exclusive.
815     //    force using of "if() else if() ..."
816     //-----------------------------------------------------------------------------------------------------
817 
818     // get threadsafe some neccessary member which are neccessary for following functionality
819     /* SAFE { */
820     ReadGuard aReadLock( m_aLock );
821     css::uno::Reference< css::frame::XFrame >              xParent      ( m_xParent, css::uno::UNO_QUERY );
822     css::uno::Reference< css::lang::XMultiServiceFactory > xFactory     = m_xFactory;
823     sal_Bool                                               bIsTopFrame  = m_bIsFrameTop;
824     sal_Bool                                               bIsTopWindow = WindowHelper::isTopWindow(m_xContainerWindow);
825     aReadLock.unlock();
826     /* } SAFE */
827 
828     //-----------------------------------------------------------------------------------------------------
829     // I.I) "_blank"
830     //  Not allowed for a normal frame - but for the desktop.
831     //  Use helper class to do so. It use the desktop automaticly.
832     //-----------------------------------------------------------------------------------------------------
833     if ( sTargetFrameName==SPECIALTARGET_BLANK )
834     {
835         TaskCreator aCreator(xFactory);
836         xTarget = aCreator.createTask(sTargetFrameName,sal_False);
837     }
838 
839     //-----------------------------------------------------------------------------------------------------
840     // I.II) "_parent"
841     //  It doesn't matter if we have a valid parent or not. User ask for him and get it.
842     //  An empty result is a valid result too.
843     //-----------------------------------------------------------------------------------------------------
844     else
845     if ( sTargetFrameName==SPECIALTARGET_PARENT )
846     {
847         xTarget = xParent;
848     }
849 
850     //-----------------------------------------------------------------------------------------------------
851     // I.III) "_top"
852     //  If we are not the top frame in this hierarchy, we must forward request to our parent.
853     //  Otherwhise we must return ourself.
854     //-----------------------------------------------------------------------------------------------------
855     else
856     if ( sTargetFrameName==SPECIALTARGET_TOP )
857     {
858         if (bIsTopFrame)
859             xTarget = this;
860         else
861         if (xParent.is()) // If we are not top - the parent MUST exist. But may it's better to check it again .-)
862             xTarget = xParent->findFrame(SPECIALTARGET_TOP,0);
863     }
864 
865     //-----------------------------------------------------------------------------------------------------
866     // I.IV) "_self", ""
867     //  This mean this frame in every case.
868     //-----------------------------------------------------------------------------------------------------
869     else
870     if (
871         ( sTargetFrameName==SPECIALTARGET_SELF ) ||
872         ( sTargetFrameName.getLength()<1       )
873        )
874     {
875         xTarget = this;
876     }
877 
878     //-----------------------------------------------------------------------------------------------------
879     // I.V) "_beamer"
880     //  This is a special sub frame of any task. We must return it if we found it on our direct childrens
881     //  or create it there if it not already exists.
882     //  Note: Such beamer exists for task(top) frames only!
883     //-----------------------------------------------------------------------------------------------------
884     else
885     if ( sTargetFrameName==SPECIALTARGET_BEAMER )
886     {
887         // We are a task => search or create the beamer
888         if (bIsTopWindow)
889         {
890             xTarget = m_aChildFrameContainer.searchOnDirectChildrens(SPECIALTARGET_BEAMER);
891             if ( ! xTarget.is() )
892             {
893                 /* TODO
894                     Creation not supported yet!
895                     Wait for new layout manager service because we can't plug it
896                     inside already opened document of this frame ...
897                 */
898             }
899         }
900         // We arent a task => forward request to our parent or ignore it.
901         else
902         if (xParent.is())
903             xTarget = xParent->findFrame(SPECIALTARGET_BEAMER,0);
904     }
905 
906     else
907     {
908         //-------------------------------------------------------------------------------------------------
909         // II) otherwhise use optional given search flags
910         //  force using of combinations of such flags. means no "else" part of use if() statements.
911         //  But we ust break further searches if target was already found.
912         //  Order of using flags is fix: SELF - CHILDREN - SIBLINGS - PARENT
913         //  TASK and CREATE are handled special.
914         //-------------------------------------------------------------------------------------------------
915 
916         // get threadsafe some neccessary member which are neccessary for following functionality
917         /* SAFE { */
918         aReadLock.lock();
919         ::rtl::OUString sOwnName = m_sName;
920         aReadLock.unlock();
921         /* } SAFE */
922 
923         //-------------------------------------------------------------------------------------------------
924         // II.I) SELF
925         //  Check for right name. If it's the searched one return ourself - otherwhise
926         //  ignore this flag.
927         //-------------------------------------------------------------------------------------------------
928         if (
929             (nSearchFlags &  css::frame::FrameSearchFlag::SELF)  &&
930             (sOwnName     == sTargetFrameName                 )
931            )
932         {
933             xTarget = this;
934         }
935 
936         //-------------------------------------------------------------------------------------------------
937         // II.II) CHILDREN
938         //  Search on all children for the given target name.
939         //  An empty name value can't occure here - because it must be already handled as "_self"
940         //  before. Used helper function of container doesn't create any frame.
941         //  It makes a deep search only.
942         //-------------------------------------------------------------------------------------------------
943         if (
944             ( ! xTarget.is()                                     ) &&
945             (nSearchFlags & css::frame::FrameSearchFlag::CHILDREN)
946            )
947         {
948             xTarget = m_aChildFrameContainer.searchOnAllChildrens(sTargetFrameName);
949         }
950 
951         //-------------------------------------------------------------------------------------------------
952         // II.III) TASKS
953         //  This is a special flag. It regulate search on this task tree only or allow search on
954         //  all other ones (which are sibling trees of us) too.
955         //  Upper search must stop at this frame if we are the topest one and the TASK flag isn't set
956         //  or we can ignore it if we have no valid parent.
957         //-------------------------------------------------------------------------------------------------
958         if (
959             (   bIsTopFrame && (nSearchFlags & css::frame::FrameSearchFlag::TASKS) )   ||
960             ( ! bIsTopFrame                                                        )
961            )
962         {
963             //-------------------------------------------------------------------------------------------------
964             // II.III.I) SIBLINGS
965             //  Search on all our direct siblings - means all childrens of our parent.
966             //  Use this flag in combination with TASK. We must supress such upper search if
967             //  user has not set it and if we are a top frame.
968             //
969             //  Attention: Don't forward this request to our parent as a findFrame() call.
970             //  In such case we must protect us against recursive calls.
971             //  Use snapshot of our parent. But don't use queryFrames() of XFrames interface.
972             //  Because it's return all siblings and all her childrens including our children too
973             //  if we call it with the CHILDREN flag. We doesn't need that - we need the direct container
974             //  items of our parent only to start searches there. So we must use the container interface
975             //  XIndexAccess instead of XFrames.
976             //-------------------------------------------------------------------------------------------------
977             if (
978                 ( ! xTarget.is()                                      ) &&
979                 (nSearchFlags &  css::frame::FrameSearchFlag::SIBLINGS) &&
980                 (   xParent.is()                                      ) // search on siblings is impossible without a parent
981                )
982             {
983                 css::uno::Reference< css::frame::XFramesSupplier > xSupplier( xParent, css::uno::UNO_QUERY );
984                 if (xSupplier.is())
985                 {
986                     css::uno::Reference< css::container::XIndexAccess > xContainer( xSupplier->getFrames(), css::uno::UNO_QUERY );
987                     if (xContainer.is())
988                     {
989                         sal_Int32 nCount = xContainer->getCount();
990                         for( sal_Int32 i=0; i<nCount; ++i )
991                         {
992                             css::uno::Reference< css::frame::XFrame > xSibling;
993                             if (
994                                 ( !(xContainer->getByIndex(i)>>=xSibling)                                 ) ||  // control unpacking
995                                 ( ! xSibling.is()                                     ) ||  // check for valid items
996                                 ( xSibling==static_cast< ::cppu::OWeakObject* >(this) )     // ignore ourself! (We are a part of this container too - but search on our children was already done.)
997                             )
998                             {
999                                 continue;
1000                             }
1001 
1002                             // Don't allow upper search here! Use rigth flags to regulate it.
1003 							// And allow deep search on children only - if it was allowed for us too.
1004 							sal_Int32 nRightFlags = css::frame::FrameSearchFlag::SELF;
1005 							if (nSearchFlags & css::frame::FrameSearchFlag::CHILDREN)
1006 								nRightFlags |= css::frame::FrameSearchFlag::CHILDREN;
1007                             xTarget = xSibling->findFrame(sTargetFrameName, nRightFlags );
1008                             // perform search be breaking further search if a result exist.
1009                             if (xTarget.is())
1010                                 break;
1011                         }
1012                     }
1013                 }
1014             }
1015 
1016             //-------------------------------------------------------------------------------------------------
1017             // II.III.II) PARENT
1018             //  Forward search to our parent (if he exists.)
1019             //  To prevent us against recursive and superflous calls (which can occure if we allow him
1020             //  to search on his childrens too) we must change used search flags.
1021             //-------------------------------------------------------------------------------------------------
1022             if (
1023                 ( ! xTarget.is()                                    ) &&
1024                 (nSearchFlags &  css::frame::FrameSearchFlag::PARENT) &&
1025                 (   xParent.is()                                    )
1026                )
1027             {
1028 				if (xParent->getName() == sTargetFrameName)
1029 					xTarget = xParent;
1030 				else
1031 				{
1032 					sal_Int32 nRightFlags  = nSearchFlags;
1033 							  nRightFlags &= ~css::frame::FrameSearchFlag::CHILDREN;
1034 					xTarget = xParent->findFrame(sTargetFrameName, nRightFlags);
1035 				}
1036             }
1037         }
1038 
1039         //-------------------------------------------------------------------------------------------------
1040         // II.IV) CREATE
1041         //  If we haven't found any valid target frame by using normal flags - but user allowed us to create
1042         //  a new one ... we should do that. Used TaskCreator use Desktop instance automaticly as parent!
1043         //-------------------------------------------------------------------------------------------------
1044         if (
1045             ( ! xTarget.is()                                   )    &&
1046             (nSearchFlags & css::frame::FrameSearchFlag::CREATE)
1047            )
1048         {
1049             TaskCreator aCreator(xFactory);
1050             xTarget = aCreator.createTask(sTargetFrameName,sal_False);
1051         }
1052     }
1053 
1054     return xTarget;
1055 }
1056 
1057 /*-****************************************************************************************************//**
1058 	@short		-
1059 	@descr		Returns sal_True, if this frame is a "top frame", otherwise sal_False.
1060 				The "m_bIsFrameTop" member must be set in the ctor or setCreator() method.
1061     			A top frame is a member of the top frame container or a member of the
1062     			task frame container. Both containers can create new frames if the findFrame()
1063                 method of their css::frame::XFrame interface is called with a frame name not yet known.
1064 
1065 	@seealso	ctor
1066 	@seealso	method setCreator()
1067 	@seealso	method findFrame()
1068 
1069 	@param		-
1070 	@return		true, if is it a top frame ... false otherwise.
1071 
1072 	@onerror	No error should occure!
1073 *//*-*****************************************************************************************************/
1074 sal_Bool SAL_CALL Frame::isTop() throw( css::uno::RuntimeException )
1075 {
1076 	/* UNSAFE AREA --------------------------------------------------------------------------------------------- */
1077     // Register transaction and reject wrong calls.
1078     TransactionGuard aTransaction( m_aTransactionManager, E_HARDEXCEPTIONS );
1079 
1080 	/* SAFE AREA ----------------------------------------------------------------------------------------------- */
1081     ReadGuard aReadLock( m_aLock );
1082 
1083     // This information is set in setCreator().
1084     // We are top, if ouer parent is a task or the desktop or if no parent exist!
1085     return m_bIsFrameTop;
1086 }
1087 
1088 /*-****************************************************************************************************//**
1089 	@short		activate frame in hierarchy
1090 	@descr		This feature is used to mark active pathes in our frame hierarchy.
1091 				You can be a listener for this event to react for it ... change some internal states or something else.
1092 
1093 	@seealso	method deactivate()
1094 	@seealso	method isActivate()
1095 	@seealso	enum EActiveState
1096 	@seealso	listener mechanism
1097 
1098 	@param		-
1099 	@return		-
1100 
1101 	@onerror	-
1102 *//*-*****************************************************************************************************/
1103 void SAL_CALL Frame::activate() throw( css::uno::RuntimeException )
1104 {
1105 	/* UNSAFE AREA --------------------------------------------------------------------------------------------- */
1106     // Register transaction and reject wrong calls.
1107     TransactionGuard aTransaction( m_aTransactionManager, E_HARDEXCEPTIONS );
1108 
1109 	/* SAFE AREA ----------------------------------------------------------------------------------------------- */
1110     WriteGuard aWriteLock( m_aLock );
1111 
1112     // Copy neccessary member and free the lock.
1113     // It's not neccessary for m_aChildFrameContainer ... because
1114     // he is threadsafe himself and live if we live.
1115     // We use a registered transaction to prevent us against
1116     // breaks during this operation!
1117     css::uno::Reference< css::frame::XFrame >           xActiveChild    = m_aChildFrameContainer.getActive()                                ;
1118     css::uno::Reference< css::frame::XFramesSupplier >  xParent         ( m_xParent, css::uno::UNO_QUERY )                                ;
1119     css::uno::Reference< css::frame::XFrame >           xThis           ( static_cast< ::cppu::OWeakObject* >(this), css::uno::UNO_QUERY );
1120     css::uno::Reference< css::awt::XWindow >            xComponentWindow( m_xComponentWindow, css::uno::UNO_QUERY )                       ;
1121     EActiveState                                        eState          = m_eActiveState                                                  ;
1122 
1123     aWriteLock.unlock();
1124     /* UNSAFE AREA --------------------------------------------------------------------------------------------- */
1125 
1126     //_________________________________________________________________________________________________________
1127     //  1)  If I'am not active before ...
1128     if( eState == E_INACTIVE )
1129     {
1130         // ... do it then.
1131         aWriteLock.lock();
1132         eState         = E_ACTIVE;
1133         m_eActiveState = eState;
1134         aWriteLock.unlock();
1135         // Deactivate sibling path and forward activation to parent ... if any parent exist!
1136         if( xParent.is() == sal_True )
1137         {
1138             // Everytime set THIS frame as active child of parent and activate it.
1139             // We MUST have a valid path from bottom to top as active path!
1140             // But we must deactivate the old active sibling path first.
1141 
1142             // Attention: Deactivation of an active path, deactivate the whole path ... from bottom to top!
1143             // But we wish to deactivate founded sibling-tree only.
1144             // [ see deactivate() / step 4) for further informations! ]
1145 
1146             xParent->setActiveFrame( xThis );
1147 
1148             // Then we can activate from here to top.
1149             // Attention: We are ACTIVE now. And the parent will call activate() at us!
1150             // But we do nothing then! We are already activated.
1151             xParent->activate();
1152         }
1153         // Its neccessary to send event NOW - not before.
1154         // Activation goes from bottom to top!
1155         // Thats the reason to activate parent first and send event now.
1156         implts_sendFrameActionEvent( css::frame::FrameAction_FRAME_ACTIVATED );
1157     }
1158 
1159     //_________________________________________________________________________________________________________
1160     //  2)  I was active before or current activated and there is a path from here to bottom, who CAN be active.
1161     //      But ouer direct child of path is not active yet.
1162     //      (It can be, if activation occur in the middle of a current path!)
1163     //      In these case we activate path to bottom to set focus on right frame!
1164     if  (
1165             ( eState                    ==  E_ACTIVE    )   &&
1166             ( xActiveChild.is()         ==  sal_True    )   &&
1167             ( xActiveChild->isActive()  ==  sal_False   )
1168         )
1169     {
1170         xActiveChild->activate();
1171     }
1172 
1173     //_________________________________________________________________________________________________________
1174     //  3)  I was active before or current activated. But if I have no active child => I will get the focus!
1175     if  (
1176             ( eState            ==  E_ACTIVE    )   &&
1177             ( xActiveChild.is() ==  sal_False   )
1178         )
1179     {
1180         aWriteLock.lock();
1181         eState         = E_FOCUS;
1182         m_eActiveState = eState;
1183         aWriteLock.unlock();
1184         implts_sendFrameActionEvent( css::frame::FrameAction_FRAME_UI_ACTIVATED );
1185     }
1186 }
1187 
1188 /*-****************************************************************************************************//**
1189 	@short		deactivate frame in hierarchy
1190 	@descr		This feature is used to deactive pathes in our frame hierarchy.
1191 				You can be a listener for this event to react for it ... change some internal states or something else.
1192 
1193 	@seealso	method activate()
1194 	@seealso	method isActivate()
1195 	@seealso	enum EActiveState
1196 	@seealso	listener mechanism
1197 
1198 	@param		-
1199 	@return		-
1200 
1201 	@onerror	-
1202 *//*-*****************************************************************************************************/
1203 void SAL_CALL Frame::deactivate() throw( css::uno::RuntimeException )
1204 {
1205 	/* UNSAFE AREA --------------------------------------------------------------------------------------------- */
1206     // Register transaction and reject wrong calls.
1207     TransactionGuard aTransaction( m_aTransactionManager, E_HARDEXCEPTIONS );
1208 
1209 	/* SAFE AREA ----------------------------------------------------------------------------------------------- */
1210     WriteGuard aWriteLock( m_aLock );
1211 
1212     // Copy neccessary member and free the lock.
1213     css::uno::Reference< css::frame::XFrame >           xActiveChild    = m_aChildFrameContainer.getActive()                                     ;
1214     css::uno::Reference< css::frame::XFramesSupplier >  xParent         ( m_xParent, css::uno::UNO_QUERY )                                ;
1215     css::uno::Reference< css::frame::XFrame >           xThis           ( static_cast< ::cppu::OWeakObject* >(this), css::uno::UNO_QUERY );
1216     EActiveState                                        eState          = m_eActiveState                                                  ;
1217 
1218     aWriteLock.unlock();
1219     /* UNSAFE AREA --------------------------------------------------------------------------------------------- */
1220 
1221     // Work only, if there something to do!
1222     if( eState != E_INACTIVE )
1223     {
1224         //_____________________________________________________________________________________________________
1225         //  1)  Deactivate all active childs.
1226         if  (
1227                 ( xActiveChild.is()         ==  sal_True    )   &&
1228                 ( xActiveChild->isActive()  ==  sal_True    )
1229             )
1230         {
1231             xActiveChild->deactivate();
1232         }
1233 
1234         //_____________________________________________________________________________________________________
1235         //  2)  If I have the focus - I will lost it now.
1236         if( eState == E_FOCUS )
1237         {
1238             // Set new state INACTIVE(!) and send message to all listener.
1239             // Don't set ACTIVE as new state. This frame is deactivated for next time - due to activate().
1240             aWriteLock.lock();
1241             eState          = E_ACTIVE;
1242             m_eActiveState  = eState  ;
1243             aWriteLock.unlock();
1244             implts_sendFrameActionEvent( css::frame::FrameAction_FRAME_UI_DEACTIVATING );
1245         }
1246 
1247         //_____________________________________________________________________________________________________
1248         //  3)  If I'am active - I will be deactivated now.
1249         if( eState == E_ACTIVE )
1250         {
1251             // Set new state and send message to all listener.
1252             aWriteLock.lock();
1253             eState          = E_INACTIVE;
1254             m_eActiveState  = eState    ;
1255             aWriteLock.unlock();
1256             implts_sendFrameActionEvent( css::frame::FrameAction_FRAME_DEACTIVATING );
1257         }
1258 
1259         //_____________________________________________________________________________________________________
1260         //  4)  If there is a path from here to my parent ...
1261         //      ... I'am on the top or in the middle of deactivated subtree and action was started here.
1262         //      I must deactivate all frames from here to top, which are members of current path.
1263         //      Stop, if THESE frame not the active frame of ouer parent!
1264         if  (
1265                 ( xParent.is()              ==  sal_True    )   &&
1266                 ( xParent->getActiveFrame() ==  xThis       )
1267             )
1268         {
1269             // We MUST break the path - otherwise we will get the focus - not ouer parent! ...
1270             // Attention: Ouer parent don't call us again - WE ARE NOT ACTIVE YET!
1271             // [ see step 3 and condition "if ( m_eActiveState!=INACTIVE ) ..." in this method! ]
1272             xParent->deactivate();
1273         }
1274     }
1275 }
1276 
1277 /*-****************************************************************************************************//**
1278 	@short		returns active state
1279 	@descr		Call it to get informations about current active state of this frame.
1280 
1281 	@seealso	method activate()
1282 	@seealso	method deactivate()
1283 	@seealso	enum EActiveState
1284 
1285 	@param		-
1286 	@return		true if active, false otherwise.
1287 
1288 	@onerror	No error should occure.
1289 *//*-*****************************************************************************************************/
1290 sal_Bool SAL_CALL Frame::isActive() throw( css::uno::RuntimeException )
1291 {
1292 	/* UNSAFE AREA --------------------------------------------------------------------------------------------- */
1293     // Register transaction and reject wrong calls.
1294     TransactionGuard aTransaction( m_aTransactionManager, E_HARDEXCEPTIONS );
1295 
1296 	/* SAFE AREA ----------------------------------------------------------------------------------------------- */
1297     ReadGuard aReadLock( m_aLock );
1298 
1299     return  (
1300                 ( m_eActiveState    ==  E_ACTIVE    )   ||
1301                 ( m_eActiveState    ==  E_FOCUS     )
1302             );
1303 }
1304 
1305 /*-****************************************************************************************************//**
1306 	@short		???
1307 	@descr		-
1308 
1309 	@seealso	-
1310 
1311 	@param		-
1312 	@return		-
1313 
1314 	@onerror	-
1315 *//*-*****************************************************************************************************/
1316 void SAL_CALL Frame::contextChanged() throw( css::uno::RuntimeException )
1317 {
1318     // Look for rejected calls!
1319     // Sometimes called during closing object... => soft exceptions
1320     TransactionGuard aTransaction( m_aTransactionManager, E_SOFTEXCEPTIONS );
1321     // Impl-method is threadsafe himself!
1322 	// Send event to all listener for frame actions.
1323     implts_sendFrameActionEvent( css::frame::FrameAction_CONTEXT_CHANGED );
1324 }
1325 
1326 /*-****************************************************************************************************//**
1327 	@short		set new component inside the frame
1328 	@descr		A frame is a container for a component. Use this method to set, change or realease it!
1329 				We accept null references! The xComponentWindow will be a child of our container window
1330 				and get all window events from us.
1331 
1332     @attention  (a) A current set component can disagree with the suspend() request!
1333                     We don't set the new one and return with false then.
1334                 (b) It's possible to set:
1335                         (b1) a simple component here which supports the window only - no controller;
1336                         (b2) a full featured component which supports window and controller;
1337                         (b3) or both to NULL if outside code which to forget this component.
1338 
1339 	@seealso	method getComponentWindow()
1340 	@seealso	method getController()
1341 
1342     @param      xComponentWindow
1343                     valid reference to new component window which will be a child of internal container window
1344                     May <NULL/> for releasing.
1345     @param      xController
1346                     reference to new component controller
1347                     (may <NULL/> for relasing or setting of a simple component)
1348 
1349     @return     <TRUE/> if operation was successful, <FALSE/> otherwise.
1350 
1351     @onerror    We return <FALSE/>.
1352     @threadsafe yes
1353     @modified   06.05.2002 11:39, as96863
1354 *//*-*****************************************************************************************************/
1355 sal_Bool SAL_CALL Frame::setComponent(  const   css::uno::Reference< css::awt::XWindow >&       xComponentWindow ,
1356                                         const   css::uno::Reference< css::frame::XController >& xController      ) throw( css::uno::RuntimeException )
1357 {
1358     //_____________________________________________________________________________________________________
1359     // Ignore this HACK of sfx2!
1360     // He call us with an valid controller without a valid window ... Thats not allowed!
1361     if  ( xController.is() && ! xComponentWindow.is() )
1362 		return sal_True;
1363 
1364 	TransactionGuard aTransaction( m_aTransactionManager, E_HARDEXCEPTIONS );
1365 
1366     //_____________________________________________________________________________________________________
1367     // Get threadsafe some copies of used members.
1368     /* SAFE { */
1369     ReadGuard aReadLock( m_aLock );
1370     css::uno::Reference< css::awt::XWindow >       xContainerWindow    = m_xContainerWindow;
1371     css::uno::Reference< css::awt::XWindow >       xOldComponentWindow = m_xComponentWindow;
1372     css::uno::Reference< css::frame::XController > xOldController      = m_xController;
1373     Window*                                        pOwnWindow = VCLUnoHelper::GetWindow( xContainerWindow );
1374     sal_Bool                                       bHadFocus           = pOwnWindow->HasChildPathFocus();
1375     sal_Bool                                       bWasConnected       = m_bConnected;
1376     aReadLock.unlock();
1377     /* } SAFE */
1378 
1379     //_____________________________________________________________________________________________________
1380 	// stop listening on old window
1381 	// May it produce some trouble.
1382     // But don't forget to listen on new window again ... or reactivate listening
1383     // if we reject this setComponent() request and leave this method without changing the old window.
1384     implts_stopWindowListening();
1385 
1386 	// Notify all listener, that this component (if current one exist) will be unloaded.
1387 	if (bWasConnected)
1388 		implts_sendFrameActionEvent( css::frame::FrameAction_COMPONENT_DETACHING );
1389 
1390     //_____________________________________________________________________________________________________
1391     // otherwhise release old component first
1392     // Always release controller before releasing window,
1393     // because controller may want to access its window!
1394     // But check for real changes - may the new controller is the old one.
1395     if (
1396         (xOldController.is()          )   &&
1397         (xOldController != xController)
1398        )
1399     {
1400         /* ATTENTION
1401             Don't suspend the old controller here. Because the outside caller must do that
1402             by definition. We have to dispose it here only.
1403          */
1404 
1405         // Before we dispose this controller we should hide it inside this frame instance.
1406         // We hold it alive for next calls by using xOldController!
1407         /* SAFE {*/
1408         WriteGuard aWriteLock( m_aLock );
1409         m_xController = NULL;
1410         aWriteLock.unlock();
1411         /* } SAFE */
1412 
1413         css::uno::Reference< css::lang::XComponent > xDisposable( xOldController, css::uno::UNO_QUERY );
1414         if (xDisposable.is())
1415         {
1416             try
1417             {
1418                 xDisposable->dispose();
1419             }
1420             catch(const css::lang::DisposedException&)
1421                 {}
1422         }
1423 	    xOldController = NULL;
1424     }
1425 
1426     //_____________________________________________________________________________________________________
1427     // Now it's time to release the component window.
1428     // If controller wasn't released successfully - this code line shouldn't be reached.
1429     // Because in case of "suspend()==false" we return immediately with false ...
1430     // see before
1431     // Check for real changes too.
1432     if (
1433         (xOldComponentWindow.is()               )   &&
1434         (xOldComponentWindow != xComponentWindow)
1435        )
1436     {
1437         /* SAFE { */
1438         WriteGuard aWriteLock( m_aLock );
1439         m_xComponentWindow = NULL;
1440         aWriteLock.unlock();
1441         /* } SAFE */
1442 
1443         css::uno::Reference< css::lang::XComponent > xDisposable( xOldComponentWindow, css::uno::UNO_QUERY );
1444         if (xDisposable.is())
1445         {
1446             try
1447             {
1448                 xDisposable->dispose();
1449             }
1450             catch(const css::lang::DisposedException&)
1451                 {}
1452         }
1453 	    xOldComponentWindow = NULL;
1454     }
1455 
1456     //_____________________________________________________________________________________________________
1457     // Now it's time to set the new component ...
1458     // By the way - find out our new "load state" - means if we have a valid component inside.
1459     /* SAFE { */
1460     WriteGuard aWriteLock( m_aLock );
1461 	m_xComponentWindow = xComponentWindow;
1462     m_xController      = xController     ;
1463     m_bConnected       = (m_xComponentWindow.is() || m_xController.is());
1464     sal_Bool bIsConnected       = m_bConnected;
1465     aWriteLock.unlock();
1466     /* } SAFE */
1467 
1468     //_____________________________________________________________________________________________________
1469 	// notifies all interest listener, that current component was changed or a new one was loaded
1470     if (bIsConnected && bWasConnected)
1471         implts_sendFrameActionEvent( css::frame::FrameAction_COMPONENT_REATTACHED );
1472     else
1473     if (bIsConnected && !bWasConnected)
1474         implts_sendFrameActionEvent( css::frame::FrameAction_COMPONENT_ATTACHED   );
1475 
1476     //_____________________________________________________________________________________________________
1477     // A new component window doesn't know anything about current active/focus states.
1478     // Set this information on it!
1479     if (
1480         (bHadFocus            ) &&
1481         (xComponentWindow.is())
1482        )
1483     {
1484         xComponentWindow->setFocus();
1485     }
1486 
1487     // If it was a new component window - we must resize it to fill out
1488     // our container window.
1489     implts_resizeComponentWindow();
1490     // New component should change our current icon ...
1491     implts_setIconOnWindow();
1492 	// OK - start listening on new window again - or do nothing if it is an empty one.
1493     implts_startWindowListening();
1494 
1495     /* SAFE { */
1496     aWriteLock.lock();
1497     impl_checkMenuCloser();
1498     aWriteLock.unlock();
1499     /* } SAFE */
1500 
1501 	return sal_True;
1502 }
1503 
1504 /*-****************************************************************************************************//**
1505 	@short		returns current set component window
1506 	@descr		Frames are used to display components. The actual displayed component is
1507 				held by the m_xComponentWindow property. If the component implements only a
1508 				XComponent interface, the communication between the frame and the
1509 				component is very restricted. Better integration is achievable through a
1510 				XController interface.
1511 				If the component wants other objects to be able to get information about its
1512 				ResourceDescriptor it has to implement a XModel interface.
1513 				This frame is the owner of the component window.
1514 
1515 	@seealso	method setComponent()
1516 
1517 	@param		-
1518     @return     css::uno::Reference to current set component window.
1519 
1520 	@onerror	A null reference is returned.
1521 *//*-*****************************************************************************************************/
1522 css::uno::Reference< css::awt::XWindow > SAL_CALL Frame::getComponentWindow() throw( css::uno::RuntimeException )
1523 {
1524 	/* UNSAFE AREA --------------------------------------------------------------------------------------------- */
1525     // Register transaction and reject wrong calls.
1526     TransactionGuard aTransaction( m_aTransactionManager, E_HARDEXCEPTIONS );
1527 
1528 	/* SAFE AREA ----------------------------------------------------------------------------------------------- */
1529     ReadGuard aReadLock( m_aLock );
1530 
1531     return m_xComponentWindow;
1532 }
1533 
1534 /*-****************************************************************************************************//**
1535 	@short		returns current set controller
1536 	@descr		Frames are used to display components. The actual displayed component is
1537 				held by the m_xComponentWindow property. If the component implements only a
1538 				XComponent interface, the communication between the frame and the
1539 				component is very restricted. Better integration is achievable through a
1540 				XController interface.
1541 				If the component wants other objects to be able to get information about its
1542 				ResourceDescriptor it has to implement a XModel interface.
1543 				This frame is the owner of the component window.
1544 
1545 	@seealso	method setComponent()
1546 
1547 	@param		-
1548     @return     css::uno::Reference to current set controller.
1549 
1550 	@onerror	A null reference is returned.
1551 *//*-*****************************************************************************************************/
1552 css::uno::Reference< css::frame::XController > SAL_CALL Frame::getController() throw( css::uno::RuntimeException )
1553 {
1554 	/* UNSAFE AREA --------------------------------------------------------------------------------------------- */
1555     // It seems to be unavoidable that disposed frames allow to ask for a Controller (#111452)
1556     // Register transaction and reject wrong calls.
1557     // TransactionGuard aTransaction( m_aTransactionManager, E_HARDEXCEPTIONS );
1558 
1559 	/* SAFE AREA ----------------------------------------------------------------------------------------------- */
1560     ReadGuard aReadLock( m_aLock );
1561 
1562     return m_xController;
1563 }
1564 
1565 /*-****************************************************************************************************//**
1566 	@short		add/remove listener for activate/deactivate/contextChanged events
1567 	@descr		-
1568 
1569 	@seealso	method activate()
1570 	@seealso	method deactivate()
1571 	@seealso	method contextChanged()
1572 
1573 	@param		"xListener" reference to your listener object
1574 	@return		-
1575 
1576 	@onerror	Listener is ignored.
1577 *//*-*****************************************************************************************************/
1578 void SAL_CALL Frame::addFrameActionListener( const css::uno::Reference< css::frame::XFrameActionListener >& xListener ) throw( css::uno::RuntimeException )
1579 {
1580 	/* UNSAFE AREA --------------------------------------------------------------------------------------------- */
1581 	// Check incoming parameter.
1582     LOG_ASSERT2( implcp_addFrameActionListener( xListener ), "Frame::addFrameActionListener()", "Invalid parameter detected." )
1583     // Listener container is threadsafe by himself ... but we must look for rejected calls!
1584     // Our OMenuDispatch-helper (is a member of ODispatchProvider!) is create at startup of this frame BEFORE initialize!
1585     // => soft exceptions!
1586     TransactionGuard aTransaction( m_aTransactionManager, E_SOFTEXCEPTIONS );
1587 
1588 	/* SAFE AREA ----------------------------------------------------------------------------------------------- */
1589     m_aListenerContainer.addInterface( ::getCppuType( (const css::uno::Reference< css::frame::XFrameActionListener >*)NULL ), xListener );
1590 }
1591 
1592 //*****************************************************************************************************************
1593 void SAL_CALL Frame::removeFrameActionListener( const css::uno::Reference< css::frame::XFrameActionListener >& xListener ) throw( css::uno::RuntimeException )
1594 {
1595 	/* UNSAFE AREA --------------------------------------------------------------------------------------------- */
1596 	// Check incoming parameter.
1597     LOG_ASSERT2( implcp_removeFrameActionListener( xListener ), "Frame::removeFrameActionListener()", "Invalid parameter detected." )
1598 	// Listener container is threadsafe by himself ... but we must look for rejected calls after disposing!
1599     // But we must work with E_SOFTEXCEPTIONS ... because sometimes we are called from our listeners
1600     // during dispose! Our work mode is E_BEFORECLOSE then ... and E_HARDEXCEPTIONS whould throw a DisposedException.
1601     TransactionGuard aTransaction( m_aTransactionManager, E_SOFTEXCEPTIONS );
1602 
1603 	/* SAFE AREA ----------------------------------------------------------------------------------------------- */
1604     m_aListenerContainer.removeInterface( ::getCppuType( (const css::uno::Reference< css::frame::XFrameActionListener >*)NULL ), xListener );
1605 }
1606 
1607 /*-****************************************************************************************************//**
1608     @short      support two way mechanism to release a frame
1609     @descr      This method ask internal component (controller) if he accept this close request.
1610                 In case of <TRUE/> nothing will be happen (from point of caller of this close method).
1611                 In case of <FALSE/> a CloseVetoException is thrown. After such exception given parameter
1612                 <var>bDeliverOwnerShip</var> regulate which will be the new owner of this instance.
1613 
1614     @attention  It's the replacement for XTask::close() which is marked as obsolete method.
1615 
1616     @param      bDeliverOwnerShip
1617                     If parameter is set to <FALSE/> the original caller will be the owner after thrown
1618                     veto exception and must try to close this frame at later time again. Otherwhise the
1619                     source of throwed exception is the right one. May it will be the frame himself.
1620 
1621     @thrown     CloseVetoException
1622                     if any internal things willn't be closed
1623 
1624     @threadsafe yes
1625     @modified   06.05.2002 08:33, as96863
1626 *//*-*****************************************************************************************************/
1627 void SAL_CALL Frame::close( sal_Bool bDeliverOwnerShip ) throw( css::util::CloseVetoException,
1628                                                                 css::uno::RuntimeException   )
1629 {
1630     TransactionGuard aTransaction( m_aTransactionManager, E_HARDEXCEPTIONS );
1631 
1632     // At the end of this method may we must dispose ourself ...
1633     // and may nobody from outside hold a reference to us ...
1634     // then it's a good idea to do that by ourself.
1635     css::uno::Reference< css::uno::XInterface > xSelfHold( static_cast< ::cppu::OWeakObject* >(this) );
1636 
1637     // Check any close listener before we look for currently running internal processes.
1638     // Because if a listener disagree with this close() request - we hace time to finish this
1639     // internal operations too ...
1640     // Note: container is threadsafe himself.
1641     css::lang::EventObject             aSource    (static_cast< ::cppu::OWeakObject*>(this));
1642     ::cppu::OInterfaceContainerHelper* pContainer = m_aListenerContainer.getContainer( ::getCppuType( ( const css::uno::Reference< css::util::XCloseListener >*) NULL ) );
1643     if (pContainer!=NULL)
1644 	{
1645         ::cppu::OInterfaceIteratorHelper pIterator(*pContainer);
1646         while (pIterator.hasMoreElements())
1647         {
1648             try
1649             {
1650                 ((css::util::XCloseListener*)pIterator.next())->queryClosing( aSource, bDeliverOwnerShip );
1651             }
1652             catch( css::uno::RuntimeException& )
1653             {
1654                 pIterator.remove();
1655             }
1656         }
1657 	}
1658 
1659     // Ok - no listener disagreed with this close() request
1660     // check if this frame is used for any load process currently
1661     if (isActionLocked())
1662     {
1663         if (bDeliverOwnerShip)
1664 		{
1665 			/* SAFE */
1666 			WriteGuard aWriteLock( m_aLock );
1667 			m_bSelfClose = sal_True;
1668 			aWriteLock.unlock();
1669 			/* SAFE */
1670 		}
1671 
1672 		throw css::util::CloseVetoException(DECLARE_ASCII("Frame in use for loading document ..."),static_cast< ::cppu::OWeakObject*>(this));
1673     }
1674 
1675     if ( ! setComponent(NULL,NULL) )
1676         throw css::util::CloseVetoException(DECLARE_ASCII("Component couldn't be deattached ..."),static_cast< ::cppu::OWeakObject*>(this));
1677 
1678     // If closing is allowed ... inform all istener and dispose this frame!
1679     pContainer = m_aListenerContainer.getContainer( ::getCppuType( ( const css::uno::Reference< css::util::XCloseListener >*) NULL ) );
1680     if (pContainer!=NULL)
1681 	{
1682         ::cppu::OInterfaceIteratorHelper pIterator(*pContainer);
1683         while (pIterator.hasMoreElements())
1684         {
1685             try
1686             {
1687                 ((css::util::XCloseListener*)pIterator.next())->notifyClosing( aSource );
1688             }
1689             catch( css::uno::RuntimeException& )
1690             {
1691                 pIterator.remove();
1692             }
1693         }
1694 	}
1695 
1696     /* SAFE { */
1697 	WriteGuard aWriteLock( m_aLock );
1698     m_bIsHidden = sal_True;
1699     aWriteLock.unlock();
1700     /* } SAFE */
1701     impl_checkMenuCloser();
1702 
1703     // Attention: We must release our own registered transaction here. Otherwhise following dispose() call
1704     // wait for us too ....
1705     aTransaction.stop();
1706     dispose();
1707 }
1708 
1709 /*-****************************************************************************************************//**
1710     @short      be a listener for close events!
1711     @descr      Adds/remove a CloseListener at this frame instance. If the close() method is called on
1712                 this object, the such listener are informed and can disagree with that by throwing
1713                 a CloseVetoException.
1714 
1715     @seealso    Frame::close()
1716 
1717     @param      xListener
1718                     reference to your listener object
1719 
1720 	@onerror	Listener is ignored.
1721 
1722     @threadsafe yes
1723     @modified   06.05.2002 10:03, as96863
1724 *//*-*****************************************************************************************************/
1725 void SAL_CALL Frame::addCloseListener( const css::uno::Reference< css::util::XCloseListener >& xListener ) throw (css::uno::RuntimeException)
1726 {
1727     TransactionGuard aTransaction( m_aTransactionManager, E_HARDEXCEPTIONS );
1728     // We doesn't need any lock here ...
1729     // Container lives if we live and is threadsafe by himself.
1730     m_aListenerContainer.addInterface( ::getCppuType( ( const css::uno::Reference< css::util::XCloseListener >* ) NULL ), xListener );
1731 }
1732 
1733 //*****************************************************************************************************************
1734 void SAL_CALL Frame::removeCloseListener( const css::uno::Reference< css::util::XCloseListener >& xListener ) throw (css::uno::RuntimeException)
1735 {
1736     // Use soft exception mode - moslty this method is called during disposing of this frame ...
1737     TransactionGuard aTransaction( m_aTransactionManager, E_SOFTEXCEPTIONS );
1738     // We doesn't need any lock here ...
1739     // Container lives if we live and is threadsafe by himself.
1740     m_aListenerContainer.removeInterface( ::getCppuType( ( const css::uno::Reference< css::util::XCloseListener >* ) NULL ), xListener );
1741 }
1742 
1743 //*****************************************************************************************************************
1744 ::rtl::OUString SAL_CALL Frame::getTitle()
1745     throw (css::uno::RuntimeException)
1746 {
1747     TransactionGuard aTransaction( m_aTransactionManager, E_HARDEXCEPTIONS );
1748 
1749 	// SAFE ->
1750 	ReadGuard aReadLock(m_aLock);
1751 	css::uno::Reference< css::frame::XTitle > xTitle(m_xTitleHelper, css::uno::UNO_QUERY_THROW);
1752 	aReadLock.unlock();
1753 	// <- SAFE
1754 
1755     return xTitle->getTitle();
1756 }
1757 
1758 //*****************************************************************************************************************
1759 void SAL_CALL Frame::setTitle( const ::rtl::OUString& sTitle )
1760     throw (css::uno::RuntimeException)
1761 {
1762     TransactionGuard aTransaction( m_aTransactionManager, E_HARDEXCEPTIONS );
1763 
1764 	// SAFE ->
1765 	ReadGuard aReadLock(m_aLock);
1766 	css::uno::Reference< css::frame::XTitle > xTitle(m_xTitleHelper, css::uno::UNO_QUERY_THROW);
1767 	aReadLock.unlock();
1768 	// <- SAFE
1769 
1770     xTitle->setTitle(sTitle);
1771 }
1772 
1773 //*****************************************************************************************************************
1774 void SAL_CALL Frame::addTitleChangeListener( const css::uno::Reference< css::frame::XTitleChangeListener >& xListener)
1775     throw (css::uno::RuntimeException)
1776 {
1777     TransactionGuard aTransaction( m_aTransactionManager, E_HARDEXCEPTIONS );
1778 
1779 	// SAFE ->
1780 	ReadGuard aReadLock(m_aLock);
1781 	css::uno::Reference< css::frame::XTitleChangeBroadcaster > xTitle(m_xTitleHelper, css::uno::UNO_QUERY_THROW);
1782 	aReadLock.unlock();
1783 	// <- SAFE
1784 
1785     xTitle->addTitleChangeListener(xListener);
1786 }
1787 
1788 //*****************************************************************************************************************
1789 void SAL_CALL Frame::removeTitleChangeListener( const css::uno::Reference< css::frame::XTitleChangeListener >& xListener )
1790     throw (css::uno::RuntimeException)
1791 {
1792     TransactionGuard aTransaction( m_aTransactionManager, E_HARDEXCEPTIONS );
1793 
1794 	// SAFE ->
1795 	ReadGuard aReadLock(m_aLock);
1796 	css::uno::Reference< css::frame::XTitleChangeBroadcaster > xTitle(m_xTitleHelper, css::uno::UNO_QUERY_THROW);
1797 	aReadLock.unlock();
1798 	// <- SAFE
1799 
1800     xTitle->removeTitleChangeListener(xListener);
1801 }
1802 
1803 /*-****************************************************************************************************/
1804 void Frame::implts_forgetSubFrames()
1805 {
1806 	// SAFE ->
1807 	ReadGuard aReadLock(m_aLock);
1808 	css::uno::Reference< css::container::XIndexAccess > xContainer(m_xFramesHelper, css::uno::UNO_QUERY_THROW);
1809 	aReadLock.unlock();
1810 	// <- SAFE
1811 
1812 	sal_Int32 c = xContainer->getCount();
1813 	sal_Int32 i = 0;
1814 
1815 	for (i=0; i<c; ++i)
1816 	{
1817 		try
1818 		{
1819 			css::uno::Reference< css::frame::XFrame > xFrame;
1820 			xContainer->getByIndex(i) >>= xFrame;
1821 			if (xFrame.is())
1822 				xFrame->setCreator(css::uno::Reference< css::frame::XFramesSupplier >());
1823 		}
1824 		catch(const css::uno::Exception&)
1825 		{
1826 			// Ignore errors here.
1827 			// Nobody can guarantee a stable index in multi threaded environments .-)
1828 		}
1829 	}
1830 
1831 	// SAFE ->
1832 	WriteGuard aWriteLock(m_aLock);
1833     m_xFramesHelper.clear(); // clear uno reference
1834     m_aChildFrameContainer.clear(); // clear container content
1835 	aWriteLock.unlock();
1836 	// <- SAFE
1837 }
1838 
1839 /*-****************************************************************************************************//**
1840 	@short		destroy instance
1841 	@descr		The owner of this object calles the dispose method if the object
1842 				should be destroyed. All other objects and components, that are registered
1843 				as an EventListener are forced to release their references to this object.
1844 				Furthermore this frame is removed from its parent frame container to release
1845 				this reference. The reference attributes are disposed and released also.
1846 
1847 	@attention	Look for globale description at beginning of file too!
1848 				(DisposedException, FairRWLock ..., initialize, dispose)
1849 
1850 	@seealso	method initialize()
1851 	@seealso	baseclass FairRWLockBase!
1852 
1853 	@param		-
1854 	@return		-
1855 
1856 	@onerror	-
1857 *//*-*****************************************************************************************************/
1858 void SAL_CALL Frame::dispose() throw( css::uno::RuntimeException )
1859 {
1860     // We should hold a reference to ourself ...
1861     // because our owner dispose us and release our reference ...
1862     // May be we will die before we could finish this method ...
1863     css::uno::Reference< css::frame::XFrame > xThis( static_cast< ::cppu::OWeakObject* >(this), css::uno::UNO_QUERY );
1864 
1865     LOG_DISPOSEEVENT( "Frame", sName )
1866 
1867     // First operation should be ... "stopp all listening for window events on our container window".
1868     // These events are superflous but can make trouble!
1869     // We will die, die and die ...
1870     implts_stopWindowListening();
1871 
1872     // Send message to all listener and forget her references.
1873     css::lang::EventObject aEvent( xThis );
1874     m_aListenerContainer.disposeAndClear( aEvent );
1875 
1876     // set "end of live" for our property set helper
1877     impl_disablePropertySet();
1878 
1879     // interception/dispatch chain must be destructed explicitly
1880     // Otherwhise some dispatches and/or interception objects wont die.
1881     css::uno::Reference< css::lang::XEventListener > xDispatchHelper(m_xDispatchHelper, css::uno::UNO_QUERY_THROW);
1882     xDispatchHelper->disposing(aEvent);
1883     xDispatchHelper.clear();
1884 
1885     // Disable this instance for further work.
1886     // This will wait for all current running ones ...
1887     // and reject all further requests!
1888     m_aTransactionManager.setWorkingMode( E_BEFORECLOSE );
1889 
1890     // Don't show any dialogs, errors or something else any more!
1891     // If somewhere called dispose() whitout close() before - normaly no dialogs
1892     // should exist. Otherwhise it's the problem of the outside caller.
1893     // Note:
1894     //      (a) Do it after stopWindowListening(). May that force some active/deactive
1895     //          notifications which we doesn't need here realy.
1896     //      (b) Don't forget to save the old value of IsDialogCancelEnabled() to
1897     //          restore it afterwards. We cannot call EnableDialogCancel( sal_False )
1898     //          as we would kill the headless mode!
1899     sal_Bool bCancelDialogs( Application::IsDialogCancelEnabled() );
1900     Application::EnableDialogCancel( sal_True );
1901 
1902     // We should be alone for ever and further dispose calls are rejected by lines before ...
1903     // I hope it :-)
1904 
1905     // Free references of our frame tree.
1906     // Force parent container to forget this frame too ...
1907     // ( It's contained in m_xParent and so no css::lang::XEventListener for m_xParent! )
1908     // It's important to do that before we free some other internal structures.
1909     // Because if our parent gets an activate and found us as last possible active frame
1910     // he try to deactivate us ... and we run into some trouble (DisposedExceptions!).
1911     if( m_xParent.is() == sal_True )
1912     {
1913         m_xParent->getFrames()->remove( xThis );
1914         m_xParent = css::uno::Reference< css::frame::XFramesSupplier >();
1915     }
1916 
1917     /* } SAFE */
1918     // Forget our internal component and her window first.
1919     // So we can release our container window later without problems.
1920     // Because this container window is the parent of the component window ...
1921     // Note: Dispose it hard - because suspending must be done inside close() call!
1922 	// But try to dispose the controller first befor you destroy the window.
1923 	// Because the window is used by the controller too ...
1924     if (m_xController.is())
1925     {
1926         css::uno::Reference< css::lang::XComponent > xDisposable( m_xController, css::uno::UNO_QUERY );
1927         if (xDisposable.is())
1928             xDisposable->dispose();
1929     }
1930 
1931     if (m_xComponentWindow.is())
1932     {
1933         css::uno::Reference< css::lang::XComponent > xDisposable( m_xComponentWindow, css::uno::UNO_QUERY );
1934         if (xDisposable.is())
1935             xDisposable->dispose();
1936     }
1937 
1938     impl_checkMenuCloser();
1939 
1940     impl_disposeContainerWindow( m_xContainerWindow );
1941 
1942     /*ATTENTION
1943         Clear container after successful removing from parent container ...
1944         because our parent could be the desktop which stand in dispose too!
1945         If we have already cleared our own container we lost our child before this could be
1946         remove himself at this instance ...
1947         Release m_xFramesHelper after that ... it's the same problem between parent and child!
1948         "m_xParent->getFrames()->remove( xThis );" needs this helper ...
1949         Otherwise we get a null reference and could finish removing successfuly.
1950         => You see: Order of calling operations is important!!!
1951      */
1952 	implts_forgetSubFrames();
1953 
1954     // Release some other references.
1955     // This calls should be easy ... I hope it :-)
1956     m_xDispatchHelper.clear();
1957     m_xFactory.clear();
1958     m_xDropTargetListener.clear();
1959     m_xDispatchRecorderSupplier.clear();
1960     m_xLayoutManager.clear();
1961     m_xIndicatorFactoryHelper.clear();
1962 
1963     // It's important to set default values here!
1964     // If may be later somewhere change the disposed-behaviour of this implementation
1965     // and doesn't throw any DisposedExceptions we must guarantee best matching default values ...
1966     m_eActiveState       = E_INACTIVE;
1967     m_sName              = ::rtl::OUString();
1968     m_bIsFrameTop        = sal_False;
1969     m_bConnected         = sal_False;
1970     m_nExternalLockCount = 0;
1971     m_bSelfClose         = sal_False;
1972     m_bIsHidden          = sal_True;
1973 
1974     // Disable this instance for further working realy!
1975     m_aTransactionManager.setWorkingMode( E_CLOSE );
1976 
1977     // Don't forget it restore old value -
1978     // otherwhise no dialogs can be shown anymore in other frames.
1979     Application::EnableDialogCancel( bCancelDialogs );
1980 }
1981 
1982 /*-****************************************************************************************************//**
1983 	@short		Be a listener for dispose events!
1984 	@descr		Adds/remove an EventListener to this object. If the dispose method is called on
1985 				this object, the disposing method of the listener is called.
1986 
1987 	@seealso	-
1988 
1989 	@param		"xListener" reference to your listener object.
1990 	@return		-
1991 
1992 	@onerror	Listener is ignored.
1993 *//*-*****************************************************************************************************/
1994 void SAL_CALL Frame::addEventListener( const css::uno::Reference< css::lang::XEventListener >& xListener ) throw( css::uno::RuntimeException )
1995 {
1996 	/* UNSAFE AREA --------------------------------------------------------------------------------------------- */
1997 	// Check incoming parameter.
1998     LOG_ASSERT2( implcp_addEventListener( xListener ), "Frame::addEventListener()", "Invalid parameter detected." )
1999     // Look for rejected calls only!
2000     // Container is threadsafe.
2001     TransactionGuard aTransaction( m_aTransactionManager, E_HARDEXCEPTIONS );
2002 
2003 	/* SAFE AREA ----------------------------------------------------------------------------------------------- */
2004     m_aListenerContainer.addInterface( ::getCppuType( ( const css::uno::Reference< css::lang::XEventListener >* ) NULL ), xListener );
2005 }
2006 
2007 //*****************************************************************************************************************
2008 void SAL_CALL Frame::removeEventListener( const css::uno::Reference< css::lang::XEventListener >& xListener ) throw( css::uno::RuntimeException )
2009 {
2010 	/* UNSAFE AREA --------------------------------------------------------------------------------------------- */
2011 	// Check incoming parameter.
2012     LOG_ASSERT2( implcp_removeEventListener( xListener ), "Frame::removeEventListener()", "Invalid parameter detected." )
2013     // Look for rejected calls only!
2014     // Container is threadsafe.
2015     // Use E_SOFTEXCEPTIONS to allow removing listeners during dispose call!
2016     TransactionGuard aTransaction( m_aTransactionManager, E_SOFTEXCEPTIONS );
2017 
2018 	/* SAFE AREA ----------------------------------------------------------------------------------------------- */
2019     m_aListenerContainer.removeInterface( ::getCppuType( ( const css::uno::Reference< css::lang::XEventListener >* ) NULL ), xListener );
2020 }
2021 
2022 /*-****************************************************************************************************//**
2023 	@short		create new status indicator
2024 	@descr		Use returned status indicator to show progresses and some text informations.
2025 				All created objects share the same dialog! Only the last one can show his information.
2026 
2027     @seealso    class StatusIndicatorFactory
2028     @seealso    class StatusIndicator
2029 
2030 	@param		-
2031 	@return		A reference to created object.
2032 
2033 	@onerror	We return a null reference.
2034 *//*-*****************************************************************************************************/
2035 css::uno::Reference< css::task::XStatusIndicator > SAL_CALL Frame::createStatusIndicator() throw( css::uno::RuntimeException )
2036 {
2037     /* UNSAFE AREA ----------------------------------------------------------------------------------------- */
2038     // Look for rejected calls!
2039     TransactionGuard aTransaction( m_aTransactionManager, E_HARDEXCEPTIONS );
2040 
2041 	/* SAFE AREA ----------------------------------------------------------------------------------------------- */
2042     ReadGuard aReadLock( m_aLock );
2043 
2044     // Make snapshot of neccessary member and define default return value.
2045     css::uno::Reference< css::task::XStatusIndicator >        xExternal(m_xIndicatorInterception.get(), css::uno::UNO_QUERY);
2046     css::uno::Reference< css::task::XStatusIndicatorFactory > xFactory = m_xIndicatorFactoryHelper;
2047 
2048     aReadLock.unlock();
2049     /* UNSAFE AREA ----------------------------------------------------------------------------------------- */
2050 
2051     // Was set from outside to intercept any progress activities!
2052     if (xExternal.is())
2053         return xExternal;
2054 
2055     // Or use our own factory as fallback, to create such progress.
2056     if (xFactory.is())
2057         return xFactory->createStatusIndicator();
2058 
2059 	return css::uno::Reference< css::task::XStatusIndicator >();
2060 }
2061 
2062 /*-****************************************************************************************************//**
2063 	@short		search for target to load URL
2064 	@descr		This method searches for a dispatch for the specified DispatchDescriptor.
2065 				The FrameSearchFlags and the FrameName of the DispatchDescriptor are
2066 				treated as described for findFrame.
2067 
2068 	@seealso	method findFrame()
2069 	@seealso	method queryDispatches()
2070 	@seealso	method set/getName()
2071 	@seealso	class TargetFinder
2072 
2073 	@param		"aURL"				, URL for loading
2074 	@param		"sTargetFrameName"	, name of target frame
2075 	@param		"nSearchFlags"		, additional flags to regulate search if sTargetFrameName isn't clear
2076     @return     css::uno::Reference to dispatch handler.
2077 
2078 	@onerror	A null reference is returned.
2079 *//*-*****************************************************************************************************/
2080 css::uno::Reference< css::frame::XDispatch > SAL_CALL Frame::queryDispatch( const css::util::URL&   aURL            ,
2081                                                                             const ::rtl::OUString&  sTargetFrameName,
2082                                                                                   sal_Int32         nSearchFlags    ) throw( css::uno::RuntimeException )
2083 {
2084 	const char UNO_PROTOCOL[] = ".uno:";
2085 
2086 	// Don't check incoming parameter here! Our helper do it for us and it isn't a good idea to do it more then ones!
2087     // But look for rejected calls!
2088     TransactionGuard aTransaction( m_aTransactionManager, E_HARDEXCEPTIONS );
2089 
2090 	// Remove uno and cmd protocol part as we want to support both of them. We store only the command part
2091 	// in our hash map. All other protocols are stored with the protocol part.
2092 	String aCommand( aURL.Main );
2093 	if ( aURL.Protocol.equalsIgnoreAsciiCaseAsciiL( UNO_PROTOCOL, sizeof( UNO_PROTOCOL )-1 ))
2094 		aCommand = aURL.Path;
2095 
2096 	// Make hash_map lookup if the current URL is in the disabled list
2097 	if ( m_aCommandOptions.Lookup( SvtCommandOptions::CMDOPTION_DISABLED, aCommand ) )
2098 		return css::uno::Reference< css::frame::XDispatch >();
2099 	else
2100 	{
2101 		// We use a helper to support these interface and an interceptor mechanism.
2102 		// Our helper is threadsafe by himself!
2103 		return m_xDispatchHelper->queryDispatch( aURL, sTargetFrameName, nSearchFlags );
2104 	}
2105 }
2106 
2107 /*-****************************************************************************************************//**
2108 	@short		handle more then ones dispatches at same call
2109     @descr      Returns a sequence of dispatches. For details see the queryDispatch method.
2110 				For failed dispatches we return empty items in list!
2111 
2112 	@seealso	method queryDispatch()
2113 
2114 	@param		"lDescriptor" list of dispatch arguments for queryDispatch()!
2115 	@return		List of dispatch references. Some elements can be NULL!
2116 
2117 	@onerror	An empty list is returned.
2118 *//*-*****************************************************************************************************/
2119 css::uno::Sequence< css::uno::Reference< css::frame::XDispatch > > SAL_CALL Frame::queryDispatches( const css::uno::Sequence< css::frame::DispatchDescriptor >& lDescriptor ) throw( css::uno::RuntimeException )
2120 {
2121 	// Don't check incoming parameter here! Our helper do it for us and it isn't a good idea to do it more then ones!
2122     // But look for rejected calls!
2123     TransactionGuard aTransaction( m_aTransactionManager, E_HARDEXCEPTIONS );
2124 
2125 	// We use a helper to support these interface and an interceptor mechanism.
2126     // Our helper is threadsafe by himself!
2127     return m_xDispatchHelper->queryDispatches( lDescriptor );
2128 }
2129 
2130 /*-****************************************************************************************************//**
2131 	@short		register/unregister interceptor for dispatch calls
2132 	@descr		If you whish to handle some dispatches by himself ... you should be
2133 				an interceptor for it. Please see class OInterceptionHelper for further informations.
2134 
2135 	@seealso	class OInterceptionHelper
2136 
2137 	@param		"xInterceptor", reference to your interceptor implementation.
2138 	@return		-
2139 
2140 	@onerror	Interceptor is ignored.
2141 *//*-*****************************************************************************************************/
2142 void SAL_CALL Frame::registerDispatchProviderInterceptor( const css::uno::Reference< css::frame::XDispatchProviderInterceptor >& xInterceptor ) throw( css::uno::RuntimeException )
2143 {
2144 	// We use a helper to support these interface and an interceptor mechanism.
2145     // This helper is threadsafe himself and check incoming parameter too.
2146     // I think we don't need any lock here!
2147     // But we must look for rejected calls.
2148     TransactionGuard aTransaction( m_aTransactionManager, E_HARDEXCEPTIONS );
2149 
2150     css::uno::Reference< css::frame::XDispatchProviderInterception > xInterceptionHelper( m_xDispatchHelper, css::uno::UNO_QUERY );
2151     xInterceptionHelper->registerDispatchProviderInterceptor( xInterceptor );
2152 }
2153 
2154 //*****************************************************************************************************************
2155 void SAL_CALL Frame::releaseDispatchProviderInterceptor( const css::uno::Reference< css::frame::XDispatchProviderInterceptor >& xInterceptor ) throw( css::uno::RuntimeException )
2156 {
2157 	// We use a helper to support these interface and an interceptor mechanism.
2158     // This helper is threadsafe himself and check incoming parameter too.
2159     // I think we don't need any lock here!
2160     // But we must look for rejected calls ...
2161     // Sometimes we are called during our dispose() method ... => soft exceptions!
2162     TransactionGuard aTransaction( m_aTransactionManager, E_SOFTEXCEPTIONS );
2163 
2164     css::uno::Reference< css::frame::XDispatchProviderInterception > xInterceptionHelper( m_xDispatchHelper, css::uno::UNO_QUERY );
2165     xInterceptionHelper->releaseDispatchProviderInterceptor( xInterceptor );
2166 }
2167 
2168 /*-****************************************************************************************************//**
2169 	@short		provides information about all possible dispatch functions
2170                 inside the currnt frame environment
2171 *//*-*****************************************************************************************************/
2172 css::uno::Sequence< sal_Int16 > SAL_CALL Frame::getSupportedCommandGroups()
2173     throw(css::uno::RuntimeException)
2174 {
2175     return m_xDispatchInfoHelper->getSupportedCommandGroups();
2176 }
2177 
2178 //*****************************************************************************************************************
2179 css::uno::Sequence< css::frame::DispatchInformation > SAL_CALL Frame::getConfigurableDispatchInformation(sal_Int16 nCommandGroup)
2180     throw(css::uno::RuntimeException)
2181 {
2182     return m_xDispatchInfoHelper->getConfigurableDispatchInformation(nCommandGroup);
2183 }
2184 
2185 /*-****************************************************************************************************//**
2186 	@short		notifications for window events
2187 	@descr		We are a listener on our container window to forward it to our component window.
2188 
2189 	@seealso	method setComponent()
2190 	@seealso	member m_xContainerWindow
2191 	@seealso	member m_xComponentWindow
2192 
2193 	@param		"aEvent" describe source of detected event
2194 	@return		-
2195 
2196 	@onerror	-
2197 *//*-*****************************************************************************************************/
2198 void SAL_CALL Frame::windowResized( const css::awt::WindowEvent&
2199 #if OSL_DEBUG_LEVEL > 0
2200 aEvent
2201 #endif
2202 ) throw( css::uno::RuntimeException )
2203 {
2204 	/* UNSAFE AREA --------------------------------------------------------------------------------------------- */
2205 	// Check incoming parameter.
2206     LOG_ASSERT2( implcp_windowResized( aEvent ), "Frame::windowResized()", "Invalid parameter detected." )
2207     // Look for rejected calls.
2208     // Part of dispose-mechanism => soft exceptions
2209     TransactionGuard aTransaction( m_aTransactionManager, E_SOFTEXCEPTIONS );
2210 
2211 	/* SAFE AREA ----------------------------------------------------------------------------------------------- */
2212 	// Impl-method is threadsafe!
2213 	// If we have a current component window - we must resize it!
2214     implts_resizeComponentWindow();
2215 }
2216 
2217 //*****************************************************************************************************************
2218 void SAL_CALL Frame::focusGained( const css::awt::FocusEvent&
2219 #if OSL_DEBUG_LEVEL > 0
2220 aEvent
2221 #endif
2222 ) throw( css::uno::RuntimeException )
2223 {
2224 	/* UNSAFE AREA --------------------------------------------------------------------------------------------- */
2225 	// Check incoming parameter.
2226     LOG_ASSERT2( implcp_focusGained( aEvent ), "Frame::focusGained()", "Invalid parameter detected." )
2227     // Look for rejected calls.
2228     // Part of dispose() mechanism ... => soft exceptions!
2229     TransactionGuard aTransaction( m_aTransactionManager, E_SOFTEXCEPTIONS );
2230 
2231 	/* SAFE AREA ----------------------------------------------------------------------------------------------- */
2232     ReadGuard aReadLock( m_aLock );
2233     // Make snapshot of member!
2234     css::uno::Reference< css::awt::XWindow > xComponentWindow = m_xComponentWindow;
2235     aReadLock.unlock();
2236     /* UNSAFE AREA --------------------------------------------------------------------------------------------- */
2237 
2238     if( xComponentWindow.is() == sal_True )
2239     {
2240         xComponentWindow->setFocus();
2241     }
2242 }
2243 
2244 /*-****************************************************************************************************//**
2245 	@short		notifications for window events
2246 	@descr		We are a listener on our container window to forward it to our component window ...
2247 				but a XTopWindowListener we are only if we are a top frame!
2248 
2249 	@seealso	method setComponent()
2250 	@seealso	member m_xContainerWindow
2251 	@seealso	member m_xComponentWindow
2252 
2253 	@param		"aEvent" describe source of detected event
2254 	@return		-
2255 
2256 	@onerror	-
2257 *//*-*****************************************************************************************************/
2258 void SAL_CALL Frame::windowActivated( const css::lang::EventObject&
2259 #if OSL_DEBUG_LEVEL > 0
2260 aEvent
2261 #endif
2262 ) throw( css::uno::RuntimeException )
2263 {
2264 	/* UNSAFE AREA --------------------------------------------------------------------------------------------- */
2265 	// Check incoming parameter.
2266     LOG_ASSERT2( implcp_windowActivated( aEvent ), "Frame::windowActivated()", "Invalid parameter detected." )
2267     // Look for rejected calls.
2268     TransactionGuard aTransaction( m_aTransactionManager, E_HARDEXCEPTIONS );
2269 
2270 	/* SAFE AREA ----------------------------------------------------------------------------------------------- */
2271     ReadGuard aReadLock( m_aLock );
2272     // Make snapshot of member!
2273     EActiveState eState = m_eActiveState;
2274     aReadLock.unlock();
2275     /* UNSAFE AREA --------------------------------------------------------------------------------------------- */
2276     // Activate the new active path from here to top.
2277     if( eState == E_INACTIVE )
2278     {
2279 //       CheckMenuCloser_Impl();
2280         setActiveFrame( css::uno::Reference< css::frame::XFrame >() );
2281         activate();
2282     }
2283 }
2284 
2285 //*****************************************************************************************************************
2286 void SAL_CALL Frame::windowDeactivated( const css::lang::EventObject&
2287 #if OSL_DEBUG_LEVEL > 0
2288 aEvent
2289 #endif
2290 ) throw( css::uno::RuntimeException )
2291 {
2292 	/* UNSAFE AREA --------------------------------------------------------------------------------------------- */
2293 	// Check incoming parameter.
2294     LOG_ASSERT2( implcp_windowDeactivated( aEvent ), "Frame::windowDeactivated()", "Invalid parameter detected." )
2295     // Look for rejected calls.
2296     // Sometimes called during dispose() => soft exceptions
2297     TransactionGuard aTransaction( m_aTransactionManager, E_SOFTEXCEPTIONS );
2298 
2299 	/* SAFE AREA ----------------------------------------------------------------------------------------------- */
2300     ReadGuard aReadLock( m_aLock );
2301 
2302     css::uno::Reference< css::frame::XFrame > xParent          ( m_xParent, css::uno::UNO_QUERY );
2303     css::uno::Reference< css::awt::XWindow >  xContainerWindow = m_xContainerWindow;
2304     EActiveState                              eActiveState     = m_eActiveState    ;
2305 
2306     aReadLock.unlock();
2307 
2308     if( eActiveState != E_INACTIVE )
2309     {
2310         // Deactivation is always done implicitely by activation of another frame.
2311         // Only if no activation is done, deactivations have to be processed if the activated window
2312         // is a parent window of the last active Window!
2313         ::vos::OClearableGuard aSolarGuard( Application::GetSolarMutex() );
2314 //       CheckMenuCloser_Impl();
2315         Window* pFocusWindow = Application::GetFocusWindow();
2316         if  (
2317                 ( xContainerWindow.is()                                                              ==  sal_True    )   &&
2318                 ( xParent.is()                                                                       ==  sal_True    )   &&
2319                 ( (css::uno::Reference< css::frame::XDesktop >( xParent, css::uno::UNO_QUERY )).is() ==  sal_False   )
2320             )
2321         {
2322             css::uno::Reference< css::awt::XWindow >  xParentWindow   = xParent->getContainerWindow()             ;
2323             Window*                                   pParentWindow   = VCLUnoHelper::GetWindow( xParentWindow    );
2324             //#i70261#: dialogs opend from an OLE object will cause a deactivate on the frame of the OLE object
2325             // on Solaris/Linux at that time pFocusWindow is still NULL because the focus handling is different; right after
2326             // the deactivation the focus will be set into the dialog!
2327             // currently I see no case where a sub frame could get a deactivate with pFocusWindow being NULL permanently
2328             // so for now this case is omitted from handled deactivations
2329             if( pFocusWindow && pParentWindow->IsChild( pFocusWindow ) )
2330             {
2331                 css::uno::Reference< css::frame::XFramesSupplier > xSupplier( xParent, css::uno::UNO_QUERY );
2332                 if( xSupplier.is() == sal_True )
2333                 {
2334                     aSolarGuard.clear();
2335                     xSupplier->setActiveFrame( css::uno::Reference< css::frame::XFrame >() );
2336                 }
2337             }
2338         }
2339     }
2340 }
2341 
2342 //*****************************************************************************************************************
2343 void SAL_CALL Frame::windowClosing( const css::lang::EventObject& ) throw( css::uno::RuntimeException )
2344 {
2345     /* #i62088#
2346         Some interceptor objects intercept our "internaly asynchronoues implemented" dispatch call.
2347         And they close this frame directly (means synchronous then).
2348         Means: Frame::windowClosing()->Frame::close()
2349         In such situation its not a good idea to hold this transaction count alive .-)
2350     */
2351     {
2352         // Look for rejected calls.
2353         TransactionGuard aTransaction( m_aTransactionManager, E_HARDEXCEPTIONS );
2354         // deactivate this frame ...
2355     	deactivate();
2356     }
2357 
2358     // ... and try to close it
2359     // But do it asynchron inside the main thread.
2360     // VCL has no fun to do such things outside his main thread :-(
2361     // Note: The used dispatch make it asynchronous for us .-)
2362 
2363     /*ATTENTION!
2364         Don't try to suspend the controller here! Because it's done inside used dispatch().
2365         Otherwhise the dialog "would you save your changes?" will be shown more then once ...
2366      */
2367 
2368     /* SAFE */
2369     ReadGuard aReadLock( m_aLock );
2370     css::uno::Reference< css::lang::XMultiServiceFactory > xFactory = m_xFactory;
2371     aReadLock.unlock();
2372     /* SAFE */
2373 
2374     css::util::URL aURL;
2375     aURL.Complete = DECLARE_ASCII(".uno:CloseFrame");
2376     css::uno::Reference< css::util::XURLTransformer > xParser(xFactory->createInstance(SERVICENAME_URLTRANSFORMER), css::uno::UNO_QUERY_THROW);
2377     xParser->parseStrict(aURL);
2378 
2379     css::uno::Reference< css::frame::XDispatch > xCloser = queryDispatch(aURL, SPECIALTARGET_SELF, 0);
2380     if (xCloser.is())
2381         xCloser->dispatch(aURL, css::uno::Sequence< css::beans::PropertyValue >());
2382 
2383     // Attention: If this dispatch works synchronous ... and full fill its job ...
2384     // this line of code will never be reached ...
2385     // Or if it will be reached it will be for sure that all your member are gone .-)
2386 }
2387 
2388 /*-****************************************************************************************************//**
2389     @short      react for a show event for the internal container window
2390     @descr      Normaly we doesn't need this information realy. But we can use it to
2391                 implement the special feature "trigger first visible task".
2392 
2393                 Algorithm: - first we have to check if we are a top (task) frame
2394                              It's not enough to be a top frame! Because we MUST have the desktop as parent.
2395                              But frames without a parent are top too. So it's not possible to check isTop() here!
2396                              We have to look for the type of our parent.
2397                            - if we are a task frame, then we have to check if we are the first one.
2398                              We use a static variable to do so. They will be reset to afterwards be shure
2399                              that further calls of this method doesn't do anything then.
2400                            - Then we have to trigger the right event string on the global job executor.
2401 
2402     @seealso    css::task::JobExecutor
2403 
2404     @param      aEvent
2405                     describes the source of this event
2406                     We are not interested on this information. We are interested on the visible state only.
2407 
2408     @threadsafe yes
2409     @modified   31.07.2002 07:56, as96863
2410 *//*-*****************************************************************************************************/
2411 void SAL_CALL Frame::windowShown( const css::lang::EventObject& ) throw(css::uno::RuntimeException)
2412 {
2413     static sal_Bool bFirstVisibleTask = sal_True;
2414 
2415     /* SAFE { */
2416     ReadGuard aReadLock(m_aLock);
2417     css::uno::Reference< css::frame::XDesktop >             xDesktopCheck( m_xParent, css::uno::UNO_QUERY );
2418     css::uno::Reference< css::lang::XMultiServiceFactory >  xFactory     = m_xFactory;
2419     m_bIsHidden = sal_False;
2420     aReadLock.unlock();
2421     /* } SAFE */
2422 
2423     impl_checkMenuCloser();
2424 
2425     if (xDesktopCheck.is())
2426     {
2427         /* STATIC SAFE { */
2428         WriteGuard aStaticWriteLock( LockHelper::getGlobalLock() );
2429         sal_Bool bMustBeTriggered  = bFirstVisibleTask;
2430                  bFirstVisibleTask = sal_False;
2431         aStaticWriteLock.unlock();
2432         /* } STATIC SAFE */
2433 
2434         if (bMustBeTriggered)
2435         {
2436             css::uno::Reference< css::task::XJobExecutor > xExecutor( xFactory->createInstance( SERVICENAME_JOBEXECUTOR ), css::uno::UNO_QUERY );
2437             if (xExecutor.is())
2438             {
2439                 xExecutor->trigger( DECLARE_ASCII("onFirstVisibleTask") );
2440             }
2441         }
2442     }
2443 }
2444 
2445 void SAL_CALL Frame::windowHidden( const css::lang::EventObject& ) throw(css::uno::RuntimeException)
2446 {
2447     /* SAFE { */
2448     ReadGuard aReadLock(m_aLock);
2449     m_bIsHidden = sal_True;
2450     aReadLock.unlock();
2451     /* } SAFE */
2452 
2453     impl_checkMenuCloser();
2454 }
2455 
2456 /*-****************************************************************************************************//**
2457 	@short		called by dispose of our windows!
2458 	@descr		This object is forced to release all references to the interfaces given
2459 				by the parameter source. We are a listener at our container window and
2460 				should listen for his diposing.
2461 
2462 	@seealso	XWindowListener
2463 	@seealso	XTopWindowListener
2464 	@seealso	XFocusListener
2465 
2466 	@param		-
2467 	@return		-
2468 
2469 	@onerror	-
2470 *//*-*****************************************************************************************************/
2471 void SAL_CALL Frame::disposing( const css::lang::EventObject& aEvent ) throw( css::uno::RuntimeException )
2472 {
2473 	/* UNSAFE AREA --------------------------------------------------------------------------------------------- */
2474 	// Check incoming parameter.
2475     LOG_ASSERT2( implcp_disposing( aEvent ), "Frame::disposing()", "Invalid parameter detected." )
2476     // Look for rejected calls.
2477     // May be we are called during releasing our windows in our in dispose call!? => soft exceptions
2478     TransactionGuard aTransaction( m_aTransactionManager, E_SOFTEXCEPTIONS );
2479 
2480 	/* SAFE AREA ----------------------------------------------------------------------------------------------- */
2481     WriteGuard aWriteLock( m_aLock );
2482 
2483     if( aEvent.Source == m_xContainerWindow )
2484     {
2485         // NECCESSARY: Impl-method is threadsafe by himself!
2486         aWriteLock.unlock();
2487         implts_stopWindowListening();
2488         aWriteLock.lock();
2489         m_xContainerWindow = css::uno::Reference< css::awt::XWindow >();
2490     }
2491 }
2492 
2493 /*-************************************************************************************************************//**
2494     @interface  com.sun.star.document.XActionLockable
2495     @short      implement locking of frame/task from outside
2496     @descr      Sometimes we have problems to decide if closing of task is allowed. Because; frame/task
2497                 could be used for pending loading jobs. So you can lock this object from outside and
2498                 prevent instance against closing during using! But - don't do it in a wrong or expensive manner.
2499                 Otherwise task couldn't die anymore!!!
2500 
2501     @seealso    interface XActionLockable
2502     @seeelso    method BaseDispatcher::implts_loadIt()
2503     @seeelso    method Desktop::loadComponentFromURL()
2504 
2505     @param      -
2506     @return     true if frame/task is locked
2507                 false otherwise
2508 
2509     @onerror    -
2510     @threadsafe yes
2511 *//*-*************************************************************************************************************/
2512 sal_Bool SAL_CALL Frame::isActionLocked() throw( css::uno::RuntimeException )
2513 {
2514 	/* SAFE AREA ----------------------------------------------------------------------------------------------- */
2515     ReadGuard aReadLock( m_aLock );
2516     return( m_nExternalLockCount!=0);
2517 }
2518 
2519 //*****************************************************************************************************************
2520 void SAL_CALL Frame::addActionLock() throw( css::uno::RuntimeException )
2521 {
2522 	/* SAFE AREA ----------------------------------------------------------------------------------------------- */
2523     WriteGuard aWriteLock( m_aLock );
2524     ++m_nExternalLockCount;
2525 }
2526 
2527 //*****************************************************************************************************************
2528 void SAL_CALL Frame::removeActionLock() throw( css::uno::RuntimeException )
2529 {
2530 	// Register no transaction here! Otherwhise we wait for ever inside possible
2531 	// implts_checkSuicide()/dispose() request ...
2532 
2533     /* SAFE AREA */{
2534         WriteGuard aWriteLock( m_aLock );
2535         LOG_ASSERT2( m_nExternalLockCount<=0, "Frame::removeActionLock()", "Frame isn't locked! Possible multithreading problem detected." )
2536         --m_nExternalLockCount;
2537     }/* SAFE */
2538 
2539     implts_checkSuicide();
2540 }
2541 
2542 //*****************************************************************************************************************
2543 void SAL_CALL Frame::setActionLocks( sal_Int16 nLock ) throw( css::uno::RuntimeException )
2544 {
2545 	/* SAFE AREA ----------------------------------------------------------------------------------------------- */
2546     WriteGuard aWriteLock( m_aLock );
2547     // Attention: If somewhere called resetActionLocks() before and get e.g. 5 locks ...
2548     //            and tried to set these 5 ones here after his operations ...
2549     //            we can't ignore setted requests during these two calls!
2550     //            So we must add(!) these 5 locks here.
2551     m_nExternalLockCount = m_nExternalLockCount + nLock;
2552 }
2553 
2554 //*****************************************************************************************************************
2555 sal_Int16 SAL_CALL Frame::resetActionLocks() throw( css::uno::RuntimeException )
2556 {
2557 	// Register no transaction here! Otherwhise we wait for ever inside possible
2558 	// implts_checkSuicide()/dispose() request ...
2559 
2560     sal_Int16 nCurrentLocks = 0;
2561     /* SAFE */{
2562         WriteGuard aWriteLock( m_aLock );
2563         nCurrentLocks = m_nExternalLockCount;
2564         m_nExternalLockCount = 0;
2565     }/* SAFE */
2566 
2567     // Attention:
2568 	// external lock count is 0 here every time ... but if
2569     // member m_bSelfClose is set to true too .... we call our own close()/dispose().
2570     // See close() for further informations
2571     implts_checkSuicide();
2572 
2573     return nCurrentLocks;
2574 }
2575 
2576 //*****************************************************************************************************************
2577 void Frame::impl_initializePropInfo()
2578 {
2579     impl_setPropertyChangeBroadcaster(static_cast< css::frame::XFrame* >(this));
2580 
2581     impl_addPropertyInfo(
2582         css::beans::Property(
2583             FRAME_PROPNAME_DISPATCHRECORDERSUPPLIER,
2584             FRAME_PROPHANDLE_DISPATCHRECORDERSUPPLIER,
2585             ::getCppuType((const css::uno::Reference< css::frame::XDispatchRecorderSupplier >*)NULL),
2586             css::beans::PropertyAttribute::TRANSIENT));
2587 
2588     impl_addPropertyInfo(
2589         css::beans::Property(
2590             FRAME_PROPNAME_INDICATORINTERCEPTION,
2591             FRAME_PROPHANDLE_INDICATORINTERCEPTION,
2592             ::getCppuType((const css::uno::Reference< css::task::XStatusIndicator >*)NULL),
2593             css::beans::PropertyAttribute::TRANSIENT));
2594 
2595     impl_addPropertyInfo(
2596         css::beans::Property(
2597             FRAME_PROPNAME_ISHIDDEN,
2598             FRAME_PROPHANDLE_ISHIDDEN,
2599             ::getBooleanCppuType(),
2600             css::beans::PropertyAttribute::TRANSIENT | css::beans::PropertyAttribute::READONLY));
2601 
2602     impl_addPropertyInfo(
2603         css::beans::Property(
2604             FRAME_PROPNAME_LAYOUTMANAGER,
2605             FRAME_PROPHANDLE_LAYOUTMANAGER,
2606             ::getCppuType((const css::uno::Reference< ::com::sun::star::frame::XLayoutManager >*)NULL),
2607             css::beans::PropertyAttribute::TRANSIENT));
2608 
2609     impl_addPropertyInfo(
2610         css::beans::Property(
2611             FRAME_PROPNAME_TITLE,
2612             FRAME_PROPHANDLE_TITLE,
2613             ::getCppuType((const ::rtl::OUString*)NULL),
2614             css::beans::PropertyAttribute::TRANSIENT));
2615 }
2616 
2617 //*****************************************************************************************************************
2618 void SAL_CALL Frame::impl_setPropertyValue(const ::rtl::OUString& /*sProperty*/,
2619                                                  sal_Int32        nHandle  ,
2620                                            const css::uno::Any&   aValue   )
2621 
2622 {
2623     static ::rtl::OUString MATERIALPROP_TITLE = ::rtl::OUString::createFromAscii("title");
2624 
2625     /* There is no need to lock any mutex here. Because we share the
2626        solar mutex with our base class. And we said to our base class: "dont release it on calling us" .-)
2627        see ctor of PropertySetHelper for further informations.
2628     */
2629 
2630     /* Attention: You can use nHandle only, if you are sure that all supported
2631                   properties has an unique handle. That must be guaranteed
2632                   inside method impl_initializePropInfo()!
2633     */
2634 	switch (nHandle)
2635 	{
2636         case FRAME_PROPHANDLE_TITLE :
2637                 {
2638                     ::rtl::OUString sExternalTitle;
2639                     aValue >>= sExternalTitle;
2640 					setTitle (sExternalTitle);
2641                 }
2642                 break;
2643 
2644         case FRAME_PROPHANDLE_DISPATCHRECORDERSUPPLIER :
2645                 aValue >>= m_xDispatchRecorderSupplier;
2646                 break;
2647 
2648         case FRAME_PROPHANDLE_LAYOUTMANAGER :
2649                 {
2650                     css::uno::Reference< css::frame::XLayoutManager > xOldLayoutManager = m_xLayoutManager;
2651                     css::uno::Reference< css::frame::XLayoutManager > xNewLayoutManager;
2652                     aValue >>= xNewLayoutManager;
2653 
2654                     if (xOldLayoutManager != xNewLayoutManager)
2655                     {
2656                         m_xLayoutManager = xNewLayoutManager;
2657                         if (xOldLayoutManager.is())
2658                             lcl_disableLayoutManager(xOldLayoutManager, this);
2659                         if (xNewLayoutManager.is())
2660                             lcl_enableLayoutManager(xNewLayoutManager, this);
2661                     }
2662                 }
2663                 break;
2664 
2665         case FRAME_PROPHANDLE_INDICATORINTERCEPTION :
2666                 {
2667                     css::uno::Reference< css::task::XStatusIndicator > xProgress;
2668                     aValue >>= xProgress;
2669                     m_xIndicatorInterception = xProgress;
2670                 }
2671                 break;
2672 
2673         #ifdef ENABLE_WARNINGS
2674         default :
2675                 LOG_WARNING( "Frame::setFastPropertyValue_NoBroadcast()", "Invalid handle detected!" )
2676                 break;
2677 		#endif
2678 	}
2679 }
2680 
2681 //*****************************************************************************************************************
2682 css::uno::Any SAL_CALL Frame::impl_getPropertyValue(const ::rtl::OUString& /*sProperty*/,
2683                                                           sal_Int32        nHandle  )
2684 {
2685     /* There is no need to lock any mutex here. Because we share the
2686        solar mutex with our base class. And we said to our base class: "dont release it on calling us" .-)
2687        see ctor of PropertySetHelper for further informations.
2688     */
2689 
2690     /* Attention: You can use nHandle only, if you are sure that all supported
2691                   properties has an unique handle. That must be guaranteed
2692                   inside method impl_initializePropInfo()!
2693     */
2694     css::uno::Any aValue;
2695 	switch (nHandle)
2696 	{
2697         case FRAME_PROPHANDLE_TITLE :
2698 				aValue <<= getTitle ();
2699                 break;
2700 
2701         case FRAME_PROPHANDLE_DISPATCHRECORDERSUPPLIER :
2702                 aValue <<= m_xDispatchRecorderSupplier;
2703                 break;
2704 
2705         case FRAME_PROPHANDLE_ISHIDDEN :
2706                 aValue <<= m_bIsHidden;
2707                 break;
2708 
2709         case FRAME_PROPHANDLE_LAYOUTMANAGER :
2710                 aValue <<= m_xLayoutManager;
2711                 break;
2712 
2713         case FRAME_PROPHANDLE_INDICATORINTERCEPTION :
2714                 {
2715                     css::uno::Reference< css::task::XStatusIndicator > xProgress(m_xIndicatorInterception.get(), css::uno::UNO_QUERY);
2716                     aValue = css::uno::makeAny(xProgress);
2717                 }
2718                 break;
2719 
2720         #ifdef ENABLE_WARNINGS
2721         default :
2722                 LOG_WARNING( "Frame::getFastPropertyValue()", "Invalid handle detected!" )
2723                 break;
2724 		#endif
2725 	}
2726 
2727     return aValue;
2728 }
2729 
2730 /*-****************************************************************************************************//**
2731     @short      dispose old container window and forget his reference
2732     @descr      Sometimes we must repair our "modal dialog parent mechanism" too!
2733 
2734 	@seealso	-
2735 
2736     @param      "xWindow", reference to old container window to dispose it
2737     @return     An empty reference.
2738 
2739     @onerror    -
2740     @threadsafe NO!
2741 *//*-*****************************************************************************************************/
2742 void Frame::impl_disposeContainerWindow( css::uno::Reference< css::awt::XWindow >& xWindow )
2743 {
2744     if( xWindow.is() == sal_True )
2745     {
2746         xWindow->setVisible( sal_False );
2747         // All VclComponents are XComponents; so call dispose before discarding
2748         // a css::uno::Reference< XVclComponent >, because this frame is the owner of the window
2749         xWindow->dispose();
2750         xWindow = css::uno::Reference< css::awt::XWindow >();
2751     }
2752 }
2753 
2754 /*-****************************************************************************************************//**
2755 	@short		send frame action event to our listener
2756 	@descr		This method is threadsafe AND can be called by our dispose method too!
2757 
2758 	@seealso	-
2759 
2760 	@param		"aAction", describe the event for sending
2761 	@return		-
2762 
2763 	@onerror	-
2764 *//*-*****************************************************************************************************/
2765 void Frame::implts_sendFrameActionEvent( const css::frame::FrameAction& aAction )
2766 {
2767     /* UNSAFE AREA --------------------------------------------------------------------------------------------- */
2768     // Sometimes used by dispose() => soft exceptions!
2769     TransactionGuard aTransaction( m_aTransactionManager, E_SOFTEXCEPTIONS );
2770 
2771 	// Log informations about order of events to file!
2772 	// (only activated in debug version!)
2773 	LOG_FRAMEACTIONEVENT( "Frame", m_sName, aAction )
2774 
2775 	/* SAFE AREA ----------------------------------------------------------------------------------------------- */
2776     // Send css::frame::FrameAction event to all listener.
2777 	// Get container for right listener.
2778     // FOLLOW LINES ARE THREADSAFE!!!
2779     // ( OInterfaceContainerHelper is synchronized with m_aListenerContainer! )
2780     ::cppu::OInterfaceContainerHelper* pContainer = m_aListenerContainer.getContainer( ::getCppuType( ( const css::uno::Reference< css::frame::XFrameActionListener >*) NULL ) );
2781 
2782 	if( pContainer != NULL )
2783 	{
2784 		// Build action event.
2785         css::frame::FrameActionEvent aFrameActionEvent( static_cast< ::cppu::OWeakObject* >(this), this, aAction );
2786 
2787 		// Get iterator for access to listener.
2788         ::cppu::OInterfaceIteratorHelper aIterator( *pContainer );
2789 		// Send message to all listener.
2790         while( aIterator.hasMoreElements() == sal_True )
2791 		{
2792             try
2793             {
2794                 ((css::frame::XFrameActionListener*)aIterator.next())->frameAction( aFrameActionEvent );
2795             }
2796             catch( css::uno::RuntimeException& )
2797             {
2798                 aIterator.remove();
2799             }
2800 		}
2801 	}
2802 }
2803 
2804 /*-****************************************************************************************************//**
2805 	@short		helper to resize our component window
2806 	@descr		A frame contains 2 windows - a container ~ and a component window.
2807 				This method resize inner component window to full size of outer container window.
2808 				This method is threadsafe AND can be called by our dispose method too!
2809 
2810 	@seealso	-
2811 
2812 	@param		-
2813 	@return		-
2814 
2815 	@onerror	-
2816 *//*-*****************************************************************************************************/
2817 void Frame::implts_resizeComponentWindow()
2818 {
2819 	// usually the LayoutManager does the resizing
2820     // in case there is no LayoutManager resizing has to be done here
2821     if ( !m_xLayoutManager.is() )
2822     {
2823         css::uno::Reference< css::awt::XWindow > xComponentWindow( getComponentWindow() );
2824         if( xComponentWindow.is() == sal_True )
2825         {
2826             css::uno::Reference< css::awt::XDevice > xDevice( getContainerWindow(), css::uno::UNO_QUERY );
2827 
2828             // Convert relativ size to output size.
2829             css::awt::Rectangle  aRectangle  = getContainerWindow()->getPosSize();
2830             css::awt::DeviceInfo aInfo       = xDevice->getInfo();
2831             css::awt::Size       aSize       (  aRectangle.Width  - aInfo.LeftInset - aInfo.RightInset  ,
2832                                                 aRectangle.Height - aInfo.TopInset  - aInfo.BottomInset );
2833 
2834             // Resize our component window.
2835             xComponentWindow->setPosSize( 0, 0, aSize.Width, aSize.Height, css::awt::PosSize::POSSIZE );
2836         }
2837     }
2838 }
2839 
2840 /*-****************************************************************************************************//**
2841     @short      helper to set icon on our container window (if it is a system window!)
2842     @descr      We use our internal set controller (if it exist) to specify which factory he represanted.
2843                 These information can be used to find right icon. But our controller can say it us directly
2844                 too ... we should ask his optional property set first ...
2845 
2846     @seealso    method Window::SetIcon()
2847 
2848     @param      -
2849     @return     -
2850 
2851     @onerror    We do nothing.
2852 *//*-*****************************************************************************************************/
2853 void Frame::implts_setIconOnWindow()
2854 {
2855     /* UNSAFE AREA --------------------------------------------------------------------------------------------- */
2856     // Look for rejected calls.
2857     TransactionGuard aTransaction( m_aTransactionManager, E_HARDEXCEPTIONS );
2858 
2859 	/* SAFE AREA ----------------------------------------------------------------------------------------------- */
2860     // Make snapshot of neccessary members and release lock.
2861     ReadGuard aReadLock( m_aLock );
2862     css::uno::Reference< css::awt::XWindow >       xContainerWindow( m_xContainerWindow, css::uno::UNO_QUERY );
2863     css::uno::Reference< css::frame::XController > xController     ( m_xController     , css::uno::UNO_QUERY );
2864     aReadLock.unlock();
2865     /* UNSAFE AREA --------------------------------------------------------------------------------------------- */
2866 
2867     if(
2868         ( xContainerWindow.is() == sal_True )   &&
2869         ( xController.is()      == sal_True )
2870       )
2871     {
2872         //-------------------------------------------------------------------------------------------------------------
2873         // a) set default value to an invalid one. So we can start further searches for right icon id, if
2874         //    first steps failed!
2875         //    We must reset it to any fallback value - if no search step returns a valid result.
2876         sal_Int32 nIcon = -1;
2877 
2878         //-------------------------------------------------------------------------------------------------------------
2879         // b) try to find information on controller propertyset directly
2880         //    Don't forget to catch possible exceptions - because these property is an optional one!
2881         css::uno::Reference< css::beans::XPropertySet > xSet( xController, css::uno::UNO_QUERY );
2882         if( xSet.is() == sal_True )
2883         {
2884             try
2885             {
2886                 css::uno::Reference< css::beans::XPropertySetInfo > const xPSI( xSet->getPropertySetInfo(), css::uno::UNO_SET_THROW );
2887                 if ( xPSI->hasPropertyByName( CONTROLLER_PROPNAME_ICONID ) )
2888                     xSet->getPropertyValue( CONTROLLER_PROPNAME_ICONID ) >>= nIcon;
2889             }
2890             catch( css::uno::Exception& )
2891             {
2892                 DBG_UNHANDLED_EXCEPTION();
2893             }
2894         }
2895 
2896         //-------------------------------------------------------------------------------------------------------------
2897         // c) if b) failed ... analyze argument list of currently loaded document insde the frame to find the filter.
2898         //    He can be used to detect right factory - and these can be used to match factory to icon ...
2899         if( nIcon == -1 )
2900         {
2901             css::uno::Reference< css::frame::XModel > xModel = xController->getModel();
2902             if( xModel.is() == sal_True )
2903             {
2904                 SvtModuleOptions::EFactory eFactory = SvtModuleOptions::ClassifyFactoryByModel(xModel);
2905                 if (eFactory != SvtModuleOptions::E_UNKNOWN_FACTORY)
2906                     nIcon = SvtModuleOptions().GetFactoryIcon( eFactory );
2907             }
2908         }
2909 
2910         //-------------------------------------------------------------------------------------------------------------
2911         // d) if all steps failed - use fallback!
2912         if( nIcon == -1 )
2913         {
2914             nIcon = 0;
2915         }
2916 
2917         //-------------------------------------------------------------------------------------------------------------
2918         // e) set icon on container window now
2919         //    Don't forget SolarMutex! We use vcl directly :-(
2920         //    Check window pointer for right WorkWindow class too!!!
2921         /* SAFE AREA ----------------------------------------------------------------------------------------------- */
2922         ::vos::OClearableGuard aSolarGuard( Application::GetSolarMutex() );
2923         Window* pWindow = (VCLUnoHelper::GetWindow( xContainerWindow ));
2924         if(
2925             ( pWindow            != NULL              ) &&
2926             ( pWindow->GetType() == WINDOW_WORKWINDOW )
2927         )
2928         {
2929             WorkWindow* pWorkWindow = (WorkWindow*)pWindow;
2930             pWorkWindow->SetIcon( (sal_uInt16)nIcon );
2931         }
2932         aSolarGuard.clear();
2933         /* UNSAFE AREA --------------------------------------------------------------------------------------------- */
2934     }
2935 }
2936 
2937 /*-************************************************************************************************************//**
2938     @short      helper to start/stop listeneing for window events on container window
2939     @descr      If we get a new container window, we must set it on internal memeber ...
2940                 and stop listening at old one ... and start listening on new one!
2941                 But sometimes (in dispose() call!) it's neccessary to stop listeneing without starting
2942                 on new connections. So we split this functionality to make it easier at use.
2943 
2944     @seealso    method initialize()
2945     @seealso    method dispose()
2946 
2947     @param      -
2948     @return     -
2949 
2950     @onerror    We do nothing!
2951     @threadsafe yes
2952 *//*-*************************************************************************************************************/
2953 void Frame::implts_startWindowListening()
2954 {
2955     /* UNSAFE AREA --------------------------------------------------------------------------------------------- */
2956     TransactionGuard aTransaction( m_aTransactionManager, E_HARDEXCEPTIONS );
2957 
2958     /* SAFE AREA ----------------------------------------------------------------------------------------------- */
2959     // Make snapshot of neccessary member!
2960     ReadGuard aReadLock( m_aLock );
2961     css::uno::Reference< css::awt::XWindow >                            xContainerWindow    = m_xContainerWindow   ;
2962     css::uno::Reference< css::lang::XMultiServiceFactory >              xFactory            = m_xFactory           ;
2963     css::uno::Reference< css::datatransfer::dnd::XDropTargetListener >  xDragDropListener   = m_xDropTargetListener;
2964     css::uno::Reference< css::awt::XWindowListener >                    xWindowListener     ( static_cast< ::cppu::OWeakObject* >(this), css::uno::UNO_QUERY );
2965     css::uno::Reference< css::awt::XFocusListener >                     xFocusListener      ( static_cast< ::cppu::OWeakObject* >(this), css::uno::UNO_QUERY );
2966     css::uno::Reference< css::awt::XTopWindowListener >                 xTopWindowListener  ( static_cast< ::cppu::OWeakObject* >(this), css::uno::UNO_QUERY );
2967     aReadLock.unlock();
2968     /* UNSAFE AREA --------------------------------------------------------------------------------------------- */
2969 
2970     if( xContainerWindow.is() == sal_True )
2971     {
2972         xContainerWindow->addWindowListener( xWindowListener);
2973         xContainerWindow->addFocusListener ( xFocusListener );
2974 
2975         css::uno::Reference< css::awt::XTopWindow > xTopWindow( xContainerWindow, css::uno::UNO_QUERY );
2976         if( xTopWindow.is() == sal_True )
2977         {
2978             xTopWindow->addTopWindowListener( xTopWindowListener );
2979 
2980             css::uno::Reference< css::awt::XDataTransferProviderAccess > xTransfer( xFactory->createInstance( SERVICENAME_VCLTOOLKIT ), css::uno::UNO_QUERY );
2981             if( xTransfer.is() == sal_True )
2982 			{
2983                 css::uno::Reference< css::datatransfer::dnd::XDropTarget > xDropTarget = xTransfer->getDropTarget( xContainerWindow );
2984                 if( xDropTarget.is() == sal_True )
2985 				{
2986                     xDropTarget->addDropTargetListener( xDragDropListener );
2987 					xDropTarget->setActive( sal_True );
2988 				}
2989 			}
2990 		}
2991     }
2992 }
2993 
2994 //*****************************************************************************************************************
2995 void Frame::implts_stopWindowListening()
2996 {
2997     /* UNSAFE AREA --------------------------------------------------------------------------------------------- */
2998     // Sometimes used by dispose() => soft exceptions!
2999     TransactionGuard aTransaction( m_aTransactionManager, E_SOFTEXCEPTIONS );
3000 
3001     /* SAFE AREA ----------------------------------------------------------------------------------------------- */
3002     // Make snapshot of neccessary member!
3003     ReadGuard aReadLock( m_aLock );
3004     css::uno::Reference< css::awt::XWindow >                            xContainerWindow    = m_xContainerWindow   ;
3005     css::uno::Reference< css::lang::XMultiServiceFactory >              xFactory            = m_xFactory           ;
3006     css::uno::Reference< css::datatransfer::dnd::XDropTargetListener >  xDragDropListener   = m_xDropTargetListener;
3007     css::uno::Reference< css::awt::XWindowListener >                    xWindowListener     ( static_cast< ::cppu::OWeakObject* >(this), css::uno::UNO_QUERY );
3008     css::uno::Reference< css::awt::XFocusListener >                     xFocusListener      ( static_cast< ::cppu::OWeakObject* >(this), css::uno::UNO_QUERY );
3009     css::uno::Reference< css::awt::XTopWindowListener >                 xTopWindowListener  ( static_cast< ::cppu::OWeakObject* >(this), css::uno::UNO_QUERY );
3010     aReadLock.unlock();
3011     /* UNSAFE AREA --------------------------------------------------------------------------------------------- */
3012 
3013     if( xContainerWindow.is() == sal_True )
3014     {
3015         xContainerWindow->removeWindowListener( xWindowListener);
3016         xContainerWindow->removeFocusListener ( xFocusListener );
3017 
3018         css::uno::Reference< css::awt::XTopWindow > xTopWindow( xContainerWindow, css::uno::UNO_QUERY );
3019         if( xTopWindow.is() == sal_True )
3020         {
3021             xTopWindow->removeTopWindowListener( xTopWindowListener );
3022 
3023             css::uno::Reference< css::awt::XDataTransferProviderAccess > xTransfer( xFactory->createInstance( SERVICENAME_VCLTOOLKIT ), css::uno::UNO_QUERY );
3024             if( xTransfer.is() == sal_True )
3025 			{
3026                 css::uno::Reference< css::datatransfer::dnd::XDropTarget > xDropTarget = xTransfer->getDropTarget( xContainerWindow );
3027                 if( xDropTarget.is() == sal_True )
3028 				{
3029                     xDropTarget->removeDropTargetListener( xDragDropListener );
3030 					xDropTarget->setActive( sal_False );
3031 				}
3032 			}
3033         }
3034     }
3035 }
3036 
3037 /*-****************************************************************************************************//**
3038     @short      helper to force breaked close() request again
3039     @descr      If we self disagree with a close() request, and detect that all external locks are gone ...
3040                 then we must try to close this frame again.
3041 
3042     @seealso    XCloseable::close()
3043     @seealso    Frame::close()
3044     @seealso    Frame::removeActionLock()
3045     @seealso    Frame::resetActionLock()
3046     @seealso    m_bSelfClose
3047     @seealso    m_nExternalLockCount
3048 
3049     @threadsafe yes
3050     @modified   06.05.2002 09:31, as96863
3051 *//*-*****************************************************************************************************/
3052 void Frame::implts_checkSuicide()
3053 {
3054     /* SAFE */
3055     ReadGuard aReadLock(m_aLock);
3056     // in case of lock==0 and safed state of previous close() request m_bSelfClose
3057     // we must force close() again. Because we had disagreed with that before.
3058     sal_Bool bSuicide = (m_nExternalLockCount==0 && m_bSelfClose);
3059     m_bSelfClose = sal_False;
3060     aReadLock.unlock();
3061     /* } SAFE */
3062     // force close and deliver owner ship to source of possible throwed veto exception
3063     // Attention: Because this method isn't designed to throw such exception we must supress
3064     // it for outside code!
3065     try
3066     {
3067         if (bSuicide)
3068             close(sal_True);
3069     }
3070     catch(const css::util::CloseVetoException&)
3071         {}
3072     catch(const css::lang::DisposedException&)
3073         {}
3074 }
3075 
3076 //_______________________________________________________________
3077 
3078 /** little helper to enable/disable the menu closer at the menubar of the given frame.
3079 
3080     @param  xFrame
3081             we use its layout manager to set/reset a special callback.
3082             Its existence regulate visibility of this closer item.
3083 
3084     @param  bState
3085                 <TRUE/> enable; <FALSE/> disable this state
3086  */
3087 
3088 void Frame::impl_setCloser( /*IN*/ const css::uno::Reference< css::frame::XFrame >& xFrame ,
3089                             /*IN*/       sal_Bool                                   bState  )
3090 {
3091     // Note: If start module isnt installed - no closer has to be shown!
3092     if (!SvtModuleOptions().IsModuleInstalled(SvtModuleOptions::E_SSTARTMODULE))
3093         return;
3094 
3095     try
3096     {
3097         css::uno::Reference< css::beans::XPropertySet > xFrameProps(xFrame, css::uno::UNO_QUERY_THROW);
3098         css::uno::Reference< css::frame::XLayoutManager > xLayoutManager;
3099         xFrameProps->getPropertyValue(FRAME_PROPNAME_LAYOUTMANAGER) >>= xLayoutManager;
3100         css::uno::Reference< css::beans::XPropertySet > xLayoutProps(xLayoutManager, css::uno::UNO_QUERY_THROW);
3101         xLayoutProps->setPropertyValue(LAYOUTMANAGER_PROPNAME_MENUBARCLOSER, css::uno::makeAny(bState));
3102     }
3103     catch(const css::uno::RuntimeException&)
3104         { throw; }
3105     catch(const css::uno::Exception&)
3106         {}
3107 }
3108 
3109 //_______________________________________________________________
3110 
3111 /** it checks, which of the top level task frames must have the special menu closer for
3112     switching to the backing window mode.
3113 
3114     It analyze the current list of visible top level frames. Only the last real document
3115     frame can have this symbol. Not the help frame nor the backing task itself.
3116     Here we do anything related to this closer. We remove it from the old frame and set it
3117     for the new one.
3118  */
3119 
3120 void Frame::impl_checkMenuCloser()
3121 {
3122     /* SAFE { */
3123     ReadGuard aReadLock(m_aLock);
3124 
3125     // only top frames, which are part of our desktop hierarchy, can
3126     // do so! By the way - we need the desktop instance to have acess
3127     // to all other top level frames too.
3128     css::uno::Reference< css::frame::XDesktop >        xDesktop     (m_xParent, css::uno::UNO_QUERY);
3129     css::uno::Reference< css::frame::XFramesSupplier > xTaskSupplier(xDesktop , css::uno::UNO_QUERY);
3130     if ( !xDesktop.is() || !xTaskSupplier.is() )
3131         return;
3132 
3133     aReadLock.unlock();
3134     /* } SAFE */
3135 
3136     // analyze the list of current open tasks
3137     // Suppress search for other views to the same model ...
3138     // It's not needed here and can be very expensive.
3139     FrameListAnalyzer aAnalyzer(
3140         xTaskSupplier,
3141         this,
3142         FrameListAnalyzer::E_HIDDEN | FrameListAnalyzer::E_HELP | FrameListAnalyzer::E_BACKINGCOMPONENT);
3143 
3144     // specify the new frame, which must have this special state ...
3145     css::uno::Reference< css::frame::XFrame > xNewCloserFrame;
3146 
3147     // -----------------------------
3148     // a)
3149     // If there exist ate least one other frame - there are two frames currently open.
3150     // But we can enable this closer only, if one of these two tasks includes the help module.
3151     // The "other frame" couldn't be the help. Because then it wouldn't be part of this "other list".
3152     // In such case it will be seperated to the reference aAnalyzer.m_xHelp!
3153     // But we must check, if weself includes the help ...
3154     // Check aAnalyzer.m_bReferenceIsHelp!
3155     if (
3156         (aAnalyzer.m_lOtherVisibleFrames.getLength()==1)   &&
3157         (
3158             (aAnalyzer.m_bReferenceIsHelp  ) ||
3159             (aAnalyzer.m_bReferenceIsHidden)
3160         )
3161        )
3162     {
3163         // others[0] can't be the backing component!
3164         // Because it's set at the special member aAnalyzer.m_xBackingComponent ... :-)
3165         xNewCloserFrame = aAnalyzer.m_lOtherVisibleFrames[0];
3166     }
3167     else
3168     // -----------------------------
3169     // b)
3170     // There is no other frame ... means no other document frame. The help module
3171     // will be handled seperatly and must(!) be ignored here ... excepting weself includes the help.
3172     if (
3173         (aAnalyzer.m_lOtherVisibleFrames.getLength()==0) &&
3174         (!aAnalyzer.m_bReferenceIsHelp                 ) &&
3175         (!aAnalyzer.m_bReferenceIsHidden               ) &&
3176         (!aAnalyzer.m_bReferenceIsBacking              )
3177        )
3178     {
3179         xNewCloserFrame = this;
3180     }
3181 
3182     // Look for neccessary actions ...
3183     // Only if the closer state must be moved from one frame to another one
3184     // or must be enabled/disabled at all.
3185     /* STATIC SAFE { */
3186     WriteGuard aStaticWriteLock(LockHelper::getGlobalLock());
3187     css::uno::Reference< css::frame::XFrame > xCloserFrame (m_xCloserFrame.get(), css::uno::UNO_QUERY);
3188     if (xCloserFrame!=xNewCloserFrame)
3189     {
3190         if (xCloserFrame.is())
3191             impl_setCloser(xCloserFrame, sal_False);
3192         if (xNewCloserFrame.is())
3193             impl_setCloser(xNewCloserFrame, sal_True);
3194         m_xCloserFrame = xNewCloserFrame;
3195     }
3196     aStaticWriteLock.unlock();
3197     /* } STATIC SAFE */
3198 }
3199 
3200 //_________________________________________________________________________________________________________________
3201 //	debug methods
3202 //_________________________________________________________________________________________________________________
3203 
3204 /*-----------------------------------------------------------------------------------------------------------------
3205 	The follow methods checks the parameter for other functions. If a parameter or his value is non valid,
3206     we return "sal_True". (otherwise sal_False) This mechanism is used to throw an ASSERT!
3207 -----------------------------------------------------------------------------------------------------------------*/
3208 
3209 #ifdef ENABLE_ASSERTIONS
3210 
3211 //*****************************************************************************************************************
3212 // We don't accept null pointer or references!
3213 sal_Bool Frame::implcp_ctor( const css::uno::Reference< css::lang::XMultiServiceFactory >& xFactory )
3214 {
3215 	return	(
3216 				( &xFactory		==	NULL		)	||
3217 				( xFactory.is()	==	sal_False	)
3218 			);
3219 }
3220 
3221 //*****************************************************************************************************************
3222 // Its allowed to reset the active frame membervariable with a NULL-css::uno::Reference but not with a NULL-pointer!
3223 // And we accept frames only! No tasks and desktops!
3224 sal_Bool Frame::implcp_setActiveFrame( const css::uno::Reference< css::frame::XFrame >& xFrame )
3225 {
3226 	return	(
3227                 ( &xFrame                                                                                   ==  NULL        )   ||
3228                 ( css::uno::Reference< css::frame::XDesktop >( xFrame, css::uno::UNO_QUERY ).is()           ==  sal_True    )
3229 			);
3230 }
3231 
3232 //*****************************************************************************************************************
3233 sal_Bool Frame::implcp_addFrameActionListener( const css::uno::Reference< css::frame::XFrameActionListener >& xListener )
3234 {
3235 	return	(
3236 				( &xListener		==	NULL		)	||
3237 				( xListener.is()	==	sal_False	)
3238 			);
3239 }
3240 
3241 //*****************************************************************************************************************
3242 sal_Bool Frame::implcp_removeFrameActionListener( const css::uno::Reference< css::frame::XFrameActionListener >& xListener )
3243 {
3244 	return	(
3245 				( &xListener		==	NULL		)	||
3246 				( xListener.is()	==	sal_False	)
3247 			);
3248 }
3249 
3250 //*****************************************************************************************************************
3251 sal_Bool Frame::implcp_addEventListener( const css::uno::Reference< css::lang::XEventListener >& xListener )
3252 {
3253 	return	(
3254 				( &xListener		==	NULL		)	||
3255 				( xListener.is()	==	sal_False	)
3256 			);
3257 }
3258 
3259 //*****************************************************************************************************************
3260 sal_Bool Frame::implcp_removeEventListener( const css::uno::Reference< css::lang::XEventListener >& xListener )
3261 {
3262 	return	(
3263 				( &xListener		==	NULL		)	||
3264 				( xListener.is()	==	sal_False	)
3265 			);
3266 }
3267 
3268 //*****************************************************************************************************************
3269 sal_Bool Frame::implcp_windowResized( const css::awt::WindowEvent& aEvent )
3270 {
3271 	return	(
3272 				( &aEvent				==	NULL		)	||
3273 				( aEvent.Source.is()	==	sal_False	)
3274 			);
3275 }
3276 
3277 //*****************************************************************************************************************
3278 sal_Bool Frame::implcp_focusGained( const css::awt::FocusEvent& aEvent )
3279 {
3280 	return	(
3281 				( &aEvent				==	NULL		)	||
3282 				( aEvent.Source.is()	==	sal_False	)
3283 			);
3284 }
3285 
3286 //*****************************************************************************************************************
3287 sal_Bool Frame::implcp_windowActivated( const css::lang::EventObject& aEvent )
3288 {
3289 	return	(
3290 				( &aEvent				==	NULL		)	||
3291 				( aEvent.Source.is()	==	sal_False	)
3292 			);
3293 }
3294 
3295 //*****************************************************************************************************************
3296 sal_Bool Frame::implcp_windowDeactivated( const css::lang::EventObject& aEvent )
3297 {
3298 	return	(
3299 				( &aEvent				==	NULL		)	||
3300 				( aEvent.Source.is()	==	sal_False	)
3301 			);
3302 }
3303 
3304 //*****************************************************************************************************************
3305 sal_Bool Frame::implcp_disposing( const css::lang::EventObject& aEvent )
3306 {
3307 	return	(
3308 				( &aEvent				==	NULL		)	||
3309 				( aEvent.Source.is()	==	sal_False	)
3310 			);
3311 }
3312 
3313 #endif	// #ifdef ENABLE_ASSERTIONS
3314 
3315 }	// namespace framework
3316