2016-10-07 18:19:25 +02:00
|
|
|
/* -*- 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 "SafeModeDialog.hxx"
|
|
|
|
|
|
|
|
#include <config_folders.h>
|
|
|
|
#include <rtl/bootstrap.hxx>
|
|
|
|
#include <osl/file.hxx>
|
2016-10-12 13:01:15 +02:00
|
|
|
#include <comphelper/processfactory.hxx>
|
2016-10-11 16:07:37 +02:00
|
|
|
#include <sfx2/safemode.hxx>
|
2016-10-07 18:19:25 +02:00
|
|
|
|
2016-10-12 13:01:15 +02:00
|
|
|
#include <com/sun/star/frame/Desktop.hpp>
|
|
|
|
#include <com/sun/star/frame/XDesktop2.hpp>
|
2016-10-12 13:26:10 +02:00
|
|
|
#include <com/sun/star/task/OfficeRestartManager.hpp>
|
|
|
|
#include <com/sun/star/task/XInteractionHandler.hpp>
|
2016-10-12 13:01:15 +02:00
|
|
|
|
|
|
|
using namespace css;
|
|
|
|
|
2016-10-07 18:19:25 +02:00
|
|
|
SafeModeDialog::SafeModeDialog(vcl::Window* pParent):
|
|
|
|
Dialog(pParent, "SafeModeDialog", "svx/ui/safemodedialog.ui")
|
|
|
|
{
|
|
|
|
get(mpBtnContinue, "btn_continue");
|
|
|
|
get(mpBtnQuit, "btn_quit");
|
|
|
|
get(mpBtnRestart, "btn_restart");
|
|
|
|
get(mpCBCustomizations, "check_customizations");
|
|
|
|
get(mpCBExtensions, "check_extensions");
|
|
|
|
get(mpCBFull, "check_full");
|
|
|
|
|
|
|
|
mpBtnContinue->SetClickHdl(LINK(this, SafeModeDialog, BtnHdl));
|
|
|
|
mpBtnQuit->SetClickHdl(LINK(this, SafeModeDialog, BtnHdl));
|
|
|
|
mpBtnRestart->SetClickHdl(LINK(this, SafeModeDialog, BtnHdl));
|
2016-10-12 13:35:52 +02:00
|
|
|
|
|
|
|
mpCBCustomizations->SetToggleHdl(LINK(this, SafeModeDialog, CheckBoxHdl));
|
|
|
|
mpCBExtensions->SetToggleHdl(LINK(this, SafeModeDialog, CheckBoxHdl));
|
|
|
|
mpCBFull->SetToggleHdl(LINK(this, SafeModeDialog, CheckBoxHdl));
|
|
|
|
|
|
|
|
// Disable restart btn until some checkbox is active
|
|
|
|
mpBtnRestart->Disable();
|
2016-10-07 18:19:25 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
SafeModeDialog::~SafeModeDialog()
|
|
|
|
{
|
|
|
|
disposeOnce();
|
|
|
|
}
|
|
|
|
|
|
|
|
void SafeModeDialog::dispose()
|
|
|
|
{
|
|
|
|
mpBtnContinue.clear();
|
|
|
|
mpBtnQuit.clear();
|
|
|
|
mpBtnRestart.clear();
|
|
|
|
mpCBCustomizations.clear();
|
|
|
|
mpCBExtensions.clear();
|
|
|
|
mpCBFull.clear();
|
|
|
|
|
|
|
|
Dialog::dispose();
|
|
|
|
}
|
|
|
|
|
2016-10-12 11:18:08 +02:00
|
|
|
bool SafeModeDialog::Close()
|
|
|
|
{
|
|
|
|
// Remove the safe mode flag before exiting this dialog
|
|
|
|
sfx2::SafeMode::removeFlag();
|
|
|
|
|
|
|
|
return Dialog::Close();
|
|
|
|
}
|
|
|
|
|
2016-10-12 13:01:15 +02:00
|
|
|
void SafeModeDialog::terminateOffice()
|
|
|
|
{
|
|
|
|
uno::Reference<frame::XDesktop2> xDesktop = frame::Desktop::create( comphelper::getProcessComponentContext() );
|
|
|
|
xDesktop->terminate();
|
|
|
|
}
|
|
|
|
|
2016-10-12 13:26:10 +02:00
|
|
|
void SafeModeDialog::applyChanges()
|
|
|
|
{
|
|
|
|
// TODO: Apply apply changes
|
|
|
|
|
|
|
|
// Then restart
|
|
|
|
css::task::OfficeRestartManager::get(comphelper::getProcessComponentContext())->requestRestart(
|
|
|
|
css::uno::Reference< css::task::XInteractionHandler >());
|
|
|
|
}
|
|
|
|
|
2016-10-07 18:19:25 +02:00
|
|
|
IMPL_LINK(SafeModeDialog, BtnHdl, Button*, pBtn, void)
|
|
|
|
{
|
|
|
|
if (pBtn == mpBtnContinue.get())
|
|
|
|
{
|
|
|
|
Close();
|
|
|
|
}
|
|
|
|
else if (pBtn == mpBtnQuit.get())
|
|
|
|
{
|
2016-10-12 13:01:15 +02:00
|
|
|
terminateOffice();
|
2016-10-07 18:19:25 +02:00
|
|
|
}
|
|
|
|
else if (pBtn == mpBtnRestart.get())
|
|
|
|
{
|
|
|
|
Close();
|
2016-10-12 13:26:10 +02:00
|
|
|
applyChanges();
|
2016-10-07 18:19:25 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2016-10-12 13:35:52 +02:00
|
|
|
IMPL_LINK(SafeModeDialog, CheckBoxHdl, CheckBox&, /*pCheckBox*/, void)
|
|
|
|
{
|
|
|
|
bool bEnable = mpCBCustomizations->IsChecked() || mpCBExtensions->IsChecked() || mpCBFull->IsChecked();
|
|
|
|
mpBtnRestart->Enable(bEnable);
|
|
|
|
}
|
|
|
|
|
2016-10-07 18:19:25 +02:00
|
|
|
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|