1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
|
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
/*
* This file is part of the LibreOffice project.
*
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
*/
#include <sal/config.h>
#include <cassert>
#include <com/sun/star/task/OfficeRestartManager.hpp>
#include <com/sun/star/task/XInteractionHandler.hpp>
#include <com/sun/star/uno/Reference.hxx>
#include <com/sun/star/uno/XComponentContext.hpp>
#include <svtools/restartdialog.hxx>
#include <tools/link.hxx>
#include <vcl/button.hxx>
#include <vcl/dialog.hxx>
#include <vcl/window.hxx>
namespace {
class RestartDialog: public ModalDialog {
public:
RestartDialog(vcl::Window * parent, svtools::RestartReason reason):
ModalDialog(parent, "RestartDialog", "svt/ui/restartdialog.ui")
{
get(btnYes_, "yes");
get(btnNo_, "no");
switch (reason) {
case svtools::RESTART_REASON_JAVA:
get(reason_, "reason_java");
break;
case svtools::RESTART_REASON_PDF_AS_STANDARD_JOB_FORMAT:
get(reason_, "reason_pdf");
break;
case svtools::RESTART_REASON_BIBLIOGRAPHY_INSTALL:
get(reason_, "reason_bibliography_install");
break;
case svtools::RESTART_REASON_MAILMERGE_INSTALL:
get(reason_, "reason_mailmerge_install");
break;
case svtools::RESTART_REASON_LANGUAGE_CHANGE:
get(reason_, "reason_language_change");
break;
case svtools::RESTART_REASON_ADDING_PATH:
get(reason_, "reason_adding_path");
break;
case svtools::RESTART_REASON_ASSIGNING_JAVAPARAMETERS:
get(reason_, "reason_assigning_javaparameters");
break;
case svtools::RESTART_REASON_ASSIGNING_FOLDERS:
get(reason_, "reason_assigning_folders");
break;
case svtools::RESTART_REASON_EXP_FEATURES:
get(reason_,"reason_exp_features");
break;
case svtools::RESTART_REASON_EXTENSION_INSTALL:
get(reason_, "reason_extension_install");
break;
case svtools::RESTART_REASON_OPENGL:
get(reason_, "reason_opengl");
break;
default:
assert(false); // this cannot happen
}
reason_->Show();
btnYes_->SetClickHdl(LINK(this, RestartDialog, hdlYes));
btnNo_->SetClickHdl(LINK(this, RestartDialog, hdlNo));
}
virtual ~RestartDialog() override { disposeOnce(); }
virtual void dispose() override
{
reason_.clear();
btnYes_.clear();
btnNo_.clear();
ModalDialog::dispose();
}
private:
DECL_LINK(hdlYes, Button*, void);
DECL_LINK(hdlNo, Button*, void);
VclPtr<vcl::Window> reason_;
VclPtr<PushButton> btnYes_;
VclPtr<PushButton> btnNo_;
};
IMPL_LINK_NOARG(RestartDialog, hdlYes, Button*, void)
{
EndDialog(RET_OK);
}
IMPL_LINK_NOARG(RestartDialog, hdlNo, Button*, void)
{
EndDialog();
}
}
void svtools::executeRestartDialog(
css::uno::Reference< css::uno::XComponentContext > const & context,
vcl::Window * parent, RestartReason reason)
{
if (ScopedVclPtrInstance<RestartDialog>(parent, reason)->Execute()) {
css::task::OfficeRestartManager::get(context)->requestRestart(
css::uno::Reference< css::task::XInteractionHandler >());
}
}
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|