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