[Libreoffice-commits] core.git: Branch 'feature/formula-core-rework' - 2 commits - sc/source
Kohei Yoshida
kohei.yoshida at gmail.com
Wed Jul 17 19:32:15 PDT 2013
sc/source/core/data/formulacell.cxx | 91 +++++++++++++++---------------------
1 file changed, 38 insertions(+), 53 deletions(-)
New commits:
commit 8444610c89407122cd16b5434516650f9fa82462
Author: Kohei Yoshida <kohei.yoshida at gmail.com>
Date: Wed Jul 17 22:32:23 2013 -0400
No reference update in clip or undo documents. Make that up front.
Change-Id: Ie2170bc1d183e6840d46c51910a4c150b83961ca
diff --git a/sc/source/core/data/formulacell.cxx b/sc/source/core/data/formulacell.cxx
index 343ef0d..8e8ef5c 100644
--- a/sc/source/core/data/formulacell.cxx
+++ b/sc/source/core/data/formulacell.cxx
@@ -2229,7 +2229,6 @@ bool ScFormulaCell::UpdateReferenceOnShift(
// Just in case...
return false;
- bool bCellStateChanged = false;
const ScRange& rRange = rCxt.maRange;
SCCOL nDx = rCxt.mnColDelta;
SCROW nDy = rCxt.mnRowDelta;
@@ -2247,28 +2246,24 @@ bool ScFormulaCell::UpdateReferenceOnShift(
xGroup->mnStart += nDy;
}
- bool bHasRefs = false;
+ // Check presence of any references or column row names.
+ pCode->Reset();
+ bool bHasRefs = (pCode->GetNextReferenceRPN() != NULL);
bool bHasColRowNames = false;
- bool bOnRefMove = false;
- if ( !pDocument->IsClipOrUndo() )
+ if (!bHasRefs)
{
- // Check presence of any references or column row names.
pCode->Reset();
- bHasRefs = (pCode->GetNextReferenceRPN() != NULL);
- if (!bHasRefs)
- {
- pCode->Reset();
- bHasColRowNames = (pCode->GetNextColRowName() != NULL);
- bHasRefs = bHasRefs || bHasColRowNames;
- }
- bOnRefMove = pCode->IsRecalcModeOnRefMove();
+ bHasColRowNames = (pCode->GetNextColRowName() != NULL);
+ bHasRefs = bHasRefs || bHasColRowNames;
}
+ bool bOnRefMove = pCode->IsRecalcModeOnRefMove();
if (!bHasRefs && !bOnRefMove)
// This formula cell contains no references, nor needs recalculating
// on reference update. Bail out.
- return bCellStateChanged;
+ return false;
+ bool bCellStateChanged = false;
boost::scoped_ptr<ScTokenArray> pOldCode;
if (pUndoDoc)
pOldCode.reset(pCode->Clone());
@@ -2380,7 +2375,6 @@ bool ScFormulaCell::UpdateReferenceOnMove(
if (rCxt.meMode != URM_MOVE)
return false;
- bool bCellStateChanged = false;
const ScRange& rRange = rCxt.maRange;
SCCOL nDx = rCxt.mnColDelta;
SCROW nDy = rCxt.mnRowDelta;
@@ -2402,28 +2396,25 @@ bool ScFormulaCell::UpdateReferenceOnMove(
aOldPos.Set( nCol - nDx, nRow - nDy, nTab - nDz );
}
- bool bHasRefs = false;
+
+ // Check presence of any references or column row names.
+ pCode->Reset();
+ bool bHasRefs = (pCode->GetNextReferenceRPN() != NULL);
bool bHasColRowNames = false;
- bool bOnRefMove = false;
- if ( !pDocument->IsClipOrUndo() )
+ if (!bHasRefs)
{
- // Check presence of any references or column row names.
pCode->Reset();
- bHasRefs = (pCode->GetNextReferenceRPN() != NULL);
- if (!bHasRefs)
- {
- pCode->Reset();
- bHasColRowNames = (pCode->GetNextColRowName() != NULL);
- bHasRefs = bHasRefs || bHasColRowNames;
- }
- bOnRefMove = pCode->IsRecalcModeOnRefMove();
+ bHasColRowNames = (pCode->GetNextColRowName() != NULL);
+ bHasRefs = bHasRefs || bHasColRowNames;
}
+ bool bOnRefMove = pCode->IsRecalcModeOnRefMove();
if (!bHasRefs && !bOnRefMove)
// This formula cell contains no references, nor needs recalculating
// on reference update. Bail out.
- return bCellStateChanged;
+ return false;
+ bool bCellStateChanged = false;
boost::scoped_ptr<ScTokenArray> pOldCode;
if (pUndoDoc)
pOldCode.reset(pCode->Clone());
@@ -2536,7 +2527,6 @@ bool ScFormulaCell::UpdateReferenceOnCopy(
if (rCxt.meMode != URM_COPY)
return false;
- bool bCellStateChanged = false;
const ScRange& rRange = rCxt.maRange;
SCCOL nDx = rCxt.mnColDelta;
SCROW nDy = rCxt.mnRowDelta;
@@ -2558,25 +2548,20 @@ bool ScFormulaCell::UpdateReferenceOnCopy(
aOldPos.Set( nCol - nDx, nRow - nDy, nTab - nDz );
}
- bool bHasRefs = false;
- bool bHasColRowNames = false;
- bool bOnRefMove = false;
- if ( !pDocument->IsClipOrUndo() )
- {
- // Check presence of any references or column row names.
- pCode->Reset();
- bHasRefs = (pCode->GetNextReferenceRPN() != NULL);
- pCode->Reset();
- bHasColRowNames = (pCode->GetNextColRowName() != NULL);
- bHasRefs = bHasRefs || bHasColRowNames;
- bOnRefMove = pCode->IsRecalcModeOnRefMove();
- }
+ // Check presence of any references or column row names.
+ pCode->Reset();
+ bool bHasRefs = (pCode->GetNextReferenceRPN() != NULL);
+ pCode->Reset();
+ bool bHasColRowNames = (pCode->GetNextColRowName() != NULL);
+ bHasRefs = bHasRefs || bHasColRowNames;
+ bool bOnRefMove = pCode->IsRecalcModeOnRefMove();
if (!bHasRefs && !bOnRefMove)
// This formula cell contains no references, nor needs recalculating
// on reference update. Bail out.
- return bCellStateChanged;
+ return false;
+ bool bCellStateChanged = false;
boost::scoped_ptr<ScTokenArray> pOldCode;
if (pUndoDoc)
pOldCode.reset(pCode->Clone());
@@ -2678,6 +2663,9 @@ bool ScFormulaCell::UpdateReferenceOnCopy(
bool ScFormulaCell::UpdateReference(
const sc::RefUpdateContext& rCxt, ScDocument* pUndoDoc, const ScAddress* pUndoCellPos )
{
+ if (pDocument->IsClipOrUndo())
+ return false;
+
switch (rCxt.meMode)
{
case URM_INSDEL:
commit 58df2af4afd82cb23e29de6623a58da3fb3f53f5
Author: Kohei Yoshida <kohei.yoshida at gmail.com>
Date: Wed Jul 17 22:25:48 2013 -0400
old position == current position during cell insertion / deletion.
Change-Id: I5b4541dc41951cc79572c564bf737160245c4c94
diff --git a/sc/source/core/data/formulacell.cxx b/sc/source/core/data/formulacell.cxx
index dc6570b..343ef0d 100644
--- a/sc/source/core/data/formulacell.cxx
+++ b/sc/source/core/data/formulacell.cxx
@@ -2237,17 +2237,14 @@ bool ScFormulaCell::UpdateReferenceOnShift(
ScAddress aUndoPos( aPos ); // position for undo cell in pUndoDoc
if ( pUndoCellPos )
aUndoPos = *pUndoCellPos;
- ScAddress aOldPos( aPos );
if (rRange.In(aPos))
{
// This formula cell itself is being shifted during cell range
// insertion or deletion. Update its position.
aPos.Move(nDx, nDy, nDz);
- if (xGroup && xGroup->mnStart == aOldPos.Row())
+ if (xGroup && xGroup->mnStart == aPos.Row())
xGroup->mnStart += nDy;
-
- bCellStateChanged = aPos != aOldPos;
}
bool bHasRefs = false;
@@ -2286,7 +2283,7 @@ bool ScFormulaCell::UpdateReferenceOnShift(
// Update cell or range references.
ScCompiler aComp(pDocument, aPos, *pCode);
aComp.SetGrammar(pDocument->GetGrammar());
- pSharedCode = aComp.UpdateReference(URM_INSDEL, aOldPos, rRange,
+ pSharedCode = aComp.UpdateReference(URM_INSDEL, aPos, rRange,
nDx, nDy, nDz,
bValChanged, bRefSizeChanged);
bRangeModified = aComp.HasModifiedRange();
@@ -2296,7 +2293,7 @@ bool ScFormulaCell::UpdateReferenceOnShift(
if (bOnRefMove)
// Cell may reference itself, e.g. ocColumn, ocRow without parameter
- bOnRefMove = (bValChanged || (aPos != aOldPos));
+ bOnRefMove = bValChanged;
bool bColRowNameCompile = false;
bool bHasRelName = false;
@@ -2308,7 +2305,7 @@ bool ScFormulaCell::UpdateReferenceOnShift(
// Upon Insert ColRowNames have to be recompiled in case the
// insertion occurs right in front of the range.
if (bHasColRowNames)
- bColRowNameCompile = checkCompileColRowName(rCxt, *pDocument, *pCode, aOldPos, aPos, bValChanged);
+ bColRowNameCompile = checkCompileColRowName(rCxt, *pDocument, *pCode, aPos, aPos, bValChanged);
ScChangeTrack* pChangeTrack = pDocument->GetChangeTrack();
bInDeleteUndo = (pChangeTrack && pChangeTrack->IsInDeleteUndo());
@@ -2321,7 +2318,7 @@ bool ScFormulaCell::UpdateReferenceOnShift(
|| (bValChanged && (bInDeleteUndo || bRefSizeChanged)) || bHasRelName);
if ( bNewListening )
- EndListeningTo(pDocument, pOldCode.get(), aOldPos);
+ EndListeningTo(pDocument, pOldCode.get(), aPos);
}
bool bNeedDirty = false;
@@ -2341,10 +2338,10 @@ bool ScFormulaCell::UpdateReferenceOnShift(
delete pCode;
pCode = pSharedCode->GetCode()->Clone();
// #i18937# #i110008# call MoveRelWrap, but with the old position
- ScCompiler::MoveRelWrap(*pCode, pDocument, aOldPos, pSharedCode->GetMaxCol(), pSharedCode->GetMaxRow());
+ ScCompiler::MoveRelWrap(*pCode, pDocument, aPos, pSharedCode->GetMaxCol(), pSharedCode->GetMaxRow());
ScCompiler aComp2(pDocument, aPos, *pCode);
aComp2.SetGrammar(pDocument->GetGrammar());
- aComp2.UpdateSharedFormulaReference(URM_INSDEL, aOldPos, rRange, nDx, nDy, nDz);
+ aComp2.UpdateSharedFormulaReference(URM_INSDEL, aPos, rRange, nDx, nDy, nDz);
bValChanged = true;
bNeedDirty = true;
}
More information about the Libreoffice-commits
mailing list