[Libreoffice-commits] core.git: Branch 'distro/vector/vector-5.4' - 2 commits - framework/source sfx2/source

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


 framework/source/services/dispatchhelper.cxx |   24 +++++++++++++++++++++++-
 sfx2/source/doc/sfxbasemodel.cxx             |   23 +++++++++++++++++++++--
 2 files changed, 44 insertions(+), 3 deletions(-)

New commits:
commit 6070df5b2c137a203c9f10111b3520168c208641
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 12:20:18 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.
    
    Reviewed-on: https://gerrit.libreoffice.org/67109
    Reviewed-by: Miklos Vajna <vmiklos at collabora.com>
    Tested-by: Jenkins
    (cherry picked from commit f1e775470e68fb1ca1fee390c10064c55932180d)
    
    Conflicts:
            sfx2/source/doc/sfxbasemodel.cxx
    
    Change-Id: I3516c944ece8ed0e26aa13fc9def5857b8344404

diff --git a/sfx2/source/doc/sfxbasemodel.cxx b/sfx2/source/doc/sfxbasemodel.cxx
index d2c8dbee1d3f..6cdd93c34d62 100644
--- a/sfx2/source/doc/sfxbasemodel.cxx
+++ b/sfx2/source/doc/sfxbasemodel.cxx
@@ -119,6 +119,7 @@
 #include <sfx2/DocumentMetadataAccess.hxx>
 #include "printhelper.hxx"
 #include <sfx2/sfxresid.hxx>
+#include <vcl/threadex.hxx>
 
 
 //  namespaces
@@ -1461,6 +1462,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
 
@@ -1474,6 +1483,7 @@ void SAL_CALL SfxBaseModel::storeSelf( const    Sequence< beans::PropertyValue >
         SfxSaveGuard aSaveGuard(this, m_pData);
 
         bool bCheckIn = false;
+        bool bOnMainThread = false;
         for ( sal_Int32 nInd = 0; nInd < aSeqArgs.getLength(); nInd++ )
         {
             // check that only acceptable parameters are provided here
@@ -1483,7 +1493,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" )
             {
                 OUString aMessage( "Unexpected MediaDescriptor parameter: "  );
                 aMessage += aSeqArgs[nInd].Name;
@@ -1493,6 +1504,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
@@ -1544,7 +1559,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 );
+            if (bOnMainThread)
+                bRet = vcl::solarthread::syncExecute(
+                    std::bind(&SaveImplStatic, m_pData->m_pObjectShell.get(), pParams));
+            else
+                bRet = m_pData->m_pObjectShell->Save_Impl(pParams);
             m_pData->m_pObjectShell->GetMedium( )->SetInCheckIn( nSlotId != SID_CHECKIN );
         }
 
commit 4afd4325c435cf2865a5d53b99e26fc777951e4d
Author:     Miklos Vajna <vmiklos at collabora.com>
AuthorDate: Tue Jan 29 18:01:21 2019 +0100
Commit:     Miklos Vajna <vmiklos at collabora.com>
CommitDate: Wed Jan 30 12:18:35 2019 +0100

    framework: allow dispatching a command on the main thread
    
    This is similar to commit 2dc3a6c273cb82506842864481d78df7294debbf
    (framework: allow loading a component on the main thread, 2018-12-19),
    just it allows saving (via .uno:Save) and other commands operating in a
    similar environment.
    
    The use-case is that once a document is loaded on the main thread (see
    commit message of the above mentioned commit), then saving also has to
    happen on the main thread, or OLE objects on Windows may be lost.
    
    Reviewed-on: https://gerrit.libreoffice.org/67089
    Reviewed-by: Miklos Vajna <vmiklos at collabora.com>
    Tested-by: Jenkins
    (cherry picked from commit 22aa6508e0a65e65a6f9410b498fe4fd6c236639)
    
    Conflicts:
            framework/source/services/dispatchhelper.cxx
    
    Change-Id: I7321659550b556e96085ac20f197a87d5d13f1ed

diff --git a/framework/source/services/dispatchhelper.cxx b/framework/source/services/dispatchhelper.cxx
index da6bc9c52997..8ae8e8e876f4 100644
--- a/framework/source/services/dispatchhelper.cxx
+++ b/framework/source/services/dispatchhelper.cxx
@@ -26,6 +26,8 @@
 #include <com/sun/star/frame/XNotifyingDispatch.hpp>
 
 #include <comphelper/processfactory.hxx>
+#include <unotools/mediadescriptor.hxx>
+#include <vcl/threadex.hxx>
 
 namespace framework{
 
@@ -47,6 +49,19 @@ DispatchHelper::DispatchHelper( const css::uno::Reference< css::uno::XComponentC
 {
 }
 
+/**
+ * Proxy around DispatchHelper::executeDispatch(), as
+ * vcl::solarthread::syncExecute() does not seem to accept lambdas.
+ */
+static css::uno::Any
+executeDispatchStatic(DispatchHelper* pThis,
+                      const css::uno::Reference<css::frame::XDispatch>& xDispatch,
+                      const css::util::URL& aURL, bool SyncronFlag,
+                      const css::uno::Sequence<css::beans::PropertyValue>& lArguments)
+{
+    return pThis->executeDispatch(xDispatch, aURL, SyncronFlag, lArguments);
+}
+
 /** dtor.
 */
 DispatchHelper::~DispatchHelper()
@@ -103,7 +118,14 @@ css::uno::Any SAL_CALL DispatchHelper::executeDispatch(
     // search dispatcher
     css::uno::Reference< css::frame::XDispatch >          xDispatch       = xDispatchProvider->queryDispatch(aURL, sTargetFrameName, nSearchFlags);
 
-    return executeDispatch(xDispatch, aURL, true, lArguments);
+    utl::MediaDescriptor aDescriptor(lArguments);
+    bool bOnMainThread = aDescriptor.getUnpackedValueOrDefault("OnMainThread", false);
+
+    if (bOnMainThread)
+        return vcl::solarthread::syncExecute(
+            std::bind(&executeDispatchStatic, this, xDispatch, aURL, true, lArguments));
+    else
+        return executeDispatch(xDispatch, aURL, true, lArguments);
 }
 
 


More information about the Libreoffice-commits mailing list