summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--sc/inc/column.hxx12
-rw-r--r--sc/source/core/data/column4.cxx10
-rw-r--r--sc/source/core/data/table3.cxx3
3 files changed, 15 insertions, 10 deletions
diff --git a/sc/inc/column.hxx b/sc/inc/column.hxx
index 66cd52442132..4bda39d3c00b 100644
--- a/sc/inc/column.hxx
+++ b/sc/inc/column.hxx
@@ -575,18 +575,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 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 8b46e74831ab..568b5b64ec19 100644
--- a/sc/source/core/data/column4.cxx
+++ b/sc/source/core/data/column4.cxx
@@ -439,8 +439,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 )
{
@@ -451,7 +452,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
{
@@ -463,9 +465,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 d6466784f7ac..99d6239a0262 100644
--- a/sc/source/core/data/table3.cxx
+++ b/sc/source/core/data/table3.cxx
@@ -716,8 +716,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;