formula/source/core/api/token.cxx | 9 ++++++++- sc/source/core/data/formulacell.cxx | 18 ++++++------------ 2 files changed, 14 insertions(+), 13 deletions(-)
New commits: commit 974fe915c38a07ddffff5f5fdcdde92d5ef1a77f Author: Eike Rathke <er...@redhat.com> Date: Sun Jun 21 21:48:06 2015 +0200 TableRef: use ScTokenArray::HasReferences() instead of GetNextReferenceRPN() To catch also a simple =Table[[#This Row],[Column]] that is outside of table bounds located and therefor generates an error token instead of a reference in RPN. Change-Id: I28f5ca12b5f5998c623d0f38fcf39f037aabd317 (cherry picked from commit 703832caef64e212d276667c7f2d79e4018abeea) diff --git a/sc/source/core/data/formulacell.cxx b/sc/source/core/data/formulacell.cxx index 4af29d6..24f365a 100644 --- a/sc/source/core/data/formulacell.cxx +++ b/sc/source/core/data/formulacell.cxx @@ -2896,8 +2896,7 @@ bool ScFormulaCell::UpdateReferenceOnShift( bCellStateChanged = UpdatePosOnShift(rCxt); // Check presence of any references or column row names. - pCode->Reset(); - bool bHasRefs = (pCode->GetNextReferenceRPN() != NULL); + bool bHasRefs = pCode->HasReferences(); bool bHasColRowNames = false; if (!bHasRefs) { @@ -3018,8 +3017,7 @@ bool ScFormulaCell::UpdateReferenceOnMove( } // Check presence of any references or column row names. - pCode->Reset(); - bool bHasRefs = (pCode->GetNextReferenceRPN() != NULL); + bool bHasRefs = pCode->HasReferences(); bool bHasColRowNames = false; if (!bHasRefs) { @@ -3147,8 +3145,7 @@ bool ScFormulaCell::UpdateReferenceOnCopy( } // Check presence of any references or column row names. - pCode->Reset(); - bool bHasRefs = (pCode->GetNextReferenceRPN() != NULL); + bool bHasRefs = pCode->HasReferences(); pCode->Reset(); bool bHasColRowNames = (pCode->GetNextColRowName() != NULL); bHasRefs = bHasRefs || bHasColRowNames; @@ -3228,8 +3225,7 @@ void ScFormulaCell::UpdateInsertTab( sc::RefUpdateInsertTabContext& rCxt ) // Adjust tokens only when it's not grouped or grouped top cell. bool bAdjustCode = !mxGroup || mxGroup->mpTopCell == this; bool bPosChanged = (rCxt.mnInsertPos <= aPos.Tab()); - pCode->Reset(); - if (pDocument->IsClipOrUndo() || !pCode->GetNextReferenceRPN()) + if (pDocument->IsClipOrUndo() || !pCode->HasReferences()) { if (bPosChanged) aPos.IncTab(rCxt.mnSheets); @@ -3259,8 +3255,7 @@ bool ScFormulaCell::UpdateDeleteTab( sc::RefUpdateDeleteTabContext& rCxt ) // Adjust tokens only when it's not grouped or grouped top cell. bool bAdjustCode = !mxGroup || mxGroup->mpTopCell == this; bool bPosChanged = (aPos.Tab() >= rCxt.mnDeletePos + rCxt.mnSheets); - pCode->Reset(); - if (pDocument->IsClipOrUndo() || !pCode->GetNextReferenceRPN()) + if (pDocument->IsClipOrUndo() || !pCode->HasReferences()) { if (bPosChanged) aPos.IncTab(-1*rCxt.mnSheets); @@ -3289,8 +3284,7 @@ void ScFormulaCell::UpdateMoveTab( sc::RefUpdateMoveTabContext& rCxt, SCTAB nTab // Adjust tokens only when it's not grouped or grouped top cell. bool bAdjustCode = !mxGroup || mxGroup->mpTopCell == this; - pCode->Reset(); - if (!pCode->GetNextReferenceRPN() || pDocument->IsClipOrUndo()) + if (!pCode->HasReferences() || pDocument->IsClipOrUndo()) { aPos.SetTab(nTabNo); return; commit c1ade6725452f658547b34e5b8bb891d1f478eda Author: Eike Rathke <er...@redhat.com> Date: Sun Jun 21 21:42:53 2015 +0200 TableRef: include ocTableRef in FormulaToken::IsRef() for HasReferences() let FormulaTokenArray::HasReferences() also check RPN Change-Id: Ic97332265c50485691f76b81d8396705d7728ab0 (cherry picked from commit f243e27a37ef49e6e1372ef402cd52fa4b0073b6) diff --git a/formula/source/core/api/token.cxx b/formula/source/core/api/token.cxx index cc88919..ce40870 100644 --- a/formula/source/core/api/token.cxx +++ b/formula/source/core/api/token.cxx @@ -147,7 +147,8 @@ bool FormulaToken::IsRef() const case svExternalDoubleRef: return true; default: - ; + if (eOp == ocTableRef) + return true; } return false; @@ -634,6 +635,12 @@ bool FormulaTokenArray::HasReferences() const return true; } + for (sal_uInt16 i = 0; i < nRPN; ++i) + { + if (pRPN[i]->IsRef()) + return true; + } + return false; } _______________________________________________ Libreoffice-commits mailing list libreoffice-comm...@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/libreoffice-commits