summaryrefslogtreecommitdiff
path: root/sfx2
diff options
context:
space:
mode:
authorSzymon Kłos <szymon.klos@collabora.com>2022-10-14 14:54:15 +0200
committerSzymon Kłos <szymon.klos@collabora.com>2022-11-21 12:36:35 +0100
commit58ae6705deccb614f33d20bfa4b2ab0923d426e1 (patch)
treed122c478b44c3d63cb0b274453aa807a97d0259c /sfx2
parentbe12f60b1055292ac655e53f4fb56567b5c15970 (diff)
lok: allow password reset in properties>change password
Change-Id: I92a3c658e96f602549ff5282b6ed5bc9ee780bbd Reviewed-on: https://gerrit.libreoffice.org/c/core/+/141372 Tested-by: Jenkins CollaboraOffice <jenkinscollaboraoffice@gmail.com> Reviewed-by: Andras Timar <andras.timar@collabora.com> Reviewed-on: https://gerrit.libreoffice.org/c/core/+/142992 Tested-by: Jenkins Reviewed-by: Szymon Kłos <szymon.klos@collabora.com>
Diffstat (limited to 'sfx2')
-rw-r--r--sfx2/source/dialog/dinfdlg.cxx4
-rw-r--r--sfx2/source/dialog/filedlghelper.cxx15
2 files changed, 17 insertions, 2 deletions
diff --git a/sfx2/source/dialog/dinfdlg.cxx b/sfx2/source/dialog/dinfdlg.cxx
index 3d1ee1dadac5..3067229b96eb 100644
--- a/sfx2/source/dialog/dinfdlg.cxx
+++ b/sfx2/source/dialog/dinfdlg.cxx
@@ -785,11 +785,13 @@ IMPL_LINK_NOARG(SfxDocumentPage, ChangePassHdl, weld::Button&, void)
// handle the pwd dialog asynchronously
VclAbstractDialogFactory * pFact = VclAbstractDialogFactory::Create();
m_xPasswordDialog = pFact->CreatePasswordToOpenModifyDialog(GetFrameWeld(), maxPwdLen, false);
+ m_xPasswordDialog->AllowEmpty(); // needed to remove password
m_xPasswordDialog->StartExecuteAsync([this, pFilter, pMedSet, pShell](sal_Int32 nResult)
{
if (nResult == RET_OK)
{
- sfx2::SetPassword(pFilter, pMedSet, m_xPasswordDialog->GetPasswordToOpen(), m_xPasswordDialog->GetPasswordToOpen());
+ sfx2::SetPassword(pFilter, pMedSet, m_xPasswordDialog->GetPasswordToOpen(),
+ m_xPasswordDialog->GetPasswordToOpen(), true);
pShell->SetModified();
}
m_xPasswordDialog->disposeOnce();
diff --git a/sfx2/source/dialog/filedlghelper.cxx b/sfx2/source/dialog/filedlghelper.cxx
index 93505057779f..541d26a9ae29 100644
--- a/sfx2/source/dialog/filedlghelper.cxx
+++ b/sfx2/source/dialog/filedlghelper.cxx
@@ -2878,7 +2878,9 @@ bool IsOOXML(const std::shared_ptr<const SfxFilter>& pCurrentFilter)
return IsMSType(pCurrentFilter) && lclSupportsOOXMLEncryption( pCurrentFilter->GetFilterName());
}
-ErrCode SetPassword(const std::shared_ptr<const SfxFilter>& pCurrentFilter, SfxItemSet* pSet, const OUString& rPasswordToOpen, std::u16string_view rPasswordToModify)
+ErrCode SetPassword(const std::shared_ptr<const SfxFilter>& pCurrentFilter, SfxItemSet* pSet,
+ const OUString& rPasswordToOpen, std::u16string_view rPasswordToModify,
+ bool bAllowPasswordReset)
{
const bool bMSType = IsMSType(pCurrentFilter);
const bool bOOXML = IsOOXML(pCurrentFilter);
@@ -2924,6 +2926,17 @@ ErrCode SetPassword(const std::shared_ptr<const SfxFilter>& pCurrentFilter, SfxI
aEncryptionData, comphelper::OStorageHelper::CreatePackageEncryptionData(
rPasswordToOpen)))));
}
+ else if (bAllowPasswordReset)
+ {
+ // Remove password
+
+ if (pSet->HasItem(SID_ENCRYPTIONDATA))
+ pSet->ClearItem(SID_MODIFYPASSWORDINFO);
+ if (pSet->HasItem(SID_ENCRYPTIONDATA))
+ pSet->ClearItem(SID_ENCRYPTIONDATA);
+
+ return ERRCODE_NONE;
+ }
if ( bMSType )
{