diff options
-rw-r--r-- | framework/source/services/dispatchhelper.cxx | 24 |
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); } |