sw/source/uibase/utlui/content.cxx |   32 +++++++++++++++++++++++++++++++-
 1 file changed, 31 insertions(+), 1 deletion(-)

New commits:
commit f7d848e4e2c244bd75d5c273023309cc3f7b3420
Author:     Jim Raykowski <[email protected]>
AuthorDate: Sat Dec 20 17:52:08 2025 -0900
Commit:     Xisco Fauli <[email protected]>
CommitDate: Mon Dec 22 14:18:56 2025 +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]>
    (cherry picked from commit be2212824d4271e71c25706a790d0f4928bdf43a)
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/196086
    Reviewed-by: Xisco Fauli <[email protected]>

diff --git a/sw/source/uibase/utlui/content.cxx 
b/sw/source/uibase/utlui/content.cxx
index 03a4a2859d2f..d74b33670fe7 100644
--- a/sw/source/uibase/utlui/content.cxx
+++ b/sw/source/uibase/utlui/content.cxx
@@ -132,6 +132,9 @@
 
 #include <doctxm.hxx>
 
+#include <sfx2/passwd.hxx>
+#include <svl/PasswordHelper.hxx>
+
 #define CTYPE_CNT   0
 #define CTYPE_CTT   1
 
@@ -6040,11 +6043,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")
     {

Reply via email to