1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
3 * This file is part of the LibreOffice project.
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/.
9 * This file incorporates work covered by the following license notice:
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 .
22 #include <com/sun/star/ui/dialogs/XAsynchronousExecutableDialog.hpp>
23 #include <sfx2/tabdlg.hxx>
24 #include <svtools/genericunodialog.hxx>
25 #include <vcl/svapp.hxx>
27 using namespace css::uno
;
31 typedef cppu::ImplInheritanceHelper
<::svt::OGenericUnoDialog
,
32 css::ui::dialogs::XAsynchronousExecutableDialog
>
33 OGenericUnoAsyncDialogBase
;
35 /** abstract base class for implementing UNO objects representing asynchronous dialogs
37 template <typename T
> class OGenericUnoAsyncDialog
: public OGenericUnoAsyncDialogBase
39 class UnoAsyncDialogEntryGuard
42 UnoAsyncDialogEntryGuard(OGenericUnoAsyncDialog
<T
>& _rDialog
)
43 : m_aGuard(_rDialog
.GetMutex())
48 ::osl::MutexGuard m_aGuard
;
52 std::shared_ptr
<T
> m_xAsyncDialog
;
55 OGenericUnoAsyncDialog(const css::uno::Reference
<css::uno::XComponentContext
>& _rxContext
)
56 : OGenericUnoAsyncDialogBase(_rxContext
)
61 // XAsynchronousExecutableDialog
62 void SAL_CALL
setDialogTitle(const OUString
& aTitle
) override
64 OGenericUnoDialog::setTitle(aTitle
);
67 virtual void SAL_CALL
startExecuteModal(
68 const css::uno::Reference
<css::ui::dialogs::XDialogClosedListener
>& xListener
) override
70 SolarMutexGuard aSolarGuard
;
73 UnoAsyncDialogEntryGuard
aGuard(*this);
76 throw RuntimeException("already executing the dialog (recursive call)", *this);
80 m_xAsyncDialog
= createAsyncDialog(m_xParent
);
81 OSL_ENSURE(m_xAsyncDialog
, "OGenericUnoAsyncDialog::startExecuteModal: "
82 "createAsyncDialog returned nonsense!");
86 // do some initialisations
87 if (!m_bTitleAmbiguous
)
88 m_xAsyncDialog
->set_title(m_sTitle
);
98 virtual std::shared_ptr
<T
>
99 createAsyncDialog(const css::uno::Reference
<css::awt::XWindow
>& /*rParent*/)
104 void destroyAsyncDialog()
106 SolarMutexGuard aSolarGuard
;
108 m_xAsyncDialog
.reset();
112 runAsync(const css::uno::Reference
<css::ui::dialogs::XDialogClosedListener
>& /*xListener*/)
116 virtual void executedAsyncDialog(std::shared_ptr
<T
> /*xAsyncDialog*/,
117 sal_Int32
/*_nExecutionResult*/)
124 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */