summaryrefslogtreecommitdiff
path: root/framework
diff options
context:
space:
mode:
authorMiklos Vajna <vmiklos@collabora.com>2019-01-29 18:01:21 +0100
committerMiklos Vajna <vmiklos@collabora.com>2019-01-29 19:10:56 +0100
commit22aa6508e0a65e65a6f9410b498fe4fd6c236639 (patch)
treee523df0985be81fdf6ba65d998d6b8485aa285d4 /framework
parent1554ec8430728a0dca2dc0177b93bda8d1256065 (diff)
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. Change-Id: I7321659550b556e96085ac20f197a87d5d13f1ed Reviewed-on: https://gerrit.libreoffice.org/67089 Reviewed-by: Miklos Vajna <vmiklos@collabora.com> Tested-by: Jenkins
Diffstat (limited to 'framework')
-rw-r--r--framework/source/services/dispatchhelper.cxx24
1 files changed, 23 insertions, 1 deletions
diff --git a/framework/source/services/dispatchhelper.cxx b/framework/source/services/dispatchhelper.cxx
index 3a1e6166197d..53a55d873249 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/profilezone.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);
}