sc/inc/formulacell.hxx | 2 + sc/source/core/data/formulacell.cxx | 48 +++++++++++++++++++++++++++--------- 2 files changed, 38 insertions(+), 12 deletions(-)
New commits: commit 70216f4fe287a4da04cc895f18a1b4f549c1b392 Author: Kohei Yoshida <kohei.yosh...@gmail.com> Date: Mon Aug 12 15:48:50 2013 -0400 We still need to update cell positions for non-top cells. Change-Id: If967247ed5d916535e7b52af14b00090b7c9d0d2 diff --git a/sc/inc/formulacell.hxx b/sc/inc/formulacell.hxx index 3318dd2..2e7c724 100644 --- a/sc/inc/formulacell.hxx +++ b/sc/inc/formulacell.hxx @@ -112,6 +112,8 @@ private: }; void InterpretTail( ScInterpretTailParameter ); + bool UpdatePosOnShift( const sc::RefUpdateContext& rCxt ); + /** * Update reference in response to cell insertion or deletion. */ diff --git a/sc/source/core/data/formulacell.cxx b/sc/source/core/data/formulacell.cxx index 1753153..1e120ee 100644 --- a/sc/source/core/data/formulacell.cxx +++ b/sc/source/core/data/formulacell.cxx @@ -2173,6 +2173,29 @@ bool ScFormulaCell::HasColRowName() const return (pCode->GetNextColRowName() != NULL); } +bool ScFormulaCell::UpdatePosOnShift( const sc::RefUpdateContext& rCxt ) +{ + if (rCxt.meMode != URM_INSDEL) + // Just in case... + return false; + + if (!rCxt.mnColDelta && !rCxt.mnRowDelta && !rCxt.mnTabDelta) + // No movement. + return false; + + if (!rCxt.maRange.In(aPos)) + return false; + + // This formula cell itself is being shifted during cell range + // insertion or deletion. Update its position. + if (mxGroup && mxGroup->mnStart == aPos.Row()) + mxGroup->mnStart += rCxt.mnRowDelta; + + aPos.Move(rCxt.mnColDelta, rCxt.mnRowDelta, rCxt.mnTabDelta); + + return true; +} + namespace { /** @@ -2290,17 +2313,7 @@ bool ScFormulaCell::UpdateReferenceOnShift( if ( pUndoCellPos ) aUndoPos = *pUndoCellPos; ScAddress aOldPos( aPos ); - - if (rCxt.maRange.In(aPos)) - { - // This formula cell itself is being shifted during cell range - // insertion or deletion. Update its position. - aPos.Move(rCxt.mnColDelta, rCxt.mnRowDelta, rCxt.mnTabDelta); - if (mxGroup && mxGroup->mnStart == aOldPos.Row()) - mxGroup->mnStart += rCxt.mnRowDelta; - - bCellStateChanged = aPos != aOldPos; - } + bCellStateChanged = UpdatePosOnShift(rCxt); // Check presence of any references or column row names. pCode->Reset(); @@ -2599,8 +2612,19 @@ bool ScFormulaCell::UpdateReference( return false; if (mxGroup && mxGroup->mnStart != aPos.Row()) - // Update only the top cell in case the cell is part of a formula group. + { + // This is not a top cell of a formula group. Don't update references. + + switch (rCxt.meMode) + { + case URM_INSDEL: + return UpdatePosOnShift(rCxt); + break; + default: + ; + } return false; + } switch (rCxt.meMode) { _______________________________________________ Libreoffice-commits mailing list libreoffice-comm...@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/libreoffice-commits