Kaydet (Commit) b030e83f authored tarafından Miklos Vajna's avatar Miklos Vajna

sfx2: allow storeToURL() on the main thread

This is similar to commit f1e77547
(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/67412Reviewed-by: 's avatarMiklos Vajna <vmiklos@collabora.com>
Tested-by: Jenkins
üst e7ce52ac
...@@ -407,6 +407,9 @@ public: ...@@ -407,6 +407,9 @@ public:
virtual void SAL_CALL storeToURL( const OUString& sURL, virtual void SAL_CALL storeToURL( const OUString& sURL,
const css::uno::Sequence< css::beans::PropertyValue >& seqArguments ) override; 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 // XLoadable
...@@ -715,10 +718,6 @@ private: ...@@ -715,10 +718,6 @@ private:
SAL_DLLPRIVATE void ListenForStorage_Impl( const css::uno::Reference< css::embed::XStorage >& xStorage ); SAL_DLLPRIVATE void ListenForStorage_Impl( const css::uno::Reference< css::embed::XStorage >& xStorage );
SAL_DLLPRIVATE OUString GetMediumFilterName_Impl(); 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 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 (); SAL_DLLPRIVATE css::uno::Reference< css::frame::XTitle > impl_getTitleHelper ();
......
...@@ -126,7 +126,7 @@ ...@@ -126,7 +126,7 @@
#include <sfx2/sfxresid.hxx> #include <sfx2/sfxresid.hxx>
#include <comphelper/profilezone.hxx> #include <comphelper/profilezone.hxx>
#include <vcl/threadex.hxx> #include <vcl/threadex.hxx>
#include <unotools/mediadescriptor.hxx>
// namespaces // namespaces
...@@ -1504,6 +1504,17 @@ static bool SaveImplStatic(SfxObjectShell* pThis, const SfxItemSet* pParams) ...@@ -1504,6 +1504,17 @@ static bool SaveImplStatic(SfxObjectShell* pThis, const SfxItemSet* pParams)
return pThis->Save_Impl(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 // XStorable2
...@@ -1688,7 +1699,12 @@ void SAL_CALL SfxBaseModel::storeToURL( const OUString& rURL ...@@ -1688,7 +1699,12 @@ void SAL_CALL SfxBaseModel::storeToURL( const OUString& rURL
{ {
SfxSaveGuard aSaveGuard(this, m_pData.get()); SfxSaveGuard aSaveGuard(this, m_pData.get());
try { 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) catch (const uno::Exception &e)
{ {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment