[Libreoffice-commits] core.git: sc/inc sc/source
Luboš Luňák
l.lunak at collabora.com
Mon May 14 15:33:14 UTC 2018
sc/inc/compiler.hxx | 12 ++++++++----
sc/inc/formulacell.hxx | 8 +++++---
sc/source/core/data/formulacell.cxx | 19 ++++++++++---------
sc/source/core/tool/compiler.cxx | 21 +++++++++++----------
sc/source/core/tool/interpr1.cxx | 4 ++--
5 files changed, 36 insertions(+), 28 deletions(-)
New commits:
commit a9a0601e2af539ab8feed76279181339393ae633
Author: Luboš Luňák <l.lunak at collabora.com>
Date: Thu May 10 13:44:35 2018 +0200
use optional ScInterpreterContext if possible
Avoids assertion with threaded cell computations for tdf#100811/2.
Change-Id: I2dc0fd80595ccec1824c8675fc97cfc763b88659
Reviewed-on: https://gerrit.libreoffice.org/54080
Reviewed-by: Dennis Francis <dennis.francis at collabora.co.uk>
Tested-by: Jenkins <ci at libreoffice.org>
Reviewed-by: Michael Meeks <michael.meeks at collabora.com>
Reviewed-by: Luboš Luňák <l.lunak at collabora.com>
diff --git a/sc/inc/compiler.hxx b/sc/inc/compiler.hxx
index c99b3c934ee6..c569c84b9c6c 100644
--- a/sc/inc/compiler.hxx
+++ b/sc/inc/compiler.hxx
@@ -82,6 +82,7 @@ class ScDocument;
class ScMatrix;
class ScRangeData;
class ScTokenArray;
+struct ScInterpreterContext;
namespace sc {
@@ -331,21 +332,24 @@ private:
static void InitCharClassEnglish();
public:
- ScCompiler( sc::CompileFormulaContext& rCxt, const ScAddress& rPos );
+ ScCompiler( sc::CompileFormulaContext& rCxt, const ScAddress& rPos, const ScInterpreterContext* pContext = nullptr );
/** If eGrammar == GRAM_UNSPECIFIED then the grammar of pDocument is used,
if pDocument==nullptr then GRAM_DEFAULT.
*/
ScCompiler( ScDocument* pDocument, const ScAddress&,
- formula::FormulaGrammar::Grammar eGrammar = formula::FormulaGrammar::GRAM_UNSPECIFIED );
+ formula::FormulaGrammar::Grammar eGrammar = formula::FormulaGrammar::GRAM_UNSPECIFIED,
+ const ScInterpreterContext* pContext = nullptr );
- ScCompiler( sc::CompileFormulaContext& rCxt, const ScAddress& rPos, ScTokenArray& rArr );
+ ScCompiler( sc::CompileFormulaContext& rCxt, const ScAddress& rPos, ScTokenArray& rArr,
+ const ScInterpreterContext* pContext = nullptr );
/** If eGrammar == GRAM_UNSPECIFIED then the grammar of pDocument is used,
if pDocument==nullptr then GRAM_DEFAULT.
*/
ScCompiler( ScDocument* pDocument, const ScAddress&, ScTokenArray& rArr,
- formula::FormulaGrammar::Grammar eGrammar = formula::FormulaGrammar::GRAM_UNSPECIFIED );
+ formula::FormulaGrammar::Grammar eGrammar = formula::FormulaGrammar::GRAM_UNSPECIFIED,
+ const ScInterpreterContext* pContext = nullptr );
virtual ~ScCompiler() override;
diff --git a/sc/inc/formulacell.hxx b/sc/inc/formulacell.hxx
index 376b0d0fbf5a..458dc2e10b7c 100644
--- a/sc/inc/formulacell.hxx
+++ b/sc/inc/formulacell.hxx
@@ -202,11 +202,13 @@ public:
ScFormulaVectorState GetVectorState() const;
void GetFormula( OUString& rFormula,
- const formula::FormulaGrammar::Grammar = formula::FormulaGrammar::GRAM_DEFAULT ) const;
+ const formula::FormulaGrammar::Grammar = formula::FormulaGrammar::GRAM_DEFAULT,
+ const ScInterpreterContext* pContext = nullptr ) const;
void GetFormula( OUStringBuffer& rBuffer,
- const formula::FormulaGrammar::Grammar = formula::FormulaGrammar::GRAM_DEFAULT ) const;
+ const formula::FormulaGrammar::Grammar = formula::FormulaGrammar::GRAM_DEFAULT,
+ const ScInterpreterContext* pContext = nullptr ) const;
- OUString GetFormula( sc::CompileFormulaContext& rCxt ) const;
+ OUString GetFormula( sc::CompileFormulaContext& rCxt, const ScInterpreterContext* pContext = nullptr ) const;
void SetDirty( bool bDirtyFlag=true );
void SetDirtyVar();
diff --git a/sc/source/core/data/formulacell.cxx b/sc/source/core/data/formulacell.cxx
index d0833e1296f0..8c49ec643202 100644
--- a/sc/source/core/data/formulacell.cxx
+++ b/sc/source/core/data/formulacell.cxx
@@ -961,7 +961,7 @@ ScFormulaVectorState ScFormulaCell::GetVectorState() const
}
void ScFormulaCell::GetFormula( OUStringBuffer& rBuffer,
- const FormulaGrammar::Grammar eGrammar ) const
+ const FormulaGrammar::Grammar eGrammar, const ScInterpreterContext* pContext ) const
{
if( pCode->GetCodeError() != FormulaError::NONE && !pCode->GetLen() )
{
@@ -992,7 +992,7 @@ void ScFormulaCell::GetFormula( OUStringBuffer& rBuffer,
}
else
{
- ScCompiler aComp( pDocument, aPos, *pCode, eGrammar);
+ ScCompiler aComp( pDocument, aPos, *pCode, eGrammar, pContext );
aComp.CreateStringFromTokenArray( rBuffer );
}
}
@@ -1003,7 +1003,7 @@ void ScFormulaCell::GetFormula( OUStringBuffer& rBuffer,
}
else
{
- ScCompiler aComp( pDocument, aPos, *pCode, eGrammar);
+ ScCompiler aComp( pDocument, aPos, *pCode, eGrammar, pContext );
aComp.CreateStringFromTokenArray( rBuffer );
}
@@ -1015,21 +1015,22 @@ void ScFormulaCell::GetFormula( OUStringBuffer& rBuffer,
}
}
-void ScFormulaCell::GetFormula( OUString& rFormula, const FormulaGrammar::Grammar eGrammar ) const
+void ScFormulaCell::GetFormula( OUString& rFormula, const FormulaGrammar::Grammar eGrammar,
+ const ScInterpreterContext* pContext ) const
{
OUStringBuffer rBuffer( rFormula );
- GetFormula( rBuffer, eGrammar );
+ GetFormula( rBuffer, eGrammar, pContext );
rFormula = rBuffer.makeStringAndClear();
}
-OUString ScFormulaCell::GetFormula( sc::CompileFormulaContext& rCxt ) const
+OUString ScFormulaCell::GetFormula( sc::CompileFormulaContext& rCxt, const ScInterpreterContext* pContext ) const
{
OUStringBuffer aBuf;
if (pCode->GetCodeError() != FormulaError::NONE && !pCode->GetLen())
{
ScTokenArray aCode;
aCode.AddToken( FormulaErrorToken( pCode->GetCodeError()));
- ScCompiler aComp(rCxt, aPos, aCode);
+ ScCompiler aComp(rCxt, aPos, aCode, pContext);
aComp.CreateStringFromTokenArray(aBuf);
return aBuf.makeStringAndClear();
}
@@ -1056,7 +1057,7 @@ OUString ScFormulaCell::GetFormula( sc::CompileFormulaContext& rCxt ) const
}
else
{
- ScCompiler aComp(rCxt, aPos, *pCode);
+ ScCompiler aComp(rCxt, aPos, *pCode, pContext);
aComp.CreateStringFromTokenArray(aBuf);
}
}
@@ -1067,7 +1068,7 @@ OUString ScFormulaCell::GetFormula( sc::CompileFormulaContext& rCxt ) const
}
else
{
- ScCompiler aComp(rCxt, aPos, *pCode);
+ ScCompiler aComp(rCxt, aPos, *pCode, pContext);
aComp.CreateStringFromTokenArray(aBuf);
}
diff --git a/sc/source/core/tool/compiler.cxx b/sc/source/core/tool/compiler.cxx
index 077ba35b5724..c91af03eed23 100644
--- a/sc/source/core/tool/compiler.cxx
+++ b/sc/source/core/tool/compiler.cxx
@@ -1732,11 +1732,12 @@ struct ConventionXL_R1C1 : public ScCompiler::Convention, public ConventionXL
}
};
-ScCompiler::ScCompiler( sc::CompileFormulaContext& rCxt, const ScAddress& rPos, ScTokenArray& rArr ) :
- FormulaCompiler(rArr),
+ScCompiler::ScCompiler( sc::CompileFormulaContext& rCxt, const ScAddress& rPos, ScTokenArray& rArr,
+ const ScInterpreterContext* pContext )
+ : FormulaCompiler(rArr),
pDoc(rCxt.getDoc()),
aPos(rPos),
- mpFormatter(pDoc->GetFormatTable()),
+ mpFormatter(pContext? pContext->GetFormatTable() : pDoc->GetFormatTable()),
mnCurrentSheetTab(-1),
mnCurrentSheetEndPos(0),
pCharClass(ScGlobal::pCharClass),
@@ -1752,11 +1753,11 @@ ScCompiler::ScCompiler( sc::CompileFormulaContext& rCxt, const ScAddress& rPos,
}
ScCompiler::ScCompiler( ScDocument* pDocument, const ScAddress& rPos, ScTokenArray& rArr,
- formula::FormulaGrammar::Grammar eGrammar )
+ formula::FormulaGrammar::Grammar eGrammar, const ScInterpreterContext* pContext )
: FormulaCompiler(rArr),
pDoc( pDocument ),
aPos( rPos ),
- mpFormatter(pDoc->GetFormatTable()),
+ mpFormatter(pContext ? pContext->GetFormatTable() : pDoc->GetFormatTable()),
mnCurrentSheetTab(-1),
mnCurrentSheetEndPos(0),
nSrcPos(0),
@@ -1773,10 +1774,10 @@ ScCompiler::ScCompiler( ScDocument* pDocument, const ScAddress& rPos, ScTokenArr
eGrammar );
}
-ScCompiler::ScCompiler( sc::CompileFormulaContext& rCxt, const ScAddress& rPos ) :
- pDoc(rCxt.getDoc()),
+ScCompiler::ScCompiler( sc::CompileFormulaContext& rCxt, const ScAddress& rPos, const ScInterpreterContext* pContext )
+ : pDoc(rCxt.getDoc()),
aPos(rPos),
- mpFormatter(pDoc ? pDoc->GetFormatTable() : nullptr),
+ mpFormatter(pContext ? pContext->GetFormatTable() : pDoc ? pDoc->GetFormatTable() : nullptr),
mnCurrentSheetTab(-1),
mnCurrentSheetEndPos(0),
pCharClass(ScGlobal::pCharClass),
@@ -1792,11 +1793,11 @@ ScCompiler::ScCompiler( sc::CompileFormulaContext& rCxt, const ScAddress& rPos )
}
ScCompiler::ScCompiler( ScDocument* pDocument, const ScAddress& rPos,
- formula::FormulaGrammar::Grammar eGrammar )
+ formula::FormulaGrammar::Grammar eGrammar, const ScInterpreterContext* pContext )
:
pDoc( pDocument ),
aPos( rPos ),
- mpFormatter(pDoc ? pDoc->GetFormatTable() : nullptr),
+ mpFormatter(pContext ? pContext->GetFormatTable() : pDoc ? pDoc->GetFormatTable() : nullptr),
mnCurrentSheetTab(-1),
mnCurrentSheetEndPos(0),
nSrcPos(0),
diff --git a/sc/source/core/tool/interpr1.cxx b/sc/source/core/tool/interpr1.cxx
index 4abacf0ca3cf..712c0537e330 100644
--- a/sc/source/core/tool/interpr1.cxx
+++ b/sc/source/core/tool/interpr1.cxx
@@ -2679,7 +2679,7 @@ void ScInterpreter::ScFormula()
switch (aCell.meType)
{
case CELLTYPE_FORMULA :
- aCell.mpFormula->GetFormula(aFormula);
+ aCell.mpFormula->GetFormula(aFormula, formula::FormulaGrammar::GRAM_UNSPECIFIED, &mrContext);
pResMat->PutString( mrStrPool.intern( aFormula), i,j);
break;
default:
@@ -2705,7 +2705,7 @@ void ScInterpreter::ScFormula()
switch (aCell.meType)
{
case CELLTYPE_FORMULA :
- aCell.mpFormula->GetFormula(aFormula);
+ aCell.mpFormula->GetFormula(aFormula, formula::FormulaGrammar::GRAM_UNSPECIFIED, &mrContext);
break;
default:
SetError( FormulaError::NotAvailable );
More information about the Libreoffice-commits
mailing list