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