starmath/source/document.cxx |  127 +++++++++++++++++++++----------------------
 1 file changed, 64 insertions(+), 63 deletions(-)

New commits:
commit 66be4e60100c34d315149418931a3dfb69581cdd
Author:     Gülşah Köse <gulsah.k...@collabora.com>
AuthorDate: Fri Apr 4 18:39:21 2025 +0300
Commit:     Szymon Kłos <szymon.k...@collabora.com>
CommitDate: Mon Apr 7 10:23:19 2025 +0200

    ONLINE: Make new formula dialogs async
    
    .uno:ChangeFont
    .uno:ChangeFontSize
    .uno:ChangeDistance
    .uno:ChangeAlignment
    
    Signed-off-by: Gülşah Köse <gulsah.k...@collabora.com>
    Change-Id: I938fb49db7f8bbbd57c2af90e4b3629391c59089
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/183720
    Tested-by: Jenkins CollaboraOffice <jenkinscollaboraoff...@gmail.com>
    Reviewed-by: Szymon Kłos <szymon.k...@collabora.com>

diff --git a/starmath/source/document.cxx b/starmath/source/document.cxx
index 42b6cfeb11ce..a4217d286be6 100644
--- a/starmath/source/document.cxx
+++ b/starmath/source/document.cxx
@@ -887,97 +887,98 @@ void SmDocShell::Execute(SfxRequest& rReq)
                 pDev = &SmModule::get()->GetDefaultVirtualDev();
             OSL_ENSURE (pDev, "device for font list missing" );
 
-            SmFontTypeDialog aFontTypeDialog(rReq.GetFrameWeld(), pDev);
-
+            auto pFontTypeDialog = 
std::make_shared<SmFontTypeDialog>(rReq.GetFrameWeld(), pDev);
             SmFormat aOldFormat  = GetFormat();
-            aFontTypeDialog.ReadFrom( aOldFormat );
-            if (aFontTypeDialog.run() == RET_OK)
-            {
-                SmFormat aNewFormat( aOldFormat );
+            pFontTypeDialog->ReadFrom( aOldFormat );
+            weld::DialogController::runAsync( pFontTypeDialog, [aOldFormat, 
pFontTypeDialog, this](sal_Int32 nResult) {
+                if (nResult == RET_OK)
+                {
+                    SmFormat aNewFormat( aOldFormat );
+                    pFontTypeDialog->WriteTo(aNewFormat);
 
-                aFontTypeDialog.WriteTo(aNewFormat);
-                SfxUndoManager *pTmpUndoMgr = GetUndoManager();
-                if (pTmpUndoMgr)
-                    pTmpUndoMgr->AddUndoAction(
-                        std::make_unique<SmFormatAction>(this, aOldFormat, 
aNewFormat));
+                    SfxUndoManager *pTmpUndoMgr = GetUndoManager();
+                    if (pTmpUndoMgr)
+                        pTmpUndoMgr->AddUndoAction(
+                            std::make_unique<SmFormatAction>(this, aOldFormat, 
aNewFormat));
 
-                SetFormat( aNewFormat );
-                Repaint();
-            }
+                    SetFormat( aNewFormat );
+                    Repaint();
+                }
+            });
         }
         break;
 
         case SID_FONTSIZE:
         {
-            SmFontSizeDialog aFontSizeDialog(rReq.GetFrameWeld());
-
+            auto pFontSizeDialog = 
std::make_shared<SmFontSizeDialog>(rReq.GetFrameWeld());
             SmFormat aOldFormat  = GetFormat();
-            aFontSizeDialog.ReadFrom( aOldFormat );
-            if (aFontSizeDialog.run() == RET_OK)
-            {
-                SmFormat aNewFormat( aOldFormat );
-
-                aFontSizeDialog.WriteTo(aNewFormat);
+            pFontSizeDialog->ReadFrom( aOldFormat );
+            weld::DialogController::runAsync(pFontSizeDialog, [aOldFormat, 
pFontSizeDialog, this](sal_Int32 nResult) {
+                if (nResult == RET_OK)
+                {
+                    SmFormat aNewFormat( aOldFormat );
+                    pFontSizeDialog->WriteTo(aNewFormat);
 
-                SfxUndoManager *pTmpUndoMgr = GetUndoManager();
-                if (pTmpUndoMgr)
-                    pTmpUndoMgr->AddUndoAction(
-                        std::make_unique<SmFormatAction>(this, aOldFormat, 
aNewFormat));
+                    SfxUndoManager *pTmpUndoMgr = GetUndoManager();
+                    if (pTmpUndoMgr)
+                        pTmpUndoMgr->AddUndoAction(
+                            std::make_unique<SmFormatAction>(this, aOldFormat, 
aNewFormat));
 
-                SetFormat( aNewFormat );
-                Repaint();
-            }
+                    SetFormat( aNewFormat );
+                    Repaint();
+                }
+            });
         }
         break;
 
         case SID_DISTANCE:
         {
-            SmDistanceDialog aDistanceDialog(rReq.GetFrameWeld());
-
+            auto pDistanceDialog = 
std::make_shared<SmDistanceDialog>(rReq.GetFrameWeld());
             SmFormat aOldFormat  = GetFormat();
-            aDistanceDialog.ReadFrom( aOldFormat );
-            if (aDistanceDialog.run() == RET_OK)
-            {
-                SmFormat aNewFormat( aOldFormat );
-
-                aDistanceDialog.WriteTo(aNewFormat);
+            pDistanceDialog->ReadFrom( aOldFormat );
+            weld::DialogController::runAsync(pDistanceDialog, [aOldFormat, 
pDistanceDialog, this](sal_Int32 nResult) {
+                if (nResult == RET_OK)
+                {
+                    SmFormat aNewFormat( aOldFormat );
+                    pDistanceDialog->WriteTo(aNewFormat);
 
-                SfxUndoManager *pTmpUndoMgr = GetUndoManager();
-                if (pTmpUndoMgr)
-                    pTmpUndoMgr->AddUndoAction(
-                        std::make_unique<SmFormatAction>(this, aOldFormat, 
aNewFormat));
+                    SfxUndoManager *pTmpUndoMgr = GetUndoManager();
+                    if (pTmpUndoMgr)
+                        pTmpUndoMgr->AddUndoAction(
+                            std::make_unique<SmFormatAction>(this, aOldFormat, 
aNewFormat));
 
-                SetFormat( aNewFormat );
-                Repaint();
-            }
+                    SetFormat( aNewFormat );
+                    Repaint();
+                }
+            });
         }
         break;
 
         case SID_ALIGN:
         {
-            SmAlignDialog aAlignDialog(rReq.GetFrameWeld());
-
+            auto pAlignDialog = 
std::make_shared<SmAlignDialog>(rReq.GetFrameWeld());
             SmFormat aOldFormat  = GetFormat();
-            aAlignDialog.ReadFrom( aOldFormat );
-            if (aAlignDialog.run() == RET_OK)
-            {
-                SmFormat aNewFormat( aOldFormat );
-
-                aAlignDialog.WriteTo(aNewFormat);
+            pAlignDialog->ReadFrom( aOldFormat );
+            weld::DialogController::runAsync(pAlignDialog, [aOldFormat, 
pAlignDialog, this](sal_Int32 nResult) {
+                if (nResult == RET_OK)
+                {
+                    SmFormat aNewFormat( aOldFormat );
+                    pAlignDialog->WriteTo(aNewFormat);
 
-                auto* config = SmModule::get()->GetConfig();
-                SmFormat aFmt(config->GetStandardFormat());
-                aAlignDialog.WriteTo( aFmt );
-                config->SetStandardFormat(aFmt);
+                    auto* config = SmModule::get()->GetConfig();
+                    SmFormat aFmt(config->GetStandardFormat());
+                    pAlignDialog->WriteTo( aFmt );
+                    config->SetStandardFormat(aFmt);
 
-                SfxUndoManager *pTmpUndoMgr = GetUndoManager();
-                if (pTmpUndoMgr)
-                    pTmpUndoMgr->AddUndoAction(
-                        std::make_unique<SmFormatAction>(this, aOldFormat, 
aNewFormat));
+                    SfxUndoManager *pTmpUndoMgr = GetUndoManager();
+                    if (pTmpUndoMgr)
+                        pTmpUndoMgr->AddUndoAction(
+                            std::make_unique<SmFormatAction>(this, aOldFormat, 
aNewFormat));
 
-                SetFormat( aNewFormat );
-                Repaint();
-            }
+                    SetFormat( aNewFormat );
+                    Repaint();
+                }
+            });
         }
         break;
 

Reply via email to