summaryrefslogtreecommitdiff
path: root/sc/source/core/data
diff options
context:
space:
mode:
authorKohei Yoshida <kohei.yoshida@gmail.com>2013-08-12 15:48:50 -0400
committerKohei Yoshida <kohei.yoshida@gmail.com>2013-08-12 19:46:30 -0400
commit1fd12981565dfc608620252c4abe3fbf8c1bddf2 (patch)
treee3802bc8a74a451307ec5bd5aa00ebaba79a8340 /sc/source/core/data
parent2624788f23d265f0dfeda544f57b9d90a2ab2979 (diff)
We still need to update cell positions for non-top cells.
Change-Id: If967247ed5d916535e7b52af14b00090b7c9d0d2
Diffstat (limited to 'sc/source/core/data')
-rw-r--r--sc/source/core/data/formulacell.cxx48
1 files changed, 36 insertions, 12 deletions
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)
{