LibreOffice Module dbaccess (master) 1
asyncmodaldialog.cxx
Go to the documentation of this file.
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#include <asyncmodaldialog.hxx>
21
22#include <com/sun/star/lang/IllegalArgumentException.hpp>
23
24#include <vcl/svapp.hxx>
26
27namespace dbaui
28{
29
30 using ::com::sun::star::uno::Reference;
31 using ::com::sun::star::ui::dialogs::XExecutableDialog;
32 using ::com::sun::star::lang::IllegalArgumentException;
33 using ::com::sun::star::uno::Exception;
34
35 namespace {
36
37 // AsyncDialogExecutor
38 class DialogExecutor_Impl
39 {
40 Reference< XExecutableDialog > m_xDialog;
41
42 public:
43 explicit DialogExecutor_Impl( const Reference< XExecutableDialog >& _rxDialog )
44 :m_xDialog( _rxDialog )
45 {
46 }
47
48 void execute()
49 {
50 Application::PostUserEvent( LINK( this, DialogExecutor_Impl, onExecute ) );
51 }
52
53 protected:
54 ~DialogExecutor_Impl()
55 {
56 }
57
58 private:
59 DECL_LINK( onExecute, void*, void );
60 };
61
62 }
63
64 IMPL_LINK_NOARG( DialogExecutor_Impl, onExecute, void*, void )
65 {
66 try
67 {
68 m_xDialog->execute();
69 }
70 catch( const Exception& )
71 {
72 DBG_UNHANDLED_EXCEPTION("dbaccess");
73 }
74
75 delete this;
76 }
77
78 // AsyncDialogExecutor
80 {
81 if ( !_rxDialog.is() )
82 throw IllegalArgumentException();
83
84 DialogExecutor_Impl* pExecutor = new DialogExecutor_Impl( _rxDialog );
85 pExecutor->execute();
86 // will delete itself
87 }
88
89} // namespace dbaui
90
91/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
Reference< XExecutableDialog > m_xDialog
static ImplSVEvent * PostUserEvent(const Link< void *, void > &rLink, void *pCaller=nullptr, bool bReferenceLink=false)
static void executeModalDialogAsync(const css::uno::Reference< css::ui::dialogs::XExecutableDialog > &_rxDialog)
executes the given dialog asynchronously, but still modal
#define DBG_UNHANDLED_EXCEPTION(...)
DECL_LINK(CheckNameHdl, SvxNameDialog &, bool)
@ Exception
IMPL_LINK_NOARG(OApplicationController, OnClipboardChanged, TransferableDataHelper *, void)