diff options
author | Eike Rathke <erack@redhat.com> | 2017-05-18 14:59:54 +0200 |
---|---|---|
committer | Eike Rathke <erack@redhat.com> | 2017-05-18 15:02:50 +0200 |
commit | 1469a83ca1d712e30131597d70dad1b3eb322175 (patch) | |
tree | 7354ed4bd79adf5b846d5712004e3e3f7b6e9861 /sc/qa | |
parent | 47a0e1554add5cc10c068275697108a663cd7a9a (diff) |
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
Diffstat (limited to 'sc/qa')
-rw-r--r-- | sc/qa/unit/helper/qahelper.cxx | 6 | ||||
-rw-r--r-- | sc/qa/unit/ucalc_condformat.cxx | 12 | ||||
-rw-r--r-- | sc/qa/unit/ucalc_formula.cxx | 18 |
3 files changed, 12 insertions, 24 deletions
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); |