sfx2/source/dialog/filedlghelper.cxx |   15 +++------------
 1 file changed, 3 insertions(+), 12 deletions(-)

New commits:
commit d87b96a7233f7b5df3da7e27b7199659736e4e5c
Author:     Moritz Duge <[email protected]>
AuthorDate: Thu May 23 18:10:00 2024 +0200
Commit:     Thorsten Behrens <[email protected]>
CommitDate: Wed Jul 17 21:00:46 2024 +0200

    Simplify boolean logic locally for mbIsPwdEnabled.
    
    Change-Id: I2b2611e51ce0fdffdd25a75b211ce06b5bfd6b43
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/167999
    Reviewed-by: Thorsten Behrens <[email protected]>
    Tested-by: Jenkins
    (cherry picked from commit 86276a0ae8ae86fdafcf2af48df1054f8d8ad3c4)
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/170547

diff --git a/sfx2/source/dialog/filedlghelper.cxx 
b/sfx2/source/dialog/filedlghelper.cxx
index 1933a428a07d..4cc57436c636 100644
--- a/sfx2/source/dialog/filedlghelper.cxx
+++ b/sfx2/source/dialog/filedlghelper.cxx
@@ -513,7 +513,8 @@ void FileDialogHelper_Impl::enablePasswordBox( bool bInit )
     if ( ! mbHasPassword )
         return;
 
-    bool bWasEnabled = mbIsPwdEnabled;
+    // in case of initialization assume previous state to be false
+    bool bWasEnabled = !bInit && mbIsPwdEnabled;
 
     std::shared_ptr<const SfxFilter> pCurrentFilter = getCurrentSfxFilter();
     mbIsPwdEnabled = updateExtendedControl(
@@ -521,17 +522,7 @@ void FileDialogHelper_Impl::enablePasswordBox( bool bInit )
         pCurrentFilter && ( pCurrentFilter->GetFilterFlags() & 
SfxFilterFlags::ENCRYPTION )
     );
 
-    if( bInit )
-    {
-        // in case of initialization previous state is not interesting
-        if( mbIsPwdEnabled )
-        {
-            uno::Reference< XFilePickerControlAccess > xCtrlAccess( mxFileDlg, 
UNO_QUERY );
-            if( mbPwdCheckBoxState )
-                xCtrlAccess->setValue( 
ExtendedFilePickerElementIds::CHECKBOX_PASSWORD, 0, Any( true ) );
-        }
-    }
-    else if( !bWasEnabled && mbIsPwdEnabled )
+    if( !bWasEnabled && mbIsPwdEnabled )
     {
         uno::Reference< XFilePickerControlAccess > xCtrlAccess( mxFileDlg, 
UNO_QUERY );
         if( mbPwdCheckBoxState )

Reply via email to