1 /************************************************************** 2 * 3 * Licensed to the Apache Software Foundation (ASF) under one 4 * or more contributor license agreements. See the NOTICE file 5 * distributed with this work for additional information 6 * regarding copyright ownership. The ASF licenses this file 7 * to you under the Apache License, Version 2.0 (the 8 * "License"); you may not use this file except in compliance 9 * with the License. You may obtain a copy of the License at 10 * 11 * http://www.apache.org/licenses/LICENSE-2.0 12 * 13 * Unless required by applicable law or agreed to in writing, 14 * software distributed under the License is distributed on an 15 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 16 * KIND, either express or implied. See the License for the 17 * specific language governing permissions and limitations 18 * under the License. 19 * 20 *************************************************************/ 21 22 23 24 // MARKER(update_precomp.py): autogen include statement, do not remove 25 #include "precompiled_dbaccess.hxx" 26 27 #ifndef DBACCESS_ASYNCMODALDIALOG_HXX 28 #include "asyncmodaldialog.hxx" 29 #endif 30 31 /** === begin UNO includes === **/ 32 #ifndef _COM_SUN_STAR_LANG_ILLEGALARGUMENTEXCEPTION_HPP_ 33 #include <com/sun/star/lang/IllegalArgumentException.hpp> 34 #endif 35 /** === end UNO includes === **/ 36 37 #ifndef _SV_SVAPP_HXX 38 #include <vcl/svapp.hxx> 39 #endif 40 #ifndef TOOLS_DIAGNOSE_EX_H 41 #include <tools/diagnose_ex.h> 42 #endif 43 44 //........................................................................ 45 namespace dbaui 46 { 47 //........................................................................ 48 49 /** === begin UNO using === **/ 50 using ::com::sun::star::uno::Reference; 51 using ::com::sun::star::ui::dialogs::XExecutableDialog; 52 using ::com::sun::star::lang::IllegalArgumentException; 53 using ::com::sun::star::uno::Exception; 54 /** === end UNO using === **/ 55 56 //==================================================================== 57 //= AsyncDialogExecutor 58 //==================================================================== 59 class DialogExecutor_Impl 60 { 61 Reference< XExecutableDialog > m_xDialog; 62 63 public: 64 DialogExecutor_Impl( const Reference< XExecutableDialog >& _rxDialog ) 65 :m_xDialog( _rxDialog ) 66 { 67 } 68 69 void execute() 70 { 71 Application::PostUserEvent( LINK( this, DialogExecutor_Impl, onExecute ) ); 72 } 73 74 protected: 75 ~DialogExecutor_Impl() 76 { 77 } 78 79 private: 80 DECL_LINK( onExecute, void* ); 81 }; 82 83 //-------------------------------------------------------------------- 84 IMPL_LINK( DialogExecutor_Impl, onExecute, void*, /* _notInterestedIn */ ) 85 { 86 try 87 { 88 m_xDialog->execute(); 89 } 90 catch( const Exception& ) 91 { 92 DBG_UNHANDLED_EXCEPTION(); 93 } 94 95 delete this; 96 return 0L; 97 } 98 99 //==================================================================== 100 //= AsyncDialogExecutor 101 //==================================================================== 102 //-------------------------------------------------------------------- 103 void AsyncDialogExecutor::executeModalDialogAsync( const Reference< XExecutableDialog >& _rxDialog ) 104 { 105 if ( !_rxDialog.is() ) 106 throw IllegalArgumentException(); 107 108 109 DialogExecutor_Impl* pExecutor = new DialogExecutor_Impl( _rxDialog ); 110 pExecutor->execute(); 111 // will delete itself 112 } 113 114 //........................................................................ 115 } // namespace dbaui 116 //........................................................................ 117 118