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

fdo#83765 do not update references in SortReorderByColumn() if disabled

Similar to SortReorderByRow()

Change-Id: I11dd710c00a56a5f56aeb048fa2258631555a220
üst 07113bc9
......@@ -596,18 +596,20 @@ public:
/**
* Reset column position of formula cells within specified row range.
* Reference positions are also adjusted to reflect the new position so
* that the formula cells still reference the same cells or ranges after
* the position change. The position of a formula cell before the
* call is interpreted as the old position of that cell.
* If bUpdateRefs==true then reference positions are also adjusted to
* reflect the new position so that the formula cells still reference the
* same cells or ranges after the the position change.
* The position of a formula cell before the call is interpreted as the old
* position of that cell.
*
* Caller needs to ensure that no formula groups cross the top and bottom
* row boundaries.
*
* @param nRow1 top row boundary
* @param nRow2 bottom row boundary
* @param bUpdateRefs whether to adjust references
*/
void ResetFormulaCellPositions( SCROW nRow1, SCROW nRow2 );
void ResetFormulaCellPositions( SCROW nRow1, SCROW nRow2, bool bUpdateRefs );
void SplitFormulaGroupByRelativeRef( const ScRange& rBoundRange );
......
......@@ -1008,8 +1008,9 @@ namespace {
class FormulaColPosSetter
{
SCCOL mnCol;
bool mbUpdateRefs;
public:
FormulaColPosSetter( SCCOL nCol ) : mnCol(nCol) {}
FormulaColPosSetter( SCCOL nCol, bool bUpdateRefs ) : mnCol(nCol), mbUpdateRefs(bUpdateRefs) {}
void operator() ( size_t nRow, ScFormulaCell* pCell )
{
......@@ -1020,7 +1021,8 @@ public:
ScAddress aOldPos = pCell->aPos;
pCell->aPos.SetCol(mnCol);
pCell->aPos.SetRow(nRow);
pCell->GetCode()->AdjustReferenceOnMovedOrigin(aOldPos, pCell->aPos);
if (mbUpdateRefs)
pCell->GetCode()->AdjustReferenceOnMovedOrigin(aOldPos, pCell->aPos);
}
else
{
......@@ -1032,9 +1034,9 @@ public:
}
void ScColumn::ResetFormulaCellPositions( SCROW nRow1, SCROW nRow2 )
void ScColumn::ResetFormulaCellPositions( SCROW nRow1, SCROW nRow2, bool bUpdateRefs )
{
FormulaColPosSetter aFunc(nCol);
FormulaColPosSetter aFunc(nCol, bUpdateRefs);
sc::ProcessFormula(maCells.begin(), maCells, nRow1, nRow2, aFunc);
}
......
......@@ -714,8 +714,9 @@ void ScTable::SortReorderByColumn(
}
// Reset formula cell positions which became out-of-sync after column reordering.
bool bUpdateRefs = pArray->IsUpdateRefs();
for (SCCOL nCol = nStart; nCol <= nLast; ++nCol)
aCol[nCol].ResetFormulaCellPositions(nRow1, nRow2);
aCol[nCol].ResetFormulaCellPositions(nRow1, nRow2, bUpdateRefs);
// Set up column reorder map (for later broadcasting of reference updates).
sc::ColRowReorderMapType aColMap;
......
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