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

Eike Rathke erack at redhat.com
Wed Mar 11 06:34:29 PDT 2015


 sc/inc/compiler.hxx              |    8 ++++++++
 sc/inc/token.hxx                 |   11 ++++++-----
 sc/source/core/tool/compiler.cxx |   29 ++++++++++++++++++++++++++---
 3 files changed, 40 insertions(+), 8 deletions(-)

New commits:
commit a4d67c9c9c2672ca6d2405075790e0891930b2e0
Author: Eike Rathke <erack at redhat.com>
Date:   Wed Mar 11 14:26:39 2015 +0100

    TableRef: need to distinguish between entire table and All specified
    
    Change-Id: I507b6dfc0ce1a7b0f28142b05e15834ad6e6ac80

diff --git a/sc/inc/token.hxx b/sc/inc/token.hxx
index a0a12ab..0d1aca1 100644
--- a/sc/inc/token.hxx
+++ b/sc/inc/token.hxx
@@ -215,11 +215,12 @@ public:
 
     enum Item
     {
-        ALL      = 0,
-        HEADERS  = 1,
-        DATA     = 2,
-        TOTALS   = 4,
-        THIS_ROW = 8
+        TABLE    = 0,
+        ALL      = 1,
+        HEADERS  = 2,
+        DATA     = 4,
+        TOTALS   = 8,
+        THIS_ROW = 16
     };
 
     ScTableRefToken( sal_uInt16 nIndex, Item eItem );
diff --git a/sc/source/core/tool/compiler.cxx b/sc/source/core/tool/compiler.cxx
index fd5edd4..e3d00e5 100644
--- a/sc/source/core/tool/compiler.cxx
+++ b/sc/source/core/tool/compiler.cxx
@@ -3938,7 +3938,7 @@ ScTokenArray* ScCompiler::CompileString( const OUString& rFormula )
             const FormulaToken* pPrev = pArr->PeekPrev( nIdx);
             if (pPrev && pPrev->GetOpCode() == ocDBArea)
             {
-                FormulaToken* pTableRefToken = new ScTableRefToken( pPrev->GetIndex(), ScTableRefToken::ALL);
+                FormulaToken* pTableRefToken = new ScTableRefToken( pPrev->GetIndex(), ScTableRefToken::TABLE);
                 maTableRefs.push_back( TableRefEntry( pTableRefToken));
                 // pPrev may be dead hereafter.
                 static_cast<ScTokenArray*>(pArr)->ReplaceToken( 1, pTableRefToken);
@@ -4700,7 +4700,7 @@ bool ScCompiler::HandleTableRef()
         ScTokenArray* pNew = new ScTokenArray();
         ScTableRefToken::Item eItem = pTR->GetItem();
         bool bGotToken = false;
-        if (eItem == ScTableRefToken::ALL)
+        if (eItem == ScTableRefToken::TABLE || eItem == ScTableRefToken::ALL)
         {
             ScComplexRefData aRefData;
             aRefData.InitFlags();
commit 519d2f6e5e820229d3548a33313ba15155121537
Author: Eike Rathke <erack at redhat.com>
Date:   Tue Mar 10 15:46:10 2015 +0100

    add TableRef stack
    
    Change-Id: If781e6ab13eb5ad175352e330379776d6ca4fcd8

diff --git a/sc/inc/compiler.hxx b/sc/inc/compiler.hxx
index 298e341..ec99d45 100644
--- a/sc/inc/compiler.hxx
+++ b/sc/inc/compiler.hxx
@@ -313,6 +313,14 @@ private:
     std::vector<OUString> maTabNames;                /// sheet names mangled for the current grammar for output
     std::vector<OUString> &GetSetupTabNames() const; /// get or setup tab names for the current grammar
 
+    struct TableRefEntry
+    {
+        ScTokenRef  mxToken;
+        sal_uInt16  mnLevel;
+        TableRefEntry( formula::FormulaToken* p ) : mxToken(p), mnLevel(0) {}
+    };
+    std::vector<TableRefEntry> maTableRefs;     /// "stack" of currently active ocTableRef tokens
+
     bool   NextNewToken(bool bInArray = false);
 
     virtual void SetError(sal_uInt16 nError) SAL_OVERRIDE;
diff --git a/sc/source/core/tool/compiler.cxx b/sc/source/core/tool/compiler.cxx
index c913ab7..fd5edd4 100644
--- a/sc/source/core/tool/compiler.cxx
+++ b/sc/source/core/tool/compiler.cxx
@@ -3938,11 +3938,34 @@ ScTokenArray* ScCompiler::CompileString( const OUString& rFormula )
             const FormulaToken* pPrev = pArr->PeekPrev( nIdx);
             if (pPrev && pPrev->GetOpCode() == ocDBArea)
             {
+                FormulaToken* pTableRefToken = new ScTableRefToken( pPrev->GetIndex(), ScTableRefToken::ALL);
+                maTableRefs.push_back( TableRefEntry( pTableRefToken));
                 // pPrev may be dead hereafter.
-                static_cast<ScTokenArray*>(pArr)->ReplaceToken( 1,
-                        new ScTableRefToken( pPrev->GetIndex(), ScTableRefToken::ALL));
+                static_cast<ScTokenArray*>(pArr)->ReplaceToken( 1, pTableRefToken);
             }
         }
+        switch (eOp)
+        {
+            case ocTableRefOpen:
+                SAL_WARN_IF( maTableRefs.empty(), "sc.core", "ocTableRefOpen without TableRefEntry");
+                if (maTableRefs.empty())
+                    SetError(errPair);
+                else
+                    ++maTableRefs.back().mnLevel;
+                break;
+            case ocTableRefClose:
+                SAL_WARN_IF( maTableRefs.empty(), "sc.core", "ocTableRefClose without TableRefEntry");
+                if (maTableRefs.empty())
+                    SetError(errPair);
+                else
+                {
+                    if (--maTableRefs.back().mnLevel == 0)
+                        maTableRefs.pop_back();
+                }
+                break;
+            default:
+                break;
+        }
         eLastOp = maRawToken.GetOpCode();
         if ( bAutoCorrect )
             aCorrectedFormula += aCorrectedSymbol;


More information about the Libreoffice-commits mailing list