summaryrefslogtreecommitdiff
path: root/sc
diff options
context:
space:
mode:
authorEike Rathke <erack@redhat.com>2016-08-04 18:56:20 +0200
committerEike Rathke <erack@redhat.com>2016-08-04 18:58:33 +0200
commite5632d9b2f194a89ec4e60cd99fc050691b14a1e (patch)
tree838b501a497f2672d24a20ba629a039eef4ac5a3 /sc
parent4e2673a5465f8c9f3124049f8240cefdeed453b3 (diff)
Resolves: tdf#100637 nested array jump condition needs own JumpMatrix context
... even if scalar. For all IF, CHOOSE, IFERROR, IFNA. Change-Id: If776dbcd7e5991b7a5629fff0b894a6015918572
Diffstat (limited to 'sc')
-rw-r--r--sc/source/core/inc/interpre.hxx17
-rw-r--r--sc/source/core/tool/interpr4.cxx19
2 files changed, 29 insertions, 7 deletions
diff --git a/sc/source/core/inc/interpre.hxx b/sc/source/core/inc/interpre.hxx
index 37afbda960f7..f1b8e0d4e11c 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 9f64ea04796e..ed433e31839d 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;