sw/source/uibase/utlui/content.cxx | 24 +++++++++++++++++++++++- 1 file changed, 23 insertions(+), 1 deletion(-)
New commits: commit 1d672f913942c3fdf39fb7d23df15fa27d5b49a0 Author: Jim Raykowski <[email protected]> AuthorDate: Sun Dec 21 09:39:03 2025 -0900 Commit: Stephan Bergmann <[email protected]> CommitDate: Wed Mar 4 07:45:25 2026 +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 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/200845 Reviewed-by: Stephan Bergmann <[email protected]> diff --git a/sw/source/uibase/utlui/content.cxx b/sw/source/uibase/utlui/content.cxx index dce2cbde47d8..6d0636de6176 100644 --- a/sw/source/uibase/utlui/content.cxx +++ b/sw/source/uibase/utlui/content.cxx @@ -5861,30 +5861,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()); commit 2e928f68355ae4ff0daee4c0f676543a1d26f84b Author: Jim Raykowski <[email protected]> AuthorDate: Sat Dec 20 17:52:08 2025 -0900 Commit: Stephan Bergmann <[email protected]> CommitDate: Wed Mar 4 07:45:15 2026 +0100 tdf#170067 SwNavigator: Unprotect section needs to ask for set password Makes unprotecting password protected sections from the Navigator Sections entries popup menu show the password dialog for password entry match before unprotect can be done. Change-Id: I1178a2254616a32ad33f6974071885e3021d1dcf Reviewed-on: https://gerrit.libreoffice.org/c/core/+/196040 Tested-by: Jenkins Reviewed-by: Jim Raykowski <[email protected]> Reviewed-on: https://gerrit.libreoffice.org/c/core/+/200844 Reviewed-by: Stephan Bergmann <[email protected]> diff --git a/sw/source/uibase/utlui/content.cxx b/sw/source/uibase/utlui/content.cxx index 5bf4343531a7..dce2cbde47d8 100644 --- a/sw/source/uibase/utlui/content.cxx +++ b/sw/source/uibase/utlui/content.cxx @@ -130,6 +130,9 @@ #include <rootfrm.hxx> +#include <sfx2/passwd.hxx> +#include <svl/PasswordHelper.hxx> + #define CTYPE_CNT 0 #define CTYPE_CTT 1 @@ -5857,11 +5860,38 @@ void SwContentTree::ExecuteContextMenuAction(const OUString& rSelectedPopupEntry SwSection* pSection = pSectionFormat->GetSection(); SwSectionData aSectionData(*pSection); if (rSelectedPopupEntry == "protectsection") - aSectionData.SetProtectFlag(!pSection->IsProtect()); + { + if (pSection->GetPassword().hasElements()) + { + SfxPasswordDialog aPasswordDlg(m_pDialog->GetFrameWeld()); + if (aPasswordDlg.run()) + { + 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(); + } + } + } + else + aSectionData.SetProtectFlag(!aSectionData.IsProtectFlag()); + } else aSectionData.SetHidden(!pSection->IsHidden()); m_pActiveShell->UpdateSection(m_pActiveShell->GetSectionFormatPos(*pSectionFormat), aSectionData); + Display(true); + return; } else if (rSelectedPopupEntry == "sort") {
