diff options
author | Miklos Vajna <vmiklos@collabora.com> | 2019-02-05 14:35:17 +0100 |
---|---|---|
committer | Miklos Vajna <vmiklos@collabora.com> | 2019-02-05 17:19:48 +0100 |
commit | b030e83fccbff8d82a4c84462075baa8442cde54 (patch) | |
tree | ea43fbba2864d484ed90348d639f70484e498e87 | |
parent | e7ce52acd75cf90ff90ed5fb6a809b5813337411 (diff) |
sfx2: allow storeToURL() on the main thread
This is similar to commit f1e775470e68fb1ca1fee390c10064c55932180d
(framework: allow storeSelf() on the main thread, 2019-01-30), just this
handles "save as" instead of "save".
The result is that combining this commit with the previous OnMainThread
ones allows all of document load/save/save-as/command-dispatch on the
main thread even when the action is invoked via remote UNO, which would
run on a non-main thread by default.
Change-Id: I7d50cceb66ecc6619fe25734107a2524ca872c2a
Reviewed-on: https://gerrit.libreoffice.org/67412
Reviewed-by: Miklos Vajna <vmiklos@collabora.com>
Tested-by: Jenkins
-rw-r--r-- | include/sfx2/sfxbasemodel.hxx | 7 | ||||
-rw-r--r-- | sfx2/source/doc/sfxbasemodel.cxx | 20 |
2 files changed, 21 insertions, 6 deletions
diff --git a/include/sfx2/sfxbasemodel.hxx b/include/sfx2/sfxbasemodel.hxx index d885f1385333..0f93d8652b6c 100644 --- a/include/sfx2/sfxbasemodel.hxx +++ b/include/sfx2/sfxbasemodel.hxx @@ -407,6 +407,9 @@ public: virtual void SAL_CALL storeToURL( const OUString& sURL, const css::uno::Sequence< css::beans::PropertyValue >& seqArguments ) override; + SAL_DLLPRIVATE void + impl_store(const OUString& sURL, + const css::uno::Sequence<css::beans::PropertyValue>& seqArguments, bool bSaveTo); // XLoadable @@ -715,10 +718,6 @@ private: SAL_DLLPRIVATE void ListenForStorage_Impl( const css::uno::Reference< css::embed::XStorage >& xStorage ); SAL_DLLPRIVATE OUString GetMediumFilterName_Impl(); - SAL_DLLPRIVATE void impl_store( const OUString& sURL, - const css::uno::Sequence< css::beans::PropertyValue >& seqArguments , - bool bSaveTo ) ; - SAL_DLLPRIVATE void postEvent_Impl( const OUString& aName, const css::uno::Reference< css::frame::XController2 >& xController = css::uno::Reference< css::frame::XController2 >() ); SAL_DLLPRIVATE css::uno::Reference< css::frame::XTitle > impl_getTitleHelper (); diff --git a/sfx2/source/doc/sfxbasemodel.cxx b/sfx2/source/doc/sfxbasemodel.cxx index 9d8b48f35cf4..e163345dac7a 100644 --- a/sfx2/source/doc/sfxbasemodel.cxx +++ b/sfx2/source/doc/sfxbasemodel.cxx @@ -126,7 +126,7 @@ #include <sfx2/sfxresid.hxx> #include <comphelper/profilezone.hxx> #include <vcl/threadex.hxx> - +#include <unotools/mediadescriptor.hxx> // namespaces @@ -1504,6 +1504,17 @@ static bool SaveImplStatic(SfxObjectShell* pThis, const SfxItemSet* pParams) return pThis->Save_Impl(pParams); } +/** + * Proxy around SfxBaseModel::impl_store(), as vcl::solarthread::syncExecute() + * does not seem to accept lambdas or void functions. + */ +static bool ImplStoreStatic(SfxBaseModel* pThis, const OUString& rURL, + const uno::Sequence<beans::PropertyValue>& rArgs, bool bSaveTo) +{ + pThis->impl_store(rURL, rArgs, bSaveTo); + return true; +} + // XStorable2 @@ -1688,7 +1699,12 @@ void SAL_CALL SfxBaseModel::storeToURL( const OUString& rURL { SfxSaveGuard aSaveGuard(this, m_pData.get()); try { - impl_store(rURL, rArgs, true); + utl::MediaDescriptor aDescriptor(rArgs); + bool bOnMainThread = aDescriptor.getUnpackedValueOrDefault("OnMainThread", false); + if (bOnMainThread) + vcl::solarthread::syncExecute(std::bind(&ImplStoreStatic, this, rURL, rArgs, true)); + else + impl_store(rURL, rArgs, true); } catch (const uno::Exception &e) { |