summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMatt K <mattkse@gmail.com>2022-07-27 19:33:50 -0500
committerMike Kaganski <mike.kaganski@collabora.com>2022-07-30 06:27:05 +0200
commit07250a832787acdd432dccd458536de2987a58b2 (patch)
tree09772b10613c9ef04727bf63a628da17e09d1f68
parent45312369331688bde9d1b8c97ad883a69e5982d7 (diff)
tdf#117967 Fixes Save confirmation dialog for user cancel
The "Confirm save" dialog is launched from SfxMedium::CheckFileDate via "xHandler->handle( xInteractionRequestImpl );" and if the user canceled it the error is saved in the SfxMedium via "SetError(ERRCODE_ABORT);". Then, control is returned to the calling function SfxObjectShell::SaveTo_Impl which currently doesn't handle the cancel error condition, so this change just adds a check to detect it and return instead of doing more "save" processing. This return then goes to the calling function SfxObjectShell::DoSave_Impl which also does some save processing after cancel, in particular it updates the timestamps of the current SfxMedium (which are checked in SfxMedium::CheckFileDate from above and determines whether the "Confirm save" dialog will be launched), so this change prevents the updates to the timestamps by exiting early (i.e. before "DoSaveCompleted();" is called) if the abort error condition is seen so as to avoid a timestamp comparison result of equality which would prevent the "Confirm save" dialog from showing on every subsequent save action from the user. Now the behavior is for the timestamp comparison to fail equality (as would be expected if the file changed underneath the user) so as to ensure the "Confirm save" dialog continues to show for every subsequent save action by the user. Change-Id: I9c4aefc163a06029c80a8a28cdf4a09dff0031a5 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/137540 Reviewed-by: Mike Kaganski <mike.kaganski@collabora.com> Tested-by: Jenkins
-rw-r--r--sfx2/source/doc/objstor.cxx19
1 files changed, 18 insertions, 1 deletions
diff --git a/sfx2/source/doc/objstor.cxx b/sfx2/source/doc/objstor.cxx
index 6e406d332f9a..c0872029ae5e 100644
--- a/sfx2/source/doc/objstor.cxx
+++ b/sfx2/source/doc/objstor.cxx
@@ -1229,7 +1229,15 @@ bool SfxObjectShell::SaveTo_Impl
bStoreToSameLocation = true;
if ( pMedium->DocNeedsFileDateCheck() )
+ {
rMedium.CheckFileDate( pMedium->GetInitFileDate( false ) );
+ if (rMedium.GetErrorCode() == ERRCODE_ABORT)
+ {
+ // if user cancels the save, exit early to avoid resetting SfxMedium values that
+ // would cause an invalid subsequent filedate check
+ return false;
+ }
+ }
// before we overwrite the original file, we will make a backup if there is a demand for that
// if the backup is not created here it will be created internally and will be removed in case of successful saving
@@ -2616,7 +2624,16 @@ bool SfxObjectShell::DoSave_Impl( const SfxItemSet* pArgs )
else
{
// transfer error code from medium to objectshell
- SetError(pMediumTmp->GetError());
+ ErrCode errCode = pMediumTmp->GetError();
+ SetError(errCode);
+
+ if (errCode == ERRCODE_ABORT)
+ {
+ // avoid doing DoSaveCompleted() which updates the SfxMedium timestamp values
+ // and prevents subsequent filedate checks from being accurate
+ delete pMediumTmp;
+ return false;
+ }
// reconnect to object storage
DoSaveCompleted();