sc/inc/mtvelements.hxx              |    2 ++
 sc/source/core/data/column.cxx      |    1 +
 sc/source/core/data/mtvelements.cxx |    5 +++++
 3 files changed, 8 insertions(+)

New commits:
commit 8f25d42938977b34f3281238a92fb34ebea5838c
Author:     Kohei Yoshida <ko...@libreoffice.org>
AuthorDate: Thu Feb 24 21:06:50 2022 -0500
Commit:     Kohei Yoshida <ko...@libreoffice.org>
CommitDate: Fri Feb 25 15:50:00 2022 +0100

    tdf#147298: When swapping the cell stores, swap back the event handlers.
    
    Swapping the cell stores also swap the event handlers stored therein.
    But we do want the event handlers to stay with the original column
    instances as they store pointers to their host column instances.
    
    Change-Id: Id35b89db641e94dbaa341b33d0b64dce19a99465
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/130510
    Reviewed-by: Kohei Yoshida <ko...@libreoffice.org>
    Tested-by: Kohei Yoshida <ko...@libreoffice.org>

diff --git a/sc/inc/mtvelements.hxx b/sc/inc/mtvelements.hxx
index 05a0970bd64d..75cdea9483bd 100644
--- a/sc/inc/mtvelements.hxx
+++ b/sc/inc/mtvelements.hxx
@@ -98,6 +98,8 @@ public:
 
     /** Stop processing events. */
     void stop();
+
+    void swap(CellStoreEvent& other);
 };
 
 struct CellStoreTrait
diff --git a/sc/source/core/data/column.cxx b/sc/source/core/data/column.cxx
index 167a3541f511..5e19d1b05ada 100644
--- a/sc/source/core/data/column.cxx
+++ b/sc/source/core/data/column.cxx
@@ -1975,6 +1975,7 @@ void ScColumn::SwapCol(ScColumn& rCol)
     maCellNotes.swap(rCol.maCellNotes);
 
     // Swap all CellStoreEvent mdds event_func related.
+    maCells.event_handler().swap(rCol.maCells.event_handler());
     std::swap( mnBlkCountFormula, rCol.mnBlkCountFormula);
 
     // notes update caption
diff --git a/sc/source/core/data/mtvelements.cxx 
b/sc/source/core/data/mtvelements.cxx
index ee6c9cf1499c..a06e86dcae16 100644
--- a/sc/source/core/data/mtvelements.cxx
+++ b/sc/source/core/data/mtvelements.cxx
@@ -56,6 +56,11 @@ void CellStoreEvent::stop()
     mpCol = nullptr;
 }
 
+void CellStoreEvent::swap(CellStoreEvent& other)
+{
+    std::swap(mpCol, other.mpCol);
+}
+
 ColumnBlockPositionSet::ColumnBlockPositionSet(ScDocument& rDoc) : mrDoc(rDoc) 
{}
 
 ColumnBlockPosition* ColumnBlockPositionSet::getBlockPosition(SCTAB nTab, 
SCCOL nCol)

Reply via email to