tdf#170067 SwNavigator: Unprotect section needs to ask for set password

...again

Follow up patch to always ask for the password when unprotecting
sections that have protection set with a password. The previous patch
askes for the password only the first time.

Change-Id: I54818151b8c5f43026d656065f85f2d736f98fc6
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/196049
Reviewed-by: Jim Raykowski <raykowj@gmail.com>
Tested-by: Jenkins
This commit is contained in:
Jim Raykowski
2025-12-21 23:16:42 +01:00
parent cdcbf46228
commit b70f87d395
+11 -19
View File
@@ -6044,30 +6044,22 @@ void SwContentTree::ExecuteContextMenuAction(const OUString& rSelectedPopupEntry
SwSectionData aSectionData(*pSection);
if (rSelectedPopupEntry == "protectsection")
{
if (pSection->GetPassword().hasElements())
if (pSection->GetPassword().hasElements() && aSectionData.IsProtectFlag())
{
SfxPasswordDialog aPasswordDlg(m_pDialog->GetFrameWeld());
if (aPasswordDlg.run())
if (aPasswordDlg.run() != RET_OK)
return;
if (!SvPasswordHelper::CompareHashPassword(aSectionData.GetPassword(),
aPasswordDlg.GetPassword()))
{
if (SvPasswordHelper::CompareHashPassword(aSectionData.GetPassword(),
aPasswordDlg.GetPassword()))
{
aSectionData.SetProtectFlag(!aSectionData.IsProtectFlag());
if (!aSectionData.IsProtectFlag())
aSectionData.SetPassword(uno::Sequence<sal_Int8 >());
}
else
{
std::unique_ptr<weld::MessageDialog> xInfoBox(
Application::CreateMessageDialog(
m_pDialog->GetFrameWeld(), VclMessageType::Info, VclButtonsType::Ok,
SwResId(STR_WRONG_PASSWORD)));
xInfoBox->run();
}
std::unique_ptr<weld::MessageDialog> xInfoBox(Application::CreateMessageDialog(
m_pDialog->GetFrameWeld(), VclMessageType::Info, VclButtonsType::Ok,
SwResId(STR_WRONG_PASSWORD)));
xInfoBox->run();
return;
}
}
else
aSectionData.SetProtectFlag(!aSectionData.IsProtectFlag());
aSectionData.SetProtectFlag(!aSectionData.IsProtectFlag());
}
else
aSectionData.SetHidden(!pSection->IsHidden());