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