chart2/source/controller/main/ChartController_TextEdit.cxx |   77 +++++++------
 cui/source/factory/dlgfact.cxx                             |    2 
 cui/source/factory/dlgfact.hxx                             |    2 
 sc/source/ui/view/cellsh1.cxx                              |    9 +
 sc/source/ui/view/viewutil.cxx                             |    9 +
 sd/source/ui/func/fubullet.cxx                             |    9 +
 starmath/source/view.cxx                                   |    9 +
 sw/source/ui/misc/insfnote.cxx                             |   51 ++++----
 sw/source/ui/misc/srtdlg.cxx                               |   20 ++-
 sw/source/uibase/shells/annotsh.cxx                        |    9 +
 sw/source/uibase/shells/drwtxtsh.cxx                       |    9 +
 sw/source/uibase/shells/textsh.cxx                         |    9 +
 12 files changed, 135 insertions(+), 80 deletions(-)

New commits:
commit 6a5ef1a2b009f208745a251828bf8e8c51146bfe
Author:     Noel Grandin <noel.gran...@collabora.co.uk>
AuthorDate: Mon Jan 22 12:35:50 2024 +0200
Commit:     Noel Grandin <noel.gran...@collabora.co.uk>
CommitDate: Mon Jan 22 19:48:14 2024 +0100

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

diff --git a/chart2/source/controller/main/ChartController_TextEdit.cxx 
b/chart2/source/controller/main/ChartController_TextEdit.cxx
index f2d21779ba69..10d89fd92442 100644
--- a/chart2/source/controller/main/ChartController_TextEdit.cxx
+++ b/chart2/source/controller/main/ChartController_TextEdit.cxx
@@ -177,42 +177,49 @@ void 
ChartController::executeDispatch_InsertSpecialCharacter()
     vcl::Font aCurFont = 
m_pDrawViewWrapper->getOutliner()->GetRefDevice()->GetFont();
     aSet.Put( SvxFontItem( aCurFont.GetFamilyType(), aCurFont.GetFamilyName(), 
aCurFont.GetStyleName(), aCurFont.GetPitch(), aCurFont.GetCharSet(), 
SID_ATTR_CHAR_FONT ) );
 
-    ScopedVclPtr<SfxAbstractDialog> 
pDlg(pFact->CreateCharMapDialog(GetChartFrame(), aSet, nullptr));
-    if( pDlg->Execute() != RET_OK )
-        return;
-
-    const SfxItemSet* pSet = pDlg->GetOutputItemSet();
-    OUString aString;
-    if (pSet)
-        if (const SfxStringItem* pCharMapItem = 
pSet->GetItemIfSet(SID_CHARMAP))
-            aString = pCharMapItem->GetValue();
-
-    OutlinerView* pOutlinerView = 
m_pDrawViewWrapper->GetTextEditOutlinerView();
-    SdrOutliner*  pOutliner = m_pDrawViewWrapper->getOutliner();
-
-    if(!pOutliner || !pOutlinerView)
-        return;
-
-    // insert string to outliner
-
-    // prevent flicker
-    pOutlinerView->HideCursor();
-    pOutliner->SetUpdateLayout(false);
-
-    // delete current selection by inserting empty String, so current
-    // attributes become unique (sel. has to be erased anyway)
-    pOutlinerView->InsertText(OUString());
-
-    pOutlinerView->InsertText(aString, true);
-
-    ESelection aSel = pOutlinerView->GetSelection();
-    aSel.nStartPara = aSel.nEndPara;
-    aSel.nStartPos = aSel.nEndPos;
-    pOutlinerView->SetSelection(aSel);
+    VclPtr<SfxAbstractDialog> pDlg(pFact->CreateCharMapDialog(GetChartFrame(), 
aSet, nullptr));
+    pDlg->StartExecuteAsync(
+        [this, pDlg] (sal_Int32 nResult)->void
+        {
+            if (nResult == RET_OK)
+            {
+                const SfxItemSet* pSet = pDlg->GetOutputItemSet();
+                OUString aString;
+                if (pSet)
+                    if (const SfxStringItem* pCharMapItem = 
pSet->GetItemIfSet(SID_CHARMAP))
+                        aString = pCharMapItem->GetValue();
+
+                OutlinerView* pOutlinerView = 
m_pDrawViewWrapper->GetTextEditOutlinerView();
+                SdrOutliner*  pOutliner = m_pDrawViewWrapper->getOutliner();
+
+                if(pOutliner && pOutlinerView)
+                {
+                    // insert string to outliner
+
+                    // prevent flicker
+                    pOutlinerView->HideCursor();
+                    pOutliner->SetUpdateLayout(false);
+
+                    // delete current selection by inserting empty String, so 
current
+                    // attributes become unique (sel. has to be erased anyway)
+                    pOutlinerView->InsertText(OUString());
+
+                    pOutlinerView->InsertText(aString, true);
+
+                    ESelection aSel = pOutlinerView->GetSelection();
+                    aSel.nStartPara = aSel.nEndPara;
+                    aSel.nStartPos = aSel.nEndPos;
+                    pOutlinerView->SetSelection(aSel);
+
+                    // show changes
+                    pOutliner->SetUpdateLayout(true);
+                    pOutlinerView->ShowCursor();
+                }
+            }
+            pDlg->disposeOnce();
+        }
+    );
 
-    // show changes
-    pOutliner->SetUpdateLayout(true);
-    pOutlinerView->ShowCursor();
 }
 
 rtl::Reference< ::chart::AccessibleTextHelper >
diff --git a/cui/source/factory/dlgfact.cxx b/cui/source/factory/dlgfact.cxx
index ec4532f2058d..c0d0b1deb958 100644
--- a/cui/source/factory/dlgfact.cxx
+++ b/cui/source/factory/dlgfact.cxx
@@ -115,7 +115,7 @@ IMPL_ABSTDLG_CLASS(AbstractLinksDialog)
 IMPL_ABSTDLG_CLASS(AbstractScreenshotAnnotationDlg)
 IMPL_ABSTDLG_CLASS(AbstractSignatureLineDialog)
 IMPL_ABSTDLG_CLASS(AbstractSignSignatureLineDialog)
-IMPL_ABSTDLG_CLASS(AbstractSvxCharacterMapDialog)
+IMPL_ABSTDLG_CLASS_ASYNC(AbstractSvxCharacterMapDialog, SvxCharacterMap)
 IMPL_ABSTDLG_CLASS(AbstractSvxHpLinkDlg)
 IMPL_ABSTDLG_CLASS(AbstractSvxJSearchOptionsDialog)
 IMPL_ABSTDLG_CLASS(AbstractSvxMultiPathDialog)
diff --git a/cui/source/factory/dlgfact.hxx b/cui/source/factory/dlgfact.hxx
index ec76db9490bf..e8e5186731c5 100644
--- a/cui/source/factory/dlgfact.hxx
+++ b/cui/source/factory/dlgfact.hxx
@@ -393,7 +393,7 @@ 
DECL_ABSTDLG_CLASS_SHARED_ASYNC(AbstractPasswordToOpenModifyDialog,AbstractPassw
 };
 
 // AbstractSvxCharacterMapDialog_Impl
-DECL_ABSTDLG_CLASS_UNIQUE(AbstractSvxCharacterMapDialog,SfxAbstractDialog,SvxCharacterMap)
+DECL_ABSTDLG_CLASS_SHARED_ASYNC(AbstractSvxCharacterMapDialog,SfxAbstractDialog,SvxCharacterMap)
     virtual const SfxItemSet* GetOutputItemSet() const override;
     virtual void  SetText(const OUString& rStr) override;
 };
diff --git a/sc/source/ui/view/cellsh1.cxx b/sc/source/ui/view/cellsh1.cxx
index e13229b6ed7b..ea9c1d948cc6 100644
--- a/sc/source/ui/view/cellsh1.cxx
+++ b/sc/source/ui/view/cellsh1.cxx
@@ -2812,8 +2812,13 @@ void ScCellShell::ExecuteEdit( SfxRequest& rReq )
                 aSet.Put( SvxFontItem( aCurFont.GetFamilyType(), 
aCurFont.GetFamilyName(), aCurFont.GetStyleName(), aCurFont.GetPitch(), 
aCurFont.GetCharSet(), GetPool().GetWhich(SID_ATTR_CHAR_FONT) ) );
                 SfxViewFrame& rViewFrame = pTabViewShell->GetViewFrame();
                 auto xFrame = rViewFrame.GetFrame().GetFrameInterface();
-                ScopedVclPtr<SfxAbstractDialog> 
pDlg(pFact->CreateCharMapDialog(pTabViewShell->GetFrameWeld(), aSet, xFrame));
-                pDlg->Execute();
+                VclPtr<SfxAbstractDialog> 
pDlg(pFact->CreateCharMapDialog(pTabViewShell->GetFrameWeld(), aSet, xFrame));
+                pDlg->StartExecuteAsync(
+                    [pDlg] (sal_Int32 /*nResult*/)->void
+                    {
+                        pDlg->disposeOnce();
+                    }
+                );
             }
             break;
 
diff --git a/sc/source/ui/view/viewutil.cxx b/sc/source/ui/view/viewutil.cxx
index 68575ac79f3e..379c7dd8d9aa 100644
--- a/sc/source/ui/view/viewutil.cxx
+++ b/sc/source/ui/view/viewutil.cxx
@@ -324,8 +324,13 @@ void ScViewUtil::ExecuteCharMap(const SvxFontItem& 
rOldFont,
     aSet.Put( SfxBoolItem( FN_PARAM_1, false ) );
     aSet.Put( SvxFontItem( rOldFont.GetFamily(), rOldFont.GetFamilyName(), 
rOldFont.GetStyleName(), rOldFont.GetPitch(), rOldFont.GetCharSet(), 
aSet.GetPool()->GetWhich( SID_ATTR_CHAR_FONT ) ) );
     auto xFrame = rFrame.GetFrame().GetFrameInterface();
-    ScopedVclPtr<SfxAbstractDialog> 
pDlg(pFact->CreateCharMapDialog(rShell.GetFrameWeld(), aSet, xFrame));
-    pDlg->Execute();
+    VclPtr<SfxAbstractDialog> 
pDlg(pFact->CreateCharMapDialog(rShell.GetFrameWeld(), aSet, xFrame));
+    pDlg->StartExecuteAsync(
+        [pDlg] (sal_Int32 /*nResult*/)->void
+        {
+            pDlg->disposeOnce();
+        }
+    );
 }
 
 bool ScViewUtil::IsFullScreen( const SfxViewShell& rViewShell )
diff --git a/sd/source/ui/func/fubullet.cxx b/sd/source/ui/func/fubullet.cxx
index 688ac67a83e6..e163665ea6e5 100644
--- a/sd/source/ui/func/fubullet.cxx
+++ b/sd/source/ui/func/fubullet.cxx
@@ -190,13 +190,18 @@ void FuBullet::InsertSpecialCharacter( SfxRequest const & 
rReq )
 
         SvxAbstractDialogFactory* pFact = SvxAbstractDialogFactory::Create();
         auto xFrame = mpViewShell ? 
mpViewShell->GetFrame()->GetFrame().GetFrameInterface() : nullptr;
-        ScopedVclPtr<SfxAbstractDialog> pDlg( 
pFact->CreateCharMapDialog(mpView->GetViewShell()->GetFrameWeld(), aSet,
+        VclPtr<SfxAbstractDialog> pDlg( 
pFact->CreateCharMapDialog(mpView->GetViewShell()->GetFrameWeld(), aSet,
             xFrame) );
 
         // If a character is selected, it can be shown
         // pDLg->SetFont( );
         // pDlg->SetChar( );
-        pDlg->Execute();
+        pDlg->StartExecuteAsync(
+            [pDlg] (sal_Int32 /*nResult*/)->void
+            {
+                pDlg->disposeOnce();
+            }
+        );
         return;
     }
 
diff --git a/starmath/source/view.cxx b/starmath/source/view.cxx
index 8f88b5ced643..9c704baa6aa7 100644
--- a/starmath/source/view.cxx
+++ b/starmath/source/view.cxx
@@ -1815,10 +1815,15 @@ void SmViewShell::Execute(SfxRequest& rReq)
             aSet.Put(SfxBoolItem(FN_PARAM_1, false));
             aSet.Put(SfxStringItem(SID_FONT_NAME,
                                    
GetDoc()->GetFormat().GetFont(FNT_VARIABLE).GetFamilyName()));
-            ScopedVclPtr<SfxAbstractDialog> pDialog(
+            VclPtr<SfxAbstractDialog> pDialog(
                 pFact->CreateCharMapDialog(pWin ? pWin->GetFrameWeld() : 
nullptr, aSet,
                                            
GetViewFrame().GetFrame().GetFrameInterface()));
-            pDialog->Execute();
+            pDialog->StartExecuteAsync(
+                [pDialog] (sal_Int32 /*nResult*/)->void
+                {
+                    pDialog->disposeOnce();
+                }
+            );
         }
         break;
 
diff --git a/sw/source/ui/misc/insfnote.cxx b/sw/source/ui/misc/insfnote.cxx
index f468ae51c662..49a9e7070640 100644
--- a/sw/source/ui/misc/insfnote.cxx
+++ b/sw/source/ui/misc/insfnote.cxx
@@ -101,29 +101,36 @@ IMPL_LINK_NOARG(SwInsFootNoteDlg, NumberExtCharHdl, 
weld::Button&, void)
     aAllSet.Put( rFont );
 
     SvxAbstractDialogFactory* pFact = SvxAbstractDialogFactory::Create();
-    ScopedVclPtr<SfxAbstractDialog> 
pDlg(pFact->CreateCharMapDialog(m_xDialog.get(), aAllSet, nullptr));
-    if (RET_OK != pDlg->Execute())
-        return;
-
-    const SfxStringItem* pItem = 
SfxItemSet::GetItem<SfxStringItem>(pDlg->GetOutputItemSet(), SID_CHARMAP, 
false);
-    const SvxFontItem* pFontItem = 
SfxItemSet::GetItem<SvxFontItem>(pDlg->GetOutputItemSet(), SID_ATTR_CHAR_FONT, 
false);
-    if ( !pItem )
-        return;
-
-    m_xNumberCharEdit->set_text(pItem->GetValue());
-
-    if ( pFontItem )
-    {
-        m_aFontName = pFontItem->GetFamilyName();
-        m_eCharSet  = pFontItem->GetCharSet();
-        vcl::Font aFont(m_aFontName, pFontItem->GetStyleName(), 
m_xNumberCharEdit->get_font().GetFontSize());
-        aFont.SetCharSet( pFontItem->GetCharSet() );
-        aFont.SetPitch( pFontItem->GetPitch() );
-        m_xNumberCharEdit->set_font(aFont);
-    }
+    VclPtr<SfxAbstractDialog> pDlg(pFact->CreateCharMapDialog(m_xDialog.get(), 
aAllSet, nullptr));
+    pDlg->StartExecuteAsync(
+        [this, pDlg] (sal_Int32 nResult)->void
+        {
+            if (nResult == RET_OK)
+            {
+                const SfxStringItem* pItem = 
SfxItemSet::GetItem<SfxStringItem>(pDlg->GetOutputItemSet(), SID_CHARMAP, 
false);
+                const SvxFontItem* pFontItem = 
SfxItemSet::GetItem<SvxFontItem>(pDlg->GetOutputItemSet(), SID_ATTR_CHAR_FONT, 
false);
+                if ( pItem )
+                {
+                    m_xNumberCharEdit->set_text(pItem->GetValue());
+
+                    if ( pFontItem )
+                    {
+                        m_aFontName = pFontItem->GetFamilyName();
+                        m_eCharSet  = pFontItem->GetCharSet();
+                        vcl::Font aFont(m_aFontName, 
pFontItem->GetStyleName(), m_xNumberCharEdit->get_font().GetFontSize());
+                        aFont.SetCharSet( pFontItem->GetCharSet() );
+                        aFont.SetPitch( pFontItem->GetPitch() );
+                        m_xNumberCharEdit->set_font(aFont);
+                    }
+
+                    m_bExtCharAvailable = true;
+                    
m_xOkBtn->set_sensitive(!m_xNumberCharEdit->get_text().isEmpty());
+                }
+            }
+            pDlg->disposeOnce();
+        }
+    );
 
-    m_bExtCharAvailable = true;
-    m_xOkBtn->set_sensitive(!m_xNumberCharEdit->get_text().isEmpty());
 }
 
 IMPL_LINK( SwInsFootNoteDlg, NextPrevHdl, weld::Button&, rBtn, void )
diff --git a/sw/source/ui/misc/srtdlg.cxx b/sw/source/ui/misc/srtdlg.cxx
index cd45654b8d08..724390ff6edb 100644
--- a/sw/source/ui/misc/srtdlg.cxx
+++ b/sw/source/ui/misc/srtdlg.cxx
@@ -326,13 +326,19 @@ IMPL_LINK_NOARG(SwSortDlg, DelimCharHdl, weld::Button&, 
void)
     SvxAbstractDialogFactory* pFact = SvxAbstractDialogFactory::Create();
     SfxAllItemSet aSet( m_rSh.GetAttrPool() );
     aSet.Put( SfxInt32Item( SID_ATTR_CHAR, GetDelimChar() ) );
-    ScopedVclPtr<SfxAbstractDialog> 
pMap(pFact->CreateCharMapDialog(m_xDialog.get(), aSet, nullptr));
-    if( RET_OK == pMap->Execute() )
-    {
-        const SfxInt32Item* pItem = 
SfxItemSet::GetItem<SfxInt32Item>(pMap->GetOutputItemSet(), SID_ATTR_CHAR, 
false);
-        if ( pItem )
-            m_xDelimEdt->set_text(OUString(sal_Unicode(pItem->GetValue())));
-    }
+    VclPtr<SfxAbstractDialog> pDlg(pFact->CreateCharMapDialog(m_xDialog.get(), 
aSet, nullptr));
+    pDlg->StartExecuteAsync(
+        [this, pDlg] (sal_Int32 nResult)->void
+        {
+            if (nResult == RET_OK)
+            {
+                const SfxInt32Item* pItem = 
SfxItemSet::GetItem<SfxInt32Item>(pDlg->GetOutputItemSet(), SID_ATTR_CHAR, 
false);
+                if ( pItem )
+                    
m_xDelimEdt->set_text(OUString(sal_Unicode(pItem->GetValue())));
+            }
+            pDlg->disposeOnce();
+        }
+    );
 }
 
 IMPL_LINK( SwSortDlg, CheckHdl, weld::Toggleable&, rControl, void )
diff --git a/sw/source/uibase/shells/annotsh.cxx 
b/sw/source/uibase/shells/annotsh.cxx
index d3a2735068a6..11861d1c6ed5 100644
--- a/sw/source/uibase/shells/annotsh.cxx
+++ b/sw/source/uibase/shells/annotsh.cxx
@@ -1791,8 +1791,13 @@ void SwAnnotationShell::InsertSymbol(SfxRequest& rReq)
 
         // If character is selected then it can be shown.
         auto xFrame = m_rView.GetViewFrame().GetFrame().GetFrameInterface();
-        ScopedVclPtr<SfxAbstractDialog> 
pDlg(pFact->CreateCharMapDialog(m_rView.GetFrameWeld(), aAllSet, xFrame));
-        pDlg->Execute();
+        VclPtr<SfxAbstractDialog> 
pDlg(pFact->CreateCharMapDialog(m_rView.GetFrameWeld(), aAllSet, xFrame));
+        pDlg->StartExecuteAsync(
+            [pDlg] (sal_Int32 /*nResult*/)->void
+            {
+                pDlg->disposeOnce();
+            }
+        );
         return;
     }
 
diff --git a/sw/source/uibase/shells/drwtxtsh.cxx 
b/sw/source/uibase/shells/drwtxtsh.cxx
index d97b666d5fa5..26cd846edcb9 100644
--- a/sw/source/uibase/shells/drwtxtsh.cxx
+++ b/sw/source/uibase/shells/drwtxtsh.cxx
@@ -727,8 +727,13 @@ void SwDrawTextShell::InsertSymbol(SfxRequest& rReq)
         // If character is selected, it can be shown
         SvxAbstractDialogFactory* pFact = SvxAbstractDialogFactory::Create();
         auto xFrame = m_rView.GetViewFrame().GetFrame().GetFrameInterface();
-        ScopedVclPtr<SfxAbstractDialog> 
pDlg(pFact->CreateCharMapDialog(m_rView.GetFrameWeld(), aAllSet, xFrame));
-        pDlg->Execute();
+        VclPtr<SfxAbstractDialog> 
pDlg(pFact->CreateCharMapDialog(m_rView.GetFrameWeld(), aAllSet, xFrame));
+        pDlg->StartExecuteAsync(
+            [pDlg] (sal_Int32 /*nResult*/)->void
+            {
+                pDlg->disposeOnce();
+            }
+        );
         return;
     }
 
diff --git a/sw/source/uibase/shells/textsh.cxx 
b/sw/source/uibase/shells/textsh.cxx
index 0924935b3d7e..c2d1d44068d9 100644
--- a/sw/source/uibase/shells/textsh.cxx
+++ b/sw/source/uibase/shells/textsh.cxx
@@ -997,8 +997,13 @@ void SwTextShell::InsertSymbol( SfxRequest& rReq )
 
         SvxAbstractDialogFactory* pFact = SvxAbstractDialogFactory::Create();
         auto xFrame = GetView().GetViewFrame().GetFrame().GetFrameInterface();
-        ScopedVclPtr<SfxAbstractDialog> 
pDlg(pFact->CreateCharMapDialog(GetView().GetFrameWeld(), aAllSet, xFrame));
-        pDlg->Execute();
+        VclPtr<SfxAbstractDialog> 
pDlg(pFact->CreateCharMapDialog(GetView().GetFrameWeld(), aAllSet, xFrame));
+        pDlg->StartExecuteAsync(
+            [pDlg] (sal_Int32 /*nResult*/)->void
+            {
+                pDlg->disposeOnce();
+            }
+        );
         return;
     }
 

Reply via email to