summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCaolán McNamara <caolanm@redhat.com>2022-03-23 13:03:30 +0000
committerChristian Lohmaier <lohmaier+LibreOffice@googlemail.com>2022-03-31 15:38:08 +0200
commitee87f541c9fd048ef3164d0f8a3e52385b43de92 (patch)
treea254f786e0ed7c11fadda31ce483abbf6036a61b
parentcbeafdca810107a210d3068ac5e65d27bc035817 (diff)
add infobar to prompt to refresh to replace old format
Change-Id: Id99cbf2b50a4ebf289dae6fc67e22e20afcda35b Reviewed-on: https://gerrit.libreoffice.org/c/core/+/131976 Tested-by: Jenkins Reviewed-by: Michael Stahl <michael.stahl@allotropia.de> (cherry picked from commit bbd196ff82bda9f66b4ba32a412f10cefe6da60e) Reviewed-on: https://gerrit.libreoffice.org/c/core/+/132187 Reviewed-by: Adolfo Jayme Barrientos <fitojb@ubuntu.com> Reviewed-by: Sophie Gautier <sophi@libreoffice.org> Reviewed-by: Christian Lohmaier <lohmaier+LibreOffice@googlemail.com>
-rw-r--r--include/sfx2/strings.hrc2
-rw-r--r--include/sfx2/viewfrm.hxx1
-rw-r--r--sfx2/source/view/viewfrm.cxx38
3 files changed, 41 insertions, 0 deletions
diff --git a/include/sfx2/strings.hrc b/include/sfx2/strings.hrc
index 82bd1c2168a1..c5948e316ed4 100644
--- a/include/sfx2/strings.hrc
+++ b/include/sfx2/strings.hrc
@@ -291,6 +291,8 @@
#define STR_TRACK_CHANGES_BUTTON NC_("STR_TRACK_CHANGES_BUTTON", "Show Toolbar")
#define STR_TRACK_CHANGES_BUTTON_HIDE NC_("STR_TRACK_CHANGES_BUTTON_HIDE", "Hide Toolbar")
#define STR_HYPHENATION_BUTTON NC_("STR_HYPHENATION_BUTTON", "Learn more")
+#define STR_REFRESH_MASTER_PASSWORD NC_("STR_REFRESH_MASTER_PASSWORD", "The master password is stored in an outdated format, you should refresh it")
+#define STR_REFRESH_PASSWORD NC_("STR_REFRESH_PASSWORD", "Refresh Password")
#define STR_CLOSE_PANE NC_("STR_CLOSE_PANE", "Close Pane")
diff --git a/include/sfx2/viewfrm.hxx b/include/sfx2/viewfrm.hxx
index e52a1ec437a4..24d1c35dbe90 100644
--- a/include/sfx2/viewfrm.hxx
+++ b/include/sfx2/viewfrm.hxx
@@ -68,6 +68,7 @@ class SFX2_DLLPUBLIC SfxViewFrame final : public SfxShell, public SfxListener
DECL_DLLPRIVATE_LINK(SignDocumentHandler, weld::Button&, void);
DECL_DLLPRIVATE_LINK(HiddenTrackChangesHandler, weld::Button&, void);
DECL_DLLPRIVATE_LINK(HyphenationMissingHandler, weld::Button&, void);
+ DECL_DLLPRIVATE_LINK(RefreshMasterPasswordHdl, weld::Button&, void);
SAL_DLLPRIVATE void KillDispatcher_Impl();
virtual ~SfxViewFrame() override;
diff --git a/sfx2/source/view/viewfrm.cxx b/sfx2/source/view/viewfrm.cxx
index b4924dc4474c..bc991ada4a36 100644
--- a/sfx2/source/view/viewfrm.cxx
+++ b/sfx2/source/view/viewfrm.cxx
@@ -33,6 +33,7 @@
#include <com/sun/star/frame/XLoadable.hpp>
#include <com/sun/star/frame/XLayoutManager.hpp>
#include <com/sun/star/frame/XComponentLoader.hpp>
+#include <com/sun/star/task/PasswordContainer.hpp>
#include <officecfg/Office/Common.hxx>
#include <officecfg/Setup.hxx>
#include <toolkit/helper/vclunohelper.hxx>
@@ -1476,6 +1477,22 @@ void SfxViewFrame::Notify( SfxBroadcaster& /*rBC*/, const SfxHint& rHint )
batch->commit();
}
+ if (officecfg::Office::Common::Passwords::HasMaster::get() &&
+ officecfg::Office::Common::Passwords::StorageVersion::get() == 0)
+ {
+ // master password stored in deprecated format
+ VclPtr<SfxInfoBarWindow> pOldMasterPasswordInfoBar =
+ AppendInfoBar("oldmasterpassword", "",
+ SfxResId(STR_REFRESH_MASTER_PASSWORD), InfobarType::DANGER, false);
+ if (pOldMasterPasswordInfoBar)
+ {
+ weld::Button& rButton = pOldMasterPasswordInfoBar->addButton();
+ rButton.set_label(SfxResId(STR_REFRESH_PASSWORD));
+ rButton.connect_clicked(LINK(this,
+ SfxViewFrame, RefreshMasterPasswordHdl));
+ }
+ }
+
// read-only infobar if necessary
const SfxViewShell *pVSh;
const SfxShell *pFSh;
@@ -1686,6 +1703,27 @@ IMPL_LINK_NOARG(SfxViewFrame, HyphenationMissingHandler, weld::Button&, void)
RemoveInfoBar(u"hyphenationmissing");
}
+IMPL_LINK_NOARG(SfxViewFrame, RefreshMasterPasswordHdl, weld::Button&, void)
+{
+ bool bChanged = false;
+ try
+ {
+ Reference< task::XPasswordContainer2 > xMasterPasswd(
+ task::PasswordContainer::create(comphelper::getProcessComponentContext()));
+
+ css::uno::Reference<css::frame::XFrame> xFrame = GetFrame().GetFrameInterface();
+ css::uno::Reference<css::awt::XWindow> xContainerWindow = xFrame->getContainerWindow();
+
+ uno::Reference<task::XInteractionHandler> xTmpHandler(task::InteractionHandler::createWithParent(comphelper::getProcessComponentContext(),
+ xContainerWindow));
+ bChanged = xMasterPasswd->changeMasterPassword(xTmpHandler);
+ }
+ catch (const Exception&)
+ {}
+ if (bChanged)
+ RemoveInfoBar(u"oldmasterpassword");
+}
+
void SfxViewFrame::Construct_Impl( SfxObjectShell *pObjSh )
{
m_pImpl->bResizeInToOut = true;