diff options
author | Eike Rathke <erack@redhat.com> | 2015-11-16 12:23:15 +0100 |
---|---|---|
committer | Andras Timar <andras.timar@collabora.com> | 2015-11-28 14:15:37 +0100 |
commit | 90a734fd53754471667037bdab91a51492bd22dd (patch) | |
tree | 9e0bf14e3d4739ad45864797662a161254aaf256 /include | |
parent | 08b1d4300dc2476607f77404a787e5a9baea8554 (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>
(cherry picked from commit 29adff38e8a6e340302c104c4632df9c6551bc38)
Diffstat (limited to 'include')
-rw-r--r-- | include/formula/FormulaCompiler.hxx | 29 |
1 files changed, 20 insertions, 9 deletions
diff --git a/include/formula/FormulaCompiler.hxx b/include/formula/FormulaCompiler.hxx index 6f6645b2dd50..b39cb3a2e006 100644 --- a/include/formula/FormulaCompiler.hxx +++ b/include/formula/FormulaCompiler.hxx @@ -298,6 +298,10 @@ protected: virtual void CreateStringFromIndex( OUStringBuffer& rBuffer, const FormulaToken* pToken ) const; virtual void LocalizeString( OUString& rName ) const; // modify rName - input: exact name + /** Whether parameter nParam (0-based) is forced to array for OpCode eOp. + Calc: ForceArray or ReferenceOrForceArray type. */ + virtual bool IsForceArrayParameter( const FormulaToken* pToken, sal_uInt16 nParam ) const; + void AppendErrorConstant( OUStringBuffer& rBuffer, sal_uInt16 nError ) const; bool GetToken(); @@ -328,6 +332,7 @@ protected: FormulaTokenRef mpToken; // current token FormulaTokenRef pCurrentFactorToken; // current factor token (of Factor() method) + sal_uInt16 nCurrentFactorParam; // current factor token's parameter, 1-based FormulaTokenArray* pArr; FormulaToken** pCode; @@ -358,32 +363,38 @@ private: void loadSymbols( sal_uInt16 nSymbols, FormulaGrammar::Grammar eGrammar, NonConstOpCodeMapPtr& rxMap, SeparatorType eSepType = SEMICOLON_BASE ) const; - static inline void ForceArrayOperator( FormulaTokenRef& rCurr, const FormulaTokenRef& rPrev ) - { - if ( rPrev && rPrev->HasForceArray() && rCurr->GetOpCode() != ocPush && - (rCurr->GetType() == svByte || rCurr->GetType() == svJump) && - !rCurr->HasForceArray() ) - rCurr->SetForceArray( true); - } + /** Check pCurrentFactorToken for nParam's (0-based) ForceArray types and + set ForceArray at rCurr if so. Set nParam+1 as 1-based + nCurrentFactorParam for subsequent ForceArrayOperator() calls. + */ + void CheckSetForceArrayParameter( FormulaTokenRef& rCurr, sal_uInt8 nParam ); + + void ForceArrayOperator( FormulaTokenRef& rCurr ); class CurrentFactor { FormulaTokenRef pPrevFac; + sal_uInt16 nPrevParam; FormulaCompiler* pCompiler; CurrentFactor( const CurrentFactor& ) SAL_DELETED_FUNCTION; CurrentFactor& operator=( const CurrentFactor& ) SAL_DELETED_FUNCTION; public: explicit CurrentFactor( FormulaCompiler* pComp ) : pPrevFac( pComp->pCurrentFactorToken ) + , nPrevParam( pComp->nCurrentFactorParam ) , pCompiler( pComp ) {} ~CurrentFactor() - { pCompiler->pCurrentFactorToken = pPrevFac; } + { + pCompiler->pCurrentFactorToken = pPrevFac; + pCompiler->nCurrentFactorParam = nPrevParam; + } // yes, this operator= may modify the RValue void operator=( FormulaTokenRef& r ) { - ForceArrayOperator( r, pPrevFac); + pCompiler->ForceArrayOperator( r ); pCompiler->pCurrentFactorToken = r; + pCompiler->nCurrentFactorParam = 0; } void operator=( FormulaToken* p ) { |