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