[Libreoffice-commits] core.git: 3 commits - formula/source include/formula sc/source
Eike Rathke
erack at redhat.com
Fri Mar 6 15:25:38 PST 2015
formula/source/core/api/token.cxx | 18 ++++++++++++++++++
include/formula/tokenarray.hxx | 4 ++++
sc/source/core/tool/compiler.cxx | 28 ++++++++++++++++++++++++----
3 files changed, 46 insertions(+), 4 deletions(-)
New commits:
commit 333f8a76341f5b4921e89012d133007503e49612
Author: Eike Rathke <erack at redhat.com>
Date: Fri Mar 6 23:22:45 2015 +0100
first stab at handling table[] all range
Change-Id: I608cf04cf4b0b991f4a45a868566faeae5be77c9
diff --git a/sc/source/core/tool/compiler.cxx b/sc/source/core/tool/compiler.cxx
index 0ab8f9b..dce9171 100644
--- a/sc/source/core/tool/compiler.cxx
+++ b/sc/source/core/tool/compiler.cxx
@@ -3931,6 +3931,17 @@ ScTokenArray* ScCompiler::CompileString( const OUString& rFormula )
{
static_cast<ScTokenArray*>(pArr)->MergeRangeReference( aPos);
}
+ else if (eLastOp == ocDBArea && pNewToken->GetOpCode() == ocTableRefOpen)
+ {
+ sal_uInt16 nIdx = pArr->GetLen() - 1;
+ const FormulaToken* pPrev = pArr->PeekPrev( nIdx);
+ if (pPrev && pPrev->GetOpCode() == ocDBArea)
+ {
+ // pPrev may be dead hereafter.
+ static_cast<ScTokenArray*>(pArr)->ReplaceToken( 1,
+ new ScTableRefToken( pPrev->GetIndex(), ScTableRefToken::ALL));
+ }
+ }
eLastOp = maRawToken.GetOpCode();
if ( bAutoCorrect )
aCorrectedFormula += aCorrectedSymbol;
@@ -4664,12 +4675,19 @@ bool ScCompiler::HandleTableRef()
aRange.aEnd.SetTab(aRange.aStart.Tab());
ScTokenArray* pNew = new ScTokenArray();
ScTableRefToken::Item eItem = pTR->GetItem();
+ bool bGotToken = false;
if (eItem == ScTableRefToken::ALL)
{
ScComplexRefData aRefData;
aRefData.InitFlags();
aRefData.SetRange(aRange, aPos);
pNew->AddDoubleReference( aRefData );
+ // Optional [] (or [#All]) may follow.
+ if ((bGotToken = GetToken()) && mpToken->GetOpCode() == ocTableRefOpen)
+ {
+ if ((bGotToken = GetToken()) && mpToken->GetOpCode() == ocTableRefClose)
+ bGotToken = false; // get next token below
+ }
}
else
{
@@ -4678,7 +4696,7 @@ bool ScCompiler::HandleTableRef()
}
PushTokenArray( pNew, true );
pNew->Reset();
- return GetToken();
+ return bGotToken ? true : GetToken();
}
return true;
}
commit 40c9a46b78b8919aae82dd9b94774d63bb9cb4e6
Author: Eike Rathke <erack at redhat.com>
Date: Fri Mar 6 22:39:53 2015 +0100
add FormulaTokenArray::ReplaceToken()
Change-Id: I42c893677c1b8a35ee502a9ae438d4c0f19867d3
diff --git a/formula/source/core/api/token.cxx b/formula/source/core/api/token.cxx
index 567c12c..117f276 100644
--- a/formula/source/core/api/token.cxx
+++ b/formula/source/core/api/token.cxx
@@ -849,6 +849,24 @@ FormulaToken* FormulaTokenArray::MergeArray( )
return NULL;
}
+FormulaToken* FormulaTokenArray::ReplaceToken( sal_uInt16 nOffset, FormulaToken* t )
+{
+ if (nOffset < nLen)
+ {
+ CheckToken(*t);
+ sal_uInt16 nPos = nLen - nOffset - 1;
+ t->IncRef();
+ pCode[nPos]->DecRef();
+ pCode[nPos] = t;
+ return t;
+ }
+ else
+ {
+ t->Delete();
+ return NULL;
+ }
+}
+
FormulaToken* FormulaTokenArray::Add( FormulaToken* t )
{
if( !pCode )
diff --git a/include/formula/tokenarray.hxx b/include/formula/tokenarray.hxx
index 244a7b9..c70e6c1d 100644
--- a/include/formula/tokenarray.hxx
+++ b/include/formula/tokenarray.hxx
@@ -115,6 +115,10 @@ protected:
/// Also used by the compiler. The token MUST had been allocated with new!
FormulaToken* Add( FormulaToken* );
+ /** Also used by the compiler. The token MUST had been allocated with new!
+ @param nOffset negative offset of token, 0==last, 1==previous, ...
+ */
+ FormulaToken* ReplaceToken( sal_uInt16 nOffset, FormulaToken* );
inline void SetCombinedBitsRecalcMode( ScRecalcMode nBits )
{ nMode |= (nBits & ~RECALCMODE_EMASK); }
inline ScRecalcMode GetCombinedBitsRecalcMode() const
commit bc4293bde13001a5e959ff90c189111932c05b3b
Author: Eike Rathke <erack at redhat.com>
Date: Fri Mar 6 21:56:22 2015 +0100
clarify this visually
Change-Id: I04c1a00903cc0c057fc436e391f93b1e05eed8a1
diff --git a/sc/source/core/tool/compiler.cxx b/sc/source/core/tool/compiler.cxx
index 6469918..0ab8f9b 100644
--- a/sc/source/core/tool/compiler.cxx
+++ b/sc/source/core/tool/compiler.cxx
@@ -3924,11 +3924,13 @@ ScTokenArray* ScCompiler::CompileString( const OUString& rFormula )
FormulaToken* pNewToken = static_cast<ScTokenArray*>(pArr)->Add( maRawToken.CreateToken());
if (!pNewToken)
{
- SetError(errCodeOverflow); break;
+ SetError(errCodeOverflow);
+ break;
}
- else if (eLastOp == ocRange && pNewToken->GetOpCode() == ocPush &&
- pNewToken->GetType() == svSingleRef)
+ else if (eLastOp == ocRange && pNewToken->GetOpCode() == ocPush && pNewToken->GetType() == svSingleRef)
+ {
static_cast<ScTokenArray*>(pArr)->MergeRangeReference( aPos);
+ }
eLastOp = maRawToken.GetOpCode();
if ( bAutoCorrect )
aCorrectedFormula += aCorrectedSymbol;
More information about the Libreoffice-commits
mailing list