summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEike Rathke <erack@redhat.com>2017-05-19 21:44:17 +0200
committerEike Rathke <erack@redhat.com>2017-05-22 11:00:56 +0200
commitb086633566cbcc5e73add5d195ce0ab207ea8f7c (patch)
treec5a1eb9c17e4c3a0942dbee30ba996d75ac50224
parent3a3064fcb4778b050398d98598d6ed61e8298134 (diff)
Create RefList at JumpMatrix if current function returns Reference, tdf#58874
Change-Id: I8fcdbc743c614857ee298b3d9c730ab64477dd8c
-rw-r--r--sc/source/core/tool/interpr1.cxx58
1 files changed, 47 insertions, 11 deletions
diff --git a/sc/source/core/tool/interpr1.cxx b/sc/source/core/tool/interpr1.cxx
index 29f51d6326a1..3cca0b101f15 100644
--- a/sc/source/core/tool/interpr1.cxx
+++ b/sc/source/core/tool/interpr1.cxx
@@ -581,6 +581,7 @@ bool ScInterpreter::JumpMatrix( short nStackLevel )
break;
case svSingleRef:
{
+ FormulaConstTokenRef xRef = pStack[sp-1];
ScAddress aAdr;
PopSingleRef( aAdr );
if ( nGlobalError != FormulaError::NONE )
@@ -619,10 +620,21 @@ bool ScInterpreter::JumpMatrix( short nStackLevel )
pJumpMatrix->PutResultString(aStr, nC, nR);
}
}
+
+ formula::ParamClass eReturnType = ScParameterClassification::GetParameterType( pCur, SAL_MAX_UINT16);
+ if (eReturnType == ParamClass::Reference)
+ {
+ /* TODO: What about error handling and do we actually
+ * need the result matrix above at all in this case? */
+ ScComplexRefData aRef;
+ aRef.Ref1 = aRef.Ref2 = *(xRef->GetSingleRef());
+ pJumpMatrix->GetRefList().push_back( aRef);
+ }
}
break;
case svDoubleRef:
{ // upper left plus offset within matrix
+ FormulaConstTokenRef xRef = pStack[sp-1];
double fVal;
ScRange aRange;
PopDoubleRef( aRange );
@@ -690,6 +702,14 @@ bool ScInterpreter::JumpMatrix( short nStackLevel )
SCSIZE nParmRows = aRange.aEnd.Row() - aRange.aStart.Row() + 1;
lcl_AdjustJumpMatrix( pJumpMatrix, nParmCols, nParmRows );
}
+
+ formula::ParamClass eReturnType = ScParameterClassification::GetParameterType( pCur, SAL_MAX_UINT16);
+ if (eReturnType == ParamClass::Reference)
+ {
+ /* TODO: What about error handling and do we actually
+ * need the result matrix above at all in this case? */
+ pJumpMatrix->GetRefList().push_back( *(xRef->GetDoubleRef()));
+ }
}
break;
case svMatrix:
@@ -780,17 +800,33 @@ bool ScInterpreter::JumpMatrix( short nStackLevel )
}
if ( !bCont )
{ // we're done with it, throw away jump matrix, keep result
- ScMatrix* pResMat = pJumpMatrix->GetResultMatrix();
- pJumpMatrix = nullptr;
- Pop();
- PushMatrix( pResMat );
- // Remove jump matrix from map and remember result matrix in case it
- // could be reused in another path of the same condition.
- if (pTokenMatrixMap)
- {
- pTokenMatrixMap->erase( pCur);
- pTokenMatrixMap->insert( ScTokenMatrixMap::value_type( pCur,
- pStack[sp-1]));
+ formula::ParamClass eReturnType = ScParameterClassification::GetParameterType( pCur, SAL_MAX_UINT16);
+ if (eReturnType == ParamClass::Reference)
+ {
+ FormulaTokenRef xRef = new ScRefListToken(true);
+ *(xRef->GetRefList()) = pJumpMatrix->GetRefList();
+ pJumpMatrix = nullptr;
+ Pop();
+ PushTokenRef( xRef);
+ if (pTokenMatrixMap)
+ {
+ pTokenMatrixMap->erase( pCur);
+ // There's no result matrix to remember in this case.
+ }
+ }
+ else
+ {
+ ScMatrix* pResMat = pJumpMatrix->GetResultMatrix();
+ pJumpMatrix = nullptr;
+ Pop();
+ PushMatrix( pResMat );
+ // Remove jump matrix from map and remember result matrix in case it
+ // could be reused in another path of the same condition.
+ if (pTokenMatrixMap)
+ {
+ pTokenMatrixMap->erase( pCur);
+ pTokenMatrixMap->insert( ScTokenMatrixMap::value_type( pCur, pStack[sp-1]));
+ }
}
return true;
}