sfx2/source/doc/objstor.cxx | 19 +++++++++++++------ 1 file changed, 13 insertions(+), 6 deletions(-)
New commits: commit a2007364e77aebbbc45fa8fab2c58f95a821dd18 Author: Caolán McNamara <caolan.mcnam...@collabora.com> AuthorDate: Thu May 16 14:37:52 2024 +0100 Commit: Caolán McNamara <caolan.mcnam...@collabora.com> CommitDate: Thu May 16 17:36:55 2024 +0200 always restore existing interaction handler after save In an error case we end up removing any existing interaction handler. So in all cases leave with the same interaction handler that existed before the save attempt. See also: commit 3b294f6139028014e72379ebe8eda24a2bd32195 Date: Thu Jun 8 20:53:16 2023 +0100 restore, not clear, existing interaction handler after save where the same problem can be reproduced of every change is a full-document invalidation once someone else joins a document which has had a save-fail. Change-Id: I211183c551b1d64898cfe4aaf11dd9ef23f8ca15 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/167678 Tested-by: Jenkins Reviewed-by: Caolán McNamara <caolan.mcnam...@collabora.com> diff --git a/sfx2/source/doc/objstor.cxx b/sfx2/source/doc/objstor.cxx index b3a7f8847e2e..cee4847022ed 100644 --- a/sfx2/source/doc/objstor.cxx +++ b/sfx2/source/doc/objstor.cxx @@ -3046,17 +3046,21 @@ bool SfxObjectShell::DoSave_Impl( const SfxItemSet* pArgs ) if (pImpl->bPreserveVersions) pMediumTmp->TransferVersionList_Impl( *pRetrMedium ); + // Save the original interaction handler + Any aOriginalInteract; + if (const SfxUnoAnyItem *pItem = pRetrMedium->GetItemSet().GetItemIfSet(SID_INTERACTIONHANDLER, false)) + { + aOriginalInteract = pItem->GetValue(); + // The original pRetrMedium and potential replacement pMediumTmp have the same interaction handler at this point + assert(pMediumTmp->GetItemSet().GetItemIfSet(SID_INTERACTIONHANDLER, false)->GetValue() == aOriginalInteract); + } + // an interaction handler here can acquire only in case of GUI Saving // and should be removed after the saving is done - Any aOriginalInteract; css::uno::Reference< XInteractionHandler > xInteract; const SfxUnoAnyItem* pxInteractionItem = SfxItemSet::GetItem<SfxUnoAnyItem>(pArgs, SID_INTERACTIONHANDLER, false); if ( pxInteractionItem && ( pxInteractionItem->GetValue() >>= xInteract ) && xInteract.is() ) - { - if (const SfxUnoAnyItem *pItem = pMediumTmp->GetItemSet().GetItemIfSet(SID_INTERACTIONHANDLER, false)) - aOriginalInteract = pItem->GetValue(); pMediumTmp->GetItemSet().Put( SfxUnoAnyItem( SID_INTERACTIONHANDLER, Any( xInteract ) ) ); - } const SfxBoolItem* pNoFileSync = pArgs->GetItem<SfxBoolItem>(SID_NO_FILE_SYNC, false); if (pNoFileSync && pNoFileSync->GetValue()) @@ -3096,7 +3100,10 @@ bool SfxObjectShell::DoSave_Impl( const SfxItemSet* pArgs ) // reconnect to object storage DoSaveCompleted(); - pRetrMedium->GetItemSet().ClearItem( SID_INTERACTIONHANDLER ); + if (aOriginalInteract.hasValue()) + pRetrMedium->GetItemSet().Put(SfxUnoAnyItem(SID_INTERACTIONHANDLER, aOriginalInteract)); + else + pRetrMedium->GetItemSet().ClearItem(SID_INTERACTIONHANDLER); pRetrMedium->GetItemSet().ClearItem( SID_PROGRESS_STATUSBAR_CONTROL ); delete pMediumTmp;