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