summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMuhammet Kara <muhammet.kara@collabora.com>2019-07-10 22:08:01 +0300
committerMuhammet Kara <muhammet.kara@collabora.com>2019-07-11 07:14:31 +0200
commit4e3304892171a494101c4defc4d805599cf1fc7b (patch)
tree4c6a98610fbb27d26980a58d2d62c5cc6533d5c7
parentd064b51afc84af92f877dc33c683c9521a6cd937 (diff)
lokdialog: Convert the Paste Special dialog to async exec for sw
Change-Id: I0c75def6ea09bcb191a8023421b371b49205e712 Reviewed-on: https://gerrit.libreoffice.org/75378 Tested-by: Jenkins Reviewed-by: Muhammet Kara <muhammet.kara@collabora.com>
-rw-r--r--cui/source/factory/dlgfact.cxx5
-rw-r--r--cui/source/factory/dlgfact.hxx3
-rw-r--r--sw/source/uibase/shells/basesh.cxx30
3 files changed, 24 insertions, 14 deletions
diff --git a/cui/source/factory/dlgfact.cxx b/cui/source/factory/dlgfact.cxx
index 19bd83ed5ad0..bd23fc1981d3 100644
--- a/cui/source/factory/dlgfact.cxx
+++ b/cui/source/factory/dlgfact.cxx
@@ -264,6 +264,11 @@ short AbstractPasteDialog_Impl::Execute()
return m_xDlg->run();
}
+bool AbstractPasteDialog_Impl::StartExecuteAsync(AsyncContext &rCtx)
+{
+ return SfxDialogController::runAsync(m_xDlg, rCtx.maEndDialogFn);
+}
+
short AbstractInsertObjectDialog_Impl::Execute()
{
return m_xDlg->run();
diff --git a/cui/source/factory/dlgfact.hxx b/cui/source/factory/dlgfact.hxx
index f0e343947aaf..0badc8fffd98 100644
--- a/cui/source/factory/dlgfact.hxx
+++ b/cui/source/factory/dlgfact.hxx
@@ -561,13 +561,14 @@ public:
class AbstractPasteDialog_Impl : public SfxAbstractPasteDialog
{
- std::unique_ptr<SvPasteObjectDialog> m_xDlg;
+ std::shared_ptr<SvPasteObjectDialog> m_xDlg;
public:
explicit AbstractPasteDialog_Impl(std::unique_ptr<SvPasteObjectDialog> p)
: m_xDlg(std::move(p))
{
}
virtual short Execute() override;
+ virtual bool StartExecuteAsync(AsyncContext &rCtx) override;
public:
virtual void Insert( SotClipboardFormatId nFormat, const OUString & rFormatName ) override;
virtual void SetObjName( const SvGlobalName & rClass, const OUString & rObjName ) override;
diff --git a/sw/source/uibase/shells/basesh.cxx b/sw/source/uibase/shells/basesh.cxx
index dc5e0c5be334..156c969797d1 100644
--- a/sw/source/uibase/shells/basesh.cxx
+++ b/sw/source/uibase/shells/basesh.cxx
@@ -374,34 +374,36 @@ void SwBaseShell::ExecClpbrd(SfxRequest &rReq)
case SID_PASTE_SPECIAL:
{
- TransferableDataHelper aDataHelper(
- TransferableDataHelper::CreateFromSystemClipboard( &rSh.GetView().GetEditWin()) );
- if( aDataHelper.GetXTransferable().is()
- && SwTransferable::IsPaste( rSh, aDataHelper )
+ std::shared_ptr<TransferableDataHelper> aDataHelper;
+ aDataHelper.reset(new TransferableDataHelper(TransferableDataHelper::CreateFromSystemClipboard( &rSh.GetView().GetEditWin())));
+
+ if( aDataHelper->GetXTransferable().is()
+ && SwTransferable::IsPaste( rSh, *aDataHelper )
&& !rSh.CursorInsideInputField() )
{
- // Temporary variables, because the shell could already be
- // destroyed after the paste.
- SwView* pView = &rView;
- SotClipboardFormatId nFormatId = SotClipboardFormatId::NONE;
rReq.Ignore();
bIgnore = true;
- bool bRet = false;
SvxAbstractDialogFactory* pFact = SvxAbstractDialogFactory::Create();
VclPtr<SfxAbstractPasteDialog> pDlg(pFact->CreatePasteDialog( rReq.GetFrameWeld() ));
// Prepare the dialog
- SwTransferable::PrePasteSpecial(rSh, aDataHelper, pDlg);
- pDlg->PreGetFormat(aDataHelper);
+ SwTransferable::PrePasteSpecial(rSh, *aDataHelper, pDlg);
+ pDlg->PreGetFormat(*aDataHelper);
- if (pDlg->Execute() == RET_OK)
+ pDlg->StartExecuteAsync([=, &rSh](sal_Int32 nResult){
+ if (nResult == RET_OK)
{
+ // Temporary variables, because the shell could already be
+ // destroyed after the paste.
+ SwView* pView = &rView;
+ bool bRet = false;
+ SotClipboardFormatId nFormatId = SotClipboardFormatId::NONE;
nFormatId = pDlg->GetFormatOnly();
if( nFormatId != SotClipboardFormatId::NONE )
- bRet = SwTransferable::PasteFormat( rSh, aDataHelper, nFormatId );
+ bRet = SwTransferable::PasteFormat( rSh, *aDataHelper, nFormatId );
if (bRet)
{
@@ -421,6 +423,8 @@ void SwBaseShell::ExecClpbrd(SfxRequest &rReq)
}
pDlg->disposeOnce();
+
+ });
}
else
return;