diff options
-rw-r--r-- | sc/source/core/data/simpleformulacalc.cxx | 10 | ||||
-rw-r--r-- | sc/source/core/tool/interpr1.cxx | 23 |
2 files changed, 19 insertions, 14 deletions
diff --git a/sc/source/core/data/simpleformulacalc.cxx b/sc/source/core/data/simpleformulacalc.cxx index 3ed2c173f3c6..972f5091cad5 100644 --- a/sc/source/core/data/simpleformulacalc.cxx +++ b/sc/source/core/data/simpleformulacalc.cxx @@ -45,14 +45,14 @@ void ScSimpleFormulaCalculator::Calculate() return; mbCalculated = true; - ScInterpreter aInt(nullptr, mpDoc, mpDoc->GetNonThreadedContext(), maAddr, *mpCode); - - std::unique_ptr<sfx2::LinkManager> pNewLinkMgr( new sfx2::LinkManager(mpDoc->GetDocumentShell()) ); - aInt.SetLinkManager( pNewLinkMgr.get() ); + ScInterpreter aInt(mpDoc->GetFormulaCell( maAddr ), mpDoc, mpDoc->GetNonThreadedContext(), maAddr, *mpCode); if (mbMatrixFormula) aInt.AssertFormulaMatrix(); + std::unique_ptr<sfx2::LinkManager> pNewLinkMgr( new sfx2::LinkManager(mpDoc->GetDocumentShell()) ); + aInt.SetLinkManager( pNewLinkMgr.get() ); + formula::StackVar aIntType = aInt.Interpret(); if ( aIntType == formula::svMatrixCell ) { @@ -94,6 +94,8 @@ bool ScSimpleFormulaCalculator::IsValue() bool ScSimpleFormulaCalculator::IsMatrix() { + Calculate(); + return mbMatrixResult; } diff --git a/sc/source/core/tool/interpr1.cxx b/sc/source/core/tool/interpr1.cxx index fc0600368b7f..e7d00deb6aac 100644 --- a/sc/source/core/tool/interpr1.cxx +++ b/sc/source/core/tool/interpr1.cxx @@ -1738,11 +1738,12 @@ void ScInterpreter::ScPi() void ScInterpreter::ScRandom() { - if (bMatrixFormula && pMyFormulaCell) + if (bMatrixFormula) { - SCCOL nCols; - SCROW nRows; - pMyFormulaCell->GetMatColsRows( nCols, nRows); + SCCOL nCols = 0; + SCROW nRows = 0; + if(pMyFormulaCell) + pMyFormulaCell->GetMatColsRows( nCols, nRows); // ScViewFunc::EnterMatrix() might be asking for // ScFormulaCell::GetResultDimensions(), which here are none so create // a 1x1 matrix at least which exactly is the case when EnterMatrix() @@ -4385,9 +4386,10 @@ void ScInterpreter::ScColumn() nVal = aPos.Col() + 1; if (bMatrixFormula) { - SCCOL nCols; - SCROW nRows; - pMyFormulaCell->GetMatColsRows( nCols, nRows); + SCCOL nCols = 0; + SCROW nRows = 0; + if (pMyFormulaCell) + pMyFormulaCell->GetMatColsRows( nCols, nRows); if (nCols == 0) { // Happens if called via ScViewFunc::EnterMatrix() @@ -4488,9 +4490,10 @@ void ScInterpreter::ScRow() nVal = aPos.Row() + 1; if (bMatrixFormula) { - SCCOL nCols; - SCROW nRows; - pMyFormulaCell->GetMatColsRows( nCols, nRows); + SCCOL nCols = 0; + SCROW nRows = 0; + if (pMyFormulaCell) + pMyFormulaCell->GetMatColsRows( nCols, nRows); if (nRows == 0) { // Happens if called via ScViewFunc::EnterMatrix() |