diff options
author | Eike Rathke <erack@redhat.com> | 2015-11-16 12:23:15 +0100 |
---|---|---|
committer | Markus Mohrhard <markus.mohrhard@googlemail.com> | 2015-11-20 02:10:30 +0000 |
commit | 29adff38e8a6e340302c104c4632df9c6551bc38 (patch) | |
tree | 84a09922ad351dd181968d766186a8f1e0514e83 /formula | |
parent | d9b6f836e58aa3ad1dc6120df89c4001dc7d3091 (diff) |
Resolves: tdf#95670 propagate ForceArray per parameter
Regression of b5cd11b4b02a85a83db77ba9d8d1763f0cd88cb1
It was always wrong to propagate ForceArray already if a function had a
ForceArray parameter *somewhere*, we need to do this per parameter
instead.
(cherry picked from commit 49257e1da7e371fdea0fac080116b0511789cac7)
Conflicts:
formula/source/core/api/FormulaCompiler.cxx
prevent ForceArray propagation on the same token, tdf#95670 follow-up
This may happen if the last RPN token is put and the function has a
ForceArray parameter but now again would be wrong if not all parameters
are ForceArray.
(cherry picked from commit b31b17e52b2b2b94999d68c4b2ed5c74ee7eed0a)
890fb6b5b88337033cfcf2e8189371ee39461205
-Werror,-Winconsistent-missing-override
(cherry picked from commit 6edc492efd6fe2de15c1ae306b400ca054772ad1)
Backported to SAL_OVERRIDE
3bb2764b625d44f6e0cecbdde3363440faef63b5
Change-Id: If188d45366279d9a7bf641edc7e4dd7095d6d035
Reviewed-on: https://gerrit.libreoffice.org/19993
Reviewed-by: Markus Mohrhard <markus.mohrhard@googlemail.com>
Tested-by: Markus Mohrhard <markus.mohrhard@googlemail.com>
Diffstat (limited to 'formula')
-rw-r--r-- | formula/source/core/api/FormulaCompiler.cxx | 48 |
1 files changed, 46 insertions, 2 deletions
diff --git a/formula/source/core/api/FormulaCompiler.cxx b/formula/source/core/api/FormulaCompiler.cxx index dc24f459a4e1..3d0a41589794 100644 --- a/formula/source/core/api/FormulaCompiler.cxx +++ b/formula/source/core/api/FormulaCompiler.cxx @@ -532,6 +532,7 @@ void FormulaCompiler::OpCodeMap::putOpCode( const OUString & rStr, const OpCode FormulaCompiler::FormulaCompiler( FormulaTokenArray& rArr ) : + nCurrentFactorParam(0), pArr( &rArr ), pCode( NULL ), pStack( NULL ), @@ -550,6 +551,7 @@ FormulaCompiler::FormulaCompiler( FormulaTokenArray& rArr ) FormulaCompiler::FormulaCompiler() : + nCurrentFactorParam(0), pArr( NULL ), pCode( NULL ), pStack( NULL ), @@ -1169,6 +1171,7 @@ void FormulaCompiler::Factor() { // range list (A1;A2) converted to (A1~A2) pFacToken = mpToken; NextToken(); + CheckSetForceArrayParameter( mpToken, 0); eOp = Expression(); // Do not ignore error here, regardless of bIgnoreErrors, otherwise // errors like =(1;) would also result in display of =(1~) @@ -1254,6 +1257,7 @@ void FormulaCompiler::Factor() if (eOp == ocOpen) { NextToken(); + CheckSetForceArrayParameter( mpToken, 0); eOp = Expression(); } else @@ -1285,7 +1289,10 @@ void FormulaCompiler::Factor() if (eOp == ocClose) bNoParam = true; else + { + CheckSetForceArrayParameter( mpToken, 0); eOp = Expression(); + } } else if (eMyLastOp == ocBad) { @@ -1302,8 +1309,9 @@ void FormulaCompiler::Factor() nSepCount++; while ((eOp == ocSep) && (!pArr->GetCodeError() || !mbStopOnError)) { - nSepCount++; NextToken(); + CheckSetForceArrayParameter( mpToken, nSepCount); + nSepCount++; eOp = Expression(); } } @@ -1343,6 +1351,7 @@ void FormulaCompiler::Factor() if (eOp == ocOpen) { NextToken(); + CheckSetForceArrayParameter( mpToken, 0); eOp = Expression(); } else @@ -1377,6 +1386,7 @@ void FormulaCompiler::Factor() if ( ++nJumpCount <= nJumpMax ) pFacToken->GetJump()[nJumpCount] = pc-1; NextToken(); + CheckSetForceArrayParameter( mpToken, nJumpCount - 1); eOp = Expression(); // ocSep or ocClose terminate the subexpression PutCode( mpToken ); @@ -2138,7 +2148,7 @@ void FormulaCompiler::PutCode( FormulaTokenRef& p ) } if (pArr->GetCodeError() && mbJumpCommandReorder) return; - ForceArrayOperator( p, pCurrentFactorToken); + ForceArrayOperator( p); p->IncRef(); *pCode++ = p.get(); pc++; @@ -2194,6 +2204,40 @@ void FormulaCompiler::LocalizeString( OUString& /*rName*/ ) const { } +bool FormulaCompiler::IsForceArrayParameter( const FormulaToken* /*pToken*/, sal_uInt16 /*nParam*/ ) const +{ + return false; +} + +void FormulaCompiler::ForceArrayOperator( FormulaTokenRef& rCurr ) +{ + if (!pCurrentFactorToken || (pCurrentFactorToken.get() == rCurr.get())) + return; + + if (!(rCurr->GetOpCode() != ocPush && (rCurr->GetType() == svByte || rCurr->GetType() == svJump))) + return; + + if (pCurrentFactorToken->HasForceArray()) + { + rCurr->SetForceArray( true); + return; + } + + if (nCurrentFactorParam && IsForceArrayParameter( pCurrentFactorToken.get(), + static_cast<sal_uInt8>(nCurrentFactorParam - 1))) + rCurr->SetForceArray( true); +} + +void FormulaCompiler::CheckSetForceArrayParameter( FormulaTokenRef& rCurr, sal_uInt8 nParam ) +{ + if (!pCurrentFactorToken) + return; + + nCurrentFactorParam = nParam + 1; + + ForceArrayOperator( rCurr); +} + void FormulaCompiler::PushTokenArray( FormulaTokenArray* pa, bool bTemp ) { if ( bAutoCorrect && !pStack ) |