Kaydet (Commit) ea29d320 authored tarafından Eike Rathke's avatar Eike Rathke

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
üst 86b47f51
...@@ -710,6 +710,7 @@ public: ...@@ -710,6 +710,7 @@ public:
void fillSortedColumnArray( void fillSortedColumnArray(
boost::ptr_vector<SortedColumn>& rSortedCols, boost::ptr_vector<SortedColumn>& rSortedCols,
SortedRowFlags& rRowFlags, SortedRowFlags& rRowFlags,
std::vector<SvtListener*>& rCellListeners,
ScSortInfoArray* pArray, SCTAB nTab, SCCOL nCol1, SCCOL nCol2, ScProgress* pProgress ) ScSortInfoArray* pArray, SCTAB nTab, SCCOL nCol1, SCCOL nCol2, ScProgress* pProgress )
{ {
SCROW nRow1 = pArray->GetStart(); SCROW nRow1 = pArray->GetStart();
...@@ -767,6 +768,16 @@ void fillSortedColumnArray( ...@@ -767,6 +768,16 @@ void fillSortedColumnArray(
pNew->GetCode()->AdjustReferenceOnMovedOriginIfOtherSheet(aOldPos, aCellPos); 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); rCellStore.push_back(pNew);
} }
break; break;
...@@ -1082,7 +1093,7 @@ void ScTable::SortReorderByRow( ...@@ -1082,7 +1093,7 @@ void ScTable::SortReorderByRow(
// a copy before updating the document. // a copy before updating the document.
boost::ptr_vector<SortedColumn> aSortedCols; // storage for copied cells. boost::ptr_vector<SortedColumn> aSortedCols; // storage for copied cells.
SortedRowFlags aRowFlags; 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) for (size_t i = 0, n = aSortedCols.size(); i < n; ++i)
{ {
...@@ -1267,7 +1278,8 @@ void ScTable::SortReorderByRowRefUpdate( ...@@ -1267,7 +1278,8 @@ void ScTable::SortReorderByRowRefUpdate(
// a copy before updating the document. // a copy before updating the document.
boost::ptr_vector<SortedColumn> aSortedCols; // storage for copied cells. boost::ptr_vector<SortedColumn> aSortedCols; // storage for copied cells.
SortedRowFlags aRowFlags; 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) for (size_t i = 0, n = aSortedCols.size(); i < n; ++i)
{ {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment