chart2/source/controller/main/ShapeController.cxx |   28 ++++++++------
 sc/source/ui/drawfunc/drawsh.cxx                  |    9 ++--
 sc/source/ui/drawfunc/drtxtob.cxx                 |   42 +++++++++++++++-------
 sd/source/ui/func/futxtatt.cxx                    |   31 ++++++++--------
 sw/source/uibase/shells/drawdlg.cxx               |   38 +++++++++++--------
 sw/source/uibase/shells/drwtxtsh.cxx              |   24 +++++++-----
 6 files changed, 104 insertions(+), 68 deletions(-)

New commits:
commit a9ee88cc47783a809f6c49f5b7326180dc0bbead
Author:     Noel Grandin <noel.gran...@collabora.co.uk>
AuthorDate: Tue Jan 23 12:58:48 2024 +0200
Commit:     Noel Grandin <noel.gran...@collabora.co.uk>
CommitDate: Wed Jan 24 10:51:00 2024 +0100

    make text-table dialog async
    
    Change-Id: Ic24b2b935f1d539cf257194d136d901b52e00a84
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/162433
    Tested-by: Jenkins
    Reviewed-by: Noel Grandin <noel.gran...@collabora.co.uk>

diff --git a/chart2/source/controller/main/ShapeController.cxx 
b/chart2/source/controller/main/ShapeController.cxx
index fe09d3e9af61..c440a7d97925 100644
--- a/chart2/source/controller/main/ShapeController.cxx
+++ b/chart2/source/controller/main/ShapeController.cxx
@@ -320,20 +320,26 @@ void ShapeController::executeDispatch_TextAttributes()
         pDrawViewWrapper->MergeAttrFromMarked( aAttr, false );
     }
     SvxAbstractDialogFactory* pFact = SvxAbstractDialogFactory::Create();
-    ScopedVclPtr< SfxAbstractTabDialog > pDlg(
+    VclPtr< SfxAbstractTabDialog > pDlg(
         pFact->CreateTextTabDialog(pChartWindow, &aAttr, pDrawViewWrapper));
-    if ( pDlg->Execute() == RET_OK )
-    {
-        const SfxItemSet* pOutAttr = pDlg->GetOutputItemSet();
-        if ( bHasMarked )
-        {
-            pDrawViewWrapper->SetAttributes( *pOutAttr );
-        }
-        else
+    pDlg->StartExecuteAsync(
+        [pDlg, bHasMarked, pDrawViewWrapper] (sal_Int32 nResult)->void
         {
-            pDrawViewWrapper->SetDefaultAttr( *pOutAttr, false );
+            if ( RET_OK == nResult )
+            {
+                const SfxItemSet* pOutAttr = pDlg->GetOutputItemSet();
+                if ( bHasMarked )
+                {
+                    pDrawViewWrapper->SetAttributes( *pOutAttr );
+                }
+                else
+                {
+                    pDrawViewWrapper->SetDefaultAttr( *pOutAttr, false );
+                }
+            }
+            pDlg->disposeOnce();
         }
-    }
+    );
 }
 
 void ShapeController::executeDispatch_TransformDialog()
diff --git a/sc/source/ui/drawfunc/drawsh.cxx b/sc/source/ui/drawfunc/drawsh.cxx
index dfc3d94ef79f..19e455fd2169 100644
--- a/sc/source/ui/drawfunc/drawsh.cxx
+++ b/sc/source/ui/drawfunc/drawsh.cxx
@@ -559,10 +559,12 @@ void ScDrawShell::ExecuteTextAttrDlg( SfxRequest& rReq )
     weld::Window* pWin = rViewData.GetDialogParent();
     VclPtr<SfxAbstractTabDialog> pDlg(pFact->CreateTextTabDialog(pWin, 
&aNewAttr, pView));
 
+    auto xRequest = std::make_shared<SfxRequest>(rReq);
+    rReq.Ignore(); // the 'old' request is not relevant any more
     pDlg->StartExecuteAsync(
-        [pDlg, bHasMarked, pView] (sal_Int32 nResult)->void
+        [pDlg, xRequest, bHasMarked, pView] (sal_Int32 nResult)->void
         {
-            if (nResult == RET_OK)
+            if ( RET_OK == nResult )
             {
                 if ( bHasMarked )
                     pView->SetAttributes( *pDlg->GetOutputItemSet() );
@@ -570,12 +572,11 @@ void ScDrawShell::ExecuteTextAttrDlg( SfxRequest& rReq )
                     pView->SetDefaultAttr( *pDlg->GetOutputItemSet(), false );
 
                 pView->InvalidateAttribs();
+                xRequest->Done();
             }
             pDlg->disposeOnce();
         }
     );
-
-    rReq.Done();
 }
 
 void ScDrawShell::ExecuteMeasureDlg( SfxRequest& rReq )
diff --git a/sc/source/ui/drawfunc/drtxtob.cxx 
b/sc/source/ui/drawfunc/drtxtob.cxx
index a04f86a2f44d..b283e0546b6a 100644
--- a/sc/source/ui/drawfunc/drtxtob.cxx
+++ b/sc/source/ui/drawfunc/drtxtob.cxx
@@ -887,19 +887,35 @@ void ScDrawTextObjectBar::ExecuteAttr( SfxRequest &rReq )
             case SID_DRAWTEXT_ATTR_DLG:
                 {
                     SvxAbstractDialogFactory* pFact = 
SvxAbstractDialogFactory::Create();
-                    ScopedVclPtr<SfxAbstractTabDialog> 
pDlg(pFact->CreateTextTabDialog(mrViewData.GetDialogParent(), &aEditAttr, 
pView));
-
-                    bDone = ( RET_OK == pDlg->Execute() );
-
-                    if ( bDone )
-                        aNewAttr.Put( *pDlg->GetOutputItemSet() );
-
-                    pDlg.disposeAndClear();
-
-                    SfxBindings& rBindings = mrViewData.GetBindings();
-                    rBindings.Invalidate( SID_TABLE_VERT_NONE );
-                    rBindings.Invalidate( SID_TABLE_VERT_CENTER );
-                    rBindings.Invalidate( SID_TABLE_VERT_BOTTOM );
+                    VclPtr<SfxAbstractTabDialog> 
pDlg(pFact->CreateTextTabDialog(mrViewData.GetDialogParent(), &aEditAttr, 
pView));
+                    auto xRequest = std::make_shared<SfxRequest>(rReq);
+                    rReq.Ignore(); // the 'old' request is not relevant any 
more
+                    pDlg->StartExecuteAsync(
+                        [this, pDlg, pArgs, aNewAttr, bSet, xRequest, pView] 
(sal_Int32 nResult) mutable -> void
+                        {
+                            if ( RET_OK == nResult )
+                                aNewAttr.Put( *pDlg->GetOutputItemSet() );
+
+                            pDlg->disposeOnce();
+
+                            SfxBindings& rBindings = mrViewData.GetBindings();
+                            rBindings.Invalidate( SID_TABLE_VERT_NONE );
+                            rBindings.Invalidate( SID_TABLE_VERT_CENTER );
+                            rBindings.Invalidate( SID_TABLE_VERT_BOTTOM );
+
+                            if ( bSet || RET_OK == nResult )
+                            {
+                                xRequest->Done( aNewAttr );
+                                pArgs = xRequest->GetArgs();
+                            }
+                            if (pArgs)
+                            {
+                                // use args directly
+                                pView->SetAttributes( *pArgs );
+                                
mrViewData.GetScDrawView()->InvalidateDrawTextAttrs();
+                            }
+                        }
+                    );
                 }
                 break;
         }
diff --git a/sd/source/ui/func/futxtatt.cxx b/sd/source/ui/func/futxtatt.cxx
index 56f8c25696e0..9d9ce86fee67 100644
--- a/sd/source/ui/func/futxtatt.cxx
+++ b/sd/source/ui/func/futxtatt.cxx
@@ -51,28 +51,29 @@ void FuTextAttrDlg::DoExecute( SfxRequest& rReq )
 
     const SfxItemSet* pArgs = rReq.GetArgs();
 
-    if( !pArgs )
+    if( pArgs )
     {
-        SvxAbstractDialogFactory* pFact = SvxAbstractDialogFactory::Create();
-        ScopedVclPtr<SfxAbstractTabDialog> 
pDlg(pFact->CreateTextTabDialog(rReq.GetFrameWeld(), &aNewAttr, mpView));
+        mpView->SetAttributes( *pArgs );
+        return;
+    }
 
-        sal_uInt16 nResult = pDlg->Execute();
+    SvxAbstractDialogFactory* pFact = SvxAbstractDialogFactory::Create();
+    VclPtr<SfxAbstractTabDialog> 
pDlg(pFact->CreateTextTabDialog(rReq.GetFrameWeld(), &aNewAttr, mpView));
 
-        switch( nResult )
+    auto xRequest = std::make_shared<SfxRequest>(rReq);
+    rReq.Ignore(); // the 'old' request is not relevant any more
+    auto pView = mpView; // copy vars we need, FuTextAttrDlg object will be 
gone by the time the dialog completes
+    pDlg->StartExecuteAsync(
+        [pDlg, xRequest, pView] (sal_Int32 nResult)->void
         {
-            case RET_OK:
+            if (nResult == RET_OK)
             {
-                rReq.Done( *( pDlg->GetOutputItemSet() ) );
-
-                pArgs = rReq.GetArgs();
+                xRequest->Done( *pDlg->GetOutputItemSet() );
+                pView->SetAttributes( *xRequest->GetArgs() );
             }
-            break;
-
-            default:
-            return; // Cancel
+            pDlg->disposeOnce();
         }
-    }
-    mpView->SetAttributes( *pArgs );
+    );
 }
 
 } // end of namespace sd
diff --git a/sw/source/uibase/shells/drawdlg.cxx 
b/sw/source/uibase/shells/drawdlg.cxx
index ec93f35029b0..6d4573ac7a04 100644
--- a/sw/source/uibase/shells/drawdlg.cxx
+++ b/sw/source/uibase/shells/drawdlg.cxx
@@ -61,26 +61,32 @@ void SwDrawShell::ExecDrawDlg(SfxRequest& rReq)
         case FN_DRAWTEXT_ATTR_DLG:
         {
             SvxAbstractDialogFactory* pFact = 
SvxAbstractDialogFactory::Create();
-            ScopedVclPtr<SfxAbstractTabDialog> 
pDlg(pFact->CreateTextTabDialog(rReq.GetFrameWeld(), &aNewAttr, pView));
-            sal_uInt16 nResult = pDlg->Execute();
-
-            if (nResult == RET_OK)
-            {
-                if (pView->AreObjectsMarked())
+            VclPtr<SfxAbstractTabDialog> 
pDlg(pFact->CreateTextTabDialog(rReq.GetFrameWeld(), &aNewAttr, pView));
+            auto xRequest = std::make_shared<SfxRequest>(rReq);
+            rReq.Ignore(); // the 'old' request is not relevant any more
+            pDlg->StartExecuteAsync(
+                [pDlg, xRequest, pView, pSh] (sal_Int32 nResult)->void
                 {
-                    pSh->StartAction();
-                    pView->SetAttributes(*pDlg->GetOutputItemSet());
-                    auto vMarkedObjs = pView->GetMarkedObjects();
-                    for (auto pObj : vMarkedObjs)
+                    if (nResult == RET_OK)
                     {
-                        // If the shape has textframe, set its params as well.
-                        if (SwTextBoxHelper::hasTextFrame(pObj))
-                            SwTextBoxHelper::updateTextBoxMargin(pObj);
+                        if (pView->AreObjectsMarked())
+                        {
+                            pSh->StartAction();
+                            pView->SetAttributes(*pDlg->GetOutputItemSet());
+                            auto vMarkedObjs = pView->GetMarkedObjects();
+                            for (auto pObj : vMarkedObjs)
+                            {
+                                // If the shape has textframe, set its params 
as well.
+                                if (SwTextBoxHelper::hasTextFrame(pObj))
+                                    SwTextBoxHelper::updateTextBoxMargin(pObj);
+                            }
+                            xRequest->Done(*(pDlg->GetOutputItemSet()));
+                            pSh->EndAction();
+                        }
                     }
-                    rReq.Done(*(pDlg->GetOutputItemSet()));
-                    pSh->EndAction();
+                    pDlg->disposeOnce();
                 }
-            }
+            );
         }
         break;
 
diff --git a/sw/source/uibase/shells/drwtxtsh.cxx 
b/sw/source/uibase/shells/drwtxtsh.cxx
index 26cd846edcb9..209e3bf0a04a 100644
--- a/sw/source/uibase/shells/drwtxtsh.cxx
+++ b/sw/source/uibase/shells/drwtxtsh.cxx
@@ -439,19 +439,25 @@ void SwDrawTextShell::ExecDraw(SfxRequest &rReq)
                 SfxItemSet aNewAttr(m_pSdrView->GetModel().GetItemPool());
                 m_pSdrView->GetAttributes( aNewAttr );
                 SvxAbstractDialogFactory* pFact = 
SvxAbstractDialogFactory::Create();
-                ScopedVclPtr<SfxAbstractTabDialog> 
pDlg(pFact->CreateTextTabDialog(
+                VclPtr<SfxAbstractTabDialog> pDlg(pFact->CreateTextTabDialog(
                             GetView().GetFrameWeld(),
                             &aNewAttr, m_pSdrView ));
-                sal_uInt16 nResult = pDlg->Execute();
-
-                if (nResult == RET_OK)
-                {
-                    if (m_pSdrView->AreObjectsMarked())
+                auto xRequest = std::make_shared<SfxRequest>(rReq);
+                rReq.Ignore(); // the 'old' request is not relevant any more
+                pDlg->StartExecuteAsync(
+                    [this, pDlg, xRequest] (sal_Int32 nResult)->void
                     {
-                        m_pSdrView->SetAttributes(*pDlg->GetOutputItemSet());
-                        rReq.Done(*(pDlg->GetOutputItemSet()));
+                        if (nResult == RET_OK)
+                        {
+                            if (m_pSdrView->AreObjectsMarked())
+                            {
+                                
m_pSdrView->SetAttributes(*pDlg->GetOutputItemSet());
+                                xRequest->Done(*(pDlg->GetOutputItemSet()));
+                            }
+                        }
+                        pDlg->disposeOnce();
                     }
-                }
+                );
             }
             break;
         case SID_TABLE_VERT_NONE:

Reply via email to