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 <kohei@libreoffice.org>
Tested-by: Kohei Yoshida <kohei@libreoffice.org>
(cherry picked from commit 8f25d42938977b34f3281238a92fb34ebea5838c)
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/130464
Tested-by: Jenkins
diff --git a/sc/inc/mtvelements.hxx b/sc/inc/mtvelements.hxx
index 05a0970..75cdea9 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 20cfc19..9d56430 100644
--- a/sc/source/core/data/column.cxx
+++ b/sc/source/core/data/column.cxx
@@ -1970,6 +1970,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 ee6c9cf..a06e86d 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)