User: vg Date: 2007/01/15 06:33:48 Modified: dba/dbaccess/source/ui/dlg/dbwizsetup.cxx
Log: INTEGRATION: CWS dba22b (1.22.40); FILE MERGED 2006/12/04 15:03:44 fs 1.22.40.1: #i71662# keep application alive as long as the async loader event is running File Changes: Directory: /dba/dbaccess/source/ui/dlg/ ======================================= File [changed]: dbwizsetup.cxx Url: http://dba.openoffice.org/source/browse/dba/dbaccess/source/ui/dlg/dbwizsetup.cxx?r1=1.22&r2=1.23 Delta lines: +93 -23 --------------------- --- dbwizsetup.cxx 18 Oct 2006 13:30:58 -0000 1.22 +++ dbwizsetup.cxx 15 Jan 2007 14:33:46 -0000 1.23 @@ -114,15 +114,17 @@ #ifndef DBAUI_ASYNCRONOUSLINK_HXX #include "AsyncronousLink.hxx" #endif +#ifndef _FILEDLGHELPER_HXX +#include <sfx2/filedlghelper.hxx> +#endif + +/** === begin UNO includes === **/ #ifndef _COM_SUN_STAR_FRAME_XSTORABLE_HPP_ #include <com/sun/star/frame/XStorable.hpp> #endif #ifndef _COM_SUN_STAR_UNO_XNAMINGSERVICE_HPP_ #include <com/sun/star/uno/XNamingService.hpp> #endif -#ifndef _FILEDLGHELPER_HXX -#include <sfx2/filedlghelper.hxx> -#endif #ifndef _COM_SUN_STAR_SDBCX_XTABLESSUPPLIER_HPP_ #include <com/sun/star/sdbcx/XTablesSupplier.hpp> #endif @@ -138,9 +140,6 @@ #ifndef _COM_SUN_STAR_FRAME_FRAMESEARCHFLAG_HPP_ #include <com/sun/star/frame/FrameSearchFlag.hpp> #endif -#ifndef _DBAUI_LINKEDDOCUMENTS_HXX_ -#include "linkeddocuments.hxx" -#endif #ifndef _COM_SUN_STAR_FRAME_XCOMPONENTLOADER_HPP_ #include <com/sun/star/frame/XComponentLoader.hpp> #endif @@ -165,6 +164,17 @@ #ifndef _COM_SUN_STAR_IO_IOEXCEPTION_HPP_ #include <com/sun/star/io/IOException.hpp> #endif +#ifndef _COM_SUN_STAR_FRAME_XTERMINATELISTENER_HPP_ +#include <com/sun/star/frame/XTerminateListener.hpp> +#endif +#ifndef _COM_SUN_STAR_FRAME_XDESKTOP_HPP_ +#include <com/sun/star/frame/XDesktop.hpp> +#endif +/** === end UNO includes === **/ + +#ifndef _DBAUI_LINKEDDOCUMENTS_HXX_ +#include "linkeddocuments.hxx" +#endif #ifndef SVTOOLS_FILENOTATION_HXX_ #include <svtools/filenotation.hxx> #endif @@ -1185,38 +1195,99 @@ namespace { // ............................................................................. - class AsyncLoader + typedef ::cppu::WeakImplHelper1 < XTerminateListener + > AsyncLoader_Base; + class AsyncLoader : public AsyncLoader_Base { private: Reference< XComponentLoader > m_xFrameLoader; + Reference< XDesktop > m_xDesktop; ::rtl::OUString m_sURL; OAsyncronousLink m_aAsyncCaller; public: - AsyncLoader( const Reference< XComponentLoader >& _rxLoader, const ::rtl::OUString& _rURL ) - :m_xFrameLoader( _rxLoader ) - ,m_sURL( _rURL ) + AsyncLoader( const Reference< XMultiServiceFactory >& _rxORB, const ::rtl::OUString& _rURL ); + + void doLoadAsync(); + + // XTerminateListener + virtual void SAL_CALL queryTermination( const EventObject& Event ) throw (TerminationVetoException, RuntimeException); + virtual void SAL_CALL notifyTermination( const EventObject& Event ) throw (RuntimeException); + // XEventListener + virtual void SAL_CALL disposing( const ::com::sun::star::lang::EventObject& Source ) throw (::com::sun::star::uno::RuntimeException); + + private: + DECL_LINK( OnOpenDocument, void* ); + }; + + // ............................................................................. + AsyncLoader::AsyncLoader( const Reference< XMultiServiceFactory >& _rxORB, const ::rtl::OUString& _rURL ) + :m_sURL( _rURL ) ,m_aAsyncCaller( LINK( this, AsyncLoader, OnOpenDocument ) ) { + try + { + m_xDesktop.set( _rxORB->createInstance( SERVICE_FRAME_DESKTOP ), UNO_QUERY_THROW ); + m_xFrameLoader.set( m_xDesktop, UNO_QUERY_THROW ); + } + catch( const Exception& ) + { + DBG_UNHANDLED_EXCEPTION(); + } } - void doLoadAsync() + // ............................................................................. + void AsyncLoader::doLoadAsync() { - m_aAsyncCaller.Call( NULL ); + OSL_ENSURE( !m_aAsyncCaller.IsRunning(), "AsyncLoader:doLoadAsync: already running!" ); + + acquire(); + try + { + if ( m_xDesktop.is() ) + m_xDesktop->addTerminateListener( this ); } + catch( const Exception& ) { DBG_UNHANDLED_EXCEPTION(); } - private: - DECL_LINK( OnOpenDocument, void* ); - }; + m_aAsyncCaller.Call( NULL ); + } // ............................................................................. IMPL_LINK( AsyncLoader, OnOpenDocument, void*, /*_pEmptyArg*/ ) { + try + { + if ( m_xFrameLoader.is() ) m_xFrameLoader->loadComponentFromURL( m_sURL, ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "_default" ) ), FrameSearchFlag::ALL, Sequence<PropertyValue >() ); - delete this; + } + catch( const Exception& ) { DBG_UNHANDLED_EXCEPTION(); } + + try + { + if ( m_xDesktop.is() ) + m_xDesktop->removeTerminateListener( this ); + } + catch( const Exception& ) { DBG_UNHANDLED_EXCEPTION(); } + + release(); return 0L; } + + // ............................................................................. + void SAL_CALL AsyncLoader::queryTermination( const EventObject& /*Event*/ ) throw (TerminationVetoException, RuntimeException) + { + throw TerminationVetoException(); + } + + // ............................................................................. + void SAL_CALL AsyncLoader::notifyTermination( const EventObject& /*Event*/ ) throw (RuntimeException) + { + } + // ............................................................................. + void SAL_CALL AsyncLoader::disposing( const EventObject& /*Source*/ ) throw (RuntimeException) + { + } } // ----------------------------------------------------------------------------- @@ -1234,15 +1305,14 @@ Reference< XComponentLoader > xFrameLoader; try { - xFrameLoader = Reference< XComponentLoader >( getORB()->createInstance( SERVICE_FRAME_DESKTOP ), UNO_QUERY_THROW ); + AsyncLoader* pAsyncLoader = new AsyncLoader( getORB(), m_pGeneralPage->GetSelectedDocument().sURL ); + ::rtl::Reference< AsyncLoader > xKeepAlive( pAsyncLoader ); + pAsyncLoader->doLoadAsync(); } catch( const Exception& ) { DBG_UNHANDLED_EXCEPTION(); } - - AsyncLoader* pAsyncLoader = new AsyncLoader( xFrameLoader, m_pGeneralPage->GetSelectedDocument().sURL ); - pAsyncLoader->doLoadAsync(); return sal_True; } --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
