summaryrefslogtreecommitdiff
path: root/svx
diff options
context:
space:
mode:
authorSamuel Mehrbrodt <Samuel.Mehrbrodt@cib.de>2016-11-02 10:26:39 +0100
committerSamuel Mehrbrodt <Samuel.Mehrbrodt@cib.de>2016-11-03 12:19:16 +0000
commite509c22863b5184421e710cf8ae81e2ddc961623 (patch)
tree4d7b366c4e5f1fcd0dcb29f901c3732be49d8fe5 /svx
parent954f721ad59e52f039154cb01490e068cc0f0ce5 (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')
-rw-r--r--svx/AllLangResTarget_svx.mk1
-rw-r--r--svx/UIConfig_svx.mk1
-rw-r--r--svx/source/dialog/SafeMode.src17
-rw-r--r--svx/source/dialog/SafeModeDialog.cxx65
-rw-r--r--svx/source/dialog/SafeModeDialog.hxx4
-rw-r--r--svx/uiconfig/ui/profileexporteddialog.ui84
-rw-r--r--svx/uiconfig/ui/safemodedialog.ui40
7 files changed, 199 insertions, 13 deletions
diff --git a/svx/AllLangResTarget_svx.mk b/svx/AllLangResTarget_svx.mk
index 3a987344f040..8f4be3fbcf7c 100644
--- a/svx/AllLangResTarget_svx.mk
+++ b/svx/AllLangResTarget_svx.mk
@@ -50,6 +50,7 @@ $(eval $(call gb_SrsTarget_add_files,svx/res,\
svx/source/dialog/prtqry.src \
svx/source/dialog/ruler.src \
svx/source/dialog/spacing.src \
+ svx/source/dialog/SafeMode.src \
svx/source/dialog/samecontent.src \
svx/source/dialog/sdstring.src \
svx/source/dialog/srchdlg.src \
diff --git a/svx/UIConfig_svx.mk b/svx/UIConfig_svx.mk
index 65b9bdedd088..5c71dc2240de 100644
--- a/svx/UIConfig_svx.mk
+++ b/svx/UIConfig_svx.mk
@@ -53,6 +53,7 @@ $(eval $(call gb_UIConfig_add_uifiles,svx,\
svx/uiconfig/ui/paralrspacing \
svx/uiconfig/ui/paraulspacing \
svx/uiconfig/ui/passwd \
+ svx/uiconfig/ui/profileexporteddialog \
svx/uiconfig/ui/querydeletecontourdialog \
svx/uiconfig/ui/querydeleteobjectdialog \
svx/uiconfig/ui/querydeletethemedialog \
diff --git a/svx/source/dialog/SafeMode.src b/svx/source/dialog/SafeMode.src
new file mode 100644
index 000000000000..2de389e72471
--- /dev/null
+++ b/svx/source/dialog/SafeMode.src
@@ -0,0 +1,17 @@
+/* -*- 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 <svx/dialogs.hrc>
+
+String RID_SVXSTR_SAFEMODE_ZIP_FAILURE
+{
+ Text[en-US] = "The zip file could not be created.";
+};
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab cinoptions=b1,g0,N-s cinkeys+=0=break: */
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(
diff --git a/svx/source/dialog/SafeModeDialog.hxx b/svx/source/dialog/SafeModeDialog.hxx
index 05ee6a2dd2d8..9bc5d91e9e7e 100644
--- a/svx/source/dialog/SafeModeDialog.hxx
+++ b/svx/source/dialog/SafeModeDialog.hxx
@@ -56,6 +56,7 @@ private:
VclPtr<FixedHyperlink> mpBugLink;
VclPtr<FixedHyperlink> mpUserProfileLink;
+ VclPtr<Button> mpBtnCreateZip;
// local BackupFileHelper for handling possible restores
comphelper::BackupFileHelper maBackupFileHelper;
@@ -65,7 +66,8 @@ private:
DECL_LINK(RadioBtnHdl, Button*, void);
DECL_LINK(CheckBoxHdl, CheckBox&, void);
- DECL_LINK(BtnHdl, Button*, void);
+ DECL_LINK(CreateZipBtnHdl, Button*, void);
+ DECL_LINK(DialogBtnHdl, Button*, void);
};
#endif
diff --git a/svx/uiconfig/ui/profileexporteddialog.ui b/svx/uiconfig/ui/profileexporteddialog.ui
new file mode 100644
index 000000000000..3897bd53aef6
--- /dev/null
+++ b/svx/uiconfig/ui/profileexporteddialog.ui
@@ -0,0 +1,84 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!-- Generated with glade 3.20.0 -->
+<interface>
+ <requires lib="gtk+" version="3.20"/>
+ <object class="GtkDialog" id="SafeModeQueryDialog">
+ <property name="can_focus">False</property>
+ <property name="border_width">6</property>
+ <property name="title" translatable="yes">Enter Safe Mode</property>
+ <property name="resizable">False</property>
+ <property name="type_hint">dialog</property>
+ <child internal-child="vbox">
+ <object class="GtkBox" id="dialog-vbox1">
+ <property name="can_focus">False</property>
+ <property name="orientation">vertical</property>
+ <property name="spacing">12</property>
+ <child internal-child="action_area">
+ <object class="GtkButtonBox" id="dialog-action_area1">
+ <property name="can_focus">False</property>
+ <property name="layout_style">end</property>
+ <child>
+ <object class="GtkButton" id="close">
+ <property name="label">gtk-close</property>
+ <property name="visible">True</property>
+ <property name="can_focus">True</property>
+ <property name="can_default">True</property>
+ <property name="has_default">True</property>
+ <property name="receives_default">True</property>
+ <property name="use_underline">True</property>
+ <property name="use_stock">True</property>
+ </object>
+ <packing>
+ <property name="expand">False</property>
+ <property name="fill">True</property>
+ <property name="position">0</property>
+ <property name="secondary">True</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkButton" id="openfolder">
+ <property name="label">Open Containing _Folder</property>
+ <property name="visible">True</property>
+ <property name="can_focus">True</property>
+ <property name="receives_default">True</property>
+ <property name="use_underline">True</property>
+ </object>
+ <packing>
+ <property name="expand">False</property>
+ <property name="fill">True</property>
+ <property name="position">1</property>
+ </packing>
+ </child>
+ </object>
+ <packing>
+ <property name="expand">False</property>
+ <property name="fill">True</property>
+ <property name="pack_type">end</property>
+ <property name="position">0</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkLabel" id="label">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="label" translatable="yes">Your user profile has been exported as “libreoffice-profile.zip”.</property>
+ <property name="wrap">True</property>
+ <property name="max_width_chars">80</property>
+ <property name="lines">2</property>
+ <property name="xalign">0</property>
+ <property name="yalign">0</property>
+ </object>
+ <packing>
+ <property name="expand">False</property>
+ <property name="fill">True</property>
+ <property name="position">1</property>
+ </packing>
+ </child>
+ </object>
+ </child>
+ <action-widgets>
+ <action-widget response="0">close</action-widget>
+ <action-widget response="0">openfolder</action-widget>
+ </action-widgets>
+ </object>
+</interface>
diff --git a/svx/uiconfig/ui/safemodedialog.ui b/svx/uiconfig/ui/safemodedialog.ui
index 74d32df414f7..43989aa5253e 100644
--- a/svx/uiconfig/ui/safemodedialog.ui
+++ b/svx/uiconfig/ui/safemodedialog.ui
@@ -354,8 +354,7 @@ The offered possible changes get more radical from top to bottom, so it is recom
<object class="GtkLabel" id="label4">
<property name="visible">True</property>
<property name="can_focus">False</property>
- <property name="label" translatable="yes">You can also include the relevant parts of your User Profile. Beware that it might contain personal data.
-Your User Profile is located at:</property>
+ <property name="label" translatable="yes">You can also include the relevant parts of your User Profile. Beware that it might contain personal data.</property>
<property name="xalign">0</property>
</object>
<packing>
@@ -365,17 +364,42 @@ Your User Profile is located at:</property>
</packing>
</child>
<child>
- <object class="GtkLinkButton" id="linkbutton_profile">
- <property name="label" translatable="yes">Show User Profile</property>
+ <object class="GtkBox">
<property name="visible">True</property>
- <property name="can_focus">True</property>
- <property name="receives_default">True</property>
- <property name="relief">none</property>
+ <property name="can_focus">False</property>
+ <property name="homogeneous">True</property>
+ <child>
+ <object class="GtkButton" id="btn_create_zip">
+ <property name="label" translatable="yes">Create zip archive from User Profile</property>
+ <property name="visible">True</property>
+ <property name="can_focus">True</property>
+ <property name="receives_default">True</property>
+ </object>
+ <packing>
+ <property name="expand">False</property>
+ <property name="fill">True</property>
+ <property name="position">0</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkLinkButton" id="linkbutton_profile">
+ <property name="label" translatable="yes">Show User Profile</property>
+ <property name="visible">True</property>
+ <property name="can_focus">True</property>
+ <property name="receives_default">True</property>
+ <property name="relief">none</property>
+ </object>
+ <packing>
+ <property name="expand">False</property>
+ <property name="fill">True</property>
+ <property name="position">1</property>
+ </packing>
+ </child>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
- <property name="position">3</property>
+ <property name="position">4</property>
</packing>
</child>
</object>