diff options
author | Samuel Mehrbrodt <Samuel.Mehrbrodt@cib.de> | 2016-11-02 10:26:39 +0100 |
---|---|---|
committer | Samuel Mehrbrodt <Samuel.Mehrbrodt@cib.de> | 2016-11-03 12:19:16 +0000 |
commit | e509c22863b5184421e710cf8ae81e2ddc961623 (patch) | |
tree | 4d7b366c4e5f1fcd0dcb29f901c3732be49d8fe5 /svx/source/dialog/SafeModeDialog.cxx | |
parent | 954f721ad59e52f039154cb01490e068cc0f0ce5 (diff) |
SafeModeDialog: Allow to create zip file from profile
Change-Id: I4296d1cf5058be359ffed46745673cf26eba3375
Reviewed-on: https://gerrit.libreoffice.org/30479
Reviewed-by: Samuel Mehrbrodt <Samuel.Mehrbrodt@cib.de>
Tested-by: Samuel Mehrbrodt <Samuel.Mehrbrodt@cib.de>
Diffstat (limited to 'svx/source/dialog/SafeModeDialog.cxx')
-rw-r--r-- | svx/source/dialog/SafeModeDialog.cxx | 65 |
1 files changed, 61 insertions, 4 deletions
diff --git a/svx/source/dialog/SafeModeDialog.cxx b/svx/source/dialog/SafeModeDialog.cxx index 84d84769c04f..35b135bff628 100644 --- a/svx/source/dialog/SafeModeDialog.cxx +++ b/svx/source/dialog/SafeModeDialog.cxx @@ -17,8 +17,11 @@ #include <vcl/layout.hxx> #include <comphelper/anytostring.hxx> #include <comphelper/processfactory.hxx> +#include <unotools/ZipPackageHelper.hxx> #include <cppuhelper/exc_hlp.hxx> #include <unotools/configmgr.hxx> +#include <svx/dialmgr.hxx> +#include <svx/dialogs.hrc> #include <com/sun/star/frame/Desktop.hpp> #include <com/sun/star/frame/XDesktop2.hpp> @@ -79,14 +82,15 @@ SafeModeDialog::SafeModeDialog(vcl::Window* pParent) get(mpBugLink, "linkbutton_bugs"); get(mpUserProfileLink, "linkbutton_profile"); + get(mpBtnCreateZip, "btn_create_zip"); mpRadioRestore->SetClickHdl(LINK(this, SafeModeDialog, RadioBtnHdl)); mpRadioConfigure->SetClickHdl(LINK(this, SafeModeDialog, RadioBtnHdl)); mpRadioReset->SetClickHdl(LINK(this, SafeModeDialog, RadioBtnHdl)); - mpBtnContinue->SetClickHdl(LINK(this, SafeModeDialog, BtnHdl)); - mpBtnQuit->SetClickHdl(LINK(this, SafeModeDialog, BtnHdl)); - mpBtnRestart->SetClickHdl(LINK(this, SafeModeDialog, BtnHdl)); + mpBtnContinue->SetClickHdl(LINK(this, SafeModeDialog, DialogBtnHdl)); + mpBtnQuit->SetClickHdl(LINK(this, SafeModeDialog, DialogBtnHdl)); + mpBtnRestart->SetClickHdl(LINK(this, SafeModeDialog, DialogBtnHdl)); mpCBCheckProfilesafeConfig->SetToggleHdl(LINK(this, SafeModeDialog, CheckBoxHdl)); mpCBCheckProfilesafeExtensions->SetToggleHdl(LINK(this, SafeModeDialog, CheckBoxHdl)); @@ -97,6 +101,8 @@ SafeModeDialog::SafeModeDialog(vcl::Window* pParent) mpCBResetCustomizations->SetToggleHdl(LINK(this, SafeModeDialog, CheckBoxHdl)); mpCBResetWholeUserProfile->SetToggleHdl(LINK(this, SafeModeDialog, CheckBoxHdl)); + mpBtnCreateZip->SetClickHdl(LINK(this, SafeModeDialog, CreateZipBtnHdl)); + // Disable restart btn until some checkbox is active mpBtnRestart->Disable(); @@ -174,6 +180,7 @@ void SafeModeDialog::dispose() mpBugLink.clear(); mpUserProfileLink.clear(); + mpBtnCreateZip.clear(); Dialog::dispose(); } @@ -276,7 +283,7 @@ IMPL_LINK(SafeModeDialog, RadioBtnHdl, Button*, pBtn, void) } } -IMPL_LINK(SafeModeDialog, BtnHdl, Button*, pBtn, void) +IMPL_LINK(SafeModeDialog, DialogBtnHdl, Button*, pBtn, void) { if (pBtn == mpBtnContinue.get()) { @@ -294,6 +301,56 @@ IMPL_LINK(SafeModeDialog, BtnHdl, Button*, pBtn, void) } } +namespace { + class ProfileExportedDialog : public ModalDialog + { + private: + DECL_LINK(OpenHdl, Button*, void); + public: + explicit ProfileExportedDialog(); + }; + + ProfileExportedDialog::ProfileExportedDialog() + : ModalDialog(nullptr, "SafeModeQueryDialog", "svx/ui/profileexporteddialog.ui") + { + get<Button>("openfolder")->SetClickHdl(LINK(this, ProfileExportedDialog, OpenHdl)); + } + + IMPL_LINK_NOARG(ProfileExportedDialog, OpenHdl, Button*, void) + { + const OUString uri(comphelper::BackupFileHelper::getUserProfileURL()); + css::uno::Reference< css::system::XSystemShellExecute > exec( + css::system::SystemShellExecute::create(comphelper::getProcessComponentContext())); + try { + exec->execute(uri, OUString(), css::system::SystemShellExecuteFlags::URIS_ONLY); + } catch (css::uno::Exception) { + } + EndDialog(RET_OK); + } +} + +IMPL_LINK(SafeModeDialog, CreateZipBtnHdl, Button*, /*pBtn*/, void) +{ + const OUString zipFileName("libreoffice-profile.zip"); + const OUString zipFileURL(comphelper::BackupFileHelper::getUserProfileURL() + "/" + zipFileName); + osl::File::remove(zipFileURL); // Remove previous exports + try + { + utl::ZipPackageHelper aZipHelper(comphelper::getProcessComponentContext(), zipFileURL); + aZipHelper.addFolderWithContent(aZipHelper.getRootFolder(), comphelper::BackupFileHelper::getUserProfileWorkURL()); + aZipHelper.savePackage(); + } + catch (uno::Exception) + { + ScopedVclPtrInstance< MessageDialog > aErrorBox(this, SVX_RESSTR(RID_SVXSTR_SAFEMODE_ZIP_FAILURE)); + aErrorBox->Execute(); + return; + } + + ScopedVclPtrInstance< ProfileExportedDialog > aDialog; + aDialog->Execute(); +} + IMPL_LINK(SafeModeDialog, CheckBoxHdl, CheckBox&, /*pCheckBox*/, void) { const bool bEnable( |