diff options
Diffstat (limited to 'formula')
-rw-r--r-- | formula/source/core/api/FormulaCompiler.cxx | 24 | ||||
-rw-r--r-- | formula/source/ui/dlg/formula.cxx | 2 |
2 files changed, 20 insertions, 6 deletions
diff --git a/formula/source/core/api/FormulaCompiler.cxx b/formula/source/core/api/FormulaCompiler.cxx index f5e06e77deba..671d2c2b9f62 100644 --- a/formula/source/core/api/FormulaCompiler.cxx +++ b/formula/source/core/api/FormulaCompiler.cxx @@ -697,7 +697,7 @@ void FormulaCompiler::OpCodeMap::putOpCode( const OUString & rStr, const OpCode // class FormulaCompiler -FormulaCompiler::FormulaCompiler( FormulaTokenArray& rArr ) +FormulaCompiler::FormulaCompiler( FormulaTokenArray& rArr, bool bComputeII, bool bMatrixFlag ) : nCurrentFactorParam(0), pArr( &rArr ), @@ -714,13 +714,15 @@ FormulaCompiler::FormulaCompiler( FormulaTokenArray& rArr ) glSubTotal( false ), needsRPNTokenCheck( false ), mbJumpCommandReorder(true), - mbStopOnError(true) + mbStopOnError(true), + mbComputeII(bComputeII), + mbMatrixFlag(bMatrixFlag) { } FormulaTokenArray FormulaCompiler::smDummyTokenArray; -FormulaCompiler::FormulaCompiler() +FormulaCompiler::FormulaCompiler(bool bComputeII, bool bMatrixFlag) : nCurrentFactorParam(0), pArr( nullptr ), @@ -737,7 +739,9 @@ FormulaCompiler::FormulaCompiler() glSubTotal( false ), needsRPNTokenCheck( false ), mbJumpCommandReorder(true), - mbStopOnError(true) + mbStopOnError(true), + mbComputeII(bComputeII), + mbMatrixFlag(bMatrixFlag) { } @@ -1549,6 +1553,7 @@ void FormulaCompiler::Factor() else { // standard handling of 1-parameter opcodes + OpCode eMyLastOp = eOp; pFacToken = mpToken; eOp = NextToken(); if( nNumFmt == SvNumFormatType::UNDEFINED && eOp == ocNot ) @@ -1564,7 +1569,14 @@ void FormulaCompiler::Factor() if (eOp != ocClose) SetError( FormulaError::PairExpected); else if ( pArr->GetCodeError() == FormulaError::NONE ) + { pFacToken->SetByte( 1 ); + if (mbComputeII && IsIIOpCode(eMyLastOp)) + { + FormulaToken** pArg = pCode - 1; + HandleIIOpCode(eMyLastOp, pFacToken->GetInForceArray(), &pArg, 1); + } + } PutCode( pFacToken ); NextToken(); } @@ -1606,7 +1618,7 @@ void FormulaCompiler::Factor() sal_uInt32 nSepCount = 0; if( !bNoParam ) { - bool bDoIICompute = IsIIOpCode(eMyLastOp); + bool bDoIICompute = mbComputeII && IsIIOpCode(eMyLastOp); // Array of FormulaToken double pointers to collect the parameters of II opcodes. FormulaToken*** pArgArray = nullptr; if (bDoIICompute) @@ -1633,7 +1645,7 @@ void FormulaCompiler::Factor() pArgArray[nSepCount - 1] = pCode - 1; // Add rest of the arguments } if (bDoIICompute) - HandleIIOpCode(eMyLastOp, pArgArray, + HandleIIOpCode(eMyLastOp, pFacToken->GetInForceArray(), pArgArray, std::min(nSepCount, static_cast<sal_uInt32>(FORMULA_MAXPARAMSII))); } if (bBadName) diff --git a/formula/source/ui/dlg/formula.cxx b/formula/source/ui/dlg/formula.cxx index e5b07260915a..5abc04622e15 100644 --- a/formula/source/ui/dlg/formula.cxx +++ b/formula/source/ui/dlg/formula.cxx @@ -831,6 +831,8 @@ void FormulaDlg_Impl::UpdateTokenArray( const OUString& rStrExp) // #i101512# Disable special handling of jump commands. pCompiler->EnableJumpCommandReorder(false); pCompiler->EnableStopOnError(false); + pCompiler->SetComputeIIFlag(true); + pCompiler->SetMatrixFlag(m_bUserMatrixFlag); pCompiler->CompileTokenArray(); } |