[Libreoffice-commits] core.git: framework/source
Libreoffice Gerrit user
logerrit at kemper.freedesktop.org
Tue Jan 29 18:11:20 UTC 2019
framework/source/services/dispatchhelper.cxx | 24 +++++++++++++++++++++++-
1 file changed, 23 insertions(+), 1 deletion(-)
New commits:
commit 22aa6508e0a65e65a6f9410b498fe4fd6c236639
Author: Miklos Vajna <vmiklos at collabora.com>
AuthorDate: Tue Jan 29 18:01:21 2019 +0100
Commit: Miklos Vajna <vmiklos at collabora.com>
CommitDate: Tue Jan 29 19:10:56 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.
Change-Id: I7321659550b556e96085ac20f197a87d5d13f1ed
Reviewed-on: https://gerrit.libreoffice.org/67089
Reviewed-by: Miklos Vajna <vmiklos at collabora.com>
Tested-by: Jenkins
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);
}
More information about the Libreoffice-commits
mailing list