Line data Source code
1 : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 : /*
3 : * This file is part of the LibreOffice project.
4 : *
5 : * This Source Code Form is subject to the terms of the Mozilla Public
6 : * License, v. 2.0. If a copy of the MPL was not distributed with this
7 : * file, You can obtain one at http://mozilla.org/MPL/2.0/.
8 : *
9 : * This file incorporates work covered by the following license notice:
10 : *
11 : * Licensed to the Apache Software Foundation (ASF) under one or more
12 : * contributor license agreements. See the NOTICE file distributed
13 : * with this work for additional information regarding copyright
14 : * ownership. The ASF licenses this file to you under the Apache
15 : * License, Version 2.0 (the "License"); you may not use this file
16 : * except in compliance with the License. You may obtain a copy of
17 : * the License at http://www.apache.org/licenses/LICENSE-2.0 .
18 : */
19 :
20 :
21 : #include "asyncmodaldialog.hxx"
22 :
23 : #include <com/sun/star/lang/IllegalArgumentException.hpp>
24 :
25 : #include <vcl/svapp.hxx>
26 : #include <tools/diagnose_ex.h>
27 :
28 : //........................................................................
29 : namespace dbaui
30 : {
31 : //........................................................................
32 :
33 : /** === begin UNO using === **/
34 : using ::com::sun::star::uno::Reference;
35 : using ::com::sun::star::ui::dialogs::XExecutableDialog;
36 : using ::com::sun::star::lang::IllegalArgumentException;
37 : using ::com::sun::star::uno::Exception;
38 : /** === end UNO using === **/
39 :
40 : //====================================================================
41 : //= AsyncDialogExecutor
42 : //====================================================================
43 : class DialogExecutor_Impl
44 : {
45 : Reference< XExecutableDialog > m_xDialog;
46 :
47 : public:
48 0 : DialogExecutor_Impl( const Reference< XExecutableDialog >& _rxDialog )
49 0 : :m_xDialog( _rxDialog )
50 : {
51 0 : }
52 :
53 0 : void execute()
54 : {
55 0 : Application::PostUserEvent( LINK( this, DialogExecutor_Impl, onExecute ) );
56 0 : }
57 :
58 : protected:
59 0 : ~DialogExecutor_Impl()
60 0 : {
61 0 : }
62 :
63 : private:
64 : DECL_LINK( onExecute, void* );
65 : };
66 :
67 : //--------------------------------------------------------------------
68 0 : IMPL_LINK( DialogExecutor_Impl, onExecute, void*, /* _notInterestedIn */ )
69 : {
70 : try
71 : {
72 0 : m_xDialog->execute();
73 : }
74 0 : catch( const Exception& )
75 : {
76 : DBG_UNHANDLED_EXCEPTION();
77 : }
78 :
79 0 : delete this;
80 0 : return 0L;
81 : }
82 :
83 : //====================================================================
84 : //= AsyncDialogExecutor
85 : //====================================================================
86 : //--------------------------------------------------------------------
87 0 : void AsyncDialogExecutor::executeModalDialogAsync( const Reference< XExecutableDialog >& _rxDialog )
88 : {
89 0 : if ( !_rxDialog.is() )
90 0 : throw IllegalArgumentException();
91 :
92 :
93 0 : DialogExecutor_Impl* pExecutor = new DialogExecutor_Impl( _rxDialog );
94 0 : pExecutor->execute();
95 : // will delete itself
96 0 : }
97 :
98 : //........................................................................
99 : } // namespace dbaui
100 : //........................................................................
101 :
102 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|