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 : using ::com::sun::star::uno::Reference;
34 : using ::com::sun::star::ui::dialogs::XExecutableDialog;
35 : using ::com::sun::star::lang::IllegalArgumentException;
36 : using ::com::sun::star::uno::Exception;
37 :
38 : //====================================================================
39 : //= AsyncDialogExecutor
40 : //====================================================================
41 : class DialogExecutor_Impl
42 : {
43 : Reference< XExecutableDialog > m_xDialog;
44 :
45 : public:
46 0 : DialogExecutor_Impl( const Reference< XExecutableDialog >& _rxDialog )
47 0 : :m_xDialog( _rxDialog )
48 : {
49 0 : }
50 :
51 0 : void execute()
52 : {
53 0 : Application::PostUserEvent( LINK( this, DialogExecutor_Impl, onExecute ) );
54 0 : }
55 :
56 : protected:
57 0 : ~DialogExecutor_Impl()
58 0 : {
59 0 : }
60 :
61 : private:
62 : DECL_LINK( onExecute, void* );
63 : };
64 :
65 : //--------------------------------------------------------------------
66 0 : IMPL_LINK( DialogExecutor_Impl, onExecute, void*, /* _notInterestedIn */ )
67 : {
68 : try
69 : {
70 0 : m_xDialog->execute();
71 : }
72 0 : catch( const Exception& )
73 : {
74 : DBG_UNHANDLED_EXCEPTION();
75 : }
76 :
77 0 : delete this;
78 0 : return 0L;
79 : }
80 :
81 : //====================================================================
82 : //= AsyncDialogExecutor
83 : //====================================================================
84 : //--------------------------------------------------------------------
85 0 : void AsyncDialogExecutor::executeModalDialogAsync( const Reference< XExecutableDialog >& _rxDialog )
86 : {
87 0 : if ( !_rxDialog.is() )
88 0 : throw IllegalArgumentException();
89 :
90 :
91 0 : DialogExecutor_Impl* pExecutor = new DialogExecutor_Impl( _rxDialog );
92 0 : pExecutor->execute();
93 : // will delete itself
94 0 : }
95 :
96 : //........................................................................
97 12 : } // namespace dbaui
98 : //........................................................................
99 :
100 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|