16d739b60SAndrew Rist /************************************************************** 2cdf0e10cSrcweir * 36d739b60SAndrew Rist * Licensed to the Apache Software Foundation (ASF) under one 46d739b60SAndrew Rist * or more contributor license agreements. See the NOTICE file 56d739b60SAndrew Rist * distributed with this work for additional information 66d739b60SAndrew Rist * regarding copyright ownership. The ASF licenses this file 76d739b60SAndrew Rist * to you under the Apache License, Version 2.0 (the 86d739b60SAndrew Rist * "License"); you may not use this file except in compliance 96d739b60SAndrew Rist * with the License. You may obtain a copy of the License at 106d739b60SAndrew Rist * 116d739b60SAndrew Rist * http://www.apache.org/licenses/LICENSE-2.0 126d739b60SAndrew Rist * 136d739b60SAndrew Rist * Unless required by applicable law or agreed to in writing, 146d739b60SAndrew Rist * software distributed under the License is distributed on an 156d739b60SAndrew Rist * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 166d739b60SAndrew Rist * KIND, either express or implied. See the License for the 176d739b60SAndrew Rist * specific language governing permissions and limitations 186d739b60SAndrew Rist * under the License. 196d739b60SAndrew Rist * 206d739b60SAndrew Rist *************************************************************/ 216d739b60SAndrew Rist 226d739b60SAndrew Rist 23cdf0e10cSrcweir 24cdf0e10cSrcweir // MARKER(update_precomp.py): autogen include statement, do not remove 25cdf0e10cSrcweir #include "precompiled_framework.hxx" 26cdf0e10cSrcweir 27cdf0e10cSrcweir //_________________________________________________________________________________________________________________ 28cdf0e10cSrcweir // my own includes 29cdf0e10cSrcweir //_________________________________________________________________________________________________________________ 30cdf0e10cSrcweir #include <loadenv/loadenv.hxx> 31cdf0e10cSrcweir 32cdf0e10cSrcweir #ifndef __FRAMEWORK_LOADENV_TARGETHELPER_HXX_ 33cdf0e10cSrcweir #include <loadenv/targethelper.hxx> 34cdf0e10cSrcweir #endif 35cdf0e10cSrcweir 36cdf0e10cSrcweir #ifndef __FRAMEWORK_DESKTOP_HXX_ 37cdf0e10cSrcweir #include <services/desktop.hxx> 38cdf0e10cSrcweir #endif 39cdf0e10cSrcweir #include <helper/ocomponentaccess.hxx> 40cdf0e10cSrcweir #include <dispatch/dispatchprovider.hxx> 41cdf0e10cSrcweir 42cdf0e10cSrcweir #ifndef __FRAMEWORK_DISPATCH_INTERCEPTIONHELPER_HXX_ 43cdf0e10cSrcweir #include <dispatch/interceptionhelper.hxx> 44cdf0e10cSrcweir #endif 45cdf0e10cSrcweir #include <classes/taskcreator.hxx> 46cdf0e10cSrcweir #include <threadhelp/transactionguard.hxx> 47cdf0e10cSrcweir #include <threadhelp/writeguard.hxx> 48cdf0e10cSrcweir #include <threadhelp/readguard.hxx> 49cdf0e10cSrcweir #include <services.h> 50cdf0e10cSrcweir #include <general.h> 51cdf0e10cSrcweir #include <properties.h> 52cdf0e10cSrcweir 53cdf0e10cSrcweir #include <classes/resource.hrc> 54cdf0e10cSrcweir #include <classes/fwkresid.hxx> 55cdf0e10cSrcweir 56cdf0e10cSrcweir //_________________________________________________________________________________________________________________ 57cdf0e10cSrcweir // interface includes 58cdf0e10cSrcweir //_________________________________________________________________________________________________________________ 59cdf0e10cSrcweir #include <com/sun/star/beans/PropertyAttribute.hpp> 60cdf0e10cSrcweir #include <com/sun/star/frame/FrameSearchFlag.hpp> 61cdf0e10cSrcweir #include <com/sun/star/awt/XToolkit.hpp> 62cdf0e10cSrcweir #include <com/sun/star/awt/XWindow.hpp> 63cdf0e10cSrcweir #include <com/sun/star/awt/XWindowPeer.hpp> 64cdf0e10cSrcweir #include <com/sun/star/awt/WindowDescriptor.hpp> 65cdf0e10cSrcweir #include <com/sun/star/awt/WindowAttribute.hpp> 66cdf0e10cSrcweir #include <com/sun/star/awt/PosSize.hpp> 67cdf0e10cSrcweir #include <com/sun/star/util/XURLTransformer.hpp> 68cdf0e10cSrcweir #include <com/sun/star/task/XInteractionAbort.hpp> 69cdf0e10cSrcweir #include <com/sun/star/task/XInteractionApprove.hpp> 70cdf0e10cSrcweir #include <com/sun/star/document/XInteractionFilterSelect.hpp> 71cdf0e10cSrcweir #include <com/sun/star/document/AmbigousFilterRequest.hpp> 72cdf0e10cSrcweir #include <com/sun/star/task/ErrorCodeRequest.hpp> 73cdf0e10cSrcweir #include <com/sun/star/ucb/InteractiveIOException.hpp> 74cdf0e10cSrcweir #include <com/sun/star/ucb/InteractiveAugmentedIOException.hpp> 75cdf0e10cSrcweir #include <com/sun/star/frame/XNotifyingDispatch.hpp> 76cdf0e10cSrcweir #include <com/sun/star/frame/DispatchResultState.hpp> 77cdf0e10cSrcweir #include <com/sun/star/lang/IllegalArgumentException.hpp> 78cdf0e10cSrcweir #include <com/sun/star/lang/DisposedException.hpp> 79cdf0e10cSrcweir #include <com/sun/star/util/XCloseable.hpp> 80cdf0e10cSrcweir #include <com/sun/star/document/MacroExecMode.hpp> 81cdf0e10cSrcweir #include <com/sun/star/document/UpdateDocMode.hpp> 82cdf0e10cSrcweir #include <com/sun/star/frame/XTerminateListener2.hpp> 83cdf0e10cSrcweir 84cdf0e10cSrcweir //_________________________________________________________________________________________________________________ 85cdf0e10cSrcweir // includes of other projects 86cdf0e10cSrcweir //_________________________________________________________________________________________________________________ 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 <rtl/logfile.hxx> 93cdf0e10cSrcweir #include <vcl/svapp.hxx> 94cdf0e10cSrcweir 95cdf0e10cSrcweir #ifndef __RSC 96cdf0e10cSrcweir #include <tools/errinf.hxx> 97cdf0e10cSrcweir #endif 98cdf0e10cSrcweir #include <comphelper/extract.hxx> 99cdf0e10cSrcweir 100cdf0e10cSrcweir #include <fwkdllapi.h> 101cdf0e10cSrcweir 102cdf0e10cSrcweir //_________________________________________________________________________________________________________________ 103cdf0e10cSrcweir // namespace 104cdf0e10cSrcweir //_________________________________________________________________________________________________________________ 105cdf0e10cSrcweir 106cdf0e10cSrcweir namespace framework{ 107cdf0e10cSrcweir 108cdf0e10cSrcweir //_________________________________________________________________________________________________________________ 109cdf0e10cSrcweir // non exported const 110cdf0e10cSrcweir //_________________________________________________________________________________________________________________ 111cdf0e10cSrcweir 112cdf0e10cSrcweir //_________________________________________________________________________________________________________________ 113cdf0e10cSrcweir // non exported definitions 114cdf0e10cSrcweir //_________________________________________________________________________________________________________________ 115cdf0e10cSrcweir 116cdf0e10cSrcweir //_________________________________________________________________________________________________________________ 117cdf0e10cSrcweir // declarations 118cdf0e10cSrcweir //_________________________________________________________________________________________________________________ 119cdf0e10cSrcweir 120cdf0e10cSrcweir //***************************************************************************************************************** 121cdf0e10cSrcweir // XInterface, XTypeProvider, XServiceInfo 122cdf0e10cSrcweir //***************************************************************************************************************** 123cdf0e10cSrcweir DEFINE_XINTERFACE_15 ( Desktop , 124cdf0e10cSrcweir OWeakObject , 125cdf0e10cSrcweir DIRECT_INTERFACE( css::lang::XTypeProvider ), 126cdf0e10cSrcweir DIRECT_INTERFACE( css::lang::XServiceInfo ), 127cdf0e10cSrcweir DIRECT_INTERFACE( css::frame::XDesktop ), 128cdf0e10cSrcweir DIRECT_INTERFACE( css::frame::XComponentLoader ), 129cdf0e10cSrcweir DIRECT_INTERFACE( css::frame::XTasksSupplier ), 130cdf0e10cSrcweir DIRECT_INTERFACE( css::frame::XDispatchProvider ), 131cdf0e10cSrcweir DIRECT_INTERFACE( css::frame::XDispatchProviderInterception), 132cdf0e10cSrcweir DIRECT_INTERFACE( css::frame::XFramesSupplier ), 133cdf0e10cSrcweir DIRECT_INTERFACE( css::frame::XFrame ), 134cdf0e10cSrcweir DIRECT_INTERFACE( css::lang::XComponent ), 135cdf0e10cSrcweir DIRECT_INTERFACE( css::frame::XDispatchResultListener ), 136cdf0e10cSrcweir DIRECT_INTERFACE( css::lang::XEventListener ), 137cdf0e10cSrcweir DIRECT_INTERFACE( css::task::XInteractionHandler ), 138cdf0e10cSrcweir DIRECT_INTERFACE( css::beans::XPropertySet ), 139cdf0e10cSrcweir DIRECT_INTERFACE( css::frame::XUntitledNumbers ) 140cdf0e10cSrcweir ) 141cdf0e10cSrcweir 142cdf0e10cSrcweir DEFINE_XTYPEPROVIDER_15 ( Desktop , 143cdf0e10cSrcweir css::lang::XTypeProvider , 144cdf0e10cSrcweir css::lang::XServiceInfo , 145cdf0e10cSrcweir css::frame::XDesktop , 146cdf0e10cSrcweir css::frame::XComponentLoader , 147cdf0e10cSrcweir css::frame::XTasksSupplier , 148cdf0e10cSrcweir css::frame::XDispatchProvider , 149cdf0e10cSrcweir css::frame::XDispatchProviderInterception , 150cdf0e10cSrcweir css::frame::XFramesSupplier , 151cdf0e10cSrcweir css::frame::XFrame , 152cdf0e10cSrcweir css::lang::XComponent , 153cdf0e10cSrcweir css::frame::XDispatchResultListener , 154cdf0e10cSrcweir css::lang::XEventListener , 155cdf0e10cSrcweir css::task::XInteractionHandler , 156cdf0e10cSrcweir css::beans::XPropertySet , 157cdf0e10cSrcweir css::frame::XUntitledNumbers 158cdf0e10cSrcweir ) 159cdf0e10cSrcweir 160cdf0e10cSrcweir DEFINE_XSERVICEINFO_ONEINSTANCESERVICE ( Desktop , 161cdf0e10cSrcweir ::cppu::OWeakObject , 162cdf0e10cSrcweir SERVICENAME_DESKTOP , 163cdf0e10cSrcweir IMPLEMENTATIONNAME_DESKTOP 164cdf0e10cSrcweir ) 165cdf0e10cSrcweir 166cdf0e10cSrcweir DEFINE_INIT_SERVICE ( Desktop, 167cdf0e10cSrcweir { 168cdf0e10cSrcweir /*Attention 169cdf0e10cSrcweir I think we don't need any mutex or lock here ... because we are called by our own static method impl_createInstance() 170cdf0e10cSrcweir to create a new instance of this class by our own supported service factory. 171cdf0e10cSrcweir see macro DEFINE_XSERVICEINFO_MULTISERVICE and "impl_initService()" for further informations! 172cdf0e10cSrcweir */ 173cdf0e10cSrcweir 174cdf0e10cSrcweir //------------------------------------------------------------------------------------------------------------- 175cdf0e10cSrcweir // Initialize a new XFrames-helper-object to handle XIndexAccess and XElementAccess. 176cdf0e10cSrcweir // We hold member as reference ... not as pointer too! 177cdf0e10cSrcweir // Attention: We share our frame container with this helper. Container is threadsafe himself ... So I think we can do that. 178cdf0e10cSrcweir // But look on dispose() for right order of deinitialization. 179cdf0e10cSrcweir OFrames* pFramesHelper = new OFrames( m_xFactory, this, &m_aChildTaskContainer ); 180cdf0e10cSrcweir m_xFramesHelper = css::uno::Reference< css::frame::XFrames >( static_cast< ::cppu::OWeakObject* >(pFramesHelper), css::uno::UNO_QUERY ); 181cdf0e10cSrcweir 182cdf0e10cSrcweir //------------------------------------------------------------------------------------------------------------- 183cdf0e10cSrcweir // Initialize a new dispatchhelper-object to handle dispatches. 184cdf0e10cSrcweir // We use these helper as slave for our interceptor helper ... not directly! 185cdf0e10cSrcweir // But he is event listener on THIS instance! 186cdf0e10cSrcweir DispatchProvider* pDispatchHelper = new DispatchProvider( m_xFactory, this ); 187cdf0e10cSrcweir css::uno::Reference< css::frame::XDispatchProvider > xDispatchProvider( static_cast< ::cppu::OWeakObject* >(pDispatchHelper), css::uno::UNO_QUERY ); 188cdf0e10cSrcweir 189cdf0e10cSrcweir //------------------------------------------------------------------------------------------------------------- 190cdf0e10cSrcweir // Initialize a new interception helper object to handle dispatches and implement an interceptor mechanism. 191cdf0e10cSrcweir // Set created dispatch provider as slowest slave of it. 192cdf0e10cSrcweir // Hold interception helper by reference only - not by pointer! 193cdf0e10cSrcweir // So it's easiear to destroy it. 194cdf0e10cSrcweir InterceptionHelper* pInterceptionHelper = new InterceptionHelper( this, xDispatchProvider ); 195cdf0e10cSrcweir m_xDispatchHelper = css::uno::Reference< css::frame::XDispatchProvider >( static_cast< ::cppu::OWeakObject* >(pInterceptionHelper), css::uno::UNO_QUERY ); 196cdf0e10cSrcweir 197cdf0e10cSrcweir ::rtl::OUStringBuffer sUntitledPrefix (256); 198cdf0e10cSrcweir sUntitledPrefix.append (::rtl::OUString( String( FwkResId( STR_UNTITLED_DOCUMENT )))); 199cdf0e10cSrcweir sUntitledPrefix.appendAscii (" "); 200cdf0e10cSrcweir 201cdf0e10cSrcweir ::comphelper::NumberedCollection* pNumbers = new ::comphelper::NumberedCollection (); 202cdf0e10cSrcweir m_xTitleNumberGenerator = css::uno::Reference< css::frame::XUntitledNumbers >(static_cast< ::cppu::OWeakObject* >(pNumbers), css::uno::UNO_QUERY_THROW); 203cdf0e10cSrcweir pNumbers->setOwner ( static_cast< ::cppu::OWeakObject* >(this) ); 204cdf0e10cSrcweir pNumbers->setUntitledPrefix ( sUntitledPrefix.makeStringAndClear () ); 205cdf0e10cSrcweir 206cdf0e10cSrcweir // Safe impossible cases 207cdf0e10cSrcweir // We can't work without this helper! 208cdf0e10cSrcweir LOG_ASSERT2( m_xFramesHelper.is ()==sal_False, "Desktop::Desktop()", "Frames helper is not valid. XFrames, XIndexAccess and XElementAcces are not supported!\n") 209cdf0e10cSrcweir LOG_ASSERT2( m_xDispatchHelper.is()==sal_False, "Desktop::Desktop()", "Dispatch helper is not valid. XDispatch will not work correctly!\n" ) 210cdf0e10cSrcweir 211cdf0e10cSrcweir // Enable object for real working! 212cdf0e10cSrcweir // Otherwise all calls will be rejected ... 213cdf0e10cSrcweir m_aTransactionManager.setWorkingMode( E_WORK ); 214cdf0e10cSrcweir } 215cdf0e10cSrcweir ) 216cdf0e10cSrcweir 217cdf0e10cSrcweir /*-************************************************************************************************************//** 218cdf0e10cSrcweir @short standard constructor to create instance by factory 219cdf0e10cSrcweir @descr This constructor initialize a new instance of this class by valid factory, 220cdf0e10cSrcweir and will be set valid values on his member and baseclasses. 221cdf0e10cSrcweir 222cdf0e10cSrcweir @attention a) Don't use your own reference during an UNO-Service-ctor! There is no guarantee, that you 223cdf0e10cSrcweir will get over this. (e.g. using of your reference as parameter to initialize some member) 22407a3d7f1SPedro Giffuni Do such things in DEFINE_INIT_SERVICE() method, which is called automatically after your ctor!!! 225cdf0e10cSrcweir b) Baseclass OBroadcastHelper is a typedef in namespace cppu! 226cdf0e10cSrcweir The microsoft compiler has some problems to handle it right BY using namespace explicitly ::cppu::OBroadcastHelper. 227cdf0e10cSrcweir If we write it without a namespace or expand the typedef to OBrodcastHelperVar<...> -> it will be OK!? 228cdf0e10cSrcweir I don't know why! (other compiler not tested .. but it works!) 229cdf0e10cSrcweir 230cdf0e10cSrcweir @seealso method DEFINE_INIT_SERVICE() 231cdf0e10cSrcweir 232cdf0e10cSrcweir @param "xFactory" is the multi service manager, which create this instance. 233cdf0e10cSrcweir The value must be different from NULL! 234cdf0e10cSrcweir @return - 235cdf0e10cSrcweir 236cdf0e10cSrcweir @onerror We throw an ASSERT in debug version or do nothing in relaese version. 237cdf0e10cSrcweir *//*-*************************************************************************************************************/ 238cdf0e10cSrcweir Desktop::Desktop( const css::uno::Reference< css::lang::XMultiServiceFactory >& xFactory ) 239cdf0e10cSrcweir // Init baseclasses first 240cdf0e10cSrcweir // Attention: Don't change order of initialization! 241cdf0e10cSrcweir // ThreadHelpBase is a struct with a lock as member. We can't use a lock as direct member! 242cdf0e10cSrcweir // We must garant right initialization and a valid value of this to initialize other baseclasses! 243cdf0e10cSrcweir : ThreadHelpBase ( &Application::GetSolarMutex() ) 244cdf0e10cSrcweir , TransactionBase ( ) 245cdf0e10cSrcweir , ::cppu::OBroadcastHelperVar< ::cppu::OMultiTypeInterfaceContainerHelper, ::cppu::OMultiTypeInterfaceContainerHelper::keyType > ( m_aLock.getShareableOslMutex() ) 246cdf0e10cSrcweir , ::cppu::OPropertySetHelper ( *(static_cast< ::cppu::OBroadcastHelper* >(this)) ) 247cdf0e10cSrcweir , ::cppu::OWeakObject ( ) 248cdf0e10cSrcweir // Init member 249cdf0e10cSrcweir #ifdef ENABLE_ASSERTIONS 250cdf0e10cSrcweir , m_bIsTerminated ( sal_False ) // see dispose() for further informations! 251cdf0e10cSrcweir #endif 252cdf0e10cSrcweir , m_xFactory ( xFactory ) 253cdf0e10cSrcweir , m_aChildTaskContainer ( ) 254cdf0e10cSrcweir , m_aListenerContainer ( m_aLock.getShareableOslMutex() ) 255cdf0e10cSrcweir , m_xFramesHelper ( ) 256cdf0e10cSrcweir , m_xDispatchHelper ( ) 257cdf0e10cSrcweir , m_eLoadState ( E_NOTSET ) 258cdf0e10cSrcweir , m_xLastFrame ( ) 259cdf0e10cSrcweir , m_aInteractionRequest ( ) 260cdf0e10cSrcweir , m_bSuspendQuickstartVeto( sal_False ) 261cdf0e10cSrcweir , m_aCommandOptions ( ) 262cdf0e10cSrcweir , m_sName ( ) 263cdf0e10cSrcweir , m_sTitle ( ) 264cdf0e10cSrcweir , m_xDispatchRecorderSupplier( ) 265cdf0e10cSrcweir , m_xPipeTerminator ( ) 266cdf0e10cSrcweir , m_xQuickLauncher ( ) 267cdf0e10cSrcweir , m_xSWThreadManager ( ) 268cdf0e10cSrcweir , m_xSfxTerminator ( ) 269cdf0e10cSrcweir , m_xTitleNumberGenerator ( ) 270cdf0e10cSrcweir { 271cdf0e10cSrcweir // Safe impossible cases 272cdf0e10cSrcweir // We don't accept all incoming parameter. 273cdf0e10cSrcweir LOG_ASSERT2( implcp_ctor( xFactory ), "Desktop::Desktop()", "Invalid parameter detected!") 274cdf0e10cSrcweir } 275cdf0e10cSrcweir 276cdf0e10cSrcweir /*-************************************************************************************************************//** 277cdf0e10cSrcweir @short standard destructor 278cdf0e10cSrcweir @descr This one do NOTHING! Use dispose() instaed of this. 279cdf0e10cSrcweir 280cdf0e10cSrcweir @seealso method dispose() 281cdf0e10cSrcweir 282cdf0e10cSrcweir @param - 283cdf0e10cSrcweir @return - 284cdf0e10cSrcweir 285cdf0e10cSrcweir @onerror - 286cdf0e10cSrcweir *//*-*************************************************************************************************************/ 287cdf0e10cSrcweir Desktop::~Desktop() 288cdf0e10cSrcweir { 289cdf0e10cSrcweir LOG_ASSERT2( m_bIsTerminated ==sal_False, "Desktop::~Desktop()", "Who forgot to terminate the desktop service?" ) 290cdf0e10cSrcweir LOG_ASSERT2( m_aTransactionManager.getWorkingMode()!=E_CLOSE , "Desktop::~Desktop()", "Who forgot to dispose this service?" ) 291cdf0e10cSrcweir } 292cdf0e10cSrcweir 293cdf0e10cSrcweir //============================================================================= 294cdf0e10cSrcweir sal_Bool SAL_CALL Desktop::terminate() 295cdf0e10cSrcweir throw( css::uno::RuntimeException ) 296cdf0e10cSrcweir { 297cdf0e10cSrcweir TransactionGuard aTransaction( m_aTransactionManager, E_HARDEXCEPTIONS ); 298cdf0e10cSrcweir 299cdf0e10cSrcweir SYNCHRONIZED_START 300cdf0e10cSrcweir ReadGuard aReadLock( m_aLock ); 301cdf0e10cSrcweir 302cdf0e10cSrcweir css::uno::Reference< css::frame::XTerminateListener > xPipeTerminator = m_xPipeTerminator; 303cdf0e10cSrcweir css::uno::Reference< css::frame::XTerminateListener > xQuickLauncher = m_xQuickLauncher; 304cdf0e10cSrcweir css::uno::Reference< css::frame::XTerminateListener > xSWThreadManager = m_xSWThreadManager; 305cdf0e10cSrcweir css::uno::Reference< css::frame::XTerminateListener > xSfxTerminator = m_xSfxTerminator; 306cdf0e10cSrcweir 307cdf0e10cSrcweir css::lang::EventObject aEvent ( static_cast< ::cppu::OWeakObject* >(this) ); 308cdf0e10cSrcweir ::sal_Bool bAskQuickStart = !m_bSuspendQuickstartVeto ; 309cdf0e10cSrcweir 310cdf0e10cSrcweir aReadLock.unlock(); 311cdf0e10cSrcweir SYNCHRONIZED_END 312cdf0e10cSrcweir 313cdf0e10cSrcweir //------------------------------------------------------------------------------------------------------------- 314cdf0e10cSrcweir // Ask normal terminate listener. They could stop terminate without closing any open document. 315cdf0e10cSrcweir Desktop::TTerminateListenerList lCalledTerminationListener; 316cdf0e10cSrcweir ::sal_Bool bVeto = sal_False; 317cdf0e10cSrcweir impl_sendQueryTerminationEvent(lCalledTerminationListener, bVeto); 318cdf0e10cSrcweir if ( bVeto ) 319cdf0e10cSrcweir { 320cdf0e10cSrcweir impl_sendCancelTerminationEvent(lCalledTerminationListener); 321cdf0e10cSrcweir return sal_False; 322cdf0e10cSrcweir } 323cdf0e10cSrcweir 324cdf0e10cSrcweir //------------------------------------------------------------------------------------------------------------- 325cdf0e10cSrcweir // try to close all open frames. 326cdf0e10cSrcweir // Allow using of any UI ... because Desktop.terminate() was designed as UI functionality in the past. 327cdf0e10cSrcweir ::sal_Bool bAllowUI = sal_True; 328cdf0e10cSrcweir ::sal_Bool bFramesClosed = impl_closeFrames(bAllowUI); 329cdf0e10cSrcweir if ( ! bFramesClosed ) 330cdf0e10cSrcweir { 331cdf0e10cSrcweir impl_sendCancelTerminationEvent(lCalledTerminationListener); 332cdf0e10cSrcweir return sal_False; 333cdf0e10cSrcweir } 334cdf0e10cSrcweir 335cdf0e10cSrcweir //------------------------------------------------------------------------------------------------------------- 336cdf0e10cSrcweir // Normal listener had no problem ... 337cdf0e10cSrcweir // all frames was closed ... 338cdf0e10cSrcweir // now it's time to ask our specialized listener. 339cdf0e10cSrcweir // They are handled these way because they wish to hinder the office on termination 340cdf0e10cSrcweir // but they wish also closing of all frames. 341cdf0e10cSrcweir 342cdf0e10cSrcweir // Note further: 343cdf0e10cSrcweir // We shouldn't ask quicklauncher in case it was allowed from outside only. 344cdf0e10cSrcweir // This is special trick to "ignore existing quick starter" for debug purposes. 345cdf0e10cSrcweir 346cdf0e10cSrcweir // Attention: 347cdf0e10cSrcweir // Order of alled listener is important ! 348cdf0e10cSrcweir // some of them are harmless .-) 349cdf0e10cSrcweir // But some of them can be dangerous. E.g. it would be dangerous if we close our pipe 350cdf0e10cSrcweir // and dont terminate in real because another listener throws a veto exception .-) 351cdf0e10cSrcweir 352cdf0e10cSrcweir ::sal_Bool bTerminate = sal_False; 353cdf0e10cSrcweir try 354cdf0e10cSrcweir { 355cdf0e10cSrcweir if( 356cdf0e10cSrcweir ( bAskQuickStart ) && 357cdf0e10cSrcweir ( xQuickLauncher.is() ) 358cdf0e10cSrcweir ) 359cdf0e10cSrcweir { 360cdf0e10cSrcweir xQuickLauncher->queryTermination( aEvent ); 361cdf0e10cSrcweir lCalledTerminationListener.push_back( xQuickLauncher ); 362cdf0e10cSrcweir } 363cdf0e10cSrcweir 364cdf0e10cSrcweir if ( xSWThreadManager.is() ) 365cdf0e10cSrcweir { 366cdf0e10cSrcweir xSWThreadManager->queryTermination( aEvent ); 367cdf0e10cSrcweir lCalledTerminationListener.push_back( xSWThreadManager ); 368cdf0e10cSrcweir } 369cdf0e10cSrcweir 370cdf0e10cSrcweir if ( xPipeTerminator.is() ) 371cdf0e10cSrcweir { 372cdf0e10cSrcweir xPipeTerminator->queryTermination( aEvent ); 373cdf0e10cSrcweir lCalledTerminationListener.push_back( xPipeTerminator ); 374cdf0e10cSrcweir } 375cdf0e10cSrcweir 376cdf0e10cSrcweir if ( xSfxTerminator.is() ) 377cdf0e10cSrcweir { 378cdf0e10cSrcweir xSfxTerminator->queryTermination( aEvent ); 379cdf0e10cSrcweir lCalledTerminationListener.push_back( xSfxTerminator ); 380cdf0e10cSrcweir } 381cdf0e10cSrcweir 382cdf0e10cSrcweir bTerminate = sal_True; 383cdf0e10cSrcweir } 384cdf0e10cSrcweir catch(const css::frame::TerminationVetoException&) 385cdf0e10cSrcweir { 386cdf0e10cSrcweir bTerminate = sal_False; 387cdf0e10cSrcweir } 388cdf0e10cSrcweir 389cdf0e10cSrcweir if ( ! bTerminate ) 390cdf0e10cSrcweir impl_sendCancelTerminationEvent(lCalledTerminationListener); 391cdf0e10cSrcweir else 392cdf0e10cSrcweir { 393cdf0e10cSrcweir #ifdef ENABLE_ASSERTIONS 394cdf0e10cSrcweir // "Protect" us against dispose before terminate calls! 395cdf0e10cSrcweir // see dispose() for further informations. 396cdf0e10cSrcweir /* SAFE AREA --------------------------------------------------------------------------------------- */ 397cdf0e10cSrcweir WriteGuard aWriteLock( m_aLock ); 398cdf0e10cSrcweir m_bIsTerminated = sal_True; 399cdf0e10cSrcweir aWriteLock.unlock(); 400cdf0e10cSrcweir /* UNSAFE AREA ------------------------------------------------------------------------------------- */ 401cdf0e10cSrcweir #endif 402cdf0e10cSrcweir 403cdf0e10cSrcweir impl_sendNotifyTerminationEvent(); 404cdf0e10cSrcweir 405cdf0e10cSrcweir if( 406cdf0e10cSrcweir ( bAskQuickStart ) && 407cdf0e10cSrcweir ( xQuickLauncher.is() ) 408cdf0e10cSrcweir ) 409cdf0e10cSrcweir { 410cdf0e10cSrcweir xQuickLauncher->notifyTermination( aEvent ); 411cdf0e10cSrcweir } 412cdf0e10cSrcweir 413cdf0e10cSrcweir if ( xSWThreadManager.is() ) 414cdf0e10cSrcweir xSWThreadManager->notifyTermination( aEvent ); 415cdf0e10cSrcweir 416cdf0e10cSrcweir if ( xPipeTerminator.is() ) 417cdf0e10cSrcweir xPipeTerminator->notifyTermination( aEvent ); 418cdf0e10cSrcweir 41907a3d7f1SPedro Giffuni // Must be really the last listener to be called. 420cdf0e10cSrcweir // Because it shutdown the whole process asynchronous ! 421cdf0e10cSrcweir if ( xSfxTerminator.is() ) 422cdf0e10cSrcweir xSfxTerminator->notifyTermination( aEvent ); 423cdf0e10cSrcweir } 424cdf0e10cSrcweir 425cdf0e10cSrcweir return bTerminate; 426cdf0e10cSrcweir } 427cdf0e10cSrcweir 428cdf0e10cSrcweir 429cdf0e10cSrcweir //============================================================================= 430cdf0e10cSrcweir void SAL_CALL Desktop::addTerminateListener( const css::uno::Reference< css::frame::XTerminateListener >& xListener ) 431cdf0e10cSrcweir throw( css::uno::RuntimeException ) 432cdf0e10cSrcweir { 433cdf0e10cSrcweir TransactionGuard aTransaction( m_aTransactionManager, E_HARDEXCEPTIONS ); 434cdf0e10cSrcweir 435cdf0e10cSrcweir css::uno::Reference< css::lang::XServiceInfo > xInfo( xListener, css::uno::UNO_QUERY ); 436cdf0e10cSrcweir if ( xInfo.is() ) 437cdf0e10cSrcweir { 438cdf0e10cSrcweir ::rtl::OUString sImplementationName = xInfo->getImplementationName(); 439cdf0e10cSrcweir 440cdf0e10cSrcweir // SYCNHRONIZED -> 441cdf0e10cSrcweir WriteGuard aWriteLock( m_aLock ); 442cdf0e10cSrcweir 443cdf0e10cSrcweir if( sImplementationName.equals(IMPLEMENTATIONNAME_SFXTERMINATOR) ) 444cdf0e10cSrcweir { 445cdf0e10cSrcweir m_xSfxTerminator = xListener; 446cdf0e10cSrcweir return; 447cdf0e10cSrcweir } 448cdf0e10cSrcweir if( sImplementationName.equals(IMPLEMENTATIONNAME_PIPETERMINATOR) ) 449cdf0e10cSrcweir { 450cdf0e10cSrcweir m_xPipeTerminator = xListener; 451cdf0e10cSrcweir return; 452cdf0e10cSrcweir } 453cdf0e10cSrcweir if( sImplementationName.equals(IMPLEMENTATIONNAME_QUICKLAUNCHER) ) 454cdf0e10cSrcweir { 455cdf0e10cSrcweir m_xQuickLauncher = xListener; 456cdf0e10cSrcweir return; 457cdf0e10cSrcweir } 458cdf0e10cSrcweir if( sImplementationName.equals(IMPLEMENTATIONNAME_SWTHREADMANAGER) ) 459cdf0e10cSrcweir { 460cdf0e10cSrcweir m_xSWThreadManager = xListener; 461cdf0e10cSrcweir return; 462cdf0e10cSrcweir } 463cdf0e10cSrcweir 464cdf0e10cSrcweir aWriteLock.unlock(); 465cdf0e10cSrcweir // <- SYCNHRONIZED 466cdf0e10cSrcweir } 467cdf0e10cSrcweir 468cdf0e10cSrcweir // No lock required ... container is threadsafe by itself. 469cdf0e10cSrcweir m_aListenerContainer.addInterface( ::getCppuType( ( const css::uno::Reference< css::frame::XTerminateListener >*) NULL ), xListener ); 470cdf0e10cSrcweir } 471cdf0e10cSrcweir 472cdf0e10cSrcweir //============================================================================= 473cdf0e10cSrcweir void SAL_CALL Desktop::removeTerminateListener( const css::uno::Reference< css::frame::XTerminateListener >& xListener ) 474cdf0e10cSrcweir throw( css::uno::RuntimeException ) 475cdf0e10cSrcweir { 476cdf0e10cSrcweir TransactionGuard aTransaction( m_aTransactionManager, E_SOFTEXCEPTIONS ); 477cdf0e10cSrcweir 478cdf0e10cSrcweir css::uno::Reference< css::lang::XServiceInfo > xInfo( xListener, css::uno::UNO_QUERY ); 479cdf0e10cSrcweir if ( xInfo.is() ) 480cdf0e10cSrcweir { 481cdf0e10cSrcweir ::rtl::OUString sImplementationName = xInfo->getImplementationName(); 482cdf0e10cSrcweir 483cdf0e10cSrcweir // SYCNHRONIZED -> 484cdf0e10cSrcweir WriteGuard aWriteLock( m_aLock ); 485cdf0e10cSrcweir 486cdf0e10cSrcweir if( sImplementationName.equals(IMPLEMENTATIONNAME_SFXTERMINATOR) ) 487cdf0e10cSrcweir { 488cdf0e10cSrcweir m_xSfxTerminator.clear(); 489cdf0e10cSrcweir return; 490cdf0e10cSrcweir } 491cdf0e10cSrcweir 492cdf0e10cSrcweir if( sImplementationName.equals(IMPLEMENTATIONNAME_PIPETERMINATOR) ) 493cdf0e10cSrcweir { 494cdf0e10cSrcweir m_xPipeTerminator.clear(); 495cdf0e10cSrcweir return; 496cdf0e10cSrcweir } 497cdf0e10cSrcweir 498cdf0e10cSrcweir if( sImplementationName.equals(IMPLEMENTATIONNAME_QUICKLAUNCHER) ) 499cdf0e10cSrcweir { 500cdf0e10cSrcweir m_xQuickLauncher.clear(); 501cdf0e10cSrcweir return; 502cdf0e10cSrcweir } 503cdf0e10cSrcweir 504cdf0e10cSrcweir if( sImplementationName.equals(IMPLEMENTATIONNAME_SWTHREADMANAGER) ) 505cdf0e10cSrcweir { 506cdf0e10cSrcweir m_xSWThreadManager.clear(); 507cdf0e10cSrcweir return; 508cdf0e10cSrcweir } 509cdf0e10cSrcweir 510cdf0e10cSrcweir aWriteLock.unlock(); 511cdf0e10cSrcweir // <- SYCNHRONIZED 512cdf0e10cSrcweir } 513cdf0e10cSrcweir 514cdf0e10cSrcweir // No lock required ... container is threadsafe by itself. 515cdf0e10cSrcweir m_aListenerContainer.removeInterface( ::getCppuType( ( const css::uno::Reference< css::frame::XTerminateListener >*) NULL ), xListener ); 516cdf0e10cSrcweir } 517cdf0e10cSrcweir 518cdf0e10cSrcweir /*-************************************************************************************************************//** 519cdf0e10cSrcweir @interface XDesktop 520cdf0e10cSrcweir @short get access to create enumerations of all current components 521cdf0e10cSrcweir @descr You will be the owner of the returned object and must delete it if you don't use it again. 522cdf0e10cSrcweir 523cdf0e10cSrcweir @seealso class TasksAccess 524cdf0e10cSrcweir @seealso class TasksEnumeration 525cdf0e10cSrcweir 526cdf0e10cSrcweir @param - 527cdf0e10cSrcweir @return A reference to an XEnumerationAccess-object. 528cdf0e10cSrcweir 529cdf0e10cSrcweir @onerror We return a null-reference. 530cdf0e10cSrcweir @threadsafe yes 531cdf0e10cSrcweir *//*-*************************************************************************************************************/ 532cdf0e10cSrcweir css::uno::Reference< css::container::XEnumerationAccess > SAL_CALL Desktop::getComponents() throw( css::uno::RuntimeException ) 533cdf0e10cSrcweir { 534cdf0e10cSrcweir /* UNSAFE AREA --------------------------------------------------------------------------------------------- */ 535cdf0e10cSrcweir // Register transaction and reject wrong calls. 536cdf0e10cSrcweir TransactionGuard aTransaction( m_aTransactionManager, E_HARDEXCEPTIONS ); 537cdf0e10cSrcweir 538cdf0e10cSrcweir // We use a helper class OComponentAccess to have access on all child components. 539cdf0e10cSrcweir // Create it on demand and return it as a reference. 540cdf0e10cSrcweir OComponentAccess* pAccess = new OComponentAccess( this ); 541cdf0e10cSrcweir css::uno::Reference< css::container::XEnumerationAccess > xAccess( static_cast< ::cppu::OWeakObject* >(pAccess), css::uno::UNO_QUERY ); 542cdf0e10cSrcweir return xAccess; 543cdf0e10cSrcweir } 544cdf0e10cSrcweir 545cdf0e10cSrcweir /*-************************************************************************************************************//** 546cdf0e10cSrcweir @interface XDesktop 547cdf0e10cSrcweir @short return the current active component 548cdf0e10cSrcweir @descr The most current component is the window, model or the controller of the current active frame. 549cdf0e10cSrcweir 550cdf0e10cSrcweir @seealso method getCurrentFrame() 551cdf0e10cSrcweir @seealso method impl_getFrameComponent() 552cdf0e10cSrcweir 553cdf0e10cSrcweir @param - 554cdf0e10cSrcweir @return A reference to the component. 555cdf0e10cSrcweir 556cdf0e10cSrcweir @onerror We return a null-reference. 557cdf0e10cSrcweir @threadsafe yes 558cdf0e10cSrcweir *//*-*************************************************************************************************************/ 559cdf0e10cSrcweir css::uno::Reference< css::lang::XComponent > SAL_CALL Desktop::getCurrentComponent() throw( css::uno::RuntimeException ) 560cdf0e10cSrcweir { 561cdf0e10cSrcweir /* UNSAFE AREA --------------------------------------------------------------------------------------------- */ 562cdf0e10cSrcweir // Register transaction and reject wrong calls. 563cdf0e10cSrcweir TransactionGuard aTransaction( m_aTransactionManager, E_HARDEXCEPTIONS ); 564cdf0e10cSrcweir 565cdf0e10cSrcweir // Set return value if method failed. 566cdf0e10cSrcweir css::uno::Reference< css::lang::XComponent > xComponent; 567cdf0e10cSrcweir 568cdf0e10cSrcweir // Get reference to current frame ... 569cdf0e10cSrcweir // ... get component of this frame ... (It can be the window, the model or the controller.) 570cdf0e10cSrcweir // ... and return the result. 571cdf0e10cSrcweir css::uno::Reference< css::frame::XFrame > xCurrentFrame = getCurrentFrame(); 572cdf0e10cSrcweir if( xCurrentFrame.is() == sal_True ) 573cdf0e10cSrcweir { 574cdf0e10cSrcweir xComponent = impl_getFrameComponent( xCurrentFrame ); 575cdf0e10cSrcweir } 576cdf0e10cSrcweir return xComponent; 577cdf0e10cSrcweir } 578cdf0e10cSrcweir 579cdf0e10cSrcweir /*-************************************************************************************************************//** 580cdf0e10cSrcweir @interface XDesktop 581cdf0e10cSrcweir @short return the current active frame in hierarchy 58207a3d7f1SPedro Giffuni @descr There can be more then one different active paths in our frame hierarchy. But only one of them 583cdf0e10cSrcweir could be the most active frame (normal he has the focus). 584cdf0e10cSrcweir Don't mix it with getActiveFrame()! That will return our current active frame, which must be 585cdf0e10cSrcweir a direct child of us and should be a part(!) of an active path. 586cdf0e10cSrcweir 587cdf0e10cSrcweir @seealso method getActiveFrame() 588cdf0e10cSrcweir 589cdf0e10cSrcweir @param - 590cdf0e10cSrcweir @return A valid reference, if there is an active frame. 591cdf0e10cSrcweir A null reference , otherwise. 592cdf0e10cSrcweir 593cdf0e10cSrcweir @onerror We return a null reference. 594cdf0e10cSrcweir @threadsafe yes 595cdf0e10cSrcweir *//*-*************************************************************************************************************/ 596cdf0e10cSrcweir css::uno::Reference< css::frame::XFrame > SAL_CALL Desktop::getCurrentFrame() throw( css::uno::RuntimeException ) 597cdf0e10cSrcweir { 598cdf0e10cSrcweir /* UNSAFE AREA --------------------------------------------------------------------------------------------- */ 599cdf0e10cSrcweir // Register transaction and reject wrong calls. 600cdf0e10cSrcweir TransactionGuard aTransaction( m_aTransactionManager, E_HARDEXCEPTIONS ); 601cdf0e10cSrcweir 602cdf0e10cSrcweir // Start search with ouer direct active frame (if it exist!). 603cdf0e10cSrcweir // Search on his children for other active frames too. 604cdf0e10cSrcweir // Stop if no one could be found and return last of found ones. 605cdf0e10cSrcweir css::uno::Reference< css::frame::XFramesSupplier > xLast = css::uno::Reference< css::frame::XFramesSupplier >( getActiveFrame(), css::uno::UNO_QUERY ); 606cdf0e10cSrcweir if( xLast.is() == sal_True ) 607cdf0e10cSrcweir { 608cdf0e10cSrcweir css::uno::Reference< css::frame::XFramesSupplier > xNext = css::uno::Reference< css::frame::XFramesSupplier >( xLast->getActiveFrame(), css::uno::UNO_QUERY ); 609cdf0e10cSrcweir while( xNext.is() == sal_True ) 610cdf0e10cSrcweir { 611cdf0e10cSrcweir xLast = xNext; 612cdf0e10cSrcweir xNext = css::uno::Reference< css::frame::XFramesSupplier >( xNext->getActiveFrame(), css::uno::UNO_QUERY ); 613cdf0e10cSrcweir } 614cdf0e10cSrcweir } 615cdf0e10cSrcweir return css::uno::Reference< css::frame::XFrame >( xLast, css::uno::UNO_QUERY ); 616cdf0e10cSrcweir } 617cdf0e10cSrcweir 618cdf0e10cSrcweir /*-************************************************************************************************************//** 619cdf0e10cSrcweir @interface XComponentLoader 620cdf0e10cSrcweir @short try to load given URL into a task 621cdf0e10cSrcweir @descr You can give us some informations about the content, which you will load into a frame. 622cdf0e10cSrcweir We search or create this target for you, make a type detection of given URL and try to load it. 623cdf0e10cSrcweir As result of this operation we return the new created component or nothing, if loading failed. 624cdf0e10cSrcweir 625cdf0e10cSrcweir @seealso - 626cdf0e10cSrcweir 627cdf0e10cSrcweir @param "sURL" , URL, which represant the content 628cdf0e10cSrcweir @param "sTargetFrameName" , name of target frame or special value like "_self", "_blank" ... 629cdf0e10cSrcweir @param "nSearchFlags" , optional arguments for frame search, if target isn't a special one 630cdf0e10cSrcweir @param "lArguments" , optional arguments for loading 631cdf0e10cSrcweir @return A valid component reference, if loading was successfully. 632cdf0e10cSrcweir A null reference otherwise. 633cdf0e10cSrcweir 634cdf0e10cSrcweir @onerror We return a null reference. 635cdf0e10cSrcweir @threadsafe yes 636cdf0e10cSrcweir *//*-*************************************************************************************************************/ 637cdf0e10cSrcweir css::uno::Reference< css::lang::XComponent > SAL_CALL Desktop::loadComponentFromURL( const ::rtl::OUString& sURL , 638cdf0e10cSrcweir const ::rtl::OUString& sTargetFrameName, 639cdf0e10cSrcweir sal_Int32 nSearchFlags , 640cdf0e10cSrcweir const css::uno::Sequence< css::beans::PropertyValue >& lArguments ) throw( css::io::IOException , 641cdf0e10cSrcweir css::lang::IllegalArgumentException , 642cdf0e10cSrcweir css::uno::RuntimeException ) 643cdf0e10cSrcweir { 644cdf0e10cSrcweir /* UNSAFE AREA --------------------------------------------------------------------------------------------- */ 645cdf0e10cSrcweir // Register transaction and reject wrong calls. 646cdf0e10cSrcweir TransactionGuard aTransaction( m_aTransactionManager, E_HARDEXCEPTIONS ); 647cdf0e10cSrcweir RTL_LOGFILE_CONTEXT( aLog, "framework (as96863) ::Desktop::loadComponentFromURL" ); 648cdf0e10cSrcweir 649cdf0e10cSrcweir ReadGuard aReadLock(m_aLock); 650cdf0e10cSrcweir css::uno::Reference< css::frame::XComponentLoader > xThis(static_cast< css::frame::XComponentLoader* >(this), css::uno::UNO_QUERY); 651cdf0e10cSrcweir css::uno::Reference< css::lang::XMultiServiceFactory > xSMGR = m_xFactory; 652cdf0e10cSrcweir aReadLock.unlock(); 653cdf0e10cSrcweir 654cdf0e10cSrcweir RTL_LOGFILE_PRODUCT_CONTEXT( aLog2, "PERFORMANCE - Desktop::loadComponentFromURL()" ); 655cdf0e10cSrcweir return LoadEnv::loadComponentFromURL(xThis, xSMGR, sURL, sTargetFrameName, nSearchFlags, lArguments); 656cdf0e10cSrcweir } 657cdf0e10cSrcweir 658cdf0e10cSrcweir /*-************************************************************************************************************//** 659cdf0e10cSrcweir @interface XTasksSupplier 660cdf0e10cSrcweir @short get access to create enumerations of ouer taskchilds 66107a3d7f1SPedro Giffuni @descr Direct childs of desktop are tasks every time. 662cdf0e10cSrcweir Call these method to could create enumerations of it. 663cdf0e10cSrcweir 664cdf0e10cSrcweir But; Don't forget - you will be the owner of returned object and must release it! 665cdf0e10cSrcweir We use a helper class to implement the access interface. They hold a weakreference to us. 666cdf0e10cSrcweir It can be, that the desktop is dead - but not your tasksaccess-object! Then they will do nothing! 667cdf0e10cSrcweir You can't create enumerations then. 668cdf0e10cSrcweir 669*e9faf1d9Smseidel @attention Normally we don't need any lock here. We don't work on internal member! 670cdf0e10cSrcweir 671cdf0e10cSrcweir @seealso class TasksAccess 672cdf0e10cSrcweir 673cdf0e10cSrcweir @param - 674cdf0e10cSrcweir @return A reference to an accessobject, which can create enumerations of ouer childtasks. 675cdf0e10cSrcweir 676cdf0e10cSrcweir @onerror A null reference is returned. 677cdf0e10cSrcweir @threadsafe yes 678cdf0e10cSrcweir *//*-*************************************************************************************************************/ 679cdf0e10cSrcweir css::uno::Reference< css::container::XEnumerationAccess > SAL_CALL Desktop::getTasks() throw( css::uno::RuntimeException ) 680cdf0e10cSrcweir { 681cdf0e10cSrcweir LOG_WARNING("Desktop::getTasks()", "Use of obsolete interface XTaskSupplier") 682cdf0e10cSrcweir return NULL; 683cdf0e10cSrcweir /* 684cdf0e10cSrcweir TransactionGuard aTransaction( m_aTransactionManager, E_HARDEXCEPTIONS ); 685cdf0e10cSrcweir 686cdf0e10cSrcweir OTasksAccess* pTasksAccess = new OTasksAccess( this, &m_aChildTaskContainer ); 687cdf0e10cSrcweir css::uno::Reference< css::container::XEnumerationAccess > xAccess( static_cast< ::cppu::OWeakObject* >(pTasksAccess), css::uno::UNO_QUERY ); 688cdf0e10cSrcweir return xAccess; 689cdf0e10cSrcweir */ 690cdf0e10cSrcweir } 691cdf0e10cSrcweir 692cdf0e10cSrcweir /*-************************************************************************************************************//** 693cdf0e10cSrcweir @interface XTasksSupplier 694cdf0e10cSrcweir @short return current active task of ouer direct childs 695cdf0e10cSrcweir @descr Desktop childs are tasks only ! If we have an active path from desktop 696cdf0e10cSrcweir as top to any frame on bottom, we must have an active direct child. His reference is returned here. 697cdf0e10cSrcweir 698cdf0e10cSrcweir @attention a) Do not confuse it with getCurrentFrame()! The current frame don't must one of ouer direct childs. 699cdf0e10cSrcweir It can be every frame in subtree and must have the focus (Is the last one of an active path!). 700cdf0e10cSrcweir b) We don't need any lock here. Our container is threadsafe himself and live, if we live! 701cdf0e10cSrcweir 702cdf0e10cSrcweir @seealso method getCurrentFrame() 703cdf0e10cSrcweir 704cdf0e10cSrcweir @param - 705cdf0e10cSrcweir @return A reference to ouer current active taskchild. 706cdf0e10cSrcweir 707cdf0e10cSrcweir @onerror A null reference is returned. 708cdf0e10cSrcweir @threadsafe yes 709cdf0e10cSrcweir *//*-*************************************************************************************************************/ 710cdf0e10cSrcweir css::uno::Reference< css::frame::XTask > SAL_CALL Desktop::getActiveTask() throw( css::uno::RuntimeException ) 711cdf0e10cSrcweir { 712cdf0e10cSrcweir /* 713cdf0e10cSrcweir TransactionGuard aTransaction( m_aTransactionManager, E_HARDEXCEPTIONS ); 714cdf0e10cSrcweir 715cdf0e10cSrcweir return css::uno::Reference< css::frame::XTask >( m_aChildTaskContainer.getActive(), css::uno::UNO_QUERY ); 716cdf0e10cSrcweir */ 717cdf0e10cSrcweir LOG_WARNING("Desktop::getActiveTask()", "Use of obsolete interface XTaskSupplier") 718cdf0e10cSrcweir return NULL; 719cdf0e10cSrcweir } 720cdf0e10cSrcweir 721cdf0e10cSrcweir /*-************************************************************************************************************//** 722cdf0e10cSrcweir @interface XDispatchProvider 723cdf0e10cSrcweir @short search a dispatcher for given URL 724cdf0e10cSrcweir @descr We use a helper implementation (class DispatchProvider) to do so. 725cdf0e10cSrcweir So we don't must implement this algorithm twice! 726cdf0e10cSrcweir 727cdf0e10cSrcweir @attention We don't need any lock here. Our helper is threadsafe himself and live, if we live! 728cdf0e10cSrcweir 729cdf0e10cSrcweir @seealso class DispatchProvider 730cdf0e10cSrcweir 731cdf0e10cSrcweir @param "aURL" , URL to dispatch 732cdf0e10cSrcweir @param "sTargetFrameName" , name of target frame, who should dispatch these URL 733cdf0e10cSrcweir @param "nSearchFlags" , flags to regulate the search 734cdf0e10cSrcweir @param "lQueries" , list of queryDispatch() calls! 735cdf0e10cSrcweir @return A reference or list of founded dispatch objects for these URL. 736cdf0e10cSrcweir 737cdf0e10cSrcweir @onerror A null reference is returned. 738cdf0e10cSrcweir @threadsafe yes 739cdf0e10cSrcweir *//*-*************************************************************************************************************/ 740cdf0e10cSrcweir css::uno::Reference< css::frame::XDispatch > SAL_CALL Desktop::queryDispatch( const css::util::URL& aURL , 741cdf0e10cSrcweir const ::rtl::OUString& sTargetFrameName , 742cdf0e10cSrcweir sal_Int32 nSearchFlags ) throw( css::uno::RuntimeException ) 743cdf0e10cSrcweir { 744cdf0e10cSrcweir const char UNO_PROTOCOL[] = ".uno:"; 745cdf0e10cSrcweir 746cdf0e10cSrcweir /* UNSAFE AREA --------------------------------------------------------------------------------------------- */ 747cdf0e10cSrcweir // Register transaction and reject wrong calls. 748cdf0e10cSrcweir TransactionGuard aTransaction( m_aTransactionManager, E_HARDEXCEPTIONS ); 749cdf0e10cSrcweir 750cdf0e10cSrcweir // Remove uno and cmd protocol part as we want to support both of them. We store only the command part 751cdf0e10cSrcweir // in our hash map. All other protocols are stored with the protocol part. 752cdf0e10cSrcweir String aCommand( aURL.Main ); 753cdf0e10cSrcweir if ( aURL.Protocol.equalsIgnoreAsciiCaseAsciiL( UNO_PROTOCOL, sizeof( UNO_PROTOCOL )-1 )) 754cdf0e10cSrcweir aCommand = aURL.Path; 755cdf0e10cSrcweir 756cdf0e10cSrcweir // Make hash_map lookup if the current URL is in the disabled list 757cdf0e10cSrcweir if ( m_aCommandOptions.Lookup( SvtCommandOptions::CMDOPTION_DISABLED, aCommand ) ) 758cdf0e10cSrcweir return css::uno::Reference< css::frame::XDispatch >(); 759cdf0e10cSrcweir else 760cdf0e10cSrcweir { 761cdf0e10cSrcweir // We use a helper to support these interface and an interceptor mechanism. 762cdf0e10cSrcweir // Our helper is threadsafe by himself! 763cdf0e10cSrcweir return m_xDispatchHelper->queryDispatch( aURL, sTargetFrameName, nSearchFlags ); 764cdf0e10cSrcweir } 765cdf0e10cSrcweir } 766cdf0e10cSrcweir 767cdf0e10cSrcweir //***************************************************************************************************************** 768cdf0e10cSrcweir css::uno::Sequence< css::uno::Reference< css::frame::XDispatch > > SAL_CALL Desktop::queryDispatches( const css::uno::Sequence< css::frame::DispatchDescriptor >& lQueries ) throw( css::uno::RuntimeException ) 769cdf0e10cSrcweir { 770cdf0e10cSrcweir /* UNSAFE AREA --------------------------------------------------------------------------------------------- */ 771cdf0e10cSrcweir // Register transaction and reject wrong calls. 772cdf0e10cSrcweir TransactionGuard aTransaction( m_aTransactionManager, E_HARDEXCEPTIONS ); 773cdf0e10cSrcweir 774cdf0e10cSrcweir return m_xDispatchHelper->queryDispatches( lQueries ); 775cdf0e10cSrcweir } 776cdf0e10cSrcweir 777cdf0e10cSrcweir /*-************************************************************************************************************//** 778cdf0e10cSrcweir @interface XDipsatchProviderInterception 779cdf0e10cSrcweir @short supports registration/deregistration of interception objects, which 780cdf0e10cSrcweir are interested on special dispatches. 781cdf0e10cSrcweir 78207a3d7f1SPedro Giffuni @descr Its really provided by an internal helper, which is used inside the dispatch api too. 783cdf0e10cSrcweir @param xInterceptor 784cdf0e10cSrcweir the interceptor object, which wish to be (de)registered. 785cdf0e10cSrcweir 786cdf0e10cSrcweir @threadsafe yes 787cdf0e10cSrcweir *//*-*************************************************************************************************************/ 788cdf0e10cSrcweir void SAL_CALL Desktop::registerDispatchProviderInterceptor( const css::uno::Reference< css::frame::XDispatchProviderInterceptor >& xInterceptor) 789cdf0e10cSrcweir throw( css::uno::RuntimeException) 790cdf0e10cSrcweir { 791cdf0e10cSrcweir TransactionGuard aTransaction( m_aTransactionManager, E_HARDEXCEPTIONS ); 792cdf0e10cSrcweir 793cdf0e10cSrcweir css::uno::Reference< css::frame::XDispatchProviderInterception > xInterceptionHelper( m_xDispatchHelper, css::uno::UNO_QUERY ); 794cdf0e10cSrcweir xInterceptionHelper->registerDispatchProviderInterceptor( xInterceptor ); 795cdf0e10cSrcweir } 796cdf0e10cSrcweir 797cdf0e10cSrcweir //***************************************************************************************************************** 798cdf0e10cSrcweir void SAL_CALL Desktop::releaseDispatchProviderInterceptor ( const css::uno::Reference< css::frame::XDispatchProviderInterceptor >& xInterceptor) 799cdf0e10cSrcweir throw( css::uno::RuntimeException) 800cdf0e10cSrcweir { 801cdf0e10cSrcweir TransactionGuard aTransaction( m_aTransactionManager, E_SOFTEXCEPTIONS ); 802cdf0e10cSrcweir 803cdf0e10cSrcweir css::uno::Reference< css::frame::XDispatchProviderInterception > xInterceptionHelper( m_xDispatchHelper, css::uno::UNO_QUERY ); 804cdf0e10cSrcweir xInterceptionHelper->releaseDispatchProviderInterceptor( xInterceptor ); 805cdf0e10cSrcweir } 806cdf0e10cSrcweir 807cdf0e10cSrcweir /*-************************************************************************************************************//** 808cdf0e10cSrcweir @interface XFramesSupplier 809cdf0e10cSrcweir @short return access to append or remove childs on desktop 810cdf0e10cSrcweir @descr We don't implement these interface directly. We use a helper class to do this. 811cdf0e10cSrcweir If you wish to add or delete childs to/from the container, call these method to get 812cdf0e10cSrcweir a reference to the helper. 813cdf0e10cSrcweir 814cdf0e10cSrcweir @attention Helper is threadsafe himself. So we don't need any lock here. 815cdf0e10cSrcweir 816cdf0e10cSrcweir @seealso class OFrames 817cdf0e10cSrcweir 818cdf0e10cSrcweir @param - 819cdf0e10cSrcweir @return A reference to the helper. 820cdf0e10cSrcweir 821cdf0e10cSrcweir @onerror A null reference is returned. 822cdf0e10cSrcweir @threadsafe yes 823cdf0e10cSrcweir *//*-*************************************************************************************************************/ 824cdf0e10cSrcweir css::uno::Reference< css::frame::XFrames > SAL_CALL Desktop::getFrames() throw( css::uno::RuntimeException ) 825cdf0e10cSrcweir { 826cdf0e10cSrcweir /* UNSAFE AREA --------------------------------------------------------------------------------------------- */ 827cdf0e10cSrcweir // Register transaction and reject wrong calls. 828cdf0e10cSrcweir TransactionGuard aTransaction( m_aTransactionManager, E_HARDEXCEPTIONS ); 829cdf0e10cSrcweir 830cdf0e10cSrcweir return m_xFramesHelper; 831cdf0e10cSrcweir } 832cdf0e10cSrcweir 833cdf0e10cSrcweir /*-************************************************************************************************************//** 834cdf0e10cSrcweir @interface XFramesSupplier 835cdf0e10cSrcweir @short set/get the current active child frame 836cdf0e10cSrcweir @descr It must be a task. Direct childs of desktop are tasks only! No frames are accepted. 837cdf0e10cSrcweir We don't save this information directly in this class. We use ouer container-helper 838cdf0e10cSrcweir to do that. 839cdf0e10cSrcweir 840cdf0e10cSrcweir @attention Helper is threadsafe himself. So we don't need any lock here. 841cdf0e10cSrcweir 842cdf0e10cSrcweir @seealso class OFrameContainer 843cdf0e10cSrcweir 844cdf0e10cSrcweir @param "xFrame", new active frame (must be valid!) 845cdf0e10cSrcweir @return A reference to ouer current active childtask, if anyone exist. 846cdf0e10cSrcweir 847cdf0e10cSrcweir @onerror A null reference is returned. 848cdf0e10cSrcweir @threadsafe yes 849cdf0e10cSrcweir *//*-*************************************************************************************************************/ 850cdf0e10cSrcweir void SAL_CALL Desktop::setActiveFrame( const css::uno::Reference< css::frame::XFrame >& xFrame ) throw( css::uno::RuntimeException ) 851cdf0e10cSrcweir { 852cdf0e10cSrcweir /* UNSAFE AREA --------------------------------------------------------------------------------------------- */ 853cdf0e10cSrcweir // Register transaction and reject wrong calls. 854cdf0e10cSrcweir TransactionGuard aTransaction( m_aTransactionManager, E_HARDEXCEPTIONS ); 855cdf0e10cSrcweir 856cdf0e10cSrcweir // Get old active frame first. 857cdf0e10cSrcweir // If nothing will change - do nothing! 858cdf0e10cSrcweir // Otherwise set new active frame ... 859cdf0e10cSrcweir // and deactivate last frame. 86007a3d7f1SPedro Giffuni // It's necessary for our FrameActionEvent listener on a frame! 861cdf0e10cSrcweir css::uno::Reference< css::frame::XFrame > xLastActiveChild = m_aChildTaskContainer.getActive(); 862cdf0e10cSrcweir if( xLastActiveChild != xFrame ) 863cdf0e10cSrcweir { 864cdf0e10cSrcweir m_aChildTaskContainer.setActive( xFrame ); 865cdf0e10cSrcweir if( xLastActiveChild.is() == sal_True ) 866cdf0e10cSrcweir { 867cdf0e10cSrcweir xLastActiveChild->deactivate(); 868cdf0e10cSrcweir } 869cdf0e10cSrcweir } 870cdf0e10cSrcweir } 871cdf0e10cSrcweir 872cdf0e10cSrcweir //***************************************************************************************************************** 873cdf0e10cSrcweir css::uno::Reference< css::frame::XFrame > SAL_CALL Desktop::getActiveFrame() throw( css::uno::RuntimeException ) 874cdf0e10cSrcweir { 875cdf0e10cSrcweir /* UNSAFE AREA --------------------------------------------------------------------------------------------- */ 876cdf0e10cSrcweir // Register transaction and reject wrong calls. 877cdf0e10cSrcweir TransactionGuard aTransaction( m_aTransactionManager, E_HARDEXCEPTIONS ); 878cdf0e10cSrcweir 879cdf0e10cSrcweir return m_aChildTaskContainer.getActive(); 880cdf0e10cSrcweir } 881cdf0e10cSrcweir 882cdf0e10cSrcweir /*-************************************************************************************************************//** 883cdf0e10cSrcweir @interface XFrame 884cdf0e10cSrcweir @short non implemented methods! 885cdf0e10cSrcweir @descr Some method make no sense for our desktop! He has no window or parent or ... 886cdf0e10cSrcweir So we should implement it empty and warn programmer, if he use it! 887cdf0e10cSrcweir 888cdf0e10cSrcweir @seealso - 889cdf0e10cSrcweir 890cdf0e10cSrcweir @param - 891cdf0e10cSrcweir @return - 892cdf0e10cSrcweir 893cdf0e10cSrcweir @onerror - 894cdf0e10cSrcweir @threadsafe - 895cdf0e10cSrcweir *//*-*************************************************************************************************************/ 896cdf0e10cSrcweir void SAL_CALL Desktop::initialize( const css::uno::Reference< css::awt::XWindow >& ) throw( css::uno::RuntimeException ) 897cdf0e10cSrcweir { 898cdf0e10cSrcweir } 899cdf0e10cSrcweir 900cdf0e10cSrcweir //***************************************************************************************************************** 901cdf0e10cSrcweir css::uno::Reference< css::awt::XWindow > SAL_CALL Desktop::getContainerWindow() throw( css::uno::RuntimeException ) 902cdf0e10cSrcweir { 903cdf0e10cSrcweir return css::uno::Reference< css::awt::XWindow >(); 904cdf0e10cSrcweir } 905cdf0e10cSrcweir 906cdf0e10cSrcweir //***************************************************************************************************************** 907cdf0e10cSrcweir void SAL_CALL Desktop::setCreator( const css::uno::Reference< css::frame::XFramesSupplier >& /*xCreator*/ ) throw( css::uno::RuntimeException ) 908cdf0e10cSrcweir { 909cdf0e10cSrcweir } 910cdf0e10cSrcweir 911cdf0e10cSrcweir //***************************************************************************************************************** 912cdf0e10cSrcweir css::uno::Reference< css::frame::XFramesSupplier > SAL_CALL Desktop::getCreator() throw( css::uno::RuntimeException ) 913cdf0e10cSrcweir { 914cdf0e10cSrcweir return css::uno::Reference< css::frame::XFramesSupplier >(); 915cdf0e10cSrcweir } 916cdf0e10cSrcweir 917cdf0e10cSrcweir //***************************************************************************************************************** 918cdf0e10cSrcweir ::rtl::OUString SAL_CALL Desktop::getName() throw( css::uno::RuntimeException ) 919cdf0e10cSrcweir { 920cdf0e10cSrcweir /* SAFE { */ 921cdf0e10cSrcweir ReadGuard aReadLock( m_aLock ); 922cdf0e10cSrcweir return m_sName; 923cdf0e10cSrcweir /* } SAFE */ 924cdf0e10cSrcweir } 925cdf0e10cSrcweir 926cdf0e10cSrcweir //***************************************************************************************************************** 927cdf0e10cSrcweir void SAL_CALL Desktop::setName( const ::rtl::OUString& sName ) throw( css::uno::RuntimeException ) 928cdf0e10cSrcweir { 929cdf0e10cSrcweir /* SAFE { */ 930cdf0e10cSrcweir WriteGuard aWriteLock( m_aLock ); 931cdf0e10cSrcweir m_sName = sName; 932cdf0e10cSrcweir aWriteLock.unlock(); 933cdf0e10cSrcweir /* } SAFE */ 934cdf0e10cSrcweir } 935cdf0e10cSrcweir 936cdf0e10cSrcweir //***************************************************************************************************************** 937cdf0e10cSrcweir sal_Bool SAL_CALL Desktop::isTop() throw( css::uno::RuntimeException ) 938cdf0e10cSrcweir { 939cdf0e10cSrcweir return sal_True; 940cdf0e10cSrcweir } 941cdf0e10cSrcweir 942cdf0e10cSrcweir //***************************************************************************************************************** 943cdf0e10cSrcweir void SAL_CALL Desktop::activate() throw( css::uno::RuntimeException ) 944cdf0e10cSrcweir { 945cdf0e10cSrcweir // Desktop is activae always ... but sometimes our frames try to activate 946cdf0e10cSrcweir // the complete path from bottom to top ... And our desktop is the topest frame :-( 947cdf0e10cSrcweir // So - please don't show any assertions here. Do nothing! 948cdf0e10cSrcweir } 949cdf0e10cSrcweir 950cdf0e10cSrcweir //***************************************************************************************************************** 951cdf0e10cSrcweir void SAL_CALL Desktop::deactivate() throw( css::uno::RuntimeException ) 952cdf0e10cSrcweir { 953cdf0e10cSrcweir // Desktop is activae always ... but sometimes our frames try to deactivate 954cdf0e10cSrcweir // the complete path from bottom to top ... And our desktop is the topest frame :-( 955cdf0e10cSrcweir // So - please don't show any assertions here. Do nothing! 956cdf0e10cSrcweir } 957cdf0e10cSrcweir 958cdf0e10cSrcweir //***************************************************************************************************************** 959cdf0e10cSrcweir sal_Bool SAL_CALL Desktop::isActive() throw( css::uno::RuntimeException ) 960cdf0e10cSrcweir { 961cdf0e10cSrcweir return sal_True; 962cdf0e10cSrcweir } 963cdf0e10cSrcweir 964cdf0e10cSrcweir //***************************************************************************************************************** 965cdf0e10cSrcweir sal_Bool SAL_CALL Desktop::setComponent( const css::uno::Reference< css::awt::XWindow >& /*xComponentWindow*/ , 966cdf0e10cSrcweir const css::uno::Reference< css::frame::XController >& /*xController*/ ) throw( css::uno::RuntimeException ) 967cdf0e10cSrcweir { 968cdf0e10cSrcweir return sal_False; 969cdf0e10cSrcweir } 970cdf0e10cSrcweir 971cdf0e10cSrcweir //***************************************************************************************************************** 972cdf0e10cSrcweir css::uno::Reference< css::awt::XWindow > SAL_CALL Desktop::getComponentWindow() throw( css::uno::RuntimeException ) 973cdf0e10cSrcweir { 974cdf0e10cSrcweir return css::uno::Reference< css::awt::XWindow >(); 975cdf0e10cSrcweir } 976cdf0e10cSrcweir 977cdf0e10cSrcweir //***************************************************************************************************************** 978cdf0e10cSrcweir css::uno::Reference< css::frame::XController > SAL_CALL Desktop::getController() throw( css::uno::RuntimeException ) 979cdf0e10cSrcweir { 980cdf0e10cSrcweir return css::uno::Reference< css::frame::XController >(); 981cdf0e10cSrcweir } 982cdf0e10cSrcweir 983cdf0e10cSrcweir //***************************************************************************************************************** 984cdf0e10cSrcweir void SAL_CALL Desktop::contextChanged() throw( css::uno::RuntimeException ) 985cdf0e10cSrcweir { 986cdf0e10cSrcweir } 987cdf0e10cSrcweir 988cdf0e10cSrcweir //***************************************************************************************************************** 989cdf0e10cSrcweir void SAL_CALL Desktop::addFrameActionListener( const css::uno::Reference< css::frame::XFrameActionListener >& ) throw( css::uno::RuntimeException ) 990cdf0e10cSrcweir { 991cdf0e10cSrcweir } 992cdf0e10cSrcweir 993cdf0e10cSrcweir //***************************************************************************************************************** 994cdf0e10cSrcweir // css::frame::XFrame 995cdf0e10cSrcweir //***************************************************************************************************************** 996cdf0e10cSrcweir void SAL_CALL Desktop::removeFrameActionListener( const css::uno::Reference< css::frame::XFrameActionListener >& ) throw( css::uno::RuntimeException ) 997cdf0e10cSrcweir { 998cdf0e10cSrcweir } 999cdf0e10cSrcweir 1000cdf0e10cSrcweir /*-************************************************************************************************************//** 1001cdf0e10cSrcweir @interface XFrame 1002cdf0e10cSrcweir @short try to find a frame with special parameters 1003cdf0e10cSrcweir @descr This method searches for a frame with the specified name. 1004cdf0e10cSrcweir Frames may contain other frames (e.g. a frameset) and may 1005cdf0e10cSrcweir be contained in other frames. This hierarchie ist searched by 1006cdf0e10cSrcweir this method. 1007cdf0e10cSrcweir First some special names are taken into account, i.e. "", 1008cdf0e10cSrcweir "_self", "_top", "_parent" etc. The FrameSearchFlags are ignored 1009cdf0e10cSrcweir when comparing these names with aTargetFrameName, further steps are 1010cdf0e10cSrcweir controlled by the FrameSearchFlags. If allowed, the name of the frame 1011cdf0e10cSrcweir itself is compared with the desired one, then ( again if allowed ) 1012cdf0e10cSrcweir the method findFrame is called for all children of the frame. 1013cdf0e10cSrcweir If no Frame with the given name is found until the top frames container, 1014cdf0e10cSrcweir a new top Frame is created, if this is allowed by a special 1015cdf0e10cSrcweir FrameSearchFlag. The new Frame also gets the desired name. 1016cdf0e10cSrcweir We use a helper to get right search direction and react in a right manner. 1017cdf0e10cSrcweir 1018cdf0e10cSrcweir @seealso class TargetFinder 1019cdf0e10cSrcweir 1020cdf0e10cSrcweir @param "sTargetFrameName" , name of searched frame 1021cdf0e10cSrcweir @param "nSearchFlags" , flags to regulate search 1022cdf0e10cSrcweir @return A reference to an existing frame in hierarchy, if it exist. 1023cdf0e10cSrcweir 1024cdf0e10cSrcweir @onerror A null reference is returned. 1025cdf0e10cSrcweir @threadsafe yes 1026cdf0e10cSrcweir *//*-*************************************************************************************************************/ 1027cdf0e10cSrcweir css::uno::Reference< css::frame::XFrame > SAL_CALL Desktop::findFrame( const ::rtl::OUString& sTargetFrameName , 1028cdf0e10cSrcweir sal_Int32 nSearchFlags ) throw( css::uno::RuntimeException ) 1029cdf0e10cSrcweir { 1030cdf0e10cSrcweir css::uno::Reference< css::frame::XFrame > xTarget; 1031cdf0e10cSrcweir 1032cdf0e10cSrcweir //----------------------------------------------------------------------------------------------------- 1033cdf0e10cSrcweir // 0) Ignore wrong parameter! 1034cdf0e10cSrcweir // We doesn't support search for following special targets. 1035cdf0e10cSrcweir // If we reject this requests - we mustnt check for such names 1036cdf0e10cSrcweir // in following code again and again. If we do not so -wrong 103730acf5e8Spfg // search results can occur! 1038cdf0e10cSrcweir //----------------------------------------------------------------------------------------------------- 1039cdf0e10cSrcweir if ( 1040cdf0e10cSrcweir (sTargetFrameName==SPECIALTARGET_DEFAULT ) || // valid for dispatches - not for findFrame()! 1041cdf0e10cSrcweir (sTargetFrameName==SPECIALTARGET_MENUBAR ) || // valid for dispatches - not for findFrame()! 1042cdf0e10cSrcweir (sTargetFrameName==SPECIALTARGET_HELPAGENT) || // valid for dispatches - not for findFrame()! 1043cdf0e10cSrcweir (sTargetFrameName==SPECIALTARGET_PARENT ) || // we have no parent by definition 1044cdf0e10cSrcweir (sTargetFrameName==SPECIALTARGET_BEAMER ) // beamer frames are allowed as child of tasks only - 1045cdf0e10cSrcweir // and they exist more then ones. We have no idea which our sub tasks is the right one 1046cdf0e10cSrcweir ) 1047cdf0e10cSrcweir { 1048cdf0e10cSrcweir return NULL; 1049cdf0e10cSrcweir } 1050cdf0e10cSrcweir 1051cdf0e10cSrcweir //----------------------------------------------------------------------------------------------------- 1052cdf0e10cSrcweir // I) check for special defined targets first which must be handled exclusive. 1053cdf0e10cSrcweir // force using of "if() else if() ..." 1054cdf0e10cSrcweir //----------------------------------------------------------------------------------------------------- 1055cdf0e10cSrcweir 105607a3d7f1SPedro Giffuni // get threadsafe some necessary member which are necessary for following functionality 1057cdf0e10cSrcweir /* SAFE { */ 1058cdf0e10cSrcweir ReadGuard aReadLock( m_aLock ); 1059cdf0e10cSrcweir css::uno::Reference< css::lang::XMultiServiceFactory > xFactory = m_xFactory; 1060cdf0e10cSrcweir aReadLock.unlock(); 1061cdf0e10cSrcweir /* } SAFE */ 1062cdf0e10cSrcweir 1063cdf0e10cSrcweir //----------------------------------------------------------------------------------------------------- 1064cdf0e10cSrcweir // I.I) "_blank" 1065cdf0e10cSrcweir // create a new task as child of this desktop instance 106607a3d7f1SPedro Giffuni // Note: Used helper TaskCreator use us automatically ... 1067cdf0e10cSrcweir //----------------------------------------------------------------------------------------------------- 1068cdf0e10cSrcweir if ( sTargetFrameName==SPECIALTARGET_BLANK ) 1069cdf0e10cSrcweir { 1070cdf0e10cSrcweir TaskCreator aCreator(xFactory); 1071cdf0e10cSrcweir xTarget = aCreator.createTask(sTargetFrameName,sal_False); 1072cdf0e10cSrcweir } 1073cdf0e10cSrcweir 1074cdf0e10cSrcweir //----------------------------------------------------------------------------------------------------- 1075cdf0e10cSrcweir // I.II) "_top" 1076cdf0e10cSrcweir // We are top by definition 1077cdf0e10cSrcweir //----------------------------------------------------------------------------------------------------- 1078cdf0e10cSrcweir else 1079cdf0e10cSrcweir if ( sTargetFrameName==SPECIALTARGET_TOP ) 1080cdf0e10cSrcweir { 1081cdf0e10cSrcweir xTarget = this; 1082cdf0e10cSrcweir } 1083cdf0e10cSrcweir 1084cdf0e10cSrcweir //----------------------------------------------------------------------------------------------------- 1085cdf0e10cSrcweir // I.III) "_self", "" 1086cdf0e10cSrcweir // This mean this "frame" in every case. 1087cdf0e10cSrcweir //----------------------------------------------------------------------------------------------------- 1088cdf0e10cSrcweir else 1089cdf0e10cSrcweir if ( 1090cdf0e10cSrcweir ( sTargetFrameName==SPECIALTARGET_SELF ) || 1091cdf0e10cSrcweir ( sTargetFrameName.getLength()<1 ) 1092cdf0e10cSrcweir ) 1093cdf0e10cSrcweir { 1094cdf0e10cSrcweir xTarget = this; 1095cdf0e10cSrcweir } 1096cdf0e10cSrcweir 1097cdf0e10cSrcweir else 1098cdf0e10cSrcweir { 1099cdf0e10cSrcweir //------------------------------------------------------------------------------------------------- 1100cdf0e10cSrcweir // II) otherwhise use optional given search flags 1101cdf0e10cSrcweir // force using of combinations of such flags. means no "else" part of use if() statements. 1102cdf0e10cSrcweir // But we ust break further searches if target was already found. 1103cdf0e10cSrcweir // Order of using flags is fix: SELF - CHILDREN - SIBLINGS - PARENT 1104cdf0e10cSrcweir // TASK and CREATE are handled special. 110507a3d7f1SPedro Giffuni // But note: Such flags are not valid for the desktop - especially SIBLINGS or PARENT. 1106cdf0e10cSrcweir //------------------------------------------------------------------------------------------------- 1107cdf0e10cSrcweir 110807a3d7f1SPedro Giffuni // get threadsafe some necessary member which are necessary for following functionality 1109cdf0e10cSrcweir /* SAFE { */ 1110cdf0e10cSrcweir aReadLock.lock(); 1111cdf0e10cSrcweir ::rtl::OUString sOwnName = m_sName; 1112cdf0e10cSrcweir aReadLock.unlock(); 1113cdf0e10cSrcweir /* } SAFE */ 1114cdf0e10cSrcweir 1115cdf0e10cSrcweir //------------------------------------------------------------------------------------------------- 1116cdf0e10cSrcweir // II.I) SELF 1117cdf0e10cSrcweir // Check for right name. If it's the searched one return ourself - otherwhise 1118cdf0e10cSrcweir // ignore this flag. 1119cdf0e10cSrcweir //------------------------------------------------------------------------------------------------- 1120cdf0e10cSrcweir if ( 1121cdf0e10cSrcweir (nSearchFlags & css::frame::FrameSearchFlag::SELF) && 1122cdf0e10cSrcweir (sOwnName == sTargetFrameName ) 1123cdf0e10cSrcweir ) 1124cdf0e10cSrcweir { 1125cdf0e10cSrcweir xTarget = this; 1126cdf0e10cSrcweir } 1127cdf0e10cSrcweir 1128cdf0e10cSrcweir //------------------------------------------------------------------------------------------------- 1129cdf0e10cSrcweir // II.II) TASKS 1130*e9faf1d9Smseidel // This is a special flag. Normally it regulates search inside tasks and forbid access to parent trees. 1131cdf0e10cSrcweir // But the desktop exists outside such task trees. They are our sub trees. So the desktop implement 113207a3d7f1SPedro Giffuni // a special feature: We use it to start search on our direct childrens only. That means we suppress 113307a3d7f1SPedro Giffuni // search on ALL child frames. May that can be useful to get access on opened document tasks 113407a3d7f1SPedro Giffuni // only without filter out all non really required sub frames ... 1135cdf0e10cSrcweir // Used helper method on our container doesn't create any frame - its a search only. 1136cdf0e10cSrcweir //------------------------------------------------------------------------------------------------- 1137cdf0e10cSrcweir if ( 1138cdf0e10cSrcweir ( ! xTarget.is() ) && 1139cdf0e10cSrcweir (nSearchFlags & css::frame::FrameSearchFlag::TASKS) 1140cdf0e10cSrcweir ) 1141cdf0e10cSrcweir { 1142cdf0e10cSrcweir xTarget = m_aChildTaskContainer.searchOnDirectChildrens(sTargetFrameName); 1143cdf0e10cSrcweir } 1144cdf0e10cSrcweir 1145cdf0e10cSrcweir //------------------------------------------------------------------------------------------------- 1146cdf0e10cSrcweir // II.III) CHILDREN 1147cdf0e10cSrcweir // Search on all children for the given target name. 114830acf5e8Spfg // An empty name value can't occur here - because it must be already handled as "_self" 1149cdf0e10cSrcweir // before. Used helper function of container doesn't create any frame. 1150cdf0e10cSrcweir // It makes a deep search only. 1151cdf0e10cSrcweir //------------------------------------------------------------------------------------------------- 1152cdf0e10cSrcweir if ( 1153cdf0e10cSrcweir ( ! xTarget.is() ) && 1154cdf0e10cSrcweir (nSearchFlags & css::frame::FrameSearchFlag::CHILDREN) 1155cdf0e10cSrcweir ) 1156cdf0e10cSrcweir { 1157cdf0e10cSrcweir xTarget = m_aChildTaskContainer.searchOnAllChildrens(sTargetFrameName); 1158cdf0e10cSrcweir } 1159cdf0e10cSrcweir 1160cdf0e10cSrcweir //------------------------------------------------------------------------------------------------- 1161cdf0e10cSrcweir // II.IV) CREATE 1162cdf0e10cSrcweir // If we haven't found any valid target frame by using normal flags - but user allowed us to create 116307a3d7f1SPedro Giffuni // a new one ... we should do that. Used TaskCreator use us automatically as parent! 1164cdf0e10cSrcweir //------------------------------------------------------------------------------------------------- 1165cdf0e10cSrcweir if ( 1166cdf0e10cSrcweir ( ! xTarget.is() ) && 1167cdf0e10cSrcweir (nSearchFlags & css::frame::FrameSearchFlag::CREATE) 1168cdf0e10cSrcweir ) 1169cdf0e10cSrcweir { 1170cdf0e10cSrcweir TaskCreator aCreator(xFactory); 1171cdf0e10cSrcweir xTarget = aCreator.createTask(sTargetFrameName,sal_False); 1172cdf0e10cSrcweir } 1173cdf0e10cSrcweir } 1174cdf0e10cSrcweir 1175cdf0e10cSrcweir return xTarget; 1176cdf0e10cSrcweir } 1177cdf0e10cSrcweir 1178cdf0e10cSrcweir //============================================================================= 1179cdf0e10cSrcweir void SAL_CALL Desktop::dispose() 1180cdf0e10cSrcweir throw( css::uno::RuntimeException ) 1181cdf0e10cSrcweir { 1182cdf0e10cSrcweir // Safe impossible cases 1183cdf0e10cSrcweir // It's an programming error if dispose is called before terminate! 1184cdf0e10cSrcweir LOG_ASSERT2( m_bIsTerminated==sal_False, "Desktop::dispose()", "It's not allowed to dispose the desktop before terminate() is called!" ) 1185cdf0e10cSrcweir 1186cdf0e10cSrcweir SYNCHRONIZED_START 1187cdf0e10cSrcweir WriteGuard aWriteLock( m_aLock ); 1188cdf0e10cSrcweir 1189cdf0e10cSrcweir // Look for multiple calls of this method! 119007a3d7f1SPedro Giffuni // If somewhere call dispose() twice - he will be stopped here really!!! 1191cdf0e10cSrcweir TransactionGuard aTransaction( m_aTransactionManager, E_HARDEXCEPTIONS ); 1192cdf0e10cSrcweir 1193cdf0e10cSrcweir // Now - we are alone and its the first call of this method ... 1194cdf0e10cSrcweir // otherwise call before had thrown a DisposedException / hopefully .-) 119507a3d7f1SPedro Giffuni // But we dont use the transaction object created before ... we reset it immediately ... 1196cdf0e10cSrcweir // two lines of code ... for what ? 1197cdf0e10cSrcweir // The answer: We wished to synchronize concurrent dispose() calls -> OK 1198cdf0e10cSrcweir // But next line will wait for all currently running transaction (even if they 1199cdf0e10cSrcweir // are running within the same thread!) So we would block ourself there if aTransaction 1200cdf0e10cSrcweir // will stay registered .-) 1201cdf0e10cSrcweir aTransaction.stop(); 1202cdf0e10cSrcweir 1203cdf0e10cSrcweir // Disable this instance for further work. 1204cdf0e10cSrcweir // This will wait for all current running transactions ... 1205cdf0e10cSrcweir // and reject all new incoming requests! 1206cdf0e10cSrcweir m_aTransactionManager.setWorkingMode( E_BEFORECLOSE ); 1207cdf0e10cSrcweir 1208cdf0e10cSrcweir aWriteLock.unlock(); 1209cdf0e10cSrcweir SYNCHRONIZED_END 1210cdf0e10cSrcweir 1211cdf0e10cSrcweir // Following lines of code can be called outside a synchronized block ... 1212cdf0e10cSrcweir // Because our transaction manager will block all new requests to this object. 1213cdf0e10cSrcweir // So nobody can use us any longer. 121407a3d7f1SPedro Giffuni // Exception: Only removing of listener will work ... and this code can't be dangerous. 1215cdf0e10cSrcweir 1216cdf0e10cSrcweir // First we has to kill all listener connections. 1217cdf0e10cSrcweir // They might rely on our member and can hinder us on releasing them. 1218cdf0e10cSrcweir css::uno::Reference< css::uno::XInterface > xThis ( static_cast< ::cppu::OWeakObject* >(this), css::uno::UNO_QUERY ); 1219cdf0e10cSrcweir css::lang::EventObject aEvent( xThis ); 1220cdf0e10cSrcweir m_aListenerContainer.disposeAndClear( aEvent ); 1221cdf0e10cSrcweir 1222cdf0e10cSrcweir // Clear our child task container and forget all task references hardly. 1223*e9faf1d9Smseidel // Normally all open document were already closed by our terminate() function before ... 1224cdf0e10cSrcweir // New opened frames will have a problem now .-) 1225cdf0e10cSrcweir m_aChildTaskContainer.clear(); 1226cdf0e10cSrcweir 1227cdf0e10cSrcweir // Dispose our helper too. 1228cdf0e10cSrcweir css::uno::Reference< css::lang::XEventListener > xFramesHelper( m_xFramesHelper, css::uno::UNO_QUERY ); 1229cdf0e10cSrcweir if( xFramesHelper.is() ) 1230cdf0e10cSrcweir xFramesHelper->disposing( aEvent ); 1231cdf0e10cSrcweir 1232cdf0e10cSrcweir // At least clean up other member references. 1233cdf0e10cSrcweir m_xDispatchHelper.clear(); 1234cdf0e10cSrcweir m_xFramesHelper.clear(); 1235cdf0e10cSrcweir m_xLastFrame.clear(); 1236cdf0e10cSrcweir m_xFactory.clear(); 1237cdf0e10cSrcweir 1238cdf0e10cSrcweir m_xPipeTerminator.clear(); 1239cdf0e10cSrcweir m_xQuickLauncher.clear(); 1240cdf0e10cSrcweir m_xSWThreadManager.clear(); 1241cdf0e10cSrcweir m_xSfxTerminator.clear(); 1242cdf0e10cSrcweir 1243cdf0e10cSrcweir // From this point nothing will work further on this object ... 1244cdf0e10cSrcweir // excepting our dtor() .-) 1245cdf0e10cSrcweir m_aTransactionManager.setWorkingMode( E_CLOSE ); 1246cdf0e10cSrcweir } 1247cdf0e10cSrcweir 1248cdf0e10cSrcweir /*-************************************************************************************************************//** 1249cdf0e10cSrcweir @interface XComponent 1250cdf0e10cSrcweir @short add/remove listener for dispose events 1251cdf0e10cSrcweir @descr Add an event listener to this object, if you whish to get informations 125230acf5e8Spfg about our dying! 1253cdf0e10cSrcweir You must releas ethis listener reference during your own disposing() method. 1254cdf0e10cSrcweir 1255cdf0e10cSrcweir @attention Our container is threadsafe himeslf. So we doesn't need any lock here. 1256cdf0e10cSrcweir 1257cdf0e10cSrcweir @seealso - 1258cdf0e10cSrcweir 1259cdf0e10cSrcweir @param "xListener", reference to valid listener. We don't accept invalid values! 1260cdf0e10cSrcweir @return - 1261cdf0e10cSrcweir 1262cdf0e10cSrcweir @onerror - 1263cdf0e10cSrcweir @threadsafe yes 1264cdf0e10cSrcweir *//*-*************************************************************************************************************/ 1265cdf0e10cSrcweir void SAL_CALL Desktop::addEventListener( const css::uno::Reference< css::lang::XEventListener >& xListener ) throw( css::uno::RuntimeException ) 1266cdf0e10cSrcweir { 1267cdf0e10cSrcweir /* UNSAFE AREA --------------------------------------------------------------------------------------------- */ 1268cdf0e10cSrcweir // Safe impossible cases 1269cdf0e10cSrcweir // Method not defined for all incoming parameter. 1270cdf0e10cSrcweir LOG_ASSERT2( implcp_addEventListener( xListener ), "Desktop::addEventListener()", "Invalid parameter detected!" ) 1271cdf0e10cSrcweir // Register transaction and reject wrong calls. 1272cdf0e10cSrcweir TransactionGuard aTransaction( m_aTransactionManager, E_HARDEXCEPTIONS ); 1273cdf0e10cSrcweir 1274cdf0e10cSrcweir m_aListenerContainer.addInterface( ::getCppuType( ( const css::uno::Reference< css::lang::XEventListener >*) NULL ), xListener ); 1275cdf0e10cSrcweir } 1276cdf0e10cSrcweir 1277cdf0e10cSrcweir //***************************************************************************************************************** 1278cdf0e10cSrcweir void SAL_CALL Desktop::removeEventListener( const css::uno::Reference< css::lang::XEventListener >& xListener ) throw( css::uno::RuntimeException ) 1279cdf0e10cSrcweir { 1280cdf0e10cSrcweir /* UNSAFE AREA --------------------------------------------------------------------------------------------- */ 1281cdf0e10cSrcweir // Safe impossible cases 1282cdf0e10cSrcweir // Method not defined for all incoming parameter. 1283cdf0e10cSrcweir LOG_ASSERT2( implcp_removeEventListener( xListener ), "Desktop::removeEventListener()", "Invalid parameter detected!" ) 1284cdf0e10cSrcweir // Register transaction and reject wrong calls. 1285cdf0e10cSrcweir TransactionGuard aTransaction( m_aTransactionManager, E_SOFTEXCEPTIONS ); 1286cdf0e10cSrcweir 1287cdf0e10cSrcweir m_aListenerContainer.removeInterface( ::getCppuType( ( const css::uno::Reference< css::lang::XEventListener >*) NULL ), xListener ); 1288cdf0e10cSrcweir } 1289cdf0e10cSrcweir 1290cdf0e10cSrcweir /*-************************************************************************************************************//** 1291cdf0e10cSrcweir @interface XDispatchResultListener 1292cdf0e10cSrcweir @short callback for dispatches 1293cdf0e10cSrcweir @descr To support our method "loadComponentFromURL()" we are listener on temp. created dispatcher. 1294cdf0e10cSrcweir They call us back in this method "statusChanged()". As source of given state event, they give us a 1295cdf0e10cSrcweir reference to the target frame, in which dispatch was loaded! So we can use it to return his component 1296cdf0e10cSrcweir to caller! If no target exist ... ??!! 1297cdf0e10cSrcweir 1298cdf0e10cSrcweir @seealso method loadComponentFromURL() 1299cdf0e10cSrcweir 1300cdf0e10cSrcweir @param "aEvent", state event which (hopefully) valid informations 1301cdf0e10cSrcweir @return - 1302cdf0e10cSrcweir 1303cdf0e10cSrcweir @onerror - 1304cdf0e10cSrcweir @threadsafe yes 1305cdf0e10cSrcweir *//*-*************************************************************************************************************/ 1306cdf0e10cSrcweir void SAL_CALL Desktop::dispatchFinished( const css::frame::DispatchResultEvent& aEvent ) throw( css::uno::RuntimeException ) 1307cdf0e10cSrcweir { 1308cdf0e10cSrcweir /* UNSAFE AREA --------------------------------------------------------------------------------------------- */ 1309cdf0e10cSrcweir // Register transaction and reject wrong calls. 1310cdf0e10cSrcweir TransactionGuard aTransaction( m_aTransactionManager, E_HARDEXCEPTIONS ); 1311cdf0e10cSrcweir 1312cdf0e10cSrcweir /* SAFE AREA ------------------------------------------------------------------------------------------- */ 1313cdf0e10cSrcweir WriteGuard aWriteLock( m_aLock ); 1314cdf0e10cSrcweir if( m_eLoadState != E_INTERACTION ) 1315cdf0e10cSrcweir { 1316cdf0e10cSrcweir m_xLastFrame = css::uno::Reference< css::frame::XFrame >(); 1317cdf0e10cSrcweir m_eLoadState = E_FAILED ; 1318cdf0e10cSrcweir if( aEvent.State == css::frame::DispatchResultState::SUCCESS ) 1319cdf0e10cSrcweir { 1320cdf0e10cSrcweir css::uno::Reference < css::frame::XFrame > xFrame; 1321cdf0e10cSrcweir if ( aEvent.Result >>= m_xLastFrame ) 1322cdf0e10cSrcweir m_eLoadState = E_SUCCESSFUL; 1323cdf0e10cSrcweir } 1324cdf0e10cSrcweir } 1325cdf0e10cSrcweir /* UNSAFE AREA ----------------------------------------------------------------------------------------- */ 1326cdf0e10cSrcweir } 1327cdf0e10cSrcweir 1328cdf0e10cSrcweir /*-************************************************************************************************************//** 1329cdf0e10cSrcweir @interface XEventListener 1330cdf0e10cSrcweir @short not implemented! 133107a3d7f1SPedro Giffuni @descr We are a status listener ... and so we must be an event listener too ... But we doesn't need it really! 1332cdf0e10cSrcweir We are a temp. listener only and our lifetime isn't smaller then of our temp. used dispatcher. 1333cdf0e10cSrcweir 1334cdf0e10cSrcweir @seealso method loadComponentFromURL() 1335cdf0e10cSrcweir 1336cdf0e10cSrcweir @param - 1337cdf0e10cSrcweir @return - 1338cdf0e10cSrcweir 1339cdf0e10cSrcweir @onerror - 1340cdf0e10cSrcweir @threadsafe - 1341cdf0e10cSrcweir *//*-*************************************************************************************************************/ 1342cdf0e10cSrcweir void SAL_CALL Desktop::disposing( const css::lang::EventObject& ) throw( css::uno::RuntimeException ) 1343cdf0e10cSrcweir { 1344*e9faf1d9Smseidel LOG_ERROR( "Desktop::disposing()", "Algorithm error! Normally desktop is temp. listener ... not all the time. So this method shouldn't be called." ) 1345cdf0e10cSrcweir } 1346cdf0e10cSrcweir 1347cdf0e10cSrcweir /*-************************************************************************************************************//** 1348cdf0e10cSrcweir @interface XInteractionHandler 134907a3d7f1SPedro Giffuni @short callback for loadComponentFromURL for detected exceptions during load process 1350cdf0e10cSrcweir @descr In this case we must cancel loading and throw these detected exception again as result 1351cdf0e10cSrcweir of our own called method. 1352cdf0e10cSrcweir 1353cdf0e10cSrcweir @attention a) 135430acf5e8Spfg Normal loop in loadComponentFromURL() breaks on set member m_eLoadState during callback statusChanged(). 1355cdf0e10cSrcweir But these interaction feature implements second way to do so! So we must look on different callbacks 1356cdf0e10cSrcweir for same operation ... and live with it. 1357cdf0e10cSrcweir b) 1358cdf0e10cSrcweir Search for given continuations too. If any XInteractionAbort exist ... use it to abort further operations 1359cdf0e10cSrcweir for currently running operation! 1360cdf0e10cSrcweir 1361cdf0e10cSrcweir @seealso method loadComponentFromURL() 1362cdf0e10cSrcweir @seealso member m_eLoadState 1363cdf0e10cSrcweir 1364cdf0e10cSrcweir @param "xRequest", request for interaction - normal a wrapped target exception from bottom services 1365cdf0e10cSrcweir @return - 1366cdf0e10cSrcweir 1367cdf0e10cSrcweir @onerror - 1368cdf0e10cSrcweir @threadsafe yes 1369cdf0e10cSrcweir *//*-*************************************************************************************************************/ 1370cdf0e10cSrcweir void SAL_CALL Desktop::handle( const css::uno::Reference< css::task::XInteractionRequest >& xRequest ) throw( css::uno::RuntimeException ) 1371cdf0e10cSrcweir { 1372cdf0e10cSrcweir /* UNSAFE AREA --------------------------------------------------------------------------------------------- */ 1373cdf0e10cSrcweir // Register transaction and reject wrong calls. 1374cdf0e10cSrcweir TransactionGuard aTransaction( m_aTransactionManager, E_HARDEXCEPTIONS ); 1375cdf0e10cSrcweir 1376cdf0e10cSrcweir // Don't check incoming request! 137730acf5e8Spfg // If somewhere starts interaction without right parameter - he made something wrong. 1378cdf0e10cSrcweir // loadComponentFromURL() waits for thjese event - otherwise it yield for ever! 1379cdf0e10cSrcweir 1380cdf0e10cSrcweir // get packed request and work on it first 1381cdf0e10cSrcweir // Attention: Don't set it on internal member BEFORE interaction is finished - because 1382cdf0e10cSrcweir // "loadComponentFromURL()" yield tills this member is changed. If we do it before 1383cdf0e10cSrcweir // interaction finish we can't guarantee right functionality. May be we cancel load process to erliear ... 1384cdf0e10cSrcweir css::uno::Any aRequest = xRequest->getRequest(); 1385cdf0e10cSrcweir 1386cdf0e10cSrcweir // extract continuations from request 1387cdf0e10cSrcweir css::uno::Sequence< css::uno::Reference< css::task::XInteractionContinuation > > lContinuations = xRequest->getContinuations(); 1388cdf0e10cSrcweir css::uno::Reference< css::task::XInteractionAbort > xAbort ; 1389cdf0e10cSrcweir css::uno::Reference< css::task::XInteractionApprove > xApprove ; 1390cdf0e10cSrcweir css::uno::Reference< css::document::XInteractionFilterSelect > xFilterSelect ; 1391cdf0e10cSrcweir sal_Bool bAbort = sal_False; 1392cdf0e10cSrcweir 1393cdf0e10cSrcweir sal_Int32 nCount=lContinuations.getLength(); 1394cdf0e10cSrcweir for( sal_Int32 nStep=0; nStep<nCount; ++nStep ) 1395cdf0e10cSrcweir { 1396cdf0e10cSrcweir if( ! xAbort.is() ) 1397cdf0e10cSrcweir xAbort = css::uno::Reference< css::task::XInteractionAbort >( lContinuations[nStep], css::uno::UNO_QUERY ); 1398cdf0e10cSrcweir 1399cdf0e10cSrcweir if( ! xApprove.is() ) 1400cdf0e10cSrcweir xApprove = css::uno::Reference< css::task::XInteractionApprove >( lContinuations[nStep], css::uno::UNO_QUERY ); 1401cdf0e10cSrcweir 1402cdf0e10cSrcweir if( ! xFilterSelect.is() ) 1403cdf0e10cSrcweir xFilterSelect = css::uno::Reference< css::document::XInteractionFilterSelect >( lContinuations[nStep], css::uno::UNO_QUERY ); 1404cdf0e10cSrcweir } 1405cdf0e10cSrcweir 1406cdf0e10cSrcweir // differ between abortable interactions (error, unknown filter ...) 1407cdf0e10cSrcweir // and other ones (ambigous but not unknown filter ...) 1408cdf0e10cSrcweir css::task::ErrorCodeRequest aErrorCodeRequest ; 1409cdf0e10cSrcweir css::document::AmbigousFilterRequest aAmbigousFilterRequest; 1410cdf0e10cSrcweir if( aRequest >>= aAmbigousFilterRequest ) 1411cdf0e10cSrcweir { 1412cdf0e10cSrcweir if( xFilterSelect.is() ) 1413cdf0e10cSrcweir { 1414cdf0e10cSrcweir xFilterSelect->setFilter( aAmbigousFilterRequest.SelectedFilter ); // user selected filter wins! 1415cdf0e10cSrcweir xFilterSelect->select(); 1416cdf0e10cSrcweir } 1417cdf0e10cSrcweir } 1418cdf0e10cSrcweir else 1419cdf0e10cSrcweir if( aRequest >>= aErrorCodeRequest ) 1420cdf0e10cSrcweir { 1421cdf0e10cSrcweir sal_Bool bWarning = ((aErrorCodeRequest.ErrCode & ERRCODE_WARNING_MASK) == ERRCODE_WARNING_MASK); 1422cdf0e10cSrcweir if (xApprove.is() && bWarning) 1423cdf0e10cSrcweir xApprove->select(); 1424cdf0e10cSrcweir else 1425cdf0e10cSrcweir if (xAbort.is()) 1426cdf0e10cSrcweir { 1427cdf0e10cSrcweir xAbort->select(); 1428cdf0e10cSrcweir bAbort = sal_True; 1429cdf0e10cSrcweir } 1430cdf0e10cSrcweir } 1431cdf0e10cSrcweir else 1432cdf0e10cSrcweir if( xAbort.is() ) 1433cdf0e10cSrcweir { 1434cdf0e10cSrcweir xAbort->select(); 1435cdf0e10cSrcweir bAbort = sal_True; 1436cdf0e10cSrcweir } 1437cdf0e10cSrcweir 1438cdf0e10cSrcweir /* SAFE AREA ------------------------------------------------------------------------------------------- */ 1439cdf0e10cSrcweir // Ok now it's time to break yield loop of loadComponentFromURL(). 144007a3d7f1SPedro Giffuni // But only for really aborted requests! 1441cdf0e10cSrcweir // For example warnings will be approved and we wait for any success story ... 1442cdf0e10cSrcweir if (bAbort) 1443cdf0e10cSrcweir { 1444cdf0e10cSrcweir WriteGuard aWriteLock( m_aLock ); 1445cdf0e10cSrcweir m_eLoadState = E_INTERACTION; 1446cdf0e10cSrcweir m_aInteractionRequest = aRequest ; 1447cdf0e10cSrcweir aWriteLock.unlock(); 1448cdf0e10cSrcweir } 1449cdf0e10cSrcweir /* UNSAFE AREA ----------------------------------------------------------------------------------------- */ 1450cdf0e10cSrcweir } 1451cdf0e10cSrcweir 1452cdf0e10cSrcweir //----------------------------------------------------------------------------- 1453cdf0e10cSrcweir ::sal_Int32 SAL_CALL Desktop::leaseNumber( const css::uno::Reference< css::uno::XInterface >& xComponent ) 1454cdf0e10cSrcweir throw (css::lang::IllegalArgumentException, 1455cdf0e10cSrcweir css::uno::RuntimeException ) 1456cdf0e10cSrcweir { 1457cdf0e10cSrcweir TransactionGuard aTransaction( m_aTransactionManager, E_HARDEXCEPTIONS ); 1458cdf0e10cSrcweir return m_xTitleNumberGenerator->leaseNumber (xComponent); 1459cdf0e10cSrcweir } 1460cdf0e10cSrcweir 1461cdf0e10cSrcweir //----------------------------------------------------------------------------- 1462cdf0e10cSrcweir void SAL_CALL Desktop::releaseNumber( ::sal_Int32 nNumber ) 1463cdf0e10cSrcweir throw (css::lang::IllegalArgumentException, 1464cdf0e10cSrcweir css::uno::RuntimeException ) 1465cdf0e10cSrcweir { 1466cdf0e10cSrcweir TransactionGuard aTransaction( m_aTransactionManager, E_HARDEXCEPTIONS ); 1467cdf0e10cSrcweir m_xTitleNumberGenerator->releaseNumber (nNumber); 1468cdf0e10cSrcweir } 1469cdf0e10cSrcweir 1470cdf0e10cSrcweir //----------------------------------------------------------------------------- 1471cdf0e10cSrcweir void SAL_CALL Desktop::releaseNumberForComponent( const css::uno::Reference< css::uno::XInterface >& xComponent ) 1472cdf0e10cSrcweir throw (css::lang::IllegalArgumentException, 1473cdf0e10cSrcweir css::uno::RuntimeException ) 1474cdf0e10cSrcweir { 1475cdf0e10cSrcweir TransactionGuard aTransaction( m_aTransactionManager, E_HARDEXCEPTIONS ); 1476cdf0e10cSrcweir m_xTitleNumberGenerator->releaseNumberForComponent (xComponent); 1477cdf0e10cSrcweir } 1478cdf0e10cSrcweir 1479cdf0e10cSrcweir //----------------------------------------------------------------------------- 1480cdf0e10cSrcweir ::rtl::OUString SAL_CALL Desktop::getUntitledPrefix() 1481cdf0e10cSrcweir throw (css::uno::RuntimeException) 1482cdf0e10cSrcweir { 1483cdf0e10cSrcweir TransactionGuard aTransaction( m_aTransactionManager, E_HARDEXCEPTIONS ); 1484cdf0e10cSrcweir return m_xTitleNumberGenerator->getUntitledPrefix (); 1485cdf0e10cSrcweir } 1486cdf0e10cSrcweir 1487cdf0e10cSrcweir /*-************************************************************************************************************//** 1488cdf0e10cSrcweir @short try to convert a property value 1489cdf0e10cSrcweir @descr This method is called from helperclass "OPropertySetHelper". 1490cdf0e10cSrcweir Don't use this directly! 1491cdf0e10cSrcweir You must try to convert the value of given DESKTOP_PROPHANDLE and 1492cdf0e10cSrcweir return results of this operation. This will be used to ask vetoable 149307a3d7f1SPedro Giffuni listener. If no listener has a veto, we will change value really! 1494cdf0e10cSrcweir ( in method setFastPropertyValue_NoBroadcast(...) ) 1495cdf0e10cSrcweir 1496cdf0e10cSrcweir @attention Methods of OPropertySethelper are safed by using our shared osl mutex! (see ctor!) 1497cdf0e10cSrcweir So we must use different locks to make our implementation threadsafe. 1498cdf0e10cSrcweir 1499cdf0e10cSrcweir @seealso class OPropertySetHelper 1500cdf0e10cSrcweir @seealso method setFastPropertyValue_NoBroadcast() 1501cdf0e10cSrcweir 1502cdf0e10cSrcweir @param "aConvertedValue" new converted value of property 1503cdf0e10cSrcweir @param "aOldValue" old value of property 1504cdf0e10cSrcweir @param "nHandle" handle of property 1505cdf0e10cSrcweir @param "aValue" new value of property 1506cdf0e10cSrcweir @return sal_True if value will be changed, sal_FALSE otherway 1507cdf0e10cSrcweir 1508cdf0e10cSrcweir @onerror IllegalArgumentException, if you call this with an invalid argument 1509cdf0e10cSrcweir @threadsafe yes 1510cdf0e10cSrcweir *//*-*************************************************************************************************************/ 1511cdf0e10cSrcweir sal_Bool SAL_CALL Desktop::convertFastPropertyValue( css::uno::Any& aConvertedValue , 1512cdf0e10cSrcweir css::uno::Any& aOldValue , 1513cdf0e10cSrcweir sal_Int32 nHandle , 1514cdf0e10cSrcweir const css::uno::Any& aValue ) throw( css::lang::IllegalArgumentException ) 1515cdf0e10cSrcweir { 1516cdf0e10cSrcweir /* UNSAFE AREA --------------------------------------------------------------------------------------------- */ 1517cdf0e10cSrcweir // Register transaction and reject wrong calls. 1518cdf0e10cSrcweir TransactionGuard aTransaction( m_aTransactionManager, E_HARDEXCEPTIONS ); 1519cdf0e10cSrcweir 1520cdf0e10cSrcweir // Initialize state with sal_False !!! 1521cdf0e10cSrcweir // (Handle can be invalid) 1522cdf0e10cSrcweir sal_Bool bReturn = sal_False; 1523cdf0e10cSrcweir 1524cdf0e10cSrcweir switch( nHandle ) 1525cdf0e10cSrcweir { 1526cdf0e10cSrcweir case DESKTOP_PROPHANDLE_SUSPENDQUICKSTARTVETO: 1527cdf0e10cSrcweir bReturn = PropHelper::willPropertyBeChanged( 1528cdf0e10cSrcweir css::uno::makeAny(m_bSuspendQuickstartVeto), 1529cdf0e10cSrcweir aValue, 1530cdf0e10cSrcweir aOldValue, 1531cdf0e10cSrcweir aConvertedValue); 1532cdf0e10cSrcweir break; 1533cdf0e10cSrcweir case DESKTOP_PROPHANDLE_DISPATCHRECORDERSUPPLIER : 1534cdf0e10cSrcweir bReturn = PropHelper::willPropertyBeChanged( 1535cdf0e10cSrcweir css::uno::makeAny(m_xDispatchRecorderSupplier), 1536cdf0e10cSrcweir aValue, 1537cdf0e10cSrcweir aOldValue, 1538cdf0e10cSrcweir aConvertedValue); 1539cdf0e10cSrcweir break; 1540cdf0e10cSrcweir case DESKTOP_PROPHANDLE_TITLE : 1541cdf0e10cSrcweir bReturn = PropHelper::willPropertyBeChanged( 1542cdf0e10cSrcweir css::uno::makeAny(m_sTitle), 1543cdf0e10cSrcweir aValue, 1544cdf0e10cSrcweir aOldValue, 1545cdf0e10cSrcweir aConvertedValue); 1546cdf0e10cSrcweir break; 1547cdf0e10cSrcweir } 1548cdf0e10cSrcweir 1549cdf0e10cSrcweir // Return state of operation. 1550cdf0e10cSrcweir return bReturn ; 1551cdf0e10cSrcweir } 1552cdf0e10cSrcweir 1553cdf0e10cSrcweir /*-************************************************************************************************************//** 1554cdf0e10cSrcweir @short set value of a transient property 1555cdf0e10cSrcweir @descr This method is calling from helperclass "OPropertySetHelper". 1556cdf0e10cSrcweir Don't use this directly! 1557cdf0e10cSrcweir Handle and value are valid everyway! You must set the new value only. 155807a3d7f1SPedro Giffuni After this, baseclass send messages to all listener automatically. 1559cdf0e10cSrcweir 1560cdf0e10cSrcweir @seealso class OPropertySetHelper 1561cdf0e10cSrcweir 1562cdf0e10cSrcweir @param "nHandle" handle of property to change 1563cdf0e10cSrcweir @param "aValue" new value of property 1564cdf0e10cSrcweir @return - 1565cdf0e10cSrcweir 1566cdf0e10cSrcweir @onerror An exception is thrown. 1567cdf0e10cSrcweir @threadsafe yes 1568cdf0e10cSrcweir *//*-*************************************************************************************************************/ 1569cdf0e10cSrcweir void SAL_CALL Desktop::setFastPropertyValue_NoBroadcast( sal_Int32 nHandle , 1570cdf0e10cSrcweir const css::uno::Any& aValue ) throw( css::uno::Exception ) 1571cdf0e10cSrcweir { 1572cdf0e10cSrcweir /* UNSAFE AREA --------------------------------------------------------------------------------------------- */ 1573cdf0e10cSrcweir // Register transaction and reject wrong calls. 1574cdf0e10cSrcweir TransactionGuard aTransaction( m_aTransactionManager, E_HARDEXCEPTIONS ); 1575cdf0e10cSrcweir 1576cdf0e10cSrcweir switch( nHandle ) 1577cdf0e10cSrcweir { 1578cdf0e10cSrcweir case DESKTOP_PROPHANDLE_SUSPENDQUICKSTARTVETO: aValue >>= m_bSuspendQuickstartVeto; 1579cdf0e10cSrcweir break; 1580cdf0e10cSrcweir case DESKTOP_PROPHANDLE_DISPATCHRECORDERSUPPLIER: aValue >>= m_xDispatchRecorderSupplier; 1581cdf0e10cSrcweir break; 1582cdf0e10cSrcweir case DESKTOP_PROPHANDLE_TITLE: aValue >>= m_sTitle; 1583cdf0e10cSrcweir break; 1584cdf0e10cSrcweir } 1585cdf0e10cSrcweir } 1586cdf0e10cSrcweir 1587cdf0e10cSrcweir /*-************************************************************************************************************//** 1588cdf0e10cSrcweir @short get value of a transient property 1589cdf0e10cSrcweir @descr This method is calling from helperclass "OPropertySetHelper". 1590cdf0e10cSrcweir Don't use this directly! 1591cdf0e10cSrcweir 1592cdf0e10cSrcweir @attention We don't need any mutex or lock here ... We use threadsafe container or methods here only! 1593cdf0e10cSrcweir 1594cdf0e10cSrcweir @seealso class OPropertySetHelper 1595cdf0e10cSrcweir 1596cdf0e10cSrcweir @param "nHandle" handle of property to change 1597cdf0e10cSrcweir @param "aValue" current value of property 1598cdf0e10cSrcweir @return - 1599cdf0e10cSrcweir 1600cdf0e10cSrcweir @onerror - 1601cdf0e10cSrcweir @threadsafe yes 1602cdf0e10cSrcweir *//*-*************************************************************************************************************/ 1603cdf0e10cSrcweir void SAL_CALL Desktop::getFastPropertyValue( css::uno::Any& aValue , 1604cdf0e10cSrcweir sal_Int32 nHandle ) const 1605cdf0e10cSrcweir { 1606cdf0e10cSrcweir /* UNSAFE AREA --------------------------------------------------------------------------------------------- */ 1607cdf0e10cSrcweir // Register transaction and reject wrong calls. 1608cdf0e10cSrcweir TransactionGuard aTransaction( m_aTransactionManager, E_HARDEXCEPTIONS ); 1609cdf0e10cSrcweir 1610cdf0e10cSrcweir switch( nHandle ) 1611cdf0e10cSrcweir { 1612cdf0e10cSrcweir case DESKTOP_PROPHANDLE_ACTIVEFRAME : aValue <<= m_aChildTaskContainer.getActive(); 1613cdf0e10cSrcweir break; 1614cdf0e10cSrcweir case DESKTOP_PROPHANDLE_ISPLUGGED : aValue <<= sal_False; 1615cdf0e10cSrcweir break; 1616cdf0e10cSrcweir case DESKTOP_PROPHANDLE_SUSPENDQUICKSTARTVETO: aValue <<= m_bSuspendQuickstartVeto; 1617cdf0e10cSrcweir break; 1618cdf0e10cSrcweir case DESKTOP_PROPHANDLE_DISPATCHRECORDERSUPPLIER: aValue <<= m_xDispatchRecorderSupplier; 1619cdf0e10cSrcweir break; 1620cdf0e10cSrcweir case DESKTOP_PROPHANDLE_TITLE: aValue <<= m_sTitle; 1621cdf0e10cSrcweir break; 1622cdf0e10cSrcweir } 1623cdf0e10cSrcweir } 1624cdf0e10cSrcweir 1625cdf0e10cSrcweir /*-************************************************************************************************************//** 1626cdf0e10cSrcweir @short return structure and information about transient properties 1627cdf0e10cSrcweir @descr This method is calling from helperclass "OPropertySetHelper". 1628cdf0e10cSrcweir Don't use this directly! 1629cdf0e10cSrcweir 1630cdf0e10cSrcweir @attention You must use global lock (method use static variable) ... and it must be the shareable osl mutex of it. 1631cdf0e10cSrcweir Because; our baseclass use this mutex to make his code threadsafe. We use our lock! 1632cdf0e10cSrcweir So we could have two different mutex/lock mechanism at the same object. 1633cdf0e10cSrcweir 1634cdf0e10cSrcweir @seealso class OPropertySetHelper 1635cdf0e10cSrcweir 1636cdf0e10cSrcweir @param - 1637cdf0e10cSrcweir @return structure with property-informations 1638cdf0e10cSrcweir 1639cdf0e10cSrcweir @onerror - 1640cdf0e10cSrcweir @threadsafe yes 1641cdf0e10cSrcweir *//*-*************************************************************************************************************/ 1642cdf0e10cSrcweir ::cppu::IPropertyArrayHelper& SAL_CALL Desktop::getInfoHelper() 1643cdf0e10cSrcweir { 1644cdf0e10cSrcweir /* UNSAFE AREA --------------------------------------------------------------------------------------------- */ 1645cdf0e10cSrcweir // Register transaction and reject wrong calls. 1646cdf0e10cSrcweir TransactionGuard aTransaction( m_aTransactionManager, E_HARDEXCEPTIONS ); 1647cdf0e10cSrcweir 1648cdf0e10cSrcweir // Optimize this method ! 1649cdf0e10cSrcweir // We initialize a static variable only one time. And we don't must use a mutex at every call! 1650cdf0e10cSrcweir // For the first call; pInfoHelper is NULL - for the second call pInfoHelper is different from NULL! 1651cdf0e10cSrcweir static ::cppu::OPropertyArrayHelper* pInfoHelper = NULL; 1652cdf0e10cSrcweir 1653cdf0e10cSrcweir if( pInfoHelper == NULL ) 1654cdf0e10cSrcweir { 1655cdf0e10cSrcweir // Ready for multithreading 1656cdf0e10cSrcweir ::osl::MutexGuard aGuard( LockHelper::getGlobalLock().getShareableOslMutex() ); 1657cdf0e10cSrcweir // Control this pointer again, another instance can be faster then these! 1658cdf0e10cSrcweir if( pInfoHelper == NULL ) 1659cdf0e10cSrcweir { 1660cdf0e10cSrcweir // Define static member to give structure of properties to baseclass "OPropertySetHelper". 166107a3d7f1SPedro Giffuni // "impl_getStaticPropertyDescriptor" is a non exported and static function, who will define a static propertytable. 1662cdf0e10cSrcweir // "sal_True" say: Table is sorted by name. 1663cdf0e10cSrcweir static ::cppu::OPropertyArrayHelper aInfoHelper( impl_getStaticPropertyDescriptor(), sal_True ); 1664cdf0e10cSrcweir pInfoHelper = &aInfoHelper; 1665cdf0e10cSrcweir } 1666cdf0e10cSrcweir } 1667cdf0e10cSrcweir 1668cdf0e10cSrcweir return(*pInfoHelper); 1669cdf0e10cSrcweir } 1670cdf0e10cSrcweir 1671cdf0e10cSrcweir /*-************************************************************************************************************//** 1672cdf0e10cSrcweir @short return propertysetinfo 1673cdf0e10cSrcweir @descr You can call this method to get information about transient properties 1674cdf0e10cSrcweir of this object. 1675cdf0e10cSrcweir 1676cdf0e10cSrcweir @attention You must use global lock (method use static variable) ... and it must be the shareable osl mutex of it. 1677cdf0e10cSrcweir Because; our baseclass use this mutex to make his code threadsafe. We use our lock! 1678cdf0e10cSrcweir So we could have two different mutex/lock mechanism at the same object. 1679cdf0e10cSrcweir 1680cdf0e10cSrcweir @seealso class OPropertySetHelper 1681cdf0e10cSrcweir @seealso interface XPropertySet 1682cdf0e10cSrcweir @seealso interface XMultiPropertySet 1683cdf0e10cSrcweir 1684cdf0e10cSrcweir @param - 1685cdf0e10cSrcweir @return reference to object with information [XPropertySetInfo] 1686cdf0e10cSrcweir 1687cdf0e10cSrcweir @onerror - 1688cdf0e10cSrcweir @threadsafe yes 1689cdf0e10cSrcweir *//*-*************************************************************************************************************/ 1690cdf0e10cSrcweir css::uno::Reference< css::beans::XPropertySetInfo > SAL_CALL Desktop::getPropertySetInfo() throw (::com::sun::star::uno::RuntimeException) 1691cdf0e10cSrcweir { 1692cdf0e10cSrcweir /* UNSAFE AREA --------------------------------------------------------------------------------------------- */ 1693cdf0e10cSrcweir // Register transaction and reject wrong calls. 1694cdf0e10cSrcweir TransactionGuard aTransaction( m_aTransactionManager, E_HARDEXCEPTIONS ); 1695cdf0e10cSrcweir 1696cdf0e10cSrcweir // Optimize this method ! 1697cdf0e10cSrcweir // We initialize a static variable only one time. And we don't must use a mutex at every call! 1698cdf0e10cSrcweir // For the first call; pInfo is NULL - for the second call pInfo is different from NULL! 1699cdf0e10cSrcweir static css::uno::Reference< css::beans::XPropertySetInfo >* pInfo = NULL; 1700cdf0e10cSrcweir 1701cdf0e10cSrcweir if( pInfo == NULL ) 1702cdf0e10cSrcweir { 1703cdf0e10cSrcweir // Ready for multithreading 1704cdf0e10cSrcweir ::osl::MutexGuard aGuard( LockHelper::getGlobalLock().getShareableOslMutex() ); 1705cdf0e10cSrcweir // Control this pointer again, another instance can be faster then these! 1706cdf0e10cSrcweir if( pInfo == NULL ) 1707cdf0e10cSrcweir { 1708cdf0e10cSrcweir // Create structure of propertysetinfo for baseclass "OPropertySetHelper". 1709cdf0e10cSrcweir // (Use method "getInfoHelper()".) 1710cdf0e10cSrcweir static css::uno::Reference< css::beans::XPropertySetInfo > xInfo( createPropertySetInfo( getInfoHelper() ) ); 1711cdf0e10cSrcweir pInfo = &xInfo; 1712cdf0e10cSrcweir } 1713cdf0e10cSrcweir } 1714cdf0e10cSrcweir 1715cdf0e10cSrcweir return (*pInfo); 1716cdf0e10cSrcweir } 1717cdf0e10cSrcweir 1718cdf0e10cSrcweir /*-************************************************************************************************************//** 1719cdf0e10cSrcweir @short return current component of current frame 1720cdf0e10cSrcweir @descr The desktop himself has no component. But every frame in subtree. 1721cdf0e10cSrcweir If somewhere call getCurrentComponent() at this class, we try to find the right frame and 1722cdf0e10cSrcweir then we try to become his component. It can be a VCL-component, the model or the controller 1723cdf0e10cSrcweir of founded frame. 1724cdf0e10cSrcweir 1725cdf0e10cSrcweir @attention We don't work on internal member ... so we doesn't need any lock here. 1726cdf0e10cSrcweir 1727cdf0e10cSrcweir @seealso method getCurrentComponent(); 1728cdf0e10cSrcweir 1729cdf0e10cSrcweir @param "xFrame", reference to valid frame in hierarchy. Method is not defined for invalid values. 1730cdf0e10cSrcweir But we don't check these. Its an IMPL-method and caller must use it right! 1731cdf0e10cSrcweir @return A reference to found component. 1732cdf0e10cSrcweir 1733cdf0e10cSrcweir @onerror A null reference is returned. 1734cdf0e10cSrcweir @threadsafe yes 1735cdf0e10cSrcweir *//*-*************************************************************************************************************/ 1736cdf0e10cSrcweir css::uno::Reference< css::lang::XComponent > Desktop::impl_getFrameComponent( const css::uno::Reference< css::frame::XFrame >& xFrame ) const 1737cdf0e10cSrcweir { 1738cdf0e10cSrcweir /* UNSAFE AREA --------------------------------------------------------------------------------------------- */ 1739cdf0e10cSrcweir // Register transaction and reject wrong calls. 1740cdf0e10cSrcweir TransactionGuard aTransaction( m_aTransactionManager, E_HARDEXCEPTIONS ); 1741cdf0e10cSrcweir 1742cdf0e10cSrcweir // Set default return value, if method failed. 1743cdf0e10cSrcweir css::uno::Reference< css::lang::XComponent > xComponent; 1744cdf0e10cSrcweir // Does no controller exists? 1745cdf0e10cSrcweir css::uno::Reference< css::frame::XController > xController = xFrame->getController(); 1746cdf0e10cSrcweir if( xController.is() == sal_False ) 1747cdf0e10cSrcweir { 1748cdf0e10cSrcweir // Controller not exist - use the VCL-component. 1749cdf0e10cSrcweir xComponent = css::uno::Reference< css::lang::XComponent >( xFrame->getComponentWindow(), css::uno::UNO_QUERY ); 1750cdf0e10cSrcweir } 1751cdf0e10cSrcweir else 1752cdf0e10cSrcweir { 1753cdf0e10cSrcweir // Does no model exists? 1754cdf0e10cSrcweir css::uno::Reference< css::frame::XModel > xModel( xController->getModel(), css::uno::UNO_QUERY ); 1755cdf0e10cSrcweir if( xModel.is() == sal_True ) 1756cdf0e10cSrcweir { 1757cdf0e10cSrcweir // Model exist - use the model as component. 1758cdf0e10cSrcweir xComponent = css::uno::Reference< css::lang::XComponent >( xModel, css::uno::UNO_QUERY ); 1759cdf0e10cSrcweir } 1760cdf0e10cSrcweir else 1761cdf0e10cSrcweir { 1762cdf0e10cSrcweir // Model not exist - use the controller as component. 1763cdf0e10cSrcweir xComponent = css::uno::Reference< css::lang::XComponent >( xController, css::uno::UNO_QUERY ); 1764cdf0e10cSrcweir } 1765cdf0e10cSrcweir } 1766cdf0e10cSrcweir 1767cdf0e10cSrcweir return xComponent; 1768cdf0e10cSrcweir } 1769cdf0e10cSrcweir 1770cdf0e10cSrcweir /*-************************************************************************************************************//** 1771cdf0e10cSrcweir @short create table with information about properties 1772cdf0e10cSrcweir @descr We use a helper class to support properties. These class need some information about this. 1773cdf0e10cSrcweir These method create a new static description table with name, type, r/w-flags and so on ... 1774cdf0e10cSrcweir 1775cdf0e10cSrcweir @seealso class OPropertySetHelper 1776cdf0e10cSrcweir @seealso method getInfoHelper() 1777cdf0e10cSrcweir 1778cdf0e10cSrcweir @param - 1779cdf0e10cSrcweir @return Static table with information about properties. 1780cdf0e10cSrcweir 1781cdf0e10cSrcweir @onerror - 1782cdf0e10cSrcweir @threadsafe yes 1783cdf0e10cSrcweir *//*-*************************************************************************************************************/ 1784cdf0e10cSrcweir const css::uno::Sequence< css::beans::Property > Desktop::impl_getStaticPropertyDescriptor() 1785cdf0e10cSrcweir { 1786cdf0e10cSrcweir // Create a new static property array to initialize sequence! 1787cdf0e10cSrcweir // Table of all predefined properties of this class. Its used from OPropertySetHelper-class! 1788cdf0e10cSrcweir // Don't forget to change the defines (see begin of this file), if you add, change or delete a property in this list!!! 1789cdf0e10cSrcweir // It's necessary for methods of OPropertySetHelper. 1790cdf0e10cSrcweir // ATTENTION: 1791cdf0e10cSrcweir // YOU MUST SORT FOLLOW TABLE BY NAME ALPHABETICAL !!! 1792cdf0e10cSrcweir 1793cdf0e10cSrcweir static const css::beans::Property pProperties[] = 1794cdf0e10cSrcweir { 1795cdf0e10cSrcweir css::beans::Property( DESKTOP_PROPNAME_ACTIVEFRAME , DESKTOP_PROPHANDLE_ACTIVEFRAME , ::getCppuType((const css::uno::Reference< css::lang::XComponent >*)NULL) , css::beans::PropertyAttribute::TRANSIENT | css::beans::PropertyAttribute::READONLY ), 1796cdf0e10cSrcweir css::beans::Property( DESKTOP_PROPNAME_DISPATCHRECORDERSUPPLIER , DESKTOP_PROPHANDLE_DISPATCHRECORDERSUPPLIER, ::getCppuType((const css::uno::Reference< css::frame::XDispatchRecorderSupplier >*)NULL), css::beans::PropertyAttribute::TRANSIENT ), 1797cdf0e10cSrcweir css::beans::Property( DESKTOP_PROPNAME_ISPLUGGED , DESKTOP_PROPHANDLE_ISPLUGGED , ::getBooleanCppuType() , css::beans::PropertyAttribute::TRANSIENT | css::beans::PropertyAttribute::READONLY ), 1798cdf0e10cSrcweir css::beans::Property( DESKTOP_PROPNAME_SUSPENDQUICKSTARTVETO , DESKTOP_PROPHANDLE_SUSPENDQUICKSTARTVETO , ::getBooleanCppuType() , css::beans::PropertyAttribute::TRANSIENT ), 1799cdf0e10cSrcweir css::beans::Property( DESKTOP_PROPNAME_TITLE , DESKTOP_PROPHANDLE_TITLE , ::getCppuType((const ::rtl::OUString*)NULL) , css::beans::PropertyAttribute::TRANSIENT ), 1800cdf0e10cSrcweir }; 1801cdf0e10cSrcweir // Use it to initialize sequence! 1802cdf0e10cSrcweir static const css::uno::Sequence< css::beans::Property > lPropertyDescriptor( pProperties, DESKTOP_PROPCOUNT ); 1803cdf0e10cSrcweir // Return static "PropertyDescriptor" 1804cdf0e10cSrcweir return lPropertyDescriptor; 1805cdf0e10cSrcweir } 1806cdf0e10cSrcweir 1807cdf0e10cSrcweir //============================================================================= 1808cdf0e10cSrcweir void Desktop::impl_sendQueryTerminationEvent(Desktop::TTerminateListenerList& lCalledListener, 1809cdf0e10cSrcweir ::sal_Bool& bVeto ) 1810cdf0e10cSrcweir { 1811cdf0e10cSrcweir bVeto = sal_False; 1812cdf0e10cSrcweir 1813cdf0e10cSrcweir TransactionGuard aTransaction( m_aTransactionManager, E_HARDEXCEPTIONS ); 1814cdf0e10cSrcweir 1815cdf0e10cSrcweir ::cppu::OInterfaceContainerHelper* pContainer = m_aListenerContainer.getContainer( ::getCppuType( ( const css::uno::Reference< css::frame::XTerminateListener >*) NULL ) ); 1816cdf0e10cSrcweir if ( ! pContainer ) 1817cdf0e10cSrcweir return; 1818cdf0e10cSrcweir 1819cdf0e10cSrcweir css::lang::EventObject aEvent( static_cast< ::cppu::OWeakObject* >(this) ); 1820cdf0e10cSrcweir 1821cdf0e10cSrcweir ::cppu::OInterfaceIteratorHelper aIterator( *pContainer ); 1822cdf0e10cSrcweir while ( aIterator.hasMoreElements() ) 1823cdf0e10cSrcweir { 1824cdf0e10cSrcweir try 1825cdf0e10cSrcweir { 1826cdf0e10cSrcweir css::uno::Reference< css::frame::XTerminateListener > xListener(aIterator.next(), css::uno::UNO_QUERY); 1827cdf0e10cSrcweir if ( ! xListener.is() ) 1828cdf0e10cSrcweir continue; 1829cdf0e10cSrcweir xListener->queryTermination( aEvent ); 1830cdf0e10cSrcweir lCalledListener.push_back(xListener); 1831cdf0e10cSrcweir } 1832cdf0e10cSrcweir catch( const css::frame::TerminationVetoException& ) 1833cdf0e10cSrcweir { 1834cdf0e10cSrcweir // first veto will stop notification loop. 1835cdf0e10cSrcweir bVeto = sal_True; 1836cdf0e10cSrcweir return; 1837cdf0e10cSrcweir } 1838cdf0e10cSrcweir catch( const css::uno::Exception& ) 1839cdf0e10cSrcweir { 1840cdf0e10cSrcweir // clean up container. 1841cdf0e10cSrcweir // E.g. dead remote listener objects can make trouble otherwise. 1842cdf0e10cSrcweir // Iterator implementation allows removing objects during it's used ! 1843cdf0e10cSrcweir aIterator.remove(); 1844cdf0e10cSrcweir } 1845cdf0e10cSrcweir } 1846cdf0e10cSrcweir } 1847cdf0e10cSrcweir 1848cdf0e10cSrcweir //============================================================================= 1849cdf0e10cSrcweir void Desktop::impl_sendCancelTerminationEvent(const Desktop::TTerminateListenerList& lCalledListener) 1850cdf0e10cSrcweir { 1851cdf0e10cSrcweir TransactionGuard aTransaction( m_aTransactionManager, E_HARDEXCEPTIONS ); 1852cdf0e10cSrcweir 1853cdf0e10cSrcweir css::lang::EventObject aEvent( static_cast< ::cppu::OWeakObject* >(this) ); 1854cdf0e10cSrcweir Desktop::TTerminateListenerList::const_iterator pIt; 1855cdf0e10cSrcweir for ( pIt = lCalledListener.begin(); 1856cdf0e10cSrcweir pIt != lCalledListener.end (); 1857cdf0e10cSrcweir ++pIt ) 1858cdf0e10cSrcweir { 1859cdf0e10cSrcweir try 1860cdf0e10cSrcweir { 1861cdf0e10cSrcweir // Note: cancelTermination() is a new and optional interface method ! 1862cdf0e10cSrcweir css::uno::Reference< css::frame::XTerminateListener > xListener = *pIt; 1863cdf0e10cSrcweir css::uno::Reference< css::frame::XTerminateListener2 > xListenerGeneration2(xListener, css::uno::UNO_QUERY); 1864cdf0e10cSrcweir if ( ! xListenerGeneration2.is() ) 1865cdf0e10cSrcweir continue; 1866cdf0e10cSrcweir xListenerGeneration2->cancelTermination( aEvent ); 1867cdf0e10cSrcweir } 1868cdf0e10cSrcweir catch( const css::uno::Exception& ) 1869cdf0e10cSrcweir {} 1870cdf0e10cSrcweir } 1871cdf0e10cSrcweir } 1872cdf0e10cSrcweir 1873cdf0e10cSrcweir //============================================================================= 1874cdf0e10cSrcweir void Desktop::impl_sendNotifyTerminationEvent() 1875cdf0e10cSrcweir { 1876cdf0e10cSrcweir TransactionGuard aTransaction( m_aTransactionManager, E_HARDEXCEPTIONS ); 1877cdf0e10cSrcweir 1878cdf0e10cSrcweir ::cppu::OInterfaceContainerHelper* pContainer = m_aListenerContainer.getContainer( ::getCppuType( ( const css::uno::Reference< css::frame::XTerminateListener >*) NULL ) ); 1879cdf0e10cSrcweir if ( ! pContainer ) 1880cdf0e10cSrcweir return; 1881cdf0e10cSrcweir 1882cdf0e10cSrcweir css::lang::EventObject aEvent( static_cast< ::cppu::OWeakObject* >(this) ); 1883cdf0e10cSrcweir 1884cdf0e10cSrcweir ::cppu::OInterfaceIteratorHelper aIterator( *pContainer ); 1885cdf0e10cSrcweir while ( aIterator.hasMoreElements() ) 1886cdf0e10cSrcweir { 1887cdf0e10cSrcweir try 1888cdf0e10cSrcweir { 1889cdf0e10cSrcweir css::uno::Reference< css::frame::XTerminateListener > xListener(aIterator.next(), css::uno::UNO_QUERY); 1890cdf0e10cSrcweir if ( ! xListener.is() ) 1891cdf0e10cSrcweir continue; 1892cdf0e10cSrcweir xListener->notifyTermination( aEvent ); 1893cdf0e10cSrcweir } 1894cdf0e10cSrcweir catch( const css::uno::Exception& ) 1895cdf0e10cSrcweir { 1896cdf0e10cSrcweir // clean up container. 1897cdf0e10cSrcweir // E.g. dead remote listener objects can make trouble otherwise. 1898cdf0e10cSrcweir // Iterator implementation allows removing objects during it's used ! 1899cdf0e10cSrcweir aIterator.remove(); 1900cdf0e10cSrcweir } 1901cdf0e10cSrcweir } 1902cdf0e10cSrcweir } 1903cdf0e10cSrcweir 1904cdf0e10cSrcweir //============================================================================= 1905cdf0e10cSrcweir ::sal_Bool Desktop::impl_closeFrames(::sal_Bool bAllowUI) 1906cdf0e10cSrcweir { 1907cdf0e10cSrcweir SYNCHRONIZED_START 1908cdf0e10cSrcweir ReadGuard aReadLock( m_aLock ); 1909cdf0e10cSrcweir css::uno::Sequence< css::uno::Reference< css::frame::XFrame > > lFrames = m_aChildTaskContainer.getAllElements(); 1910cdf0e10cSrcweir aReadLock.unlock(); 1911cdf0e10cSrcweir SYNCHRONIZED_END 1912cdf0e10cSrcweir 1913cdf0e10cSrcweir ::sal_Int32 c = lFrames.getLength(); 1914cdf0e10cSrcweir ::sal_Int32 i = 0; 1915cdf0e10cSrcweir ::sal_Int32 nNonClosedFrames = 0; 1916cdf0e10cSrcweir 1917cdf0e10cSrcweir for( i=0; i<c; ++i ) 1918cdf0e10cSrcweir { 1919cdf0e10cSrcweir try 1920cdf0e10cSrcweir { 1921cdf0e10cSrcweir css::uno::Reference< css::frame::XFrame > xFrame = lFrames[i]; 1922cdf0e10cSrcweir 1923cdf0e10cSrcweir // XController.suspend() will show an UI ... 1924cdf0e10cSrcweir // Use it in case it was allowed from outside only. 1925cdf0e10cSrcweir sal_Bool bSuspended = sal_False; 1926cdf0e10cSrcweir css::uno::Reference< css::frame::XController > xController( xFrame->getController(), css::uno::UNO_QUERY ); 1927cdf0e10cSrcweir if ( 1928cdf0e10cSrcweir ( bAllowUI ) && 1929cdf0e10cSrcweir ( xController.is() ) 1930cdf0e10cSrcweir ) 1931cdf0e10cSrcweir { 1932cdf0e10cSrcweir bSuspended = xController->suspend( sal_True ); 1933cdf0e10cSrcweir if ( ! bSuspended ) 1934cdf0e10cSrcweir { 1935cdf0e10cSrcweir ++nNonClosedFrames; 1936cdf0e10cSrcweir continue; 1937cdf0e10cSrcweir } 1938cdf0e10cSrcweir } 1939cdf0e10cSrcweir 1940cdf0e10cSrcweir // Try to close frame (in case no UI was allowed without calling XController->suspend() before!) 1941cdf0e10cSrcweir // But don't deliver ownership to any other one! 1942cdf0e10cSrcweir // This method can be called again. 1943cdf0e10cSrcweir css::uno::Reference< css::util::XCloseable > xClose( xFrame, css::uno::UNO_QUERY ); 1944cdf0e10cSrcweir if ( xClose.is() ) 1945cdf0e10cSrcweir { 1946cdf0e10cSrcweir try 1947cdf0e10cSrcweir { 1948cdf0e10cSrcweir xClose->close(sal_False); 1949cdf0e10cSrcweir } 1950cdf0e10cSrcweir catch(const css::util::CloseVetoException&) 1951cdf0e10cSrcweir { 1952cdf0e10cSrcweir // Any internal process of this frame disagree with our request. 1953cdf0e10cSrcweir // Safe this state but dont break these loop. Other frames has to be closed! 1954cdf0e10cSrcweir ++nNonClosedFrames; 1955cdf0e10cSrcweir 1956cdf0e10cSrcweir // Reactivate controller. 1957cdf0e10cSrcweir // It can happen that XController.suspend() returned true ... but a registered close listener 1958cdf0e10cSrcweir // throwed these veto exception. Then the controller has to be reactivated. Otherwise 195907a3d7f1SPedro Giffuni // these document doesn't work any more. 1960cdf0e10cSrcweir if ( 1961cdf0e10cSrcweir (bSuspended ) && 1962cdf0e10cSrcweir (xController.is()) 1963cdf0e10cSrcweir ) 1964cdf0e10cSrcweir xController->suspend(sal_False); 1965cdf0e10cSrcweir } 1966cdf0e10cSrcweir 1967cdf0e10cSrcweir // If interface XClosable interface exists and was used ... 1968cdf0e10cSrcweir // it's not allowed to use XComponent->dispose() also ! 1969cdf0e10cSrcweir continue; 1970cdf0e10cSrcweir } 1971cdf0e10cSrcweir 1972cdf0e10cSrcweir // XClosable not supported ? 1973cdf0e10cSrcweir // Then we have to dispose these frame hardly. 1974cdf0e10cSrcweir css::uno::Reference< css::lang::XComponent > xDispose( xFrame, css::uno::UNO_QUERY ); 1975cdf0e10cSrcweir if ( xDispose.is() ) 1976cdf0e10cSrcweir xDispose->dispose(); 1977cdf0e10cSrcweir 1978cdf0e10cSrcweir // Don't remove these frame from our child container! 1979cdf0e10cSrcweir // A frame do it by itself inside close()/dispose() method. 1980cdf0e10cSrcweir } 1981cdf0e10cSrcweir catch(const css::lang::DisposedException&) 1982cdf0e10cSrcweir { 1983cdf0e10cSrcweir // Dispose frames are closed frames. 1984cdf0e10cSrcweir // So we can count it here .-) 1985cdf0e10cSrcweir } 1986cdf0e10cSrcweir } 1987cdf0e10cSrcweir 1988cdf0e10cSrcweir return (nNonClosedFrames < 1); 1989cdf0e10cSrcweir } 1990cdf0e10cSrcweir 1991cdf0e10cSrcweir //_________________________________________________________________________________________________________________ 1992cdf0e10cSrcweir // debug methods 1993cdf0e10cSrcweir //_________________________________________________________________________________________________________________ 1994cdf0e10cSrcweir 1995cdf0e10cSrcweir /*----------------------------------------------------------------------------------------------------------------- 1996cdf0e10cSrcweir The follow methods checks the parameter for other functions. If a parameter or his value is non valid, 1997cdf0e10cSrcweir we return "sal_True". (otherwise sal_False) This mechanism is used to throw an ASSERT! 1998cdf0e10cSrcweir -----------------------------------------------------------------------------------------------------------------*/ 1999cdf0e10cSrcweir 2000cdf0e10cSrcweir #ifdef ENABLE_ASSERTIONS 2001cdf0e10cSrcweir 2002cdf0e10cSrcweir //***************************************************************************************************************** 2003cdf0e10cSrcweir // We work with valid servicemanager only. 2004cdf0e10cSrcweir sal_Bool Desktop::implcp_ctor( const css::uno::Reference< css::lang::XMultiServiceFactory >& xFactory ) 2005cdf0e10cSrcweir { 2006cdf0e10cSrcweir return( 2007cdf0e10cSrcweir ( &xFactory == NULL ) || 2008cdf0e10cSrcweir ( xFactory.is() == sal_False ) 2009cdf0e10cSrcweir ); 2010cdf0e10cSrcweir } 2011cdf0e10cSrcweir 2012cdf0e10cSrcweir //***************************************************************************************************************** 2013cdf0e10cSrcweir // We work with valid listener only. 2014cdf0e10cSrcweir sal_Bool Desktop::implcp_addEventListener( const css::uno::Reference< css::lang::XEventListener >& xListener ) 2015cdf0e10cSrcweir { 2016cdf0e10cSrcweir return( 2017cdf0e10cSrcweir ( &xListener == NULL ) || 2018cdf0e10cSrcweir ( xListener.is() == sal_False ) 2019cdf0e10cSrcweir ); 2020cdf0e10cSrcweir } 2021cdf0e10cSrcweir 2022cdf0e10cSrcweir //***************************************************************************************************************** 2023cdf0e10cSrcweir // We work with valid listener only. 2024cdf0e10cSrcweir sal_Bool Desktop::implcp_removeEventListener( const css::uno::Reference< css::lang::XEventListener >& xListener ) 2025cdf0e10cSrcweir { 2026cdf0e10cSrcweir return( 2027cdf0e10cSrcweir ( &xListener == NULL ) || 2028cdf0e10cSrcweir ( xListener.is() == sal_False ) 2029cdf0e10cSrcweir ); 2030cdf0e10cSrcweir } 2031cdf0e10cSrcweir 2032cdf0e10cSrcweir #endif // #ifdef ENABLE_ASSERTIONS 2033cdf0e10cSrcweir 2034cdf0e10cSrcweir } // namespace framework 2035