[Libreoffice-commits] core.git: 3 commits - sc/inc sc/qa sc/source
Eike Rathke
erack at redhat.com
Thu May 18 13:03:33 UTC 2017
sc/inc/compiler.hxx | 12 ++++++++++--
sc/qa/unit/helper/qahelper.cxx | 6 ++----
sc/qa/unit/ucalc_condformat.cxx | 12 ++++--------
sc/qa/unit/ucalc_formula.cxx | 18 ++++++------------
sc/source/core/data/column.cxx | 3 +--
sc/source/core/data/conditio.cxx | 6 ++----
sc/source/core/data/formulacell.cxx | 24 ++++++++----------------
sc/source/core/data/grouptokenconverter.cxx | 3 +--
sc/source/core/data/simpleformulacalc.cxx | 6 ++----
sc/source/core/opencl/formulagroupcl.cxx | 3 +--
sc/source/core/tool/compiler.cxx | 14 +++++++++++---
sc/source/core/tool/interpr1.cxx | 6 ++----
sc/source/core/tool/rangenam.cxx | 15 +++++----------
sc/source/core/tool/reftokenhelper.cxx | 3 +--
sc/source/filter/excel/xechart.cxx | 3 +--
sc/source/filter/excel/xeroot.cxx | 3 +--
sc/source/filter/excel/xestream.cxx | 1 +
sc/source/filter/excel/xichart.cxx | 3 +--
sc/source/filter/oox/defnamesbuffer.cxx | 3 +--
sc/source/filter/oox/formulabuffer.cxx | 9 +++------
sc/source/filter/oox/revisionfragment.cxx | 3 +--
sc/source/filter/orcus/interface.cxx | 6 ++----
sc/source/filter/xml/xmlimprt.cxx | 3 +--
sc/source/ui/app/inputhdl.cxx | 3 +--
sc/source/ui/condformat/condformatdlgentry.cxx | 3 +--
sc/source/ui/docshell/docfunc.cxx | 3 +--
sc/source/ui/docshell/impex.cxx | 3 +--
sc/source/ui/formdlg/formula.cxx | 3 +--
sc/source/ui/miscdlgs/anyrefdg.cxx | 3 +--
sc/source/ui/namedlg/namedefdlg.cxx | 3 +--
sc/source/ui/namedlg/namedlg.cxx | 3 +--
sc/source/ui/unoobj/chart2uno.cxx | 6 ++----
sc/source/ui/unoobj/funcuno.cxx | 3 +--
sc/source/ui/unoobj/servuno.cxx | 3 +--
sc/source/ui/unoobj/tokenuno.cxx | 12 ++++--------
sc/source/ui/vba/vbaname.cxx | 3 +--
sc/source/ui/vba/vbanames.cxx | 3 +--
sc/source/ui/vba/vbarange.cxx | 6 ++----
sc/source/ui/view/tabvwsha.cxx | 3 +--
sc/source/ui/view/viewfun2.cxx | 3 +--
sc/source/ui/view/viewfun4.cxx | 3 +--
sc/source/ui/view/viewfunc.cxx | 3 +--
42 files changed, 92 insertions(+), 145 deletions(-)
New commits:
commit 1469a83ca1d712e30131597d70dad1b3eb322175
Author: Eike Rathke <erack at redhat.com>
Date: Thu May 18 14:59:54 2017 +0200
Pass grammar to ScCompiler ctor instead of subsequent SetGrammar()
Not only to have more concise code but also to avoid setting grammar
twice if the actual grammar differs from the document's default one.
Change-Id: I7bfd151c22c48a40aea05f5f983fa0370d9fd9ae
diff --git a/sc/qa/unit/helper/qahelper.cxx b/sc/qa/unit/helper/qahelper.cxx
index 7412e39e1188..3c70609298f1 100644
--- a/sc/qa/unit/helper/qahelper.cxx
+++ b/sc/qa/unit/helper/qahelper.cxx
@@ -480,8 +480,7 @@ ScTokenArray* compileFormula(
ScAddress aPos(0,0,0);
if (pPos)
aPos = *pPos;
- ScCompiler aComp(pDoc, aPos);
- aComp.SetGrammar(eGram);
+ ScCompiler aComp(pDoc, aPos, eGram);
return aComp.CompileString(rFormula);
}
@@ -554,8 +553,7 @@ bool isFormulaWithoutError(ScDocument& rDoc, const ScAddress& rPos)
OUString toString(
ScDocument& rDoc, const ScAddress& rPos, ScTokenArray& rArray, formula::FormulaGrammar::Grammar eGram)
{
- ScCompiler aComp(&rDoc, rPos, rArray);
- aComp.SetGrammar(eGram);
+ ScCompiler aComp(&rDoc, rPos, rArray, eGram);
OUStringBuffer aBuf;
aComp.CreateStringFromTokenArray(aBuf);
return aBuf.makeStringAndClear();
diff --git a/sc/qa/unit/ucalc_condformat.cxx b/sc/qa/unit/ucalc_condformat.cxx
index 60344c248bde..d436b2b0aff8 100644
--- a/sc/qa/unit/ucalc_condformat.cxx
+++ b/sc/qa/unit/ucalc_condformat.cxx
@@ -739,8 +739,7 @@ void Test::testFormulaListenerSingleCellToSingleCell()
{
m_pDoc->InsertTab(0, "test");
- ScCompiler aCompiler(m_pDoc, ScAddress(10, 10, 0));
- aCompiler.SetGrammar(formula::FormulaGrammar::GRAM_ENGLISH);
+ ScCompiler aCompiler(m_pDoc, ScAddress(10, 10, 0), formula::FormulaGrammar::GRAM_ENGLISH);
std::unique_ptr<ScTokenArray> pTokenArray(aCompiler.CompileString("A1"));
@@ -758,8 +757,7 @@ void Test::testFormulaListenerSingleCellToMultipleCells()
{
m_pDoc->InsertTab(0, "test");
- ScCompiler aCompiler(m_pDoc, ScAddress(10, 10, 0));
- aCompiler.SetGrammar(formula::FormulaGrammar::GRAM_ENGLISH);
+ ScCompiler aCompiler(m_pDoc, ScAddress(10, 10, 0), formula::FormulaGrammar::GRAM_ENGLISH);
std::unique_ptr<ScTokenArray> pTokenArray(aCompiler.CompileString("A1"));
@@ -777,8 +775,7 @@ void Test::testFormulaListenerMultipleCellsToSingleCell()
{
m_pDoc->InsertTab(0, "test");
- ScCompiler aCompiler(m_pDoc, ScAddress(10, 10, 0));
- aCompiler.SetGrammar(formula::FormulaGrammar::GRAM_ENGLISH);
+ ScCompiler aCompiler(m_pDoc, ScAddress(10, 10, 0), formula::FormulaGrammar::GRAM_ENGLISH);
std::unique_ptr<ScTokenArray> pTokenArray(aCompiler.CompileString("A1"));
@@ -796,8 +793,7 @@ void Test::testFormulaListenerMultipleCellsToMultipleCells()
{
m_pDoc->InsertTab(0, "test");
- ScCompiler aCompiler(m_pDoc, ScAddress(10, 10, 0));
- aCompiler.SetGrammar(formula::FormulaGrammar::GRAM_ENGLISH);
+ ScCompiler aCompiler(m_pDoc, ScAddress(10, 10, 0), formula::FormulaGrammar::GRAM_ENGLISH);
std::unique_ptr<ScTokenArray> pTokenArray(aCompiler.CompileString("A1"));
diff --git a/sc/qa/unit/ucalc_formula.cxx b/sc/qa/unit/ucalc_formula.cxx
index cfae1a45a00d..223b88dd1f2f 100644
--- a/sc/qa/unit/ucalc_formula.cxx
+++ b/sc/qa/unit/ucalc_formula.cxx
@@ -198,8 +198,7 @@ void Test::testFormulaCreateStringFromTokens()
#if 0
OUString aFormula = OUString::createFromAscii(aTests[i]);
#endif
- ScCompiler aComp(m_pDoc, aPos);
- aComp.SetGrammar(FormulaGrammar::GRAM_ENGLISH);
+ ScCompiler aComp(m_pDoc, aPos, FormulaGrammar::GRAM_ENGLISH);
#if 0 // TODO: This call to CompileString() causes the cppunittester to somehow fail on Windows.
pArray.reset(aComp.CompileString(aFormula));
CPPUNIT_ASSERT_MESSAGE("Failed to compile formula string.", pArray.get());
@@ -1053,8 +1052,7 @@ void Test::testFormulaCompilerJumpReordering()
CPPUNIT_ASSERT(pCode.get());
// Then generate RPN tokens.
- ScCompiler aCompRPN(m_pDoc, ScAddress(), *pCode);
- aCompRPN.SetGrammar(FormulaGrammar::GRAM_NATIVE);
+ ScCompiler aCompRPN(m_pDoc, ScAddress(), *pCode, FormulaGrammar::GRAM_NATIVE);
aCompRPN.CompileTokenArray();
// RPN tokens should be ordered: B1, ocIf, C1, ocSep, D1, ocClose.
@@ -1082,8 +1080,7 @@ void Test::testFormulaCompilerJumpReordering()
// Generate RPN tokens again, but this time no jump command reordering.
pCode->DelRPN();
- ScCompiler aCompRPN2(m_pDoc, ScAddress(), *pCode);
- aCompRPN2.SetGrammar(FormulaGrammar::GRAM_NATIVE);
+ ScCompiler aCompRPN2(m_pDoc, ScAddress(), *pCode, FormulaGrammar::GRAM_NATIVE);
aCompRPN2.EnableJumpCommandReorder(false);
aCompRPN2.CompileTokenArray();
@@ -3526,8 +3523,7 @@ void Test::testTokenArrayRefUpdateMove()
for (const OUString& aTest : aTests)
{
- ScCompiler aComp(m_pDoc, aPos);
- aComp.SetGrammar(m_pDoc->GetGrammar());
+ ScCompiler aComp(m_pDoc, aPos, m_pDoc->GetGrammar());
std::unique_ptr<ScTokenArray> pArray(aComp.CompileString(aTest));
OUString aStr = pArray->CreateString(aCxt, aPos);
@@ -7780,8 +7776,7 @@ void Test::testRefR1C1WholeCol()
CPPUNIT_ASSERT(m_pDoc->InsertTab (0, "Test"));
ScAddress aPos(1, 1, 1);
- ScCompiler aComp(m_pDoc, aPos);
- aComp.SetGrammar(FormulaGrammar::GRAM_ENGLISH_XL_R1C1);
+ ScCompiler aComp(m_pDoc, aPos, FormulaGrammar::GRAM_ENGLISH_XL_R1C1);
std::unique_ptr<ScTokenArray> pTokens(aComp.CompileString("=C[10]"));
sc::TokenStringContext aCxt(m_pDoc, formula::FormulaGrammar::GRAM_ENGLISH);
OUString aFormula = pTokens->CreateString(aCxt, aPos);
@@ -7796,8 +7791,7 @@ void Test::testRefR1C1WholeRow()
CPPUNIT_ASSERT(m_pDoc->InsertTab (0, "Test"));
ScAddress aPos(1, 1, 1);
- ScCompiler aComp(m_pDoc, aPos);
- aComp.SetGrammar(FormulaGrammar::GRAM_ENGLISH_XL_R1C1);
+ ScCompiler aComp(m_pDoc, aPos, FormulaGrammar::GRAM_ENGLISH_XL_R1C1);
std::unique_ptr<ScTokenArray> pTokens(aComp.CompileString("=R[3]"));
sc::TokenStringContext aCxt(m_pDoc, formula::FormulaGrammar::GRAM_ENGLISH);
OUString aFormula = pTokens->CreateString(aCxt, aPos);
diff --git a/sc/source/core/data/column.cxx b/sc/source/core/data/column.cxx
index 824fdca25921..6895b49aff23 100644
--- a/sc/source/core/data/column.cxx
+++ b/sc/source/core/data/column.cxx
@@ -2074,8 +2074,7 @@ class UpdateRefOnNonCopy : public std::unary_function<sc::FormulaGroupEntry, voi
// We need to re-compile the token array when a range name is
// modified, to correctly reflect the new references in the
// name.
- ScCompiler aComp(&mpCxt->mrDoc, rTopCell.aPos, *rTopCell.GetCode());
- aComp.SetGrammar(mpCxt->mrDoc.GetGrammar());
+ ScCompiler aComp(&mpCxt->mrDoc, rTopCell.aPos, *rTopCell.GetCode(), mpCxt->mrDoc.GetGrammar());
aComp.CompileTokenArray();
}
diff --git a/sc/source/core/data/conditio.cxx b/sc/source/core/data/conditio.cxx
index e0ad06cf9a77..502d0b1e0623 100644
--- a/sc/source/core/data/conditio.cxx
+++ b/sc/source/core/data/conditio.cxx
@@ -1327,8 +1327,7 @@ OUString ScConditionEntry::GetExpression( const ScAddress& rCursor, sal_uInt16 n
{
if ( pFormula1 )
{
- ScCompiler aComp(mpDoc, rCursor, *pFormula1);
- aComp.SetGrammar(eGrammar);
+ ScCompiler aComp(mpDoc, rCursor, *pFormula1, eGrammar);
OUStringBuffer aBuffer;
aComp.CreateStringFromTokenArray( aBuffer );
aRet = aBuffer.makeStringAndClear();
@@ -1346,8 +1345,7 @@ OUString ScConditionEntry::GetExpression( const ScAddress& rCursor, sal_uInt16 n
{
if ( pFormula2 )
{
- ScCompiler aComp(mpDoc, rCursor, *pFormula2);
- aComp.SetGrammar(eGrammar);
+ ScCompiler aComp(mpDoc, rCursor, *pFormula2, eGrammar);
OUStringBuffer aBuffer;
aComp.CreateStringFromTokenArray( aBuffer );
aRet = aBuffer.makeStringAndClear();
diff --git a/sc/source/core/data/formulacell.cxx b/sc/source/core/data/formulacell.cxx
index 18eb260db938..89b8d4618f35 100644
--- a/sc/source/core/data/formulacell.cxx
+++ b/sc/source/core/data/formulacell.cxx
@@ -556,8 +556,7 @@ void ScFormulaCellGroup::compileCode(
if (mpCode->GetLen() && mpCode->GetCodeError() == FormulaError::NONE && !mpCode->GetCodeLen())
{
- ScCompiler aComp(&rDoc, rPos, *mpCode);
- aComp.SetGrammar(eGram);
+ ScCompiler aComp(&rDoc, rPos, *mpCode, eGram);
mbSubTotal = aComp.CompileTokenArray();
mnFormatType = aComp.GetNumFormatType();
}
@@ -699,8 +698,7 @@ ScFormulaCell::ScFormulaCell(
// Generate RPN token array.
if (pCode->GetLen() && pCode->GetCodeError() == FormulaError::NONE && !pCode->GetCodeLen())
{
- ScCompiler aComp( pDocument, aPos, *pCode);
- aComp.SetGrammar(eTempGrammar);
+ ScCompiler aComp( pDocument, aPos, *pCode, eTempGrammar);
bSubTotal = aComp.CompileTokenArray();
nFormatType = aComp.GetNumFormatType();
}
@@ -749,8 +747,7 @@ ScFormulaCell::ScFormulaCell(
// RPN array generation
if( pCode->GetLen() && pCode->GetCodeError() == FormulaError::NONE && !pCode->GetCodeLen() )
{
- ScCompiler aComp( pDocument, aPos, *pCode);
- aComp.SetGrammar(eTempGrammar);
+ ScCompiler aComp( pDocument, aPos, *pCode, eTempGrammar);
bSubTotal = aComp.CompileTokenArray();
nFormatType = aComp.GetNumFormatType();
}
@@ -1001,8 +998,7 @@ void ScFormulaCell::GetFormula( OUStringBuffer& rBuffer,
}
else
{
- ScCompiler aComp( pDocument, aPos, *pCode);
- aComp.SetGrammar(eGrammar);
+ ScCompiler aComp( pDocument, aPos, *pCode, eGrammar);
aComp.CreateStringFromTokenArray( rBuffer );
}
}
@@ -1013,8 +1009,7 @@ void ScFormulaCell::GetFormula( OUStringBuffer& rBuffer,
}
else
{
- ScCompiler aComp( pDocument, aPos, *pCode);
- aComp.SetGrammar(eGrammar);
+ ScCompiler aComp( pDocument, aPos, *pCode, eGrammar);
aComp.CreateStringFromTokenArray( rBuffer );
}
@@ -1132,8 +1127,7 @@ void ScFormulaCell::Compile( const OUString& rFormula, bool bNoListening,
if ( pCode )
pCode->Clear();
ScTokenArray* pCodeOld = pCode;
- ScCompiler aComp( pDocument, aPos);
- aComp.SetGrammar(eGrammar);
+ ScCompiler aComp( pDocument, aPos, eGrammar);
pCode = aComp.CompileString( rFormula );
delete pCodeOld;
if( pCode->GetCodeError() == FormulaError::NONE )
@@ -1209,8 +1203,7 @@ void ScFormulaCell::CompileTokenArray( bool bNoListening )
if( !bNoListening && pCode->GetCodeLen() )
EndListeningTo( pDocument );
- ScCompiler aComp(pDocument, aPos, *pCode);
- aComp.SetGrammar(pDocument->GetGrammar());
+ ScCompiler aComp(pDocument, aPos, *pCode, pDocument->GetGrammar());
bSubTotal = aComp.CompileTokenArray();
if( pCode->GetCodeError() == FormulaError::NONE )
{
@@ -4279,8 +4272,7 @@ bool ScFormulaCell::InterpretInvariantFormulaGroup()
}
}
- ScCompiler aComp(pDocument, aPos, aCode);
- aComp.SetGrammar(pDocument->GetGrammar());
+ ScCompiler aComp(pDocument, aPos, aCode, pDocument->GetGrammar());
aComp.CompileTokenArray(); // Create RPN token array.
ScInterpreter aInterpreter(this, pDocument, aPos, aCode);
aInterpreter.Interpret();
diff --git a/sc/source/core/data/grouptokenconverter.cxx b/sc/source/core/data/grouptokenconverter.cxx
index 12751a178364..8132c1c400f1 100644
--- a/sc/source/core/data/grouptokenconverter.cxx
+++ b/sc/source/core/data/grouptokenconverter.cxx
@@ -96,8 +96,7 @@ bool ScGroupTokenConverter::convert( ScTokenArray& rCode, sc::FormulaLogger::Gro
{
#if 0
{ // debug to start with:
- ScCompiler aComp( &mrDoc, mrPos, rCode);
- aComp.SetGrammar(formula::FormulaGrammar::GRAM_NATIVE_XL_R1C1);
+ ScCompiler aComp( &mrDoc, mrPos, rCode, formula::FormulaGrammar::GRAM_NATIVE_XL_R1C1);
OUStringBuffer aAsString;
aComp.CreateStringFromTokenArray(aAsString);
}
diff --git a/sc/source/core/data/simpleformulacalc.cxx b/sc/source/core/data/simpleformulacalc.cxx
index 4a240b58a01a..ad4f01fc99bf 100644
--- a/sc/source/core/data/simpleformulacalc.cxx
+++ b/sc/source/core/data/simpleformulacalc.cxx
@@ -28,8 +28,7 @@ ScSimpleFormulaCalculator::ScSimpleFormulaCalculator( ScDocument* pDoc, const Sc
, mbMatrixFormula(bMatrixFormula)
{
// compile already here
- ScCompiler aComp(mpDoc, maAddr);
- aComp.SetGrammar(eGram);
+ ScCompiler aComp(mpDoc, maAddr, eGram);
mpCode.reset(aComp.CompileString(rFormula));
if(mpCode->GetCodeError() == FormulaError::NONE && mpCode->GetLen())
aComp.CompileTokenArray();
@@ -56,8 +55,7 @@ void ScSimpleFormulaCalculator::Calculate()
formula::StackVar aIntType = aInt.Interpret();
if ( aIntType == formula::svMatrixCell )
{
- ScCompiler aComp(mpDoc, maAddr);
- aComp.SetGrammar(maGram);
+ ScCompiler aComp(mpDoc, maAddr, maGram);
OUStringBuffer aStr;
aComp.CreateStringFromToken(aStr, aInt.GetResultToken().get());
diff --git a/sc/source/core/opencl/formulagroupcl.cxx b/sc/source/core/opencl/formulagroupcl.cxx
index c066d74fc501..35f1d7906006 100644
--- a/sc/source/core/opencl/formulagroupcl.cxx
+++ b/sc/source/core/opencl/formulagroupcl.cxx
@@ -4171,8 +4171,7 @@ CLInterpreterContext createCLInterpreterContext( const ScCalcConfig& rConfig,
void genRPNTokens( ScDocument& rDoc, const ScAddress& rTopPos, ScTokenArray& rCode )
{
- ScCompiler aComp(&rDoc, rTopPos, rCode);
- aComp.SetGrammar(rDoc.GetGrammar());
+ ScCompiler aComp(&rDoc, rTopPos, rCode, rDoc.GetGrammar());
// Disable special ordering for jump commands for the OpenCL interpreter.
aComp.EnableJumpCommandReorder(false);
aComp.CompileTokenArray(); // Regenerate RPN tokens.
diff --git a/sc/source/core/tool/interpr1.cxx b/sc/source/core/tool/interpr1.cxx
index 36e5107a814f..29f51d6326a1 100644
--- a/sc/source/core/tool/interpr1.cxx
+++ b/sc/source/core/tool/interpr1.cxx
@@ -2361,8 +2361,7 @@ void ScInterpreter::ScCellExternal()
// ODF 1.2 says we need to always display address using the ODF A1 grammar.
ScTokenArray aArray;
aArray.AddExternalSingleReference(nFileId, svl::SharedString( aTabName), aRef); // string not interned
- ScCompiler aComp(pDok, aPos, aArray);
- aComp.SetGrammar(formula::FormulaGrammar::GRAM_ODFF_A1);
+ ScCompiler aComp(pDok, aPos, aArray, formula::FormulaGrammar::GRAM_ODFF_A1);
OUString aStr;
aComp.CreateStringFromTokenArray(aStr);
PushString(aStr);
@@ -7303,8 +7302,7 @@ void ScInterpreter::ScIndirect()
{
do
{
- ScCompiler aComp( pDok, aPos);
- aComp.SetGrammar( pDok->GetGrammar());
+ ScCompiler aComp( pDok, aPos, pDok->GetGrammar());
aComp.SetRefConvention( eConv); // must be after grammar
std::unique_ptr<ScTokenArray> pArr( aComp.CompileString( sRefStr));
diff --git a/sc/source/core/tool/rangenam.cxx b/sc/source/core/tool/rangenam.cxx
index 1728460f9767..7b6e4ad96075 100644
--- a/sc/source/core/tool/rangenam.cxx
+++ b/sc/source/core/tool/rangenam.cxx
@@ -119,8 +119,7 @@ ScRangeData::ScRangeData( ScDocument* pDok,
aRefData.SetFlag3D( true );
pCode->AddSingleReference( aRefData );
pCode->SetFromRangeName(true);
- ScCompiler aComp( pDoc, aPos, *pCode );
- aComp.SetGrammar(pDoc->GetGrammar());
+ ScCompiler aComp( pDoc, aPos, *pCode, pDoc->GetGrammar() );
aComp.CompileTokenArray();
if ( pCode->GetCodeError() == FormulaError::NONE )
eType |= Type::AbsPos;
@@ -156,8 +155,7 @@ void ScRangeData::CompileRangeData( const OUString& rSymbol, bool bSetError )
eTempGrammar = FormulaGrammar::GRAM_NATIVE;
}
- ScCompiler aComp( pDoc, aPos );
- aComp.SetGrammar( eTempGrammar);
+ ScCompiler aComp( pDoc, aPos, eTempGrammar );
if (bSetError)
aComp.SetExtendedErrorDetection( ScCompiler::EXTENDED_ERROR_DETECTION_NAME_NO_BREAK);
ScTokenArray* pNewCode = aComp.CompileString( rSymbol );
@@ -252,16 +250,14 @@ void ScRangeData::GuessPosition()
void ScRangeData::GetSymbol( OUString& rSymbol, const FormulaGrammar::Grammar eGrammar ) const
{
- ScCompiler aComp(pDoc, aPos, *pCode);
- aComp.SetGrammar(eGrammar);
+ ScCompiler aComp(pDoc, aPos, *pCode, eGrammar);
aComp.CreateStringFromTokenArray( rSymbol );
}
void ScRangeData::GetSymbol( OUString& rSymbol, const ScAddress& rPos, const FormulaGrammar::Grammar eGrammar ) const
{
OUString aStr;
- ScCompiler aComp(pDoc, rPos, *pCode);
- aComp.SetGrammar(eGrammar);
+ ScCompiler aComp(pDoc, rPos, *pCode, eGrammar);
aComp.CreateStringFromTokenArray( aStr );
rSymbol = aStr;
}
@@ -269,8 +265,7 @@ void ScRangeData::GetSymbol( OUString& rSymbol, const ScAddress& rPos, const For
void ScRangeData::UpdateSymbol( OUStringBuffer& rBuffer, const ScAddress& rPos )
{
std::unique_ptr<ScTokenArray> pTemp( pCode->Clone() );
- ScCompiler aComp( pDoc, rPos, *pTemp.get());
- aComp.SetGrammar(formula::FormulaGrammar::GRAM_DEFAULT);
+ ScCompiler aComp( pDoc, rPos, *pTemp.get(), formula::FormulaGrammar::GRAM_DEFAULT);
aComp.MoveRelWrap(GetMaxCol(), GetMaxRow());
aComp.CreateStringFromTokenArray( rBuffer );
}
diff --git a/sc/source/core/tool/reftokenhelper.cxx b/sc/source/core/tool/reftokenhelper.cxx
index 8e90b038cc61..e2c5289b24b6 100644
--- a/sc/source/core/tool/reftokenhelper.cxx
+++ b/sc/source/core/tool/reftokenhelper.cxx
@@ -51,8 +51,7 @@ void ScRefTokenHelper::compileRangeRepresentation(
if (nOffset < 0)
break;
- ScCompiler aCompiler(pDoc, ScAddress(0,0,0));
- aCompiler.SetGrammar(eGrammar);
+ ScCompiler aCompiler(pDoc, ScAddress(0,0,0), eGrammar);
std::unique_ptr<ScTokenArray> pArray(aCompiler.CompileString(aToken));
// There MUST be exactly one reference per range token and nothing
diff --git a/sc/source/filter/excel/xechart.cxx b/sc/source/filter/excel/xechart.cxx
index 5a4509946dd4..5554d8dde094 100644
--- a/sc/source/filter/excel/xechart.cxx
+++ b/sc/source/filter/excel/xechart.cxx
@@ -897,8 +897,7 @@ sal_uInt16 XclExpChSourceLink::ConvertDataSequence( Reference< XDataSequence > c
// Compile the range representation string into token array. Note that the
// source range text depends on the current grammar.
OUString aRangeRepr = xDataSeq->getSourceRangeRepresentation();
- ScCompiler aComp( &GetDocRef(), ScAddress() );
- aComp.SetGrammar( GetDocRef().GetGrammar() );
+ ScCompiler aComp( &GetDocRef(), ScAddress(), GetDocRef().GetGrammar() );
std::unique_ptr<ScTokenArray> pArray(aComp.CompileString(aRangeRepr));
if( !pArray )
return nDefCount;
diff --git a/sc/source/filter/excel/xeroot.cxx b/sc/source/filter/excel/xeroot.cxx
index a06b01adbdc6..f2851a5e6712 100644
--- a/sc/source/filter/excel/xeroot.cxx
+++ b/sc/source/filter/excel/xeroot.cxx
@@ -251,8 +251,7 @@ void XclExpRoot::InitializeGlobals()
SAL_WARN( "sc", "XclExpRoot::InitializeGlobals - no OpCodeMap");
break;
}
- ScCompiler aCompiler( &rDoc, ScAddress());
- aCompiler.SetGrammar( rDoc.GetGrammar());
+ ScCompiler aCompiler( &rDoc, ScAddress(), rDoc.GetGrammar());
mrExpData.mxOpCodeMap = formula::FormulaCompiler::CreateOpCodeMap( aOpCodeMapping, true);
} while(false);
}
diff --git a/sc/source/filter/excel/xestream.cxx b/sc/source/filter/excel/xestream.cxx
index 4c5333100e70..43aa4c0b9525 100644
--- a/sc/source/filter/excel/xestream.cxx
+++ b/sc/source/filter/excel/xestream.cxx
@@ -808,6 +808,7 @@ OUString XclXmlUtils::ToOUString(
{
ScCompiler aCompiler( rCtx, rAddress, const_cast<ScTokenArray&>(*pTokenArray));
+ /* TODO: isn't this the same as passed in rCtx and thus superfluous? */
aCompiler.SetGrammar(FormulaGrammar::GRAM_OOXML);
OUStringBuffer aBuffer( pTokenArray->GetLen() * 5 );
diff --git a/sc/source/filter/excel/xichart.cxx b/sc/source/filter/excel/xichart.cxx
index dc751dca62a9..49c35f7ee6a6 100644
--- a/sc/source/filter/excel/xichart.cxx
+++ b/sc/source/filter/excel/xichart.cxx
@@ -830,8 +830,7 @@ Reference< XDataSequence > XclImpChSourceLink::CreateDataSequence( const OUStrin
{
if ( mxTokenArray )
{
- ScCompiler aComp( &GetDocRef(), ScAddress(), *mxTokenArray );
- aComp.SetGrammar(GetDoc().GetGrammar());
+ ScCompiler aComp( &GetDocRef(), ScAddress(), *mxTokenArray, GetDoc().GetGrammar() );
OUStringBuffer aRangeRep;
aComp.CreateStringFromTokenArray( aRangeRep );
try
diff --git a/sc/source/filter/oox/defnamesbuffer.cxx b/sc/source/filter/oox/defnamesbuffer.cxx
index 22055ea3da45..650256c5ab69 100644
--- a/sc/source/filter/oox/defnamesbuffer.cxx
+++ b/sc/source/filter/oox/defnamesbuffer.cxx
@@ -324,8 +324,7 @@ std::unique_ptr<ScTokenArray> DefinedName::getScTokens(
const css::uno::Sequence<css::sheet::ExternalLinkInfo>& rExternalLinks )
{
ScTokenArray aTokenArray;
- ScCompiler aCompiler(&getScDocument(), ScAddress(0, 0, mnCalcSheet));
- aCompiler.SetGrammar(formula::FormulaGrammar::GRAM_OOXML);
+ ScCompiler aCompiler(&getScDocument(), ScAddress(0, 0, mnCalcSheet), formula::FormulaGrammar::GRAM_OOXML);
aCompiler.SetExternalLinks( rExternalLinks);
std::unique_ptr<ScTokenArray> pArray(aCompiler.CompileString(maModel.maFormula));
// Compile the tokens into RPN once to populate information into tokens
diff --git a/sc/source/filter/oox/formulabuffer.cxx b/sc/source/filter/oox/formulabuffer.cxx
index 00f73eebdf70..e7dbc948c5aa 100644
--- a/sc/source/filter/oox/formulabuffer.cxx
+++ b/sc/source/filter/oox/formulabuffer.cxx
@@ -120,9 +120,8 @@ void applySharedFormulas(
sal_Int32 nId = rEntry.mnSharedId;
const OUString& rTokenStr = rEntry.maTokenStr;
- ScCompiler aComp(&rDoc.getDoc(), aPos);
+ ScCompiler aComp(&rDoc.getDoc(), aPos, formula::FormulaGrammar::GRAM_OOXML);
aComp.SetNumberFormatter(&rFormatter);
- aComp.SetGrammar(formula::FormulaGrammar::GRAM_OOXML);
ScTokenArray* pArray = aComp.CompileString(rTokenStr);
if (pArray)
{
@@ -206,9 +205,8 @@ void applyCellFormulas(
continue;
}
- ScCompiler aCompiler(&rDoc.getDoc(), aPos);
+ ScCompiler aCompiler(&rDoc.getDoc(), aPos, formula::FormulaGrammar::GRAM_OOXML);
aCompiler.SetNumberFormatter(&rFormatter);
- aCompiler.SetGrammar(formula::FormulaGrammar::GRAM_OOXML);
aCompiler.SetExternalLinks(rExternalLinks);
ScTokenArray* pCode = aCompiler.CompileString(rItem.maTokenStr);
if (!pCode)
@@ -229,9 +227,8 @@ void applyArrayFormulas(
{
const ScAddress& aPos = rAddressItem.maTokenAndAddress.maAddress;
- ScCompiler aComp(&rDoc.getDoc(), aPos);
+ ScCompiler aComp(&rDoc.getDoc(), aPos, formula::FormulaGrammar::GRAM_OOXML);
aComp.SetNumberFormatter(&rFormatter);
- aComp.SetGrammar(formula::FormulaGrammar::GRAM_OOXML);
std::unique_ptr<ScTokenArray> pArray(aComp.CompileString(rAddressItem.maTokenAndAddress.maTokenStr));
if (pArray)
rDoc.setMatrixCells(rAddressItem.maRange, *pArray, formula::FormulaGrammar::GRAM_OOXML);
diff --git a/sc/source/filter/oox/revisionfragment.cxx b/sc/source/filter/oox/revisionfragment.cxx
index 55acd53062f6..f9dc8c085361 100644
--- a/sc/source/filter/oox/revisionfragment.cxx
+++ b/sc/source/filter/oox/revisionfragment.cxx
@@ -117,8 +117,7 @@ protected:
{
// formula string
ScDocument& rDoc = getScDocument();
- ScCompiler aComp(&rDoc, mrPos);
- aComp.SetGrammar(formula::FormulaGrammar::GRAM_OOXML);
+ ScCompiler aComp(&rDoc, mrPos, formula::FormulaGrammar::GRAM_OOXML);
ScTokenArray* pArray = aComp.CompileString(rChars);
if (!pArray)
break;
diff --git a/sc/source/filter/orcus/interface.cxx b/sc/source/filter/orcus/interface.cxx
index b7e0fe208049..9efb60cc80c7 100644
--- a/sc/source/filter/orcus/interface.cxx
+++ b/sc/source/filter/orcus/interface.cxx
@@ -628,8 +628,7 @@ void ScOrcusSheet::set_shared_formula(
formula::FormulaGrammar::Grammar eGram = getCalcGrammarFromOrcus(grammar);
// Compile the formula expression into tokens.
- ScCompiler aComp(&mrDoc.getDoc(), aPos);
- aComp.SetGrammar(eGram);
+ ScCompiler aComp(&mrDoc.getDoc(), aPos, eGram);
ScTokenArray* pArray = aComp.CompileString(aFormula);
if (!pArray)
// Tokenization failed.
@@ -677,8 +676,7 @@ void ScOrcusSheet::set_array_formula(
ScRange aRange(col, row, mnTab, col+array_cols, row + array_rows, mnTab);
- ScCompiler aComp(&mrDoc.getDoc(), aRange.aStart);
- aComp.SetGrammar(eGrammar);
+ ScCompiler aComp(&mrDoc.getDoc(), aRange.aStart, eGrammar);
std::unique_ptr<ScTokenArray> pArray(aComp.CompileString(aFormula));
if (!pArray)
return;
diff --git a/sc/source/filter/xml/xmlimprt.cxx b/sc/source/filter/xml/xmlimprt.cxx
index d035e9e1cab9..437264636bc8 100644
--- a/sc/source/filter/xml/xmlimprt.cxx
+++ b/sc/source/filter/xml/xmlimprt.cxx
@@ -3058,8 +3058,7 @@ void SAL_CALL ScXMLImport::setTargetDocument( const css::uno::Reference< css::la
throw lang::IllegalArgumentException();
mpDocImport.reset(new ScDocumentImport(*pDoc));
- mpComp.reset(new ScCompiler(pDoc, ScAddress()));
- mpComp->SetGrammar(formula::FormulaGrammar::GRAM_ODFF);
+ mpComp.reset(new ScCompiler(pDoc, ScAddress(), formula::FormulaGrammar::GRAM_ODFF));
uno::Reference<document::XActionLockable> xActionLockable(xDoc, uno::UNO_QUERY);
if (xActionLockable.is())
diff --git a/sc/source/ui/app/inputhdl.cxx b/sc/source/ui/app/inputhdl.cxx
index fff0c5af78bb..3647a5633502 100644
--- a/sc/source/ui/app/inputhdl.cxx
+++ b/sc/source/ui/app/inputhdl.cxx
@@ -102,8 +102,7 @@ const sal_Unicode cParenthesesReplacement = 0x0001;
sal_Unicode lcl_getSheetSeparator(ScDocument* pDoc)
{
- ScCompiler aComp(pDoc, ScAddress());
- aComp.SetGrammar(pDoc->GetGrammar());
+ ScCompiler aComp(pDoc, ScAddress(), pDoc->GetGrammar());
return aComp.GetNativeAddressSymbol(ScCompiler::Convention::SHEET_SEPARATOR);
}
diff --git a/sc/source/ui/condformat/condformatdlgentry.cxx b/sc/source/ui/condformat/condformatdlgentry.cxx
index 167568f44a51..241838ef171d 100644
--- a/sc/source/ui/condformat/condformatdlgentry.cxx
+++ b/sc/source/ui/condformat/condformatdlgentry.cxx
@@ -314,8 +314,7 @@ IMPL_LINK(ScConditionFrmtEntry, OnEdChanged, Edit&, rEdit, void)
return;
}
- ScCompiler aComp( mpDoc, maPos );
- aComp.SetGrammar( mpDoc->GetGrammar() );
+ ScCompiler aComp( mpDoc, maPos, mpDoc->GetGrammar() );
std::unique_ptr<ScTokenArray> ta(aComp.CompileString(aFormula));
// Error, warn the user
diff --git a/sc/source/ui/docshell/docfunc.cxx b/sc/source/ui/docshell/docfunc.cxx
index 13d4baa795e8..2e79cf4d5cdf 100644
--- a/sc/source/ui/docshell/docfunc.cxx
+++ b/sc/source/ui/docshell/docfunc.cxx
@@ -4204,8 +4204,7 @@ bool ScDocFunc::EnterMatrix( const ScRange& rRange, const ScMarkData* pTabMark,
}
else if (bEnglish)
{
- ScCompiler aComp( &rDoc, rRange.aStart);
- aComp.SetGrammar(eGrammar);
+ ScCompiler aComp( &rDoc, rRange.aStart, eGrammar);
ScTokenArray* pCode = aComp.CompileString( rString );
rDoc.InsertMatrixFormula( nStartCol, nStartRow, nEndCol, nEndRow,
aMark, EMPTY_OUSTRING, pCode, eGrammar);
diff --git a/sc/source/ui/docshell/impex.cxx b/sc/source/ui/docshell/impex.cxx
index 1f2444ea7b7e..70288a814c8b 100644
--- a/sc/source/ui/docshell/impex.cxx
+++ b/sc/source/ui/docshell/impex.cxx
@@ -1835,8 +1835,7 @@ bool ScImportExport::Sylk2Doc( SvStream& rStrm )
* R1C1 is what Excel writes in SYLK, or even
* better GRAM_ENGLISH_XL_R1C1. */
const formula::FormulaGrammar::Grammar eGrammar = formula::FormulaGrammar::GRAM_PODF_A1;
- ScCompiler aComp( pDoc, aPos);
- aComp.SetGrammar(eGrammar);
+ ScCompiler aComp( pDoc, aPos, eGrammar);
ScTokenArray* pCode = aComp.CompileString( aText );
if ( ch == 'M' )
{
diff --git a/sc/source/ui/formdlg/formula.cxx b/sc/source/ui/formdlg/formula.cxx
index 76642c944d25..cbaf4dd74165 100644
--- a/sc/source/ui/formdlg/formula.cxx
+++ b/sc/source/ui/formdlg/formula.cxx
@@ -430,8 +430,7 @@ void ScFormulaDlg::SetReference( const ScRange& rRef, ScDocument* pRefDoc )
aArray.AddSingleReference(aRefData.Ref1);
else
aArray.AddDoubleReference(aRefData);
- ScCompiler aComp(m_pDoc, m_CursorPos, aArray);
- aComp.SetGrammar(m_pDoc->GetGrammar());
+ ScCompiler aComp(m_pDoc, m_CursorPos, aArray, m_pDoc->GetGrammar());
OUStringBuffer aBuf;
aComp.CreateStringFromTokenArray(aBuf);
aRefStr = aBuf.makeStringAndClear();
diff --git a/sc/source/ui/miscdlgs/anyrefdg.cxx b/sc/source/ui/miscdlgs/anyrefdg.cxx
index b334e658aa69..2dba375feed6 100644
--- a/sc/source/ui/miscdlgs/anyrefdg.cxx
+++ b/sc/source/ui/miscdlgs/anyrefdg.cxx
@@ -328,8 +328,7 @@ void ScFormulaReferenceHelper::Init()
SCTAB nTab = pViewData->GetTabNo();
ScAddress aCursorPos( nCol, nRow, nTab );
- pRefComp.reset( new ScCompiler( pDoc, aCursorPos) );
- pRefComp->SetGrammar( pDoc->GetGrammar() );
+ pRefComp.reset( new ScCompiler( pDoc, aCursorPos, pDoc->GetGrammar()) );
pRefComp->EnableJumpCommandReorder(false);
pRefComp->EnableStopOnError(false);
diff --git a/sc/source/ui/namedlg/namedefdlg.cxx b/sc/source/ui/namedlg/namedefdlg.cxx
index 23a3c1a43db8..eca7e79bbbe7 100644
--- a/sc/source/ui/namedlg/namedefdlg.cxx
+++ b/sc/source/ui/namedlg/namedefdlg.cxx
@@ -120,8 +120,7 @@ void ScNameDefDlg::CancelPushed()
bool ScNameDefDlg::IsFormulaValid()
{
- ScCompiler aComp( mpDoc, maCursorPos);
- aComp.SetGrammar( mpDoc->GetGrammar() );
+ ScCompiler aComp( mpDoc, maCursorPos, mpDoc->GetGrammar());
ScTokenArray* pCode = aComp.CompileString(m_pEdRange->GetText());
if (pCode->GetCodeError() != FormulaError::NONE)
{
diff --git a/sc/source/ui/namedlg/namedlg.cxx b/sc/source/ui/namedlg/namedlg.cxx
index e5e3e3ec80be..19e95c42de97 100644
--- a/sc/source/ui/namedlg/namedlg.cxx
+++ b/sc/source/ui/namedlg/namedlg.cxx
@@ -295,8 +295,7 @@ bool ScNameDlg::IsNameValid()
bool ScNameDlg::IsFormulaValid()
{
- ScCompiler aComp( mpDoc, maCursorPos);
- aComp.SetGrammar( mpDoc->GetGrammar() );
+ ScCompiler aComp( mpDoc, maCursorPos, mpDoc->GetGrammar());
ScTokenArray* pCode = aComp.CompileString(m_pEdAssign->GetText());
if (pCode->GetCodeError() != FormulaError::NONE)
{
diff --git a/sc/source/ui/unoobj/chart2uno.cxx b/sc/source/ui/unoobj/chart2uno.cxx
index fdf69927f950..432724da0b68 100644
--- a/sc/source/ui/unoobj/chart2uno.cxx
+++ b/sc/source/ui/unoobj/chart2uno.cxx
@@ -851,8 +851,7 @@ public:
void operator() (const ScTokenRef& rToken)
{
- ScCompiler aCompiler(mpDoc, ScAddress(0,0,0));
- aCompiler.SetGrammar(meGrammar);
+ ScCompiler aCompiler(mpDoc, ScAddress(0,0,0), meGrammar);
OUString aStr;
aCompiler.CreateStringFromToken(aStr, rToken.get());
if (mbFirst)
@@ -912,8 +911,7 @@ public:
OSL_ENSURE(bValidToken, "invalid token");
if (!bValidToken)
return;
- ScCompiler aCompiler(mpDoc, ScAddress(0,0,0));
- aCompiler.SetGrammar(FormulaGrammar::GRAM_ENGLISH);
+ ScCompiler aCompiler(mpDoc, ScAddress(0,0,0), FormulaGrammar::GRAM_ENGLISH);
{
OUString aStr;
aCompiler.CreateStringFromToken(aStr, aStart.get());
diff --git a/sc/source/ui/unoobj/funcuno.cxx b/sc/source/ui/unoobj/funcuno.cxx
index d2d0d6dc1961..81e13bde7bd8 100644
--- a/sc/source/ui/unoobj/funcuno.cxx
+++ b/sc/source/ui/unoobj/funcuno.cxx
@@ -461,8 +461,7 @@ uno::Any SAL_CALL ScFunctionAccess::callFunction( const OUString& aName,
/// TODO: check
ScAddress aAdr;
- ScCompiler aCompiler(pDoc,aAdr);
- aCompiler.SetGrammar(pDoc->GetGrammar());
+ ScCompiler aCompiler(pDoc, aAdr, pDoc->GetGrammar());
// find function
diff --git a/sc/source/ui/unoobj/servuno.cxx b/sc/source/ui/unoobj/servuno.cxx
index 2bfa684aa590..6d46da3922b8 100644
--- a/sc/source/ui/unoobj/servuno.cxx
+++ b/sc/source/ui/unoobj/servuno.cxx
@@ -540,8 +540,7 @@ uno::Reference<uno::XInterface> ScServiceProvider::MakeInstance(
{
ScDocument& rDoc = pDocShell->GetDocument();
ScAddress aAddress;
- ScCompiler* pComp = new ScCompiler(&rDoc,aAddress);
- pComp->SetGrammar( rDoc.GetGrammar() );
+ ScCompiler* pComp = new ScCompiler(&rDoc, aAddress, rDoc.GetGrammar());
xRet.set(static_cast<sheet::XFormulaOpCodeMapper*>(new ScFormulaOpCodeMapperObj(::std::unique_ptr<formula::FormulaCompiler> (pComp))));
break;
}
diff --git a/sc/source/ui/unoobj/tokenuno.cxx b/sc/source/ui/unoobj/tokenuno.cxx
index 5998f9503047..80b41cc4b5b4 100644
--- a/sc/source/ui/unoobj/tokenuno.cxx
+++ b/sc/source/ui/unoobj/tokenuno.cxx
@@ -135,8 +135,7 @@ uno::Sequence<sheet::FormulaToken> SAL_CALL ScFormulaParserObj::parseFormula(
ScAddress aRefPos( ScAddress::UNINITIALIZED );
ScUnoConversion::FillScAddress( aRefPos, rReferencePos );
- ScCompiler aCompiler( &rDoc, aRefPos);
- aCompiler.SetGrammar(rDoc.GetGrammar());
+ ScCompiler aCompiler( &rDoc, aRefPos, rDoc.GetGrammar());
SetCompilerFlags( aCompiler );
ScTokenArray* pCode = aCompiler.CompileString( aFormula );
@@ -160,8 +159,7 @@ OUString SAL_CALL ScFormulaParserObj::printFormula(
(void)ScTokenConversion::ConvertToTokenArray( rDoc, aCode, aTokens );
ScAddress aRefPos( ScAddress::UNINITIALIZED );
ScUnoConversion::FillScAddress( aRefPos, rReferencePos );
- ScCompiler aCompiler( &rDoc, aRefPos, aCode);
- aCompiler.SetGrammar(rDoc.GetGrammar());
+ ScCompiler aCompiler( &rDoc, aRefPos, aCode, rDoc.GetGrammar());
SetCompilerFlags( aCompiler );
OUStringBuffer aBuffer;
@@ -200,8 +198,7 @@ void SAL_CALL ScFormulaParserObj::setPropertyValue(
if (mxOpCodeMap.get() && mbEnglish != bOldEnglish)
{
ScDocument& rDoc = mpDocShell->GetDocument();
- ScCompiler aCompiler( &rDoc, ScAddress());
- aCompiler.SetGrammar(rDoc.GetGrammar());
+ ScCompiler aCompiler( &rDoc, ScAddress(), rDoc.GetGrammar());
mxOpCodeMap = formula::FormulaCompiler::CreateOpCodeMap( maOpCodeMapping, mbEnglish);
}
}
@@ -221,8 +218,7 @@ void SAL_CALL ScFormulaParserObj::setPropertyValue(
if (aValue >>= maOpCodeMapping)
{
ScDocument& rDoc = mpDocShell->GetDocument();
- ScCompiler aCompiler( &rDoc, ScAddress());
- aCompiler.SetGrammar(rDoc.GetGrammar());
+ ScCompiler aCompiler( &rDoc, ScAddress(), rDoc.GetGrammar());
mxOpCodeMap = formula::FormulaCompiler::CreateOpCodeMap( maOpCodeMapping, mbEnglish);
}
else
diff --git a/sc/source/ui/vba/vbaname.cxx b/sc/source/ui/vba/vbaname.cxx
index 6e6e86e9ac4b..dd0f2cd88344 100644
--- a/sc/source/ui/vba/vbaname.cxx
+++ b/sc/source/ui/vba/vbaname.cxx
@@ -122,8 +122,7 @@ void ScVbaName::setContent( const OUString& rContent, const formula::FormulaGra
if (pOldData)
{
// Shorter way of doing this ?
- ScCompiler aComp( &rDoc, pOldData->GetPos() );
- aComp.SetGrammar( eGrammar );
+ ScCompiler aComp( &rDoc, pOldData->GetPos(), eGrammar );
std::unique_ptr<ScTokenArray> pArray(aComp.CompileString(sContent));
pOldData->SetCode(*pArray);
}
diff --git a/sc/source/ui/vba/vbanames.cxx b/sc/source/ui/vba/vbanames.cxx
index 4717fcf6611f..9ff4af38f77d 100644
--- a/sc/source/ui/vba/vbanames.cxx
+++ b/sc/source/ui/vba/vbanames.cxx
@@ -152,8 +152,7 @@ ScVbaNames::Add( const css::uno::Any& Name ,
if ( !xRange.is() && !sFormula.isEmpty() )
{
ScAddress aBlank;
- ScCompiler aComp( getScDocument(), aBlank );
- aComp.SetGrammar( eGram );
+ ScCompiler aComp( getScDocument(), aBlank, eGram );
std::unique_ptr<ScTokenArray> pTokens(aComp.CompileString(sFormula));
if ( pTokens )
{
diff --git a/sc/source/ui/vba/vbarange.cxx b/sc/source/ui/vba/vbarange.cxx
index da37019e66a3..bb4164303798 100644
--- a/sc/source/ui/vba/vbarange.cxx
+++ b/sc/source/ui/vba/vbarange.cxx
@@ -883,8 +883,7 @@ protected:
if ( pUnoRangesBase )
{
ScRangeList aCellRanges = pUnoRangesBase->GetRangeList();
- ScCompiler aCompiler( m_pDoc, aCellRanges.front()->aStart );
- aCompiler.SetGrammar(m_eGrammar);
+ ScCompiler aCompiler( m_pDoc, aCellRanges.front()->aStart, m_eGrammar );
// compile the string in the format passed in
std::unique_ptr<ScTokenArray> pArray(aCompiler.CompileString(sFormula));
// set desired convention to that of the document
@@ -927,8 +926,7 @@ public:
pUnoRangesBase )
{
ScRangeList aCellRanges = pUnoRangesBase->GetRangeList();
- ScCompiler aCompiler( m_pDoc, aCellRanges.front()->aStart );
- aCompiler.SetGrammar(formula::FormulaGrammar::GRAM_DEFAULT);
+ ScCompiler aCompiler( m_pDoc, aCellRanges.front()->aStart, formula::FormulaGrammar::GRAM_DEFAULT );
std::unique_ptr<ScTokenArray> pArray(aCompiler.CompileString(sVal));
// set desired convention
aCompiler.SetGrammar( m_eGrammar );
diff --git a/sc/source/ui/view/tabvwsha.cxx b/sc/source/ui/view/tabvwsha.cxx
index 1c829ef195c9..8320d32aabb4 100644
--- a/sc/source/ui/view/tabvwsha.cxx
+++ b/sc/source/ui/view/tabvwsha.cxx
@@ -582,8 +582,7 @@ bool ScTabViewShell::IsRefInputMode() const
if ( pDoc )
{
const ScAddress aPos( rViewData.GetCurPos() );
- ScCompiler aComp( pDoc, aPos );
- aComp.SetGrammar(pDoc->GetGrammar());
+ ScCompiler aComp( pDoc, aPos, pDoc->GetGrammar() );
aComp.SetCloseBrackets( false );
std::unique_ptr<ScTokenArray> pArr(aComp.CompileString(aString));
if ( pArr && pArr->MayReferenceFollow() )
diff --git a/sc/source/ui/view/viewfun2.cxx b/sc/source/ui/view/viewfun2.cxx
index b0f5e24e1e19..9a4aea9ef7b1 100644
--- a/sc/source/ui/view/viewfun2.cxx
+++ b/sc/source/ui/view/viewfun2.cxx
@@ -722,8 +722,7 @@ OUString ScViewFunc::GetAutoSumFormula( const ScRangeList& rRangeList, bool bSub
pArray->AddOpCode(ocClose);
- ScCompiler aComp(pDoc, rAddr, *pArray);
- aComp.SetGrammar(pDoc->GetGrammar());
+ ScCompiler aComp(pDoc, rAddr, *pArray, pDoc->GetGrammar());
OUStringBuffer aBuf;
aComp.CreateStringFromTokenArray(aBuf);
OUString aFormula = aBuf.makeStringAndClear();
diff --git a/sc/source/ui/view/viewfun4.cxx b/sc/source/ui/view/viewfun4.cxx
index ddd16da0ded0..f5c7db96bf7e 100644
--- a/sc/source/ui/view/viewfun4.cxx
+++ b/sc/source/ui/view/viewfun4.cxx
@@ -268,8 +268,7 @@ void ScViewFunc::DoRefConversion()
{
ScAddress aPos = pCell->aPos;
OUString aNew = aFinder.GetText();
- ScCompiler aComp( pDoc, aPos);
- aComp.SetGrammar(pDoc->GetGrammar());
+ ScCompiler aComp( pDoc, aPos, pDoc->GetGrammar());
std::unique_ptr<ScTokenArray> pArr(aComp.CompileString(aNew));
ScFormulaCell* pNewCell =
new ScFormulaCell(
diff --git a/sc/source/ui/view/viewfunc.cxx b/sc/source/ui/view/viewfunc.cxx
index c0d8d028eb3d..ca21a561fed8 100644
--- a/sc/source/ui/view/viewfunc.cxx
+++ b/sc/source/ui/view/viewfunc.cxx
@@ -397,8 +397,7 @@ void ScViewFunc::EnterData( SCCOL nCol, SCROW nRow, SCTAB nTab,
{ // formula, compile with autoCorrection
i = rMark.GetFirstSelected();
ScAddress aPos( nCol, nRow, i );
- ScCompiler aComp( pDoc, aPos);
- aComp.SetGrammar(pDoc->GetGrammar());
+ ScCompiler aComp( pDoc, aPos, pDoc->GetGrammar());
//2do: enable/disable autoCorrection via calcoptions
aComp.SetAutoCorrection( true );
if ( rString[0] == '+' || rString[0] == '-' )
commit 47a0e1554add5cc10c068275697108a663cd7a9a
Author: Eike Rathke <erack at redhat.com>
Date: Thu May 18 14:17:05 2017 +0200
Always set a grammar when constructing ScCompiler
Otherwise mxSymbols is null, which is rather unexpected as the past has shown,
see commit 63843a97262ccfa38d838a9cbbc3faadba8290a6
Change-Id: Id4c13a5f50e711513a71a7d6cd6f87b4112b1f1d
diff --git a/sc/inc/compiler.hxx b/sc/inc/compiler.hxx
index 7f3f30e798aa..cfd5affb0b8f 100644
--- a/sc/inc/compiler.hxx
+++ b/sc/inc/compiler.hxx
@@ -335,11 +335,19 @@ private:
public:
ScCompiler( sc::CompileFormulaContext& rCxt, const ScAddress& rPos );
- ScCompiler( ScDocument* pDocument, const ScAddress&);
+ /** 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 );
ScCompiler( sc::CompileFormulaContext& rCxt, const ScAddress& rPos, ScTokenArray& rArr );
- ScCompiler( ScDocument* pDocument, const ScAddress&,ScTokenArray& rArr);
+ /** 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 );
virtual ~ScCompiler() override;
diff --git a/sc/source/core/tool/compiler.cxx b/sc/source/core/tool/compiler.cxx
index d6f171e7c621..b59b215d21d7 100644
--- a/sc/source/core/tool/compiler.cxx
+++ b/sc/source/core/tool/compiler.cxx
@@ -1758,7 +1758,8 @@ ScCompiler::ScCompiler( sc::CompileFormulaContext& rCxt, const ScAddress& rPos,
SetGrammar(rCxt.getGrammar());
}
-ScCompiler::ScCompiler( ScDocument* pDocument, const ScAddress& rPos,ScTokenArray& rArr)
+ScCompiler::ScCompiler( ScDocument* pDocument, const ScAddress& rPos, ScTokenArray& rArr,
+ formula::FormulaGrammar::Grammar eGrammar )
: FormulaCompiler(rArr),
pDoc( pDocument ),
aPos( rPos ),
@@ -1774,6 +1775,9 @@ ScCompiler::ScCompiler( ScDocument* pDocument, const ScAddress& rPos,ScTokenArra
mbCloseBrackets( true ),
mbRewind( false )
{
+ SetGrammar( ((eGrammar == formula::FormulaGrammar::GRAM_UNSPECIFIED) ?
+ (pDocument ? pDocument->GetGrammar() : formula::FormulaGrammar::GRAM_DEFAULT) :
+ eGrammar));
nMaxTab = pDoc->GetTableCount() - 1;
}
@@ -1796,7 +1800,8 @@ ScCompiler::ScCompiler( sc::CompileFormulaContext& rCxt, const ScAddress& rPos )
SetGrammar(rCxt.getGrammar());
}
-ScCompiler::ScCompiler( ScDocument* pDocument, const ScAddress& rPos)
+ScCompiler::ScCompiler( ScDocument* pDocument, const ScAddress& rPos,
+ formula::FormulaGrammar::Grammar eGrammar )
:
pDoc( pDocument ),
aPos( rPos ),
@@ -1812,6 +1817,9 @@ ScCompiler::ScCompiler( ScDocument* pDocument, const ScAddress& rPos)
mbCloseBrackets( true ),
mbRewind( false )
{
+ SetGrammar( ((eGrammar == formula::FormulaGrammar::GRAM_UNSPECIFIED) ?
+ (pDocument ? pDocument->GetGrammar() : formula::FormulaGrammar::GRAM_DEFAULT) :
+ eGrammar));
nMaxTab = pDoc ? pDoc->GetTableCount() - 1 : 0;
}
commit 730622df7c0e97917c3c0d53b1ec03691d0afb74
Author: Eike Rathke <erack at redhat.com>
Date: Thu May 18 14:13:43 2017 +0200
assert instead of OSL_ENSURE if grammar is GRAM_UNSPECIFIED
Change-Id: Ie23a5a98e9bc6dfbd5d685c482fb358ac3822845
diff --git a/sc/source/core/tool/compiler.cxx b/sc/source/core/tool/compiler.cxx
index a95f2da5698c..d6f171e7c621 100644
--- a/sc/source/core/tool/compiler.cxx
+++ b/sc/source/core/tool/compiler.cxx
@@ -195,7 +195,7 @@ void ScCompiler::InitCharClassEnglish()
void ScCompiler::SetGrammar( const FormulaGrammar::Grammar eGrammar )
{
- OSL_ENSURE( eGrammar != FormulaGrammar::GRAM_UNSPECIFIED, "ScCompiler::SetGrammar: don't pass FormulaGrammar::GRAM_UNSPECIFIED");
+ assert( eGrammar != FormulaGrammar::GRAM_UNSPECIFIED && "ScCompiler::SetGrammar: don't pass FormulaGrammar::GRAM_UNSPECIFIED");
if (eGrammar == GetGrammar())
return; // nothing to be done
More information about the Libreoffice-commits
mailing list