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/.
10 #include <sal/config.h>
14 #include <com/sun/star/task/OfficeRestartManager.hpp>
15 #include <com/sun/star/task/XInteractionHandler.hpp>
16 #include <com/sun/star/uno/Reference.hxx>
17 #include <com/sun/star/uno/XComponentContext.hpp>
18 #include <svtools/restartdialog.hxx>
19 #include <tools/link.hxx>
20 #include <vcl/button.hxx>
21 #include <vcl/dialog.hxx>
22 #include <vcl/window.hxx>
26 class RestartDialog
: public ModalDialog
{
28 RestartDialog(vcl::Window
* parent
, svtools::RestartReason reason
):
29 ModalDialog(parent
, "RestartDialog", "svt/ui/restartdialog.ui")
34 case svtools::RESTART_REASON_JAVA
:
35 get(reason_
, "reason_java");
37 case svtools::RESTART_REASON_PDF_AS_STANDARD_JOB_FORMAT
:
38 get(reason_
, "reason_pdf");
40 case svtools::RESTART_REASON_BIBLIOGRAPHY_INSTALL
:
41 get(reason_
, "reason_bibliography_install");
43 case svtools::RESTART_REASON_MAILMERGE_INSTALL
:
44 get(reason_
, "reason_mailmerge_install");
47 assert(false); // this cannot happen
50 btnYes_
->SetClickHdl(LINK(this, RestartDialog
, hdlYes
));
51 btnNo_
->SetClickHdl(LINK(this, RestartDialog
, hdlNo
));
53 virtual ~RestartDialog() { disposeOnce(); }
54 virtual void dispose() SAL_OVERRIDE
59 ModalDialog::dispose();
62 DECL_LINK(hdlYes
, void *);
63 DECL_LINK(hdlNo
, void *);
65 VclPtr
<vcl::Window
> reason_
;
66 VclPtr
<PushButton
> btnYes_
;
67 VclPtr
<PushButton
> btnNo_
;
70 IMPL_LINK_NOARG(RestartDialog
, hdlYes
) {
75 IMPL_LINK_NOARG(RestartDialog
, hdlNo
) {
76 EndDialog(RET_CANCEL
);
82 void svtools::executeRestartDialog(
83 css::uno::Reference
< css::uno::XComponentContext
> const & context
,
84 vcl::Window
* parent
, RestartReason reason
)
86 if (ScopedVclPtrInstance
<RestartDialog
>::Create(parent
, reason
)->Execute()) {
87 css::task::OfficeRestartManager::get(context
)->requestRestart(
88 css::uno::Reference
< css::task::XInteractionHandler
>());
92 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */