sc/source/ui/docshell/docsh.cxx |   24 +++++++++++++-----------
 1 file changed, 13 insertions(+), 11 deletions(-)

New commits:
commit 24c52c6f8674a716f3f5102095421c97d03b19d8
Author:     Justin Luth <jl...@mail.com>
AuthorDate: Sat Jul 15 09:57:46 2023 -0400
Commit:     Justin Luth <jl...@mail.com>
CommitDate: Tue Jul 18 22:54:54 2023 +0200

    related tdf#68565 tdf#123877 autosave: identify by args, not path
    
    It shouldn't matter where the autosave is being stored,
    the password request wants to be cancelled any time
    the save event is triggered by autosave.
    
    I couldn't really follow the discussion about needing a re-hash,
    whether the old password has would just be stored
    without being confirmed.
    
    Based on a code read, it looks like this would happen with any
    kind of password, so I'm not sure why only calc8 was singled out.
    So I eliminated that clause - even though at the time it likely
    is the only format that will trigger the need for a rehash.
    
    Change-Id: I72a11910e29e101aa98f7f8ecc0cffc7956102a5
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/154480
    Tested-by: Jenkins
    Reviewed-by: Justin Luth <jl...@mail.com>

diff --git a/sc/source/ui/docshell/docsh.cxx b/sc/source/ui/docshell/docsh.cxx
index 16cb0655c94f..8ff1b90c3f90 100644
--- a/sc/source/ui/docshell/docsh.cxx
+++ b/sc/source/ui/docshell/docsh.cxx
@@ -131,6 +131,7 @@
 #include <comphelper/processfactory.hxx>
 #include <comphelper/string.hxx>
 #include <unotools/configmgr.hxx>
+#include <unotools/mediadescriptor.hxx>
 #include <unotools/tempfile.hxx>
 #include <unotools/ucbstreamhelper.hxx>
 #include <uiitems.hxx>
@@ -1860,19 +1861,20 @@ bool ScDocShell::SaveAs( SfxMedium& rMedium )
         bNeedsRehash = ScPassHashHelper::needsPassHashRegen(*m_pDocument, 
PASSHASH_SHA256);
     }
 
-    // skip saving recovery file instead of showing re-type password dialog 
window
-    if ( bNeedsRehash && rMedium.GetFilter()->GetFilterName() == "calc8" &&
-            // it seems, utl::MediaDescriptor::PROP_AUTOSAVEEVENT is true at 
Save As, too,
-            // so check the backup path
-            rMedium.GetName().startsWith( SvtPathOptions().GetBackupPath() ) )
-    {
-        SAL_WARN("sc.filter", "Should re-type password for own format, won't 
export recovery file");
-        rMedium.SetError(ERRCODE_SFX_WRONGPASSWORD);
-        return false;
-    }
-
     if (pViewShell && bNeedsRehash)
     {
+        bool bAutoSaveEvent = false;
+        utl::MediaDescriptor lArgs(rMedium.GetArgs());
+        lArgs[utl::MediaDescriptor::PROP_AUTOSAVEEVENT] >>= bAutoSaveEvent;
+        if (bAutoSaveEvent)
+        {
+            // skip saving recovery file instead of showing re-type password 
dialog window
+            SAL_WARN("sc.filter",
+                     "Should re-type password for own format, won't export 
recovery file");
+            rMedium.SetError(ERRCODE_SFX_WRONGPASSWORD);
+            return false;
+        }
+
         if (!pViewShell->ExecuteRetypePassDlg(PASSHASH_SHA1))
             // password re-type cancelled.  Don't save the document.
             return false;

Reply via email to