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