diff options
-rw-r--r-- | desktop/source/app/app.cxx | 3 | ||||
-rw-r--r-- | include/sfx2/safemode.hxx | 32 | ||||
-rw-r--r-- | sfx2/Library_sfx.mk | 1 | ||||
-rw-r--r-- | sfx2/source/appl/appserv.cxx | 2 | ||||
-rw-r--r-- | sfx2/source/safemode/safemode.cxx | 58 | ||||
-rw-r--r-- | svx/source/dialog/SafeModeDialog.cxx | 3 | ||||
-rw-r--r-- | svx/source/dialog/crashreportdlg.cxx | 3 |
7 files changed, 99 insertions, 3 deletions
diff --git a/desktop/source/app/app.cxx b/desktop/source/app/app.cxx index a9d10c3a99ba..69da758aac42 100644 --- a/desktop/source/app/app.cxx +++ b/desktop/source/app/app.cxx @@ -101,6 +101,7 @@ #include <vcl/settings.hxx> #include <sfx2/sfx.hrc> #include <sfx2/app.hxx> +#include <sfx2/safemode.hxx> #include <svl/itemset.hxx> #include <svl/eitem.hxx> #include <basic/sbstar.hxx> @@ -2138,7 +2139,7 @@ void Desktop::OpenClients() bool bAllowRecoveryAndSessionManagement = ( !rArgs.IsNoRestore() ) && ( !rArgs.IsHeadless() ); // Enter safe mode if requested - if (rArgs.IsSafeMode()) + if (rArgs.IsSafeMode() || sfx2::SafeMode::hasFlag()) handleSafeMode(); diff --git a/include/sfx2/safemode.hxx b/include/sfx2/safemode.hxx new file mode 100644 index 000000000000..666d2d4215ef --- /dev/null +++ b/include/sfx2/safemode.hxx @@ -0,0 +1,32 @@ +/* -*- 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/. + */ + +#ifndef INCLUDED_SFX2_SAFEMODE_HXX +#define INCLUDED_SFX2_SAFEMODE_HXX + +#include <sfx2/dllapi.h> + +#include <rtl/ustring.hxx> + +namespace sfx2 { + +class SFX2_DLLPUBLIC SafeMode +{ +public: + static bool putFlag(); + static bool hasFlag(); + static bool removeFlag(); + static OUString getFileName(); +}; + +} + +#endif + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sfx2/Library_sfx.mk b/sfx2/Library_sfx.mk index 9ec5f0ee3af8..e3daa773a50d 100644 --- a/sfx2/Library_sfx.mk +++ b/sfx2/Library_sfx.mk @@ -251,6 +251,7 @@ $(eval $(call gb_Library_add_exception_objects,sfx,\ sfx2/source/notify/globalevents \ sfx2/source/notify/hintpost \ sfx2/source/notify/openurlhint \ + sfx2/source/safemode/safemode \ sfx2/source/sidebar/Sidebar \ sfx2/source/sidebar/SidebarChildWindow \ sfx2/source/sidebar/SidebarDockingWindow \ diff --git a/sfx2/source/appl/appserv.cxx b/sfx2/source/appl/appserv.cxx index b09613e081e6..defd3b601d8b 100644 --- a/sfx2/source/appl/appserv.cxx +++ b/sfx2/source/appl/appserv.cxx @@ -127,6 +127,7 @@ #include <sfx2/sidebar/Sidebar.hxx> #include <sfx2/notebookbar/SfxNotebookBar.hxx> #include <sfx2/sidebar/SidebarController.hxx> +#include <sfx2/safemode.hxx> #include <comphelper/types.hxx> #include <officecfg/Office/Common.hxx> @@ -311,6 +312,7 @@ namespace IMPL_LINK_NOARG(SafeModeQueryDialog, RestartHdl, Button*, void) { EndDialog(RET_OK); + sfx2::SafeMode::putFlag(); uno::Reference< uno::XComponentContext > xContext = comphelper::getProcessComponentContext(); css::task::OfficeRestartManager::get(xContext)->requestRestart( css::uno::Reference< css::task::XInteractionHandler >()); diff --git a/sfx2/source/safemode/safemode.cxx b/sfx2/source/safemode/safemode.cxx new file mode 100644 index 000000000000..a5669d19587f --- /dev/null +++ b/sfx2/source/safemode/safemode.cxx @@ -0,0 +1,58 @@ +/* -*- 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 <sfx2/safemode.hxx> + +#include <config_folders.h> + +#include <osl/file.hxx> +#include <rtl/bootstrap.hxx> + +using namespace osl; + +namespace sfx2 { + +bool SafeMode::putFlag() +{ + File safeModeFile(getFileName()); + if (safeModeFile.open(osl_File_OpenFlag_Create) == FileBase::E_None) + { + safeModeFile.close(); + return true; + } + return false; +} +bool SafeMode::hasFlag() +{ + File safeModeFile(getFileName()); + if (safeModeFile.open(osl_File_OpenFlag_Read) == FileBase::E_None) + { + safeModeFile.close(); + return true; + } + return false; +} +bool SafeMode::removeFlag() +{ + return File::remove(getFileName()) == FileBase::E_None; +} + +OUString SafeMode::getFileName() +{ + OUString url("${$BRAND_BASE_DIR/" LIBO_ETC_FOLDER "/" SAL_CONFIGFILE("bootstrap") ":UserInstallation}/safemode"); + rtl::Bootstrap::expandMacros(url); + + OUString aProfilePath; + FileBase::getSystemPathFromFileURL(url, aProfilePath); + return aProfilePath; +} + +} + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/svx/source/dialog/SafeModeDialog.cxx b/svx/source/dialog/SafeModeDialog.cxx index c9f6e4c7fb99..0553436bd673 100644 --- a/svx/source/dialog/SafeModeDialog.cxx +++ b/svx/source/dialog/SafeModeDialog.cxx @@ -10,9 +10,9 @@ #include "SafeModeDialog.hxx" #include <config_folders.h> - #include <rtl/bootstrap.hxx> #include <osl/file.hxx> +#include <sfx2/safemode.hxx> SafeModeDialog::SafeModeDialog(vcl::Window* pParent): Dialog(pParent, "SafeModeDialog", "svx/ui/safemodedialog.ui") @@ -60,6 +60,7 @@ IMPL_LINK(SafeModeDialog, BtnHdl, Button*, pBtn, void) { Close(); } + sfx2::SafeMode::removeFlag(); } /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/svx/source/dialog/crashreportdlg.cxx b/svx/source/dialog/crashreportdlg.cxx index bbac21157dfb..1692a444fa53 100644 --- a/svx/source/dialog/crashreportdlg.cxx +++ b/svx/source/dialog/crashreportdlg.cxx @@ -15,6 +15,7 @@ #include <rtl/bootstrap.hxx> #include <desktop/crashreport.hxx> #include <desktop/minidump.hxx> +#include <sfx2/safemode.hxx> #include <comphelper/processfactory.hxx> #include <osl/file.hxx> @@ -104,7 +105,7 @@ IMPL_LINK(CrashReportDialog, BtnHdl, Button*, pBtn, void) // Check whether to go to safe mode if (mpCBSafeMode->IsChecked()) { - //TODO: Actually set the safe mode, currently it's only restarting + sfx2::SafeMode::putFlag(); css::uno::Reference< css::uno::XComponentContext > xContext = comphelper::getProcessComponentContext(); css::task::OfficeRestartManager::get(xContext)->requestRestart( css::uno::Reference< css::task::XInteractionHandler >()); |