From 115a4b7ca36f65d93070d2e81048320d202e87a3 Mon Sep 17 00:00:00 2001 From: Eike Rathke Date: Mon, 17 Nov 2014 22:44:56 +0100 Subject: fdo#83765 do not update references in SortReorderByColumn() if disabled Similar to SortReorderByRow() Change-Id: I11dd710c00a56a5f56aeb048fa2258631555a220 --- sc/inc/column.hxx | 12 +++++++----- sc/source/core/data/column4.cxx | 10 ++++++---- sc/source/core/data/table3.cxx | 3 ++- 3 files changed, 15 insertions(+), 10 deletions(-) diff --git a/sc/inc/column.hxx b/sc/inc/column.hxx index 19bb2aa3267b..a46e55da2cb8 100644 --- a/sc/inc/column.hxx +++ b/sc/inc/column.hxx @@ -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 ); diff --git a/sc/source/core/data/column4.cxx b/sc/source/core/data/column4.cxx index 0a437e70d8ba..ba6d01546f0e 100644 --- a/sc/source/core/data/column4.cxx +++ b/sc/source/core/data/column4.cxx @@ -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); } diff --git a/sc/source/core/data/table3.cxx b/sc/source/core/data/table3.cxx index c42f777912af..1111160d4314 100644 --- a/sc/source/core/data/table3.cxx +++ b/sc/source/core/data/table3.cxx @@ -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; -- cgit v1.2.3