summaryrefslogtreecommitdiff
path: root/sc
diff options
context:
space:
mode:
authorEike Rathke <erack@redhat.com>2015-08-13 18:34:27 +0200
committerCaolán McNamara <caolanm@redhat.com>2015-08-17 12:32:27 +0000
commitcbf080ab3ff57da62820c9a0ac42974dae91b3a3 (patch)
treeea7f30ea0058288a59fb6525d2d2d37a5425d6b6 /sc
parent3d2c83982dac10bcc7f73d87134a20aec945fbc5 (diff)
Resolves: tdf#93098 replace remembered listener when replacing cell
... where SvtListener* is the base of ScFormulaCell* and lead to use after delete. Change-Id: I45b8e16f05cf5d4d0d4858dc9cd0c748f8184978 (cherry picked from commit ea29d320754fdb21b336cb78f816b8081371def9) Reviewed-on: https://gerrit.libreoffice.org/17727 Reviewed-by: Caolán McNamara <caolanm@redhat.com> Tested-by: Caolán McNamara <caolanm@redhat.com>
Diffstat (limited to 'sc')
-rw-r--r--sc/source/core/data/table3.cxx16
1 files changed, 14 insertions, 2 deletions
diff --git a/sc/source/core/data/table3.cxx b/sc/source/core/data/table3.cxx
index 46d38c83039e..6b2d692c92f4 100644
--- a/sc/source/core/data/table3.cxx
+++ b/sc/source/core/data/table3.cxx
@@ -711,6 +711,7 @@ public:
void fillSortedColumnArray(
boost::ptr_vector<SortedColumn>& rSortedCols,
SortedRowFlags& rRowFlags,
+ std::vector<SvtListener*>& rCellListeners,
ScSortInfoArray* pArray, SCTAB nTab, SCCOL nCol1, SCCOL nCol2, ScProgress* pProgress )
{
SCROW nRow1 = pArray->GetStart();
@@ -768,6 +769,16 @@ void fillSortedColumnArray(
pNew->GetCode()->AdjustReferenceOnMovedOriginIfOtherSheet(aOldPos, aCellPos);
}
+ if (!rCellListeners.empty())
+ {
+ // Original source cells will be deleted during
+ // sc::CellStoreType::transfer(), SvtListener is a base
+ // class, so we need to replace it.
+ auto it( ::std::find( rCellListeners.begin(), rCellListeners.end(), rCell.maCell.mpFormula));
+ if (it != rCellListeners.end())
+ *it = pNew;
+ }
+
rCellStore.push_back(pNew);
}
break;
@@ -1083,7 +1094,7 @@ void ScTable::SortReorderByRow(
// a copy before updating the document.
boost::ptr_vector<SortedColumn> aSortedCols; // storage for copied cells.
SortedRowFlags aRowFlags;
- fillSortedColumnArray(aSortedCols, aRowFlags, pArray, nTab, nCol1, nCol2, pProgress);
+ fillSortedColumnArray(aSortedCols, aRowFlags, aCellListeners, pArray, nTab, nCol1, nCol2, pProgress);
for (size_t i = 0, n = aSortedCols.size(); i < n; ++i)
{
@@ -1268,7 +1279,8 @@ void ScTable::SortReorderByRowRefUpdate(
// a copy before updating the document.
boost::ptr_vector<SortedColumn> aSortedCols; // storage for copied cells.
SortedRowFlags aRowFlags;
- fillSortedColumnArray(aSortedCols, aRowFlags, pArray, nTab, nCol1, nCol2, pProgress);
+ std::vector<SvtListener*> aListenersDummy;
+ fillSortedColumnArray(aSortedCols, aRowFlags, aListenersDummy, pArray, nTab, nCol1, nCol2, pProgress);
for (size_t i = 0, n = aSortedCols.size(); i < n; ++i)
{