[Libreoffice-commits] core.git: cui/source sw/source

Muhammet Kara (via logerrit) logerrit at kemper.freedesktop.org
Thu Jul 11 05:15:18 UTC 2019


 cui/source/factory/dlgfact.cxx     |    5 +++++
 cui/source/factory/dlgfact.hxx     |    3 ++-
 sw/source/uibase/shells/basesh.cxx |   30 +++++++++++++++++-------------
 3 files changed, 24 insertions(+), 14 deletions(-)

New commits:
commit 4e3304892171a494101c4defc4d805599cf1fc7b
Author:     Muhammet Kara <muhammet.kara at collabora.com>
AuthorDate: Wed Jul 10 22:08:01 2019 +0300
Commit:     Muhammet Kara <muhammet.kara at collabora.com>
CommitDate: Thu Jul 11 07:14:31 2019 +0200

    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 at collabora.com>

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;


More information about the Libreoffice-commits mailing list