sfx2/source/doc/objmisc.cxx |   14 +++++++++++---
 1 file changed, 11 insertions(+), 3 deletions(-)

New commits:
commit 6520d6f9b09085af9c63d3c35108fb8083abbefa
Author:     Samuel Mehrbrodt <samuel.mehrbr...@allotropia.de>
AuthorDate: Wed Apr 13 08:01:29 2022 +0200
Commit:     Thorsten Behrens <thorsten.behr...@allotropia.de>
CommitDate: Thu Apr 14 19:31:51 2022 +0200

    Prevent save interception when sharing Calc doc
    
    Using the dispatch mechanism means that this can be caught by the dispatch 
interceptor
    which we don't want in this place.
    
    Change-Id: Ie7e5f92e6043e2aff98d4887829a3573c12c6d08
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/132946
    Tested-by: Thorsten Behrens <thorsten.behr...@allotropia.de>
    Reviewed-by: Thorsten Behrens <thorsten.behr...@allotropia.de>

diff --git a/sfx2/source/doc/objmisc.cxx b/sfx2/source/doc/objmisc.cxx
index 4afaf1cc5d7b..04ff6ecd5314 100644
--- a/sfx2/source/doc/objmisc.cxx
+++ b/sfx2/source/doc/objmisc.cxx
@@ -113,6 +113,7 @@
 #include <workwin.hxx>
 #include <sfx2/sfxdlg.hxx>
 #include <sfx2/infobar.hxx>
+#include <sfx2/sfxbasemodel.hxx>
 #include <appbaslib.hxx>
 #include <openflag.hxx>
 #include "objstor.hxx"
@@ -521,9 +522,16 @@ bool SfxObjectShell::SwitchToShared( bool bShared, bool 
bSave )
             {
                 // TODO/LATER: currently the application guards against the 
reentrance problem
                 SetModified(); // the modified flag has to be set to let the 
document be stored with the shared flag
-                const SfxPoolItem* pItem = 
pViewFrame->GetBindings().ExecuteSynchron( HasName() ? SID_SAVEDOC : 
SID_SAVEASDOC );
-                const SfxBoolItem* pResult = dynamic_cast<const SfxBoolItem*>( 
pItem  );
-                bResult = ( pResult && pResult->GetValue() );
+                try
+                {
+                    // Do *not* use dispatch mechanism in this place - we 
don't want others (extensions etc.) to intercept this.
+                    pImpl->pBaseModel->store();
+                    bResult = true;
+                }
+                catch (...)
+                {
+                    bResult = false;
+                }
             }
         }
 

Reply via email to