[Libreoffice-commits] core.git: sfx2/source

Libreoffice Gerrit user logerrit at kemper.freedesktop.org
Wed Jan 30 10:34:26 UTC 2019


 sfx2/source/doc/sfxbasemodel.cxx |   23 +++++++++++++++++++++--
 1 file changed, 21 insertions(+), 2 deletions(-)

New commits:
commit f1e775470e68fb1ca1fee390c10064c55932180d
Author:     Miklos Vajna <vmiklos at collabora.com>
AuthorDate: Wed Jan 30 10:17:35 2019 +0100
Commit:     Miklos Vajna <vmiklos at collabora.com>
CommitDate: Wed Jan 30 11:34:01 2019 +0100

    framework: allow storeSelf() on the main thread
    
    This is similar to commit 22aa6508e0a65e65a6f9410b498fe4fd6c236639
    (framework: allow dispatching a command on the main thread, 2019-01-29),
    except it addresses the scenario where save is performed with an UNO API
    call, not with a dispatched command.
    
    This way both load and save is possible on the main thread, providing a
    safe way to interact with documents containing OLE objects on Windows.
    
    Change-Id: I3516c944ece8ed0e26aa13fc9def5857b8344404
    Reviewed-on: https://gerrit.libreoffice.org/67109
    Reviewed-by: Miklos Vajna <vmiklos at collabora.com>
    Tested-by: Jenkins

diff --git a/sfx2/source/doc/sfxbasemodel.cxx b/sfx2/source/doc/sfxbasemodel.cxx
index e7f49fdb4b32..9d8b48f35cf4 100644
--- a/sfx2/source/doc/sfxbasemodel.cxx
+++ b/sfx2/source/doc/sfxbasemodel.cxx
@@ -125,6 +125,7 @@
 #include "printhelper.hxx"
 #include <sfx2/sfxresid.hxx>
 #include <comphelper/profilezone.hxx>
+#include <vcl/threadex.hxx>
 
 
 //  namespaces
@@ -1494,6 +1495,14 @@ sal_Bool SAL_CALL SfxBaseModel::isReadonly()
     return !m_pData->m_pObjectShell.is() || m_pData->m_pObjectShell->IsReadOnly();
 }
 
+/**
+ * Proxy around SfxObjectShell::Save_Impl(), as vcl::solarthread::syncExecute()
+ * does not seem to accept lambdas.
+ */
+static bool SaveImplStatic(SfxObjectShell* pThis, const SfxItemSet* pParams)
+{
+    return pThis->Save_Impl(pParams);
+}
 
 //  XStorable2
 
@@ -1507,6 +1516,7 @@ void SAL_CALL SfxBaseModel::storeSelf( const    Sequence< beans::PropertyValue >
         SfxSaveGuard aSaveGuard(this, m_pData.get());
 
         bool bCheckIn = false;
+        bool bOnMainThread = false;
         for ( sal_Int32 nInd = 0; nInd < aSeqArgs.getLength(); nInd++ )
         {
             // check that only acceptable parameters are provided here
@@ -1516,7 +1526,8 @@ void SAL_CALL SfxBaseModel::storeSelf( const    Sequence< beans::PropertyValue >
               && aSeqArgs[nInd].Name != "VersionMajor"
               && aSeqArgs[nInd].Name != "FailOnWarning"
               && aSeqArgs[nInd].Name != "CheckIn"
-              && aSeqArgs[nInd].Name != "NoFileSync" )
+              && aSeqArgs[nInd].Name != "NoFileSync"
+              && aSeqArgs[nInd].Name != "OnMainThread" )
             {
                 const OUString aMessage( "Unexpected MediaDescriptor parameter: " + aSeqArgs[nInd].Name );
                 throw lang::IllegalArgumentException( aMessage, Reference< XInterface >(), 1 );
@@ -1525,6 +1536,10 @@ void SAL_CALL SfxBaseModel::storeSelf( const    Sequence< beans::PropertyValue >
             {
                 aSeqArgs[nInd].Value >>= bCheckIn;
             }
+            else if (aSeqArgs[nInd].Name == "OnMainThread")
+            {
+                aSeqArgs[nInd].Value >>= bOnMainThread;
+            }
         }
 
         // Remove CheckIn property if needed
@@ -1576,7 +1591,11 @@ void SAL_CALL SfxBaseModel::storeSelf( const    Sequence< beans::PropertyValue >
         {
             // Tell the SfxMedium if we are in checkin instead of normal save
             m_pData->m_pObjectShell->GetMedium( )->SetInCheckIn( nSlotId == SID_CHECKIN );
-            bRet = m_pData->m_pObjectShell->Save_Impl( pParams.get() );
+            if (bOnMainThread)
+                bRet = vcl::solarthread::syncExecute(
+                    std::bind(&SaveImplStatic, m_pData->m_pObjectShell.get(), pParams.get()));
+            else
+                bRet = m_pData->m_pObjectShell->Save_Impl(pParams.get());
             m_pData->m_pObjectShell->GetMedium( )->SetInCheckIn( nSlotId != SID_CHECKIN );
         }
 


More information about the Libreoffice-commits mailing list