Version 3.6.0.2, tag libreoffice-3.6.0.2
[LibreOffice.git] / dbaccess / source / ui / misc / asyncmodaldialog.cxx
blobf8bb1645c2981325864438c0c13c9cbdb08804d9
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*************************************************************************
4 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
6 * Copyright 2000, 2010 Oracle and/or its affiliates.
8 * OpenOffice.org - a multi-platform office productivity suite
10 * This file is part of OpenOffice.org.
12 * OpenOffice.org is free software: you can redistribute it and/or modify
13 * it under the terms of the GNU Lesser General Public License version 3
14 * only, as published by the Free Software Foundation.
16 * OpenOffice.org is distributed in the hope that it will be useful,
17 * but WITHOUT ANY WARRANTY; without even the implied warranty of
18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 * GNU Lesser General Public License version 3 for more details
20 * (a copy is included in the LICENSE file that accompanied this code).
22 * You should have received a copy of the GNU Lesser General Public License
23 * version 3 along with OpenOffice.org. If not, see
24 * <http://www.openoffice.org/license.html>
25 * for a copy of the LGPLv3 License.
27 ************************************************************************/
30 #include "asyncmodaldialog.hxx"
32 /** === begin UNO includes === **/
33 #include <com/sun/star/lang/IllegalArgumentException.hpp>
34 /** === end UNO includes === **/
36 #include <vcl/svapp.hxx>
37 #include <tools/diagnose_ex.h>
39 //........................................................................
40 namespace dbaui
42 //........................................................................
44 /** === begin UNO using === **/
45 using ::com::sun::star::uno::Reference;
46 using ::com::sun::star::ui::dialogs::XExecutableDialog;
47 using ::com::sun::star::lang::IllegalArgumentException;
48 using ::com::sun::star::uno::Exception;
49 /** === end UNO using === **/
51 //====================================================================
52 //= AsyncDialogExecutor
53 //====================================================================
54 class DialogExecutor_Impl
56 Reference< XExecutableDialog > m_xDialog;
58 public:
59 DialogExecutor_Impl( const Reference< XExecutableDialog >& _rxDialog )
60 :m_xDialog( _rxDialog )
64 void execute()
66 Application::PostUserEvent( LINK( this, DialogExecutor_Impl, onExecute ) );
69 protected:
70 ~DialogExecutor_Impl()
74 private:
75 DECL_LINK( onExecute, void* );
78 //--------------------------------------------------------------------
79 IMPL_LINK( DialogExecutor_Impl, onExecute, void*, /* _notInterestedIn */ )
81 try
83 m_xDialog->execute();
85 catch( const Exception& )
87 DBG_UNHANDLED_EXCEPTION();
90 delete this;
91 return 0L;
94 //====================================================================
95 //= AsyncDialogExecutor
96 //====================================================================
97 //--------------------------------------------------------------------
98 void AsyncDialogExecutor::executeModalDialogAsync( const Reference< XExecutableDialog >& _rxDialog )
100 if ( !_rxDialog.is() )
101 throw IllegalArgumentException();
104 DialogExecutor_Impl* pExecutor = new DialogExecutor_Impl( _rxDialog );
105 pExecutor->execute();
106 // will delete itself
109 //........................................................................
110 } // namespace dbaui
111 //........................................................................
113 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */