diff options
author | Eike Rathke <erack@redhat.com> | 2017-05-17 15:21:25 +0200 |
---|---|---|
committer | Markus Mohrhard <markus.mohrhard@googlemail.com> | 2017-05-29 10:06:30 +0200 |
commit | 9c89d41ed44c1a4126b82f0c05768f5d640f741b (patch) | |
tree | 90f8837a300f48c4122b0cbdf215cf586dd0827b | |
parent | bcd3e9f29c458847df839724def86f4ebd388cdd (diff) |
Resolves: tdf#96426 more whitespace intersection operator in Excel syntax
Handle also stacked token arrays resulting from named expressions like
=range1 range2
Change-Id: I1838af155f17b5e4f941e46895303caed75b6075
(cherry picked from commit 70cb7757f971c4c16d1b0a5585d95816cd4382e6)
Reviewed-on: https://gerrit.libreoffice.org/37712
Tested-by: Jenkins <ci@libreoffice.org>
Reviewed-by: Markus Mohrhard <markus.mohrhard@googlemail.com>
-rw-r--r-- | formula/source/core/api/FormulaCompiler.cxx | 23 | ||||
-rw-r--r-- | include/formula/FormulaCompiler.hxx | 2 |
2 files changed, 18 insertions, 7 deletions
diff --git a/formula/source/core/api/FormulaCompiler.cxx b/formula/source/core/api/FormulaCompiler.cxx index a271410d5a65..07c39037585a 100644 --- a/formula/source/core/api/FormulaCompiler.cxx +++ b/formula/source/core/api/FormulaCompiler.cxx @@ -1263,7 +1263,7 @@ bool FormulaCompiler::GetToken() if ( nRecursion > nRecursionMax ) { SetError( FormulaError::StackOverflow ); - mpToken = new FormulaByteToken( ocStop ); + mpLastToken = mpToken = new FormulaByteToken( ocStop ); return false; } if ( bAutoCorrect && !pStack ) @@ -1276,7 +1276,6 @@ bool FormulaCompiler::GetToken() bStop = true; else { - FormulaTokenRef pCurrToken = mpToken; FormulaTokenRef pSpacesToken; short nWasColRowName; if ( pArr->nIndex > 0 && pArr->pCode[ pArr->nIndex-1 ]->GetOpCode() == ocColRowName ) @@ -1302,6 +1301,9 @@ bool FormulaCompiler::GetToken() if( pStack ) { PopTokenArray(); + // mpLastToken was popped as well and corresponds to the + // then current last token during PushTokenArray(), e.g. for + // HandleRange(). return GetToken(); } else @@ -1311,17 +1313,17 @@ bool FormulaCompiler::GetToken() { if ( nWasColRowName >= 2 && mpToken->GetOpCode() == ocColRowName ) { // convert an ocSpaces to ocIntersect in RPN - mpToken = new FormulaByteToken( ocIntersect ); + mpLastToken = mpToken = new FormulaByteToken( ocIntersect ); pArr->nIndex--; // we advanced to the second ocColRowName, step back } else if (pSpacesToken && FormulaGrammar::isExcelSyntax( meGrammar) && - pCurrToken && mpToken && - isPotentialRangeType( pCurrToken.get(), false, false) && + mpLastToken && mpToken && + isPotentialRangeType( mpLastToken.get(), false, false) && isPotentialRangeType( mpToken.get(), false, true)) { // Let IntersectionLine() <- Factor() decide how to treat this, // once the actual arguments are determined in RPN. - mpToken = pSpacesToken; + mpLastToken = mpToken = pSpacesToken; pArr->nIndex--; // step back from next non-spaces token return true; } @@ -1329,9 +1331,14 @@ bool FormulaCompiler::GetToken() } if( bStop ) { - mpToken = new FormulaByteToken( ocStop ); + mpLastToken = mpToken = new FormulaByteToken( ocStop ); return false; } + + // Remember token for next round and any PushTokenArray() calls that may + // occur in handlers. + mpLastToken = mpToken; + if ( mpToken->IsExternalRef() ) { return HandleExternalReference(*mpToken); @@ -2060,6 +2067,7 @@ void FormulaCompiler::PopTokenArray() if( p->bTemp ) delete pArr; pArr = p->pArr; + mpLastToken = p->mpLastToken; delete p; } } @@ -2601,6 +2609,7 @@ void FormulaCompiler::PushTokenArray( FormulaTokenArray* pa, bool bTemp ) FormulaArrayStack* p = new FormulaArrayStack; p->pNext = pStack; p->pArr = pArr; + p->mpLastToken = mpLastToken; p->bTemp = bTemp; pStack = p; pArr = pa; diff --git a/include/formula/FormulaCompiler.hxx b/include/formula/FormulaCompiler.hxx index 96d945f220b7..37da2ef8becc 100644 --- a/include/formula/FormulaCompiler.hxx +++ b/include/formula/FormulaCompiler.hxx @@ -58,6 +58,7 @@ struct FormulaArrayStack { FormulaArrayStack* pNext; FormulaTokenArray* pArr; + FormulaTokenRef mpLastToken; bool bTemp; }; @@ -331,6 +332,7 @@ protected: FormulaTokenRef pCurrentFactorToken; // current factor token (of Factor() method) sal_uInt16 nCurrentFactorParam; // current factor token's parameter, 1-based FormulaTokenArray* pArr; + FormulaTokenRef mpLastToken; // last token FormulaToken** pCode; FormulaArrayStack* pStack; |