[Libreoffice-commits] core.git: 3 commits - sc/qa sc/source

Eike Rathke erack at redhat.com
Thu Aug 4 16:59:05 UTC 2016


 sc/qa/unit/ucalc_formula.cxx     |    6 +-----
 sc/source/core/inc/interpre.hxx  |   19 +++++++++++--------
 sc/source/core/tool/interpr1.cxx |    6 +++---
 sc/source/core/tool/interpr4.cxx |   19 +++++++++++++++++++
 4 files changed, 34 insertions(+), 16 deletions(-)

New commits:
commit e85bb29a029300bbed18ca0c25bdc9a31773e9cc
Author: Eike Rathke <erack at redhat.com>
Date:   Thu Aug 4 18:57:46 2016 +0200

    re-enable unit test for tdf#100637 nested array IF with scalar
    
    Change-Id: If2b6d5d8dcbad1472d12753083ba431b59713a7f

diff --git a/sc/qa/unit/ucalc_formula.cxx b/sc/qa/unit/ucalc_formula.cxx
index f5f65bf..d3c158f 100644
--- a/sc/qa/unit/ucalc_formula.cxx
+++ b/sc/qa/unit/ucalc_formula.cxx
@@ -3926,17 +3926,13 @@ void Test::testFuncIF()
     m_pDoc->SetValue(ScAddress(1,0,0), 3.0);
     CPPUNIT_ASSERT_EQUAL(OUString("not two"), m_pDoc->GetString(ScAddress(0,0,0)));
 
-/* FIXME: temporarily disabled because e54cd3fbf40300416ef337981bd356b88ad44a41
- * reverted; reactivate when fixed again. */
-#if 0
-    // Test nested IF in array/matrix.
+    // Test nested IF in array/matrix if the nested IF is not already a matrix.
     ScMarkData aMark;
     aMark.SelectOneTable(0);
     m_pDoc->InsertMatrixFormula(0,2, 1,2, aMark, "=IF({1;0};IF(1;23);42)");
     // Results must be 23 and 42.
     CPPUNIT_ASSERT_EQUAL(23.0, m_pDoc->GetValue(ScAddress(0,2,0)));
     CPPUNIT_ASSERT_EQUAL(42.0, m_pDoc->GetValue(ScAddress(1,2,0)));
-#endif
 
     m_pDoc->DeleteTab(0);
 }
commit e5632d9b2f194a89ec4e60cd99fc050691b14a1e
Author: Eike Rathke <erack at redhat.com>
Date:   Thu Aug 4 18:56:20 2016 +0200

    Resolves: tdf#100637 nested array jump condition needs own JumpMatrix context
    
    ... even if scalar. For all IF, CHOOSE, IFERROR, IFNA.
    
    Change-Id: If776dbcd7e5991b7a5629fff0b894a6015918572

diff --git a/sc/source/core/inc/interpre.hxx b/sc/source/core/inc/interpre.hxx
index 37afbda..f1b8e0d 100644
--- a/sc/source/core/inc/interpre.hxx
+++ b/sc/source/core/inc/interpre.hxx
@@ -360,11 +360,17 @@ void PopExternalDoubleRef(ScMatrixRef& rMat);
 void GetExternalDoubleRef(sal_uInt16 nFileId, const OUString& rTabName, const ScComplexRefData& aData, ScExternalRefCache::TokenArrayRef& rArray);
 bool PopDoubleRefOrSingleRef( ScAddress& rAdr );
 void PopDoubleRefPushMatrix();
-// If MatrixFormula: convert formula::svDoubleRef to svMatrix, create JumpMatrix.
+// If MatrixFormula: convert svDoubleRef to svMatrix, create JumpMatrix.
 // Else convert area reference parameters marked as ForceArray to array.
 // Returns true if JumpMatrix created.
 bool ConvertMatrixParameters();
-inline void MatrixJumpConditionToMatrix();      // if MatrixFormula: PopDoubleRefPushMatrix
+// If MatrixFormula: ConvertMatrixJumpConditionToMatrix()
+inline void MatrixJumpConditionToMatrix();
+// For MatrixFormula (preconditions already checked by
+// MatrixJumpConditionToMatrix()): convert svDoubleRef to svMatrix, or if
+// JumpMatrix currently in effect convert also other types to svMatrix so
+// another JumpMatrix will be created by jump commands.
+void ConvertMatrixJumpConditionToMatrix();
 // If MatrixFormula or ForceArray: ConvertMatrixParameters()
 inline bool MatrixParameterConversion();
 ScMatrixRef PopMatrix();
@@ -977,11 +983,8 @@ public:
 
 inline void ScInterpreter::MatrixJumpConditionToMatrix()
 {
-    if ( (bMatrixFormula || pCur->IsInForceArray()) && GetStackType() == formula::svDoubleRef )
-    {
-        GetTokenMatrixMap();    // make sure it exists, create if not.
-        PopDoubleRefPushMatrix();
-    }
+    if (bMatrixFormula || pCur->IsInForceArray())
+        ConvertMatrixJumpConditionToMatrix();
 }
 
 inline bool ScInterpreter::MatrixParameterConversion()
diff --git a/sc/source/core/tool/interpr4.cxx b/sc/source/core/tool/interpr4.cxx
index 9f64ea0..ed433e3 100644
--- a/sc/source/core/tool/interpr4.cxx
+++ b/sc/source/core/tool/interpr4.cxx
@@ -1374,6 +1374,25 @@ void ScInterpreter::PopDoubleRefPushMatrix()
         SetError( errNoRef );
 }
 
+void ScInterpreter::ConvertMatrixJumpConditionToMatrix()
+{
+    StackVar eStackType = GetStackType();
+    if (eStackType == svUnknown)
+        return;     // can't do anything, some caller will catch that
+    if (eStackType == svMatrix)
+        return;     // already matrix, nothing to do
+
+    if (eStackType != svDoubleRef && GetStackType(2) != svJumpMatrix)
+        return;     // always convert svDoubleRef, others only in JumpMatrix context
+
+    GetTokenMatrixMap();    // make sure it exists, create if not.
+    ScMatrixRef pMat = GetMatrix();
+    if ( pMat )
+        PushMatrix( pMat );
+    else
+        PushIllegalParameter();
+}
+
 ScTokenMatrixMap* ScInterpreter::CreateTokenMatrixMap()
 {
     return new ScTokenMatrixMap;
commit 4e2673a5465f8c9f3124049f8240cefdeed453b3
Author: Eike Rathke <erack at redhat.com>
Date:   Thu Aug 4 16:39:23 2016 +0200

    rename MatrixDoubleRefToMatrix() to MatrixJumpConditionToMatrix()
    
    ... because that is actually where and how it is used and functionality is to
    be expanded for other stack types as well for tdf#100637.
    
    Change-Id: I29a0f7be6bf3d555ed86ebed06a636eff1d37087

diff --git a/sc/source/core/inc/interpre.hxx b/sc/source/core/inc/interpre.hxx
index e26aa5a..37afbda 100644
--- a/sc/source/core/inc/interpre.hxx
+++ b/sc/source/core/inc/interpre.hxx
@@ -364,7 +364,7 @@ void PopDoubleRefPushMatrix();
 // Else convert area reference parameters marked as ForceArray to array.
 // Returns true if JumpMatrix created.
 bool ConvertMatrixParameters();
-inline void MatrixDoubleRefToMatrix();      // if MatrixFormula: PopDoubleRefPushMatrix
+inline void MatrixJumpConditionToMatrix();      // if MatrixFormula: PopDoubleRefPushMatrix
 // If MatrixFormula or ForceArray: ConvertMatrixParameters()
 inline bool MatrixParameterConversion();
 ScMatrixRef PopMatrix();
@@ -975,7 +975,7 @@ public:
     sal_uLong                   GetRetFormatIndex() const   { return nRetFmtIndex; }
 };
 
-inline void ScInterpreter::MatrixDoubleRefToMatrix()
+inline void ScInterpreter::MatrixJumpConditionToMatrix()
 {
     if ( (bMatrixFormula || pCur->IsInForceArray()) && GetStackType() == formula::svDoubleRef )
     {
diff --git a/sc/source/core/tool/interpr1.cxx b/sc/source/core/tool/interpr1.cxx
index 32b17f9..e14aaea 100644
--- a/sc/source/core/tool/interpr1.cxx
+++ b/sc/source/core/tool/interpr1.cxx
@@ -87,7 +87,7 @@ void ScInterpreter::ScIfJump()
 {
     const short* pJump = pCur->GetJump();
     short nJumpCount = pJump[ 0 ];
-    MatrixDoubleRefToMatrix();
+    MatrixJumpConditionToMatrix();
     switch ( GetStackType() )
     {
         case svMatrix:
@@ -255,7 +255,7 @@ void ScInterpreter::ScIfError( bool bNAonly )
     sal_uInt16 nOldGlobalError = nGlobalError;
     nGlobalError = 0;
 
-    MatrixDoubleRefToMatrix();
+    MatrixJumpConditionToMatrix();
     switch (GetStackType())
     {
         default:
@@ -410,7 +410,7 @@ void ScInterpreter::ScChooseJump()
     bool bHaveJump = false;
     const short* pJump = pCur->GetJump();
     short nJumpCount = pJump[ 0 ];
-    MatrixDoubleRefToMatrix();
+    MatrixJumpConditionToMatrix();
     switch ( GetStackType() )
     {
         case svMatrix:


More information about the Libreoffice-commits mailing list