sc/source/core/data/colcontainer.cxx |    5 +---
 sc/source/core/data/table2.cxx       |    2 +
 sw/inc/swabstdlg.hxx                 |    1 
 sw/source/ui/dialog/swdlgfact.cxx    |    8 +++++-
 sw/source/ui/dialog/swdlgfact.hxx    |    6 +++--
 sw/source/ui/misc/glossary.cxx       |    8 ------
 sw/source/uibase/dochdl/gloshdl.cxx  |   42 +++++++++++++++++++++--------------
 sw/source/uibase/inc/glossary.hxx    |    3 --
 sw/source/uibase/shells/textglos.cxx |    3 --
 9 files changed, 44 insertions(+), 34 deletions(-)

New commits:
commit b4e5aa7bffc32aa15359808085cc69638467f5d5
Author:     Noel Grandin <noel.gran...@collabora.co.uk>
AuthorDate: Tue Jan 30 15:22:36 2024 +0200
Commit:     Noel Grandin <noel.gran...@collabora.co.uk>
CommitDate: Tue Jan 30 20:12:20 2024 +0100

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

diff --git a/sw/inc/swabstdlg.hxx b/sw/inc/swabstdlg.hxx
index 65fbf918efca..f9398ad73fca 100644
--- a/sw/inc/swabstdlg.hxx
+++ b/sw/inc/swabstdlg.hxx
@@ -93,6 +93,7 @@ class AbstractGlossaryDlg : public VclAbstractDialog
 protected:
     virtual ~AbstractGlossaryDlg() override = default;
 public:
+    virtual void Apply() = 0;
     virtual OUString        GetCurrGrpName() const = 0;
     virtual OUString        GetCurrShortName() const = 0;
 };
diff --git a/sw/source/ui/dialog/swdlgfact.cxx 
b/sw/source/ui/dialog/swdlgfact.cxx
index 8676ec08a8d2..8b79dc4446bf 100644
--- a/sw/source/ui/dialog/swdlgfact.cxx
+++ b/sw/source/ui/dialog/swdlgfact.cxx
@@ -270,7 +270,13 @@ short AbstractSwModalRedlineAcceptDlg_Impl::Execute()
 
 short AbstractGlossaryDlg_Impl::Execute()
 {
-    return m_xDlg->run();
+    assert(false);
+    return -1;
+}
+
+bool AbstractGlossaryDlg_Impl::StartExecuteAsync(AsyncContext &rCtx)
+{
+    return weld::GenericDialogController::runAsync(m_xDlg, rCtx.maEndDialogFn);
 }
 
 short AbstractFieldInputDlg_Impl::Execute()
diff --git a/sw/source/ui/dialog/swdlgfact.hxx 
b/sw/source/ui/dialog/swdlgfact.hxx
index 2fd0b0b70183..c8c6de47d489 100644
--- a/sw/source/ui/dialog/swdlgfact.hxx
+++ b/sw/source/ui/dialog/swdlgfact.hxx
@@ -515,13 +515,15 @@ public:
 class SwGlossaryDlg;
 class AbstractGlossaryDlg_Impl : public AbstractGlossaryDlg
 {
-    std::unique_ptr<SwGlossaryDlg> m_xDlg;
+    std::shared_ptr<SwGlossaryDlg> m_xDlg;
 public:
-    explicit AbstractGlossaryDlg_Impl(std::unique_ptr<SwGlossaryDlg> p)
+    explicit AbstractGlossaryDlg_Impl(std::shared_ptr<SwGlossaryDlg> p)
         : m_xDlg(std::move(p))
     {
     }
     virtual short Execute() override;
+    virtual bool StartExecuteAsync(AsyncContext &rCtx) override;
+    virtual void Apply() override { m_xDlg->Apply(); }
     virtual OUString        GetCurrGrpName() const override;
     virtual OUString        GetCurrShortName() const override;
 };
diff --git a/sw/source/ui/misc/glossary.cxx b/sw/source/ui/misc/glossary.cxx
index 9769e78d8a0c..c68d4d75f86f 100644
--- a/sw/source/ui/misc/glossary.cxx
+++ b/sw/source/ui/misc/glossary.cxx
@@ -421,14 +421,6 @@ IMPL_LINK(SwGlossaryDlg, GrpSelect, weld::TreeView&, rBox, 
void)
     }
 }
 
-short SwGlossaryDlg::run()
-{
-    short nRet = SfxDialogController::run();
-    if (nRet == RET_OK)
-        Apply();
-    return nRet;
-}
-
 void SwGlossaryDlg::Apply()
 {
     const OUString aGlosName(m_xShortNameEdit->get_text());
diff --git a/sw/source/uibase/dochdl/gloshdl.cxx 
b/sw/source/uibase/dochdl/gloshdl.cxx
index e70ed7ffc4b2..dcc90033cd9b 100644
--- a/sw/source/uibase/dochdl/gloshdl.cxx
+++ b/sw/source/uibase/dochdl/gloshdl.cxx
@@ -69,25 +69,35 @@ struct TextBlockInfo_Impl
 void SwGlossaryHdl::GlossaryDlg()
 {
     SwAbstractDialogFactory* pFact = SwAbstractDialogFactory::Create();
-    ScopedVclPtr<AbstractGlossaryDlg> 
pDlg(pFact->CreateGlossaryDlg(m_rViewFrame, this, m_pWrtShell));
-    OUString sName;
-    OUString sShortName;
+    VclPtr<AbstractGlossaryDlg> pDlg(pFact->CreateGlossaryDlg(m_rViewFrame, 
this, m_pWrtShell));
 
-    if( RET_EDIT == pDlg->Execute() )
-    {
-        sName = pDlg->GetCurrGrpName();
-        sShortName = pDlg->GetCurrShortName();
-    }
+    pDlg->StartExecuteAsync(
+        [this, pDlg] (sal_Int32 nResult)->void
+        {
+            OUString sName;
+            OUString sShortName;
+            if (nResult == RET_OK)
+                pDlg->Apply();
+            if (nResult == RET_EDIT)
+            {
+                sName = pDlg->GetCurrGrpName();
+                sShortName = pDlg->GetCurrShortName();
+            }
+            pDlg->disposeOnce();
+            m_pCurGrp.reset();
+            if(HasGlossaryList())
+            {
+                GetGlossaryList()->ClearGroups();
+            }
 
-    pDlg.disposeAndClear();
-    m_pCurGrp.reset();
-    if(HasGlossaryList())
-    {
-        GetGlossaryList()->ClearGroups();
-    }
+            if( !sName.isEmpty() || !sShortName.isEmpty() )
+                m_rStatGlossaries.EditGroupDoc( sName, sShortName );
 
-    if( !sName.isEmpty() || !sShortName.isEmpty() )
-        m_rStatGlossaries.EditGroupDoc( sName, sShortName );
+            SwGlossaryList* pList = ::GetGlossaryList();
+            if(pList->IsActive())
+                pList->Update();
+        }
+    );
 }
 
 // set the default group; if called from the dialog
diff --git a/sw/source/uibase/inc/glossary.hxx 
b/sw/source/uibase/inc/glossary.hxx
index b93925f344d1..c65ece04ea49 100644
--- a/sw/source/uibase/inc/glossary.hxx
+++ b/sw/source/uibase/inc/glossary.hxx
@@ -96,7 +96,6 @@ class SwGlossaryDlg final : public SfxDialogController
     DECL_LINK( KeyInputHdl, const KeyEvent&, bool );
     DECL_LINK( TextFilterHdl, OUString&, bool );
 
-    void            Apply();
     void            Init();
     std::unique_ptr<weld::TreeIter> DoesBlockExist(std::u16string_view sBlock, 
std::u16string_view rShort);
     void            ShowAutoText(const OUString& rGroup, const OUString& 
rShortName);
@@ -110,8 +109,8 @@ class SwGlossaryDlg final : public SfxDialogController
     void            DeleteEntry();
 public:
     SwGlossaryDlg(const SfxViewFrame& rViewFrame, SwGlossaryHdl* pGlosHdl, 
SwWrtShell *pWrtShell);
-    virtual short run() override;
     virtual ~SwGlossaryDlg() override;
+    void Apply();
     OUString GetCurrGrpName() const;
     OUString GetCurrShortName() const
     {
diff --git a/sw/source/uibase/shells/textglos.cxx 
b/sw/source/uibase/shells/textglos.cxx
index d229964d2072..7faa1aa58081 100644
--- a/sw/source/uibase/shells/textglos.cxx
+++ b/sw/source/uibase/shells/textglos.cxx
@@ -48,8 +48,7 @@ void SwTextShell::ExecGlossary(SfxRequest &rReq)
     switch( nSlot )
     {
         case FN_GLOSSARY_DLG:
-            pGlosHdl->GlossaryDlg();
-            bUpdateList = true;
+            pGlosHdl->GlossaryDlg(); // async dialog
             rReq.Ignore();
             break;
         case FN_EXPAND_GLOSSARY:
commit 21dd07f95d7dcb95f243753306108c18d9ba115a
Author:     Noel Grandin <noelgran...@collabora.co.uk>
AuthorDate: Tue Jan 30 13:51:20 2024 +0200
Commit:     Noel Grandin <noel.gran...@collabora.co.uk>
CommitDate: Tue Jan 30 20:12:06 2024 +0100

    tdf#159131 Calc is laggy when moving a line (row)
    
    revert  69910b540ae5140123fd2d4d67a9d338f980db53 and
    add a couple of pre-emptive reserve calls, to prevent repeated
    resizing.
    
    I'm not sure why the above commit causes trouble on Windows, but
    not Linux, something in the std::vector::reserve implementation
    no doubt.
    
    Change-Id: I858303a0a1e12d204fd3bbccc6c6c7ce57564e5b
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/162746
    Tested-by: Jenkins
    Reviewed-by: Noel Grandin <noel.gran...@collabora.co.uk>

diff --git a/sc/source/core/data/colcontainer.cxx 
b/sc/source/core/data/colcontainer.cxx
index f6ef8ff7da17..a0a9d845772f 100644
--- a/sc/source/core/data/colcontainer.cxx
+++ b/sc/source/core/data/colcontainer.cxx
@@ -47,10 +47,9 @@ void ScColContainer::Clear()
 void ScColContainer::resize( ScSheetLimits const & rSheetLimits, const size_t 
aNewColSize )
 {
     size_t aOldColSize = aCols.size();
-    if (aNewColSize > aCols.capacity())
-        aCols.reserve( aNewColSize );
+    aCols.resize( aNewColSize );
     for ( size_t nCol = aOldColSize; nCol < aNewColSize; ++nCol )
-        aCols.emplace_back(new ScColumn(rSheetLimits));
+        aCols[nCol].reset(new ScColumn(rSheetLimits));
 }
 
 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sc/source/core/data/table2.cxx b/sc/source/core/data/table2.cxx
index 9dac5733fd41..6f713ca9f957 100644
--- a/sc/source/core/data/table2.cxx
+++ b/sc/source/core/data/table2.cxx
@@ -502,6 +502,7 @@ void ScTable::CopyToClip(
 
     nCol2 = ClampToAllocatedColumns(nCol2);
 
+    pTable->CreateColumnIfNotExists(nCol2);  // prevent repeated resizing
     for ( SCCOL i = nCol1; i <= nCol2; i++)
         aCol[i].CopyToClip(rCxt, nRow1, nRow2, 
pTable->CreateColumnIfNotExists(i));  // notes are handled at column level
 
@@ -1351,6 +1352,7 @@ void ScTable::CopyToTable(
         // can lead to repetitive splitting and rejoining of the same formula 
group, which can get
         // quadratically expensive with large groups. So do the grouping just 
once at the end.
         sc::DelayFormulaGroupingSwitch delayGrouping( pDestTab->rDocument, 
true );
+        pDestTab->CreateColumnIfNotExists(ClampToAllocatedColumns(nCol2)); // 
avoid repeated resizing
         for (SCCOL i = nCol1; i <= ClampToAllocatedColumns(nCol2); i++)
             aCol[i].CopyToColumn(rCxt, nRow1, nRow2, bToUndoDoc ? nFlags : 
nTempFlags, bMarked,
                                  pDestTab->CreateColumnIfNotExists(i), 
pMarkData, bAsLink, bGlobalNamesToLocal);

Reply via email to