sfx2/source/doc/objstor.cxx |   10 +++++++++-
 1 file changed, 9 insertions(+), 1 deletion(-)

New commits:
commit 770df258bc0a66ee7551a59807d79cebcdcbb85e
Author:     Caolán McNamara <caolan.mcnam...@collabora.com>
AuthorDate: Thu Jun 8 20:53:16 2023 +0100
Commit:     Michael Meeks <michael.me...@collabora.com>
CommitDate: Fri Jun 9 09:11:54 2023 +0200

    restore, not clear, existing interaction handler after save
    
    put things back the way they were found.
    
    In this case I want it back to the original state, because
    
    a) lok sets its own interaction handler on load
    b) at framework/source/loadenv/loadenv.cxx:1137
       Because that handler supports XInitialization we show the
       window early
    c) that happens to be before the menubar is set
    d) so the menubar changes the size of the window after
       it is shown
    e) so Window::ImplPosSizeWindow calls
       ImplInvalidateFrameRegion(nullptr, InvalidateFlags::Children)
    f) which sets ImplPaintFlags::PaintAllChildren on the PaintFlags
       of the workwindow
    g) which means that when a SwEditWin calls PaintImmediately vcl
       sees that flag on its WorkWindow grandparent and calls
       ImplCallPaint with the grandparent, not the SwEditWin.
       It happens that the grandparent has no LokId so that does
       nothing.
    
    if we clear this interaction on save, then the next joiner instead
    has no interaction so gets the default one which does not
    support XInitialization, so the window is not shown before menubar
    is added, so when it is shown it is already at the final size,
    so there is no ImplInvalidateFrameRegion and so no
    ImplPaintFlags::PaintAllChildren bits on the WorkWindow, so
    PaintImmediately on SwEditWin calls that Invalidate, which is
    special cased to broadcast the invalidation as a real thing
    
    Change-Id: Ie3fde4c53476aada2b1fdabb1dc70b08485074b7
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/152772
    Tested-by: Jenkins
    Reviewed-by: Michael Meeks <michael.me...@collabora.com>
    (cherry picked from commit 2768d6042539e628216d72423c7972da8b42d621)
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/152764
    Tested-by: Michael Meeks <michael.me...@collabora.com>

diff --git a/sfx2/source/doc/objstor.cxx b/sfx2/source/doc/objstor.cxx
index 9ef664d1cb2f..7f8401cc2ee8 100644
--- a/sfx2/source/doc/objstor.cxx
+++ b/sfx2/source/doc/objstor.cxx
@@ -2609,10 +2609,15 @@ bool SfxObjectShell::DoSave_Impl( const SfxItemSet* 
pArgs )
 
     // 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())
@@ -2625,7 +2630,10 @@ bool SfxObjectShell::DoSave_Impl( const SfxItemSet* 
pArgs )
 
         if( pMediumTmp->GetItemSet() )
         {
-            pMediumTmp->GetItemSet()->ClearItem( SID_INTERACTIONHANDLER );
+            if (aOriginalInteract.hasValue())
+                
pMediumTmp->GetItemSet()->Put(SfxUnoAnyItem(SID_INTERACTIONHANDLER, 
aOriginalInteract));
+            else
+                pMediumTmp->GetItemSet()->ClearItem(SID_INTERACTIONHANDLER);
             pMediumTmp->GetItemSet()->ClearItem( 
SID_PROGRESS_STATUSBAR_CONTROL );
         }
 

Reply via email to