[Libreoffice-commits] core.git: Branch 'libreoffice-4-2' - formula/source include/formula sc/source

Eike Rathke erack at redhat.com
Tue Jun 17 07:12:30 PDT 2014


 formula/source/core/api/token.cxx   |    7 ++++++-
 include/formula/FormulaCompiler.hxx |    6 +++---
 include/formula/token.hxx           |    9 +++++++--
 sc/source/core/inc/interpre.hxx     |    2 +-
 4 files changed, 17 insertions(+), 7 deletions(-)

New commits:
commit 35e31aac7224676b383d63ed4591bbc9c6ba4c08
Author: Eike Rathke <erack at redhat.com>
Date:   Fri Jun 13 10:50:27 2014 +0200

    resolved fdo#79957 propagate ForceArray through jump tokens
    
    ForceArray parameters weren't propagated and enforced to array arguments
    on svJump tokens (FormulaJumpToken), namely IF, CHOOSE, IFERROR and
    IFNA.
    
    (cherry picked from commit c9d037e5e8e5850e9c69372580e7a506b573fc2a)
    
    Conflicts:
    	include/formula/token.hxx
    
    Change-Id: Icf9074f11b826655a52858d778d9a0122d207aa4
    Reviewed-on: https://gerrit.libreoffice.org/9767
    Reviewed-by: Markus Mohrhard <markus.mohrhard at googlemail.com>
    Tested-by: Markus Mohrhard <markus.mohrhard at googlemail.com>

diff --git a/formula/source/core/api/token.cxx b/formula/source/core/api/token.cxx
index 3777d09..e933a34 100644
--- a/formula/source/core/api/token.cxx
+++ b/formula/source/core/api/token.cxx
@@ -275,11 +275,16 @@ bool FormulaFAPToken::operator==( const FormulaToken& r ) const
 {
     return FormulaByteToken::operator==( r ) && pOrigToken == r.GetFAPOrigToken();
 }
+
+
 short* FormulaJumpToken::GetJump() const                     { return pJump; }
+bool FormulaJumpToken::HasForceArray() const                 { return bHasForceArray; }
+void FormulaJumpToken::SetForceArray( bool b )               { bHasForceArray = b; }
 bool FormulaJumpToken::operator==( const FormulaToken& r ) const
 {
     return FormulaToken::operator==( r ) && pJump[0] == r.GetJump()[0] &&
-        memcmp( pJump+1, r.GetJump()+1, pJump[0] * sizeof(short) ) == 0;
+        memcmp( pJump+1, r.GetJump()+1, pJump[0] * sizeof(short) ) == 0 &&
+        bHasForceArray == r.HasForceArray();
 }
 FormulaJumpToken::~FormulaJumpToken()
 {
diff --git a/include/formula/FormulaCompiler.hxx b/include/formula/FormulaCompiler.hxx
index 591103a..e2d6edd 100644
--- a/include/formula/FormulaCompiler.hxx
+++ b/include/formula/FormulaCompiler.hxx
@@ -356,9 +356,9 @@ private:
 
     static inline void ForceArrayOperator( FormulaTokenRef& rCurr, const FormulaTokenRef& rPrev )
         {
-            if ( rPrev && rPrev->HasForceArray() &&
-                    rCurr->GetType() == svByte && rCurr->GetOpCode() != ocPush
-                    && !rCurr->HasForceArray() )
+            if ( rPrev && rPrev->HasForceArray() && rCurr->GetOpCode() != ocPush &&
+                    (rCurr->GetType() == svByte || rCurr->GetType() == svJump) &&
+                    !rCurr->HasForceArray() )
                 rCurr->SetForceArray( true);
         }
 
diff --git a/include/formula/token.hxx b/include/formula/token.hxx
index 002cefb..f09fbae 100644
--- a/include/formula/token.hxx
+++ b/include/formula/token.hxx
@@ -356,15 +356,18 @@ class FORMULA_DLLPUBLIC FormulaJumpToken : public FormulaToken
 {
 private:
             short*              pJump;
+            bool                bHasForceArray;
 public:
                                 FormulaJumpToken( OpCode e, short* p ) :
-                                    FormulaToken( formula::svJump , e)
+                                    FormulaToken( formula::svJump , e),
+                                    bHasForceArray( false)
                                 {
                                     pJump = new short[ p[0] + 1 ];
                                     memcpy( pJump, p, (p[0] + 1) * sizeof(short) );
                                 }
                                 FormulaJumpToken( const FormulaJumpToken& r ) :
-                                    FormulaToken( r )
+                                    FormulaToken( r ),
+                                    bHasForceArray( r.bHasForceArray)
                                 {
                                     pJump = new short[ r.pJump[0] + 1 ];
                                     memcpy( pJump, r.pJump, (r.pJump[0] + 1) * sizeof(short) );
@@ -373,6 +376,8 @@ public:
     virtual short*              GetJump() const;
     virtual bool                operator==( const formula::FormulaToken& rToken ) const;
     virtual FormulaToken*       Clone() const { return new FormulaJumpToken(*this); }
+    virtual bool                HasForceArray() const;
+    virtual void                SetForceArray( bool b );
 };
 
 
diff --git a/sc/source/core/inc/interpre.hxx b/sc/source/core/inc/interpre.hxx
index aa2dd73..d082648 100644
--- a/sc/source/core/inc/interpre.hxx
+++ b/sc/source/core/inc/interpre.hxx
@@ -867,7 +867,7 @@ public:
 
 inline void ScInterpreter::MatrixDoubleRefToMatrix()
 {
-    if ( bMatrixFormula && GetStackType() == formula::svDoubleRef )
+    if ( (bMatrixFormula || pCur->HasForceArray()) && GetStackType() == formula::svDoubleRef )
     {
         GetTokenMatrixMap();    // make sure it exists, create if not.
         PopDoubleRefPushMatrix();


More information about the Libreoffice-commits mailing list