cui/source/factory/dlgfact.cxx   |   21 +++++++++++++++++++++
 cui/source/factory/dlgfact.hxx   |    5 +++++
 include/sfx2/sfxdlg.hxx          |   14 ++++++++++++++
 sfx2/source/dialog/StyleList.cxx |   29 +++++++++++++++++------------
 4 files changed, 57 insertions(+), 12 deletions(-)

New commits:
commit 4fe57c6c8cf2de730eabe890807c058099c20e99
Author:     Szymon Kłos <[email protected]>
AuthorDate: Tue Dec 16 15:26:01 2025 +0000
Commit:     Caolán McNamara <[email protected]>
CommitDate: Thu Feb 26 13:14:23 2026 +0100

    Make New Style Dialog Async
    
    - can be found in "Styles sidebar"
    - top toolbar contains "new by example"
    
    Change-Id: I91d5a34e85d8e2613f1f754fe4c5246e8425cccf
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/195730
    Reviewed-by: Caolán McNamara <[email protected]>
    Tested-by: Jenkins CollaboraOffice <[email protected]>
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/200256
    Tested-by: Caolán McNamara <[email protected]>

diff --git a/cui/source/factory/dlgfact.cxx b/cui/source/factory/dlgfact.cxx
index 0fba26c9628d..207d43ef430f 100644
--- a/cui/source/factory/dlgfact.cxx
+++ b/cui/source/factory/dlgfact.cxx
@@ -30,6 +30,7 @@
 #include <securityoptions.hxx>
 #include <AdditionsDialog.hxx>
 #include <sfx2/app.hxx>
+#include <sfx2/newstyle.hxx>
 #include <sfx2/pageids.hxx>
 #include <svx/dialogs.hrc>
 #include <svx/svxids.hrc>
@@ -1602,6 +1603,26 @@ AbstractDialogFactory_Impl::CreateDiagramDialog(
     return VclPtr<AbstractDiagramDialog_Impl>::Create(pParent, rDiagram);
 }
 
+namespace
+{
+class AbstractNewStyleDialog_Impl final
+    : public vcl::AbstractDialogImpl_Async<AbstractNewStyleDialog, 
SfxNewStyleDlg>
+{
+public:
+    using AbstractDialogImpl_BASE::AbstractDialogImpl_BASE;
+    OUString GetName() const override { return m_pDlg->GetName(); }
+};
+}
+
+VclPtr<AbstractNewStyleDialog>
+AbstractDialogFactory_Impl::CreateNewStyleDialog(
+    weld::Container* pParent,
+    SfxStyleSheetBasePool& rPool,
+    SfxStyleFamily nFamily)
+{
+    return VclPtr<AbstractNewStyleDialog_Impl>::Create(pParent, rPool, 
nFamily);
+}
+
 #ifdef _WIN32
 VclPtr<VclAbstractDialog>
 AbstractDialogFactory_Impl::CreateFileExtCheckDialog(weld::Window* pParent, 
const OUString& sTitle,
diff --git a/cui/source/factory/dlgfact.hxx b/cui/source/factory/dlgfact.hxx
index c949c2fc4eb0..99576b1e491e 100644
--- a/cui/source/factory/dlgfact.hxx
+++ b/cui/source/factory/dlgfact.hxx
@@ -230,6 +230,11 @@ public:
         const OUString& sTitle, const OUString& sText, const OUString& 
sQuestion,
         bool bShowAgain) override;
 
+    virtual VclPtr<AbstractNewStyleDialog> CreateNewStyleDialog(
+        weld::Container* pParent,
+        SfxStyleSheetBasePool& rPool,
+        SfxStyleFamily nFamily) override;
+
 #ifdef _WIN32
     virtual VclPtr<VclAbstractDialog> CreateFileExtCheckDialog(weld::Window* 
pParent,
                                                                const OUString& 
sTitle,
diff --git a/include/sfx2/sfxdlg.hxx b/include/sfx2/sfxdlg.hxx
index ee9c502943a0..af2ea611b659 100644
--- a/include/sfx2/sfxdlg.hxx
+++ b/include/sfx2/sfxdlg.hxx
@@ -26,6 +26,7 @@
 
 #include <sot/formats.hxx>
 #include <sfx2/tabdlg.hxx>
+#include <svl/style.hxx>
 #include <com/sun/star/uno/Reference.h>
 
 class SfxItemSet;
@@ -122,6 +123,15 @@ public:
     virtual void LoadLastUsedMacro() const = 0;
 };
 
+class AbstractNewStyleDialog : virtual public VclAbstractDialog
+{
+protected:
+    virtual ~AbstractNewStyleDialog() override = default;
+
+public:
+    virtual OUString GetName() const = 0;
+};
+
 namespace com::sun::star::frame { class XFrame; }
 
 class SFX2_DLLPUBLIC SfxAbstractDialogFactory : virtual public 
VclAbstractDialogFactory
@@ -169,6 +179,10 @@ public:
     virtual VclPtr<VclAbstractDialog> CreateWidgetTestDialog(weld::Window* 
_pParent) = 0;
 
     virtual VclPtr<SfxAbstractTabDialog> CreateWelcomeDialog(weld::Window* 
pParent, const bool bIsFirstStart) =0;
+
+    virtual VclPtr<AbstractNewStyleDialog>     
CreateNewStyleDialog(weld::Container* pParent,
+                                                                    
SfxStyleSheetBasePool& rPool,
+                                                                    
SfxStyleFamily nFamily) = 0;
 };
 
 #endif
diff --git a/sfx2/source/dialog/StyleList.cxx b/sfx2/source/dialog/StyleList.cxx
index 9d7064b0c94b..fe23f59cc1db 100644
--- a/sfx2/source/dialog/StyleList.cxx
+++ b/sfx2/source/dialog/StyleList.cxx
@@ -43,10 +43,10 @@
 #include <sfx2/bindings.hxx>
 #include <templdgi.hxx>
 #include <tplcitem.hxx>
+#include <sfx2/sfxdlg.hxx>
 #include <sfx2/styfitem.hxx>
 #include <sfx2/objsh.hxx>
 #include <sfx2/viewsh.hxx>
-#include <sfx2/newstyle.hxx>
 #include <sfx2/tplpitem.hxx>
 #include <sfx2/sfxresid.hxx>
 
@@ -578,17 +578,22 @@ IMPL_LINK_NOARG(StyleList, NewMenuExecuteAction, void*, 
void)
         nFilter = m_nAppFilter;
 
     // why? : FloatingWindow must not be parent of a modal dialog
-    SfxNewStyleDlg aDlg(m_pContainer, *m_pStyleSheetPool, eFam);
-    auto nResult = aDlg.run();
-    if (nResult == RET_OK)
-    {
-        const OUString aTemplName(aDlg.GetName());
-        m_pParentDialog->Execute_Impl(SID_STYLE_NEW_BY_EXAMPLE, aTemplName, 
u""_ustr,
-                                      
static_cast<sal_uInt16>(GetFamilyItem()->GetFamily()), *this,
-                                      nFilter);
-        UpdateFamily();
-        m_aUpdateFamily.Call(*this);
-    }
+    SfxAbstractDialogFactory* pFact = SfxAbstractDialogFactory::Create();
+    VclPtr<AbstractNewStyleDialog> pDlg(
+        pFact->CreateNewStyleDialog(m_pContainer, *m_pStyleSheetPool, eFam));
+
+    pDlg->StartExecuteAsync([this, pDlg, eFam, nFilter](sal_Int32 nResult) {
+        if (nResult == RET_OK)
+        {
+            const OUString aTemplName(pDlg->GetName());
+            m_pParentDialog->Execute_Impl(SID_STYLE_NEW_BY_EXAMPLE, 
aTemplName, u""_ustr,
+                                          static_cast<sal_uInt16>(eFam), 
*this, nFilter);
+            UpdateFamily();
+            m_aUpdateFamily.Call(*this);
+        }
+
+        pDlg->disposeOnce();
+    });
 }
 
 void StyleList::DropHdl(const OUString& rStyle, const OUString& rParent)

Reply via email to