LibreOffice Module svtools (master) 1
genericasyncunodialog.hxx
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#pragma once
21
22#include <com/sun/star/ui/dialogs/XAsynchronousExecutableDialog.hpp>
23#include <sfx2/tabdlg.hxx>
25#include <vcl/svapp.hxx>
26
27using namespace css::uno;
28
29namespace svt
30{
31typedef cppu::ImplInheritanceHelper<::svt::OGenericUnoDialog,
32 css::ui::dialogs::XAsynchronousExecutableDialog>
34
37template <typename T> class OGenericUnoAsyncDialog : public OGenericUnoAsyncDialogBase
38{
40 {
41 public:
43 : m_aGuard(_rDialog.GetMutex())
44 {
45 }
46
47 private:
48 ::osl::MutexGuard m_aGuard;
49 };
50
51protected:
52 std::shared_ptr<T> m_xAsyncDialog;
53
54protected:
55 OGenericUnoAsyncDialog(const css::uno::Reference<css::uno::XComponentContext>& _rxContext)
56 : OGenericUnoAsyncDialogBase(_rxContext)
57 {
58 }
59
60public:
61 // XAsynchronousExecutableDialog
62 void SAL_CALL setDialogTitle(const OUString& aTitle) override
63 {
65 }
66
67 virtual void SAL_CALL startExecuteModal(
68 const css::uno::Reference<css::ui::dialogs::XDialogClosedListener>& xListener) override
69 {
70 SolarMutexGuard aSolarGuard;
71
72 {
73 UnoAsyncDialogEntryGuard aGuard(*this);
74
75 if (m_bExecuting)
76 throw RuntimeException("already executing the dialog (recursive call)", *this);
77
78 if (!m_xAsyncDialog)
79 {
81 OSL_ENSURE(m_xAsyncDialog, "OGenericUnoAsyncDialog::startExecuteModal: "
82 "createAsyncDialog returned nonsense!");
83 if (!m_xAsyncDialog)
84 return;
85
86 // do some initialisations
87 if (!m_bTitleAmbiguous)
88 m_xAsyncDialog->set_title(m_sTitle);
89 }
90
91 m_bExecuting = true;
92 }
93
94 runAsync(xListener);
95 }
96
97protected:
98 virtual std::shared_ptr<T>
99 createAsyncDialog(const css::uno::Reference<css::awt::XWindow>& /*rParent*/)
100 {
101 return nullptr;
102 }
103
105 {
106 SolarMutexGuard aSolarGuard;
107 if (m_xAsyncDialog)
108 m_xAsyncDialog.reset();
109 }
110
111 virtual void
112 runAsync(const css::uno::Reference<css::ui::dialogs::XDialogClosedListener>& /*xListener*/)
113 {
114 }
115
116 virtual void executedAsyncDialog(std::shared_ptr<T> /*xAsyncDialog*/,
117 sal_Int32 /*_nExecutionResult*/)
118 {
119 }
120};
121
122} // namespace svt
123
124/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
UnoAsyncDialogEntryGuard(OGenericUnoAsyncDialog< T > &_rDialog)
abstract base class for implementing UNO objects representing asynchronous dialogs
virtual std::shared_ptr< T > createAsyncDialog(const css::uno::Reference< css::awt::XWindow > &)
OGenericUnoAsyncDialog(const css::uno::Reference< css::uno::XComponentContext > &_rxContext)
virtual void SAL_CALL startExecuteModal(const css::uno::Reference< css::ui::dialogs::XDialogClosedListener > &xListener) override
void SAL_CALL setDialogTitle(const OUString &aTitle) override
virtual void executedAsyncDialog(std::shared_ptr< T >, sal_Int32)
virtual void runAsync(const css::uno::Reference< css::ui::dialogs::XDialogClosedListener > &)
abstract base class for implementing UNO objects representing dialogs (com.sun.star....
virtual void SAL_CALL setTitle(const OUString &aTitle) override
OUString m_sTitle
cppu::ImplInheritanceHelper<::svt::OGenericUnoDialog, css::ui::dialogs::XAsynchronousExecutableDialog > OGenericUnoAsyncDialogBase