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