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

fdo#86762 re-establish listeners on moved broadcasters

...  also in SortReorderByColumn() similar to SortReorderByRow()

Change-Id: I7665dcc90d70fcf3b08bef0adb9ab6aaff1cdcdf
üst 08793e08
...@@ -715,6 +715,28 @@ void ScTable::SortReorderByColumn( ...@@ -715,6 +715,28 @@ void ScTable::SortReorderByColumn(
for (SCCOL nCol = nStart; nCol <= nLast; ++nCol) for (SCCOL nCol = nStart; nCol <= nLast; ++nCol)
aCol[nCol].SplitFormulaGroupByRelativeRef(aSortRange); aCol[nCol].SplitFormulaGroupByRelativeRef(aSortRange);
// Collect all listeners of cell broadcasters of sorted range.
std::vector<SvtListener*> aCellListeners;
if (!pArray->IsUpdateRefs())
{
// Collect listeners of cell broadcasters.
for (SCCOL nCol = nStart; nCol <= nLast; ++nCol)
aCol[nCol].CollectListeners(aCellListeners, nRow1, nRow2);
// Remove any duplicate listener entries. We must ensure that we
// notify each unique listener only once.
std::sort(aCellListeners.begin(), aCellListeners.end());
aCellListeners.erase(std::unique(aCellListeners.begin(), aCellListeners.end()), aCellListeners.end());
// Notify the cells' listeners to stop listening.
/* TODO: for performance this could be enhanced to stop and later
* restart only listening to within the reordered range and keep
* listening to everything outside untouched. */
StopListeningNotifier aFunc;
std::for_each(aCellListeners.begin(), aCellListeners.end(), aFunc);
}
// table to keep track of column index to position in the index table. // table to keep track of column index to position in the index table.
std::vector<SCCOLROW> aPosTable(nCount); std::vector<SCCOLROW> aPosTable(nCount);
for (size_t i = 0; i < nCount; ++i) for (size_t i = 0; i < nCount; ++i)
...@@ -743,6 +765,8 @@ void ScTable::SortReorderByColumn( ...@@ -743,6 +765,8 @@ void ScTable::SortReorderByColumn(
for (SCCOL nCol = nStart; nCol <= nLast; ++nCol) for (SCCOL nCol = nStart; nCol <= nLast; ++nCol)
aCol[nCol].ResetFormulaCellPositions(nRow1, nRow2, bUpdateRefs); aCol[nCol].ResetFormulaCellPositions(nRow1, nRow2, bUpdateRefs);
if (pArray->IsUpdateRefs())
{
// Set up column reorder map (for later broadcasting of reference updates). // Set up column reorder map (for later broadcasting of reference updates).
sc::ColRowReorderMapType aColMap; sc::ColRowReorderMapType aColMap;
const std::vector<SCCOLROW>& rOldIndices = pArray->GetOrderIndices(); const std::vector<SCCOLROW>& rOldIndices = pArray->GetOrderIndices();
...@@ -756,8 +780,11 @@ void ScTable::SortReorderByColumn( ...@@ -756,8 +780,11 @@ void ScTable::SortReorderByColumn(
// Collect all listeners within sorted range ahead of time. // Collect all listeners within sorted range ahead of time.
std::vector<SvtListener*> aListeners; std::vector<SvtListener*> aListeners;
// Get all area listeners that listen on one column within the range and for (SCCOL nCol = nStart; nCol <= nLast; ++nCol)
// end their listening. aCol[nCol].CollectListeners(aListeners, nRow1, nRow2);
// Get all area listeners that listen on one column within the range
// and end their listening.
ScRange aMoveRange( nStart, nRow1, nTab, nLast, nRow2, nTab); ScRange aMoveRange( nStart, nRow1, nTab, nLast, nRow2, nTab);
std::vector<sc::AreaListener> aAreaListeners = pDocument->GetBASM()->GetAllListeners( std::vector<sc::AreaListener> aAreaListeners = pDocument->GetBASM()->GetAllListeners(
aMoveRange, sc::OneColumnInsideArea); aMoveRange, sc::OneColumnInsideArea);
...@@ -770,11 +797,6 @@ void ScTable::SortReorderByColumn( ...@@ -770,11 +797,6 @@ void ScTable::SortReorderByColumn(
} }
} }
if (pArray->IsUpdateRefs())
{
for (SCCOL nCol = nStart; nCol <= nLast; ++nCol)
aCol[nCol].CollectListeners(aListeners, nRow1, nRow2);
// Remove any duplicate listener entries and notify all listeners // Remove any duplicate listener entries and notify all listeners
// afterward. We must ensure that we notify each unique listener only // afterward. We must ensure that we notify each unique listener only
// once. // once.
...@@ -782,7 +804,6 @@ void ScTable::SortReorderByColumn( ...@@ -782,7 +804,6 @@ void ScTable::SortReorderByColumn(
aListeners.erase(std::unique(aListeners.begin(), aListeners.end()), aListeners.end()); aListeners.erase(std::unique(aListeners.begin(), aListeners.end()), aListeners.end());
ColReorderNotifier aFunc(aColMap, nTab, nRow1, nRow2); ColReorderNotifier aFunc(aColMap, nTab, nRow1, nRow2);
std::for_each(aListeners.begin(), aListeners.end(), aFunc); std::for_each(aListeners.begin(), aListeners.end(), aFunc);
}
// Re-start area listeners on the reordered columns. // Re-start area listeners on the reordered columns.
{ {
...@@ -799,6 +820,13 @@ void ScTable::SortReorderByColumn( ...@@ -799,6 +820,13 @@ void ScTable::SortReorderByColumn(
pDocument->StartListeningArea(aNewRange, it->mbGroupListening, it->mpListener); pDocument->StartListeningArea(aNewRange, it->mbGroupListening, it->mpListener);
} }
} }
}
else // !(pArray->IsUpdateRefs())
{
// Notify the cells' listeners to (re-)start listening.
StartListeningNotifier aFunc;
std::for_each(aCellListeners.begin(), aCellListeners.end(), aFunc);
}
// Re-join formulas at row boundaries now that all the references have // Re-join formulas at row boundaries now that all the references have
// been adjusted for column reordering. // been adjusted for column reordering.
......
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