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