summaryrefslogtreecommitdiff
path: root/sfx2
diff options
context:
space:
mode:
authorSzymon Kłos <szymon.klos@collabora.com>2022-10-14 14:54:15 +0200
committerAndras Timar <andras.timar@collabora.com>2022-10-18 21:19:28 +0200
commit8a84b5c024ed511548d6749a6038ae933e4d589d (patch)
tree0e6aed247a67de6975b08bce8c9ddebbc0c646ae /sfx2
parentfc9c654b7f4ba7cfc92eeefe8b5dfcb515b0b800 (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>
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 26609290d9c5..799d8fbd3168 100644
--- a/sfx2/source/dialog/dinfdlg.cxx
+++ b/sfx2/source/dialog/dinfdlg.cxx
@@ -782,11 +782,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 7cd4b3653c54..8239219ea20b 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, const OUString& rPasswordToModify)
+ErrCode SetPassword(const std::shared_ptr<const SfxFilter>& pCurrentFilter, SfxItemSet* pSet,
+ const OUString& rPasswordToOpen, const OUString& 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 )
{