sw/source/uibase/utlui/content.cxx | 30 +++++++++++------------------- 1 file changed, 11 insertions(+), 19 deletions(-)
New commits: commit b70f87d395c689b075c74afb4068794333fc41ea Author: Jim Raykowski <[email protected]> AuthorDate: Sun Dec 21 09:39:03 2025 -0900 Commit: Jim Raykowski <[email protected]> CommitDate: Sun Dec 21 23:16:42 2025 +0100 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 <[email protected]> Tested-by: Jenkins diff --git a/sw/source/uibase/utlui/content.cxx b/sw/source/uibase/utlui/content.cxx index 18733b74ed5b..2b0611896673 100644 --- a/sw/source/uibase/utlui/content.cxx +++ b/sw/source/uibase/utlui/content.cxx @@ -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());
