diff options
author | Kohei Yoshida <kohei.yoshida@gmail.com> | 2013-08-12 15:48:50 -0400 |
---|---|---|
committer | Kohei Yoshida <kohei.yoshida@gmail.com> | 2013-08-12 19:46:30 -0400 |
commit | 1fd12981565dfc608620252c4abe3fbf8c1bddf2 (patch) | |
tree | e3802bc8a74a451307ec5bd5aa00ebaba79a8340 /sc | |
parent | 2624788f23d265f0dfeda544f57b9d90a2ab2979 (diff) |
We still need to update cell positions for non-top cells.
Change-Id: If967247ed5d916535e7b52af14b00090b7c9d0d2
Diffstat (limited to 'sc')
-rw-r--r-- | sc/inc/formulacell.hxx | 2 | ||||
-rw-r--r-- | sc/source/core/data/formulacell.cxx | 48 |
2 files changed, 38 insertions, 12 deletions
diff --git a/sc/inc/formulacell.hxx b/sc/inc/formulacell.hxx index 3318dd2ffddc..2e7c724c7257 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 1753153ca3ad..1e120ee53bcd 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) { |