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