[Libreoffice-commits] core.git: 2 commits - formula/source sc/source

Eike Rathke erack at redhat.com
Sun Jun 21 12:54:56 PDT 2015


 formula/source/core/api/token.cxx   |    9 ++++++++-
 sc/source/core/data/formulacell.cxx |   18 ++++++------------
 2 files changed, 14 insertions(+), 13 deletions(-)

New commits:
commit 703832caef64e212d276667c7f2d79e4018abeea
Author: Eike Rathke <erack at 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

diff --git a/sc/source/core/data/formulacell.cxx b/sc/source/core/data/formulacell.cxx
index 72b698b..fad80e4 100644
--- a/sc/source/core/data/formulacell.cxx
+++ b/sc/source/core/data/formulacell.cxx
@@ -2894,8 +2894,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)
     {
@@ -3016,8 +3015,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)
     {
@@ -3145,8 +3143,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;
@@ -3226,8 +3223,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);
@@ -3257,8 +3253,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);
@@ -3287,8 +3282,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 f243e27a37ef49e6e1372ef402cd52fa4b0073b6
Author: Eike Rathke <erack at 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

diff --git a/formula/source/core/api/token.cxx b/formula/source/core/api/token.cxx
index 6e938cd..e098a49 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;
 }
 


More information about the Libreoffice-commits mailing list