cui/source/factory/dlgfact.cxx  |    2 -
 cui/source/inc/cuitabarea.hxx   |    2 +
 cui/source/tabpages/tphatch.cxx |   57 +++++++++++++++++++++++-----------------
 3 files changed, 36 insertions(+), 25 deletions(-)

New commits:
commit 5aa806563aa634da71eb46570664235a1306d86a
Author:     Caolán McNamara <[email protected]>
AuthorDate: Tue Jan 20 12:35:53 2026 +0000
Commit:     Caolán McNamara <[email protected]>
CommitDate: Tue Feb 24 11:50:32 2026 +0100

    name hatch add and retry message async
    
    Change-Id: I323767ab25f0d5a0c7e4b12741bb97d26b8c214d
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/197663
    Tested-by: Jenkins CollaboraOffice <[email protected]>
    Reviewed-by: Miklos Vajna <[email protected]>
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/200131
    Reviewed-by: Caolán McNamara <[email protected]>

diff --git a/cui/source/factory/dlgfact.cxx b/cui/source/factory/dlgfact.cxx
index 259cc071ab77..0fba26c9628d 100644
--- a/cui/source/factory/dlgfact.cxx
+++ b/cui/source/factory/dlgfact.cxx
@@ -746,7 +746,7 @@ VclPtr<VclAbstractDialog> 
AbstractDialogFactory_Impl::CreateSvxEditDictionaryDia
 namespace
 {
 class AbstractSvxNameDialog_Impl final
-    : public vcl::AbstractDialogImpl_Sync<AbstractSvxNameDialog, SvxNameDialog>
+    : public vcl::AbstractDialogImpl_Async<AbstractSvxNameDialog, 
SvxNameDialog>
 {
 public:
     using AbstractDialogImpl_BASE::AbstractDialogImpl_BASE;
diff --git a/cui/source/inc/cuitabarea.hxx b/cui/source/inc/cuitabarea.hxx
index c7a787bc7ae0..8eca1094fb62 100644
--- a/cui/source/inc/cuitabarea.hxx
+++ b/cui/source/inc/cuitabarea.hxx
@@ -28,6 +28,7 @@
 #include <svx/svdview.hxx>
 #include <vcl/hexcolorcontrol.hxx>
 
+class AbstractSvxNameDialog;
 class ColorListBox;
 class SdrModel;
 class SvxBitmapCtl;
@@ -485,6 +486,7 @@ private:
     sal_Int32 SearchHatchList(std::u16string_view rHatchName);
 
     void AddHatch(const OUString& aName, tools::Long nCount);
+    void runNameDialog(VclPtr<AbstractSvxNameDialog> pDlg, tools::Long nCount);
 
 public:
     SvxHatchTabPage(weld::Container* pPage, weld::DialogController* 
pController, const SfxItemSet& rInAttrs);
diff --git a/cui/source/tabpages/tphatch.cxx b/cui/source/tabpages/tphatch.cxx
index 166d16057e4d..dc2b039e09dc 100644
--- a/cui/source/tabpages/tphatch.cxx
+++ b/cui/source/tabpages/tphatch.cxx
@@ -434,6 +434,37 @@ void SvxHatchTabPage::AddHatch(const OUString& aName, 
tools::Long nCount)
     ChangeHatchHdl_Impl();
 }
 
+void SvxHatchTabPage::runNameDialog(VclPtr<AbstractSvxNameDialog> pDlg, 
tools::Long nCount)
+{
+    pDlg->StartExecuteAsync([pDlg, nCount, this](sal_Int32 nResult) {
+        if (nResult != RET_OK)
+        {
+            pDlg->disposeOnce();
+            return;
+        }
+
+        OUString aName = pDlg->GetName();
+
+        bool bValidHatchName = (SearchHatchList(aName) == -1);
+        if( bValidHatchName )
+        {
+            pDlg->disposeOnce();
+            AddHatch(aName, nCount);
+            return;
+        }
+
+        // Offer to try again
+        auto xWarnBox = 
std::make_shared<weld::MessageDialogController>(GetFrameWeld(),
+                "cui/ui/queryduplicatedialog.ui", "DuplicateNameDialog");
+        weld::DialogController::runAsync(xWarnBox, [pDlg, nCount, 
this](sal_Int32 nWarnResult) {
+            if (nWarnResult == RET_OK)
+                runNameDialog(pDlg, nCount);
+            else
+                pDlg->disposeOnce();
+        });
+    });
+}
+
 IMPL_LINK_NOARG(SvxHatchTabPage, ClickAddHdl_Impl, weld::Button&, void)
 {
     OUString aNewName( SvxResId( RID_SVXSTR_HATCH ) );
@@ -451,31 +482,9 @@ IMPL_LINK_NOARG(SvxHatchTabPage, ClickAddHdl_Impl, 
weld::Button&, void)
     }
 
     SvxAbstractDialogFactory* pFact = SvxAbstractDialogFactory::Create();
-    ScopedVclPtr<AbstractSvxNameDialog> 
pDlg(pFact->CreateSvxNameDialog(GetFrameWeld(), aName, aDesc));
-    sal_uInt16         nError   = 1;
-
-    while( pDlg->Execute() == RET_OK )
-    {
-        aName = pDlg->GetName();
-
-        bValidHatchName = (SearchHatchList(aName) == -1);
-        if( bValidHatchName )
-        {
-            nError = 0;
-            break;
-        }
-
-        std::unique_ptr<weld::Builder> 
xBuilder(Application::CreateBuilder(GetFrameWeld(), 
u"cui/ui/queryduplicatedialog.ui"_ustr));
-        std::unique_ptr<weld::MessageDialog> 
xWarnBox(xBuilder->weld_message_dialog(u"DuplicateNameDialog"_ustr));
-        if (xWarnBox->run() != RET_OK)
-            break;
-    }
-    pDlg.disposeAndClear();
-
-    if( nError )
-        return;
+    VclPtr<AbstractSvxNameDialog> 
pDlg(pFact->CreateSvxNameDialog(GetFrameWeld(), aName, aDesc));
 
-    AddHatch(aName, nCount);
+    runNameDialog(pDlg, nCount);
 }
 
 IMPL_LINK_NOARG(SvxHatchTabPage, ClickModifyHdl_Impl, weld::Button&, void)

Reply via email to