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 | 12 ++++++++++-- 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 +-- sw/inc/docary.hxx | 8 +++++--- sw/source/core/doc/DocumentRedlineManager.cxx | 9 ++++++--- sw/source/core/doc/docredln.cxx | 6 +++--- vcl/headless/svpbmp.cxx | 18 ++++++++++++++++-- vcl/source/gdi/salmisc.cxx | 19 ++++++++++++++++++- vcl/unx/generic/gdi/salbmp.cxx | 17 ++++++++++++++++- 48 files changed, 155 insertions(+), 157 deletions(-)
New commits: commit 8d6ca5f089feba768a0522f4ef6f1dbd8634a831 Author: Caolán McNamara <[email protected]> Date: Thu May 18 13:52:04 2017 +0100 ofz# InsertWithValidRanges didn't report that it deleted its argument anymore since... commit ddd84d08c9bb6e00fbd9a73bd52a28688a8c1ba7 Date: Fri Jul 20 17:16:03 2012 +0200 Convert SV_DECL_PTRARR_SORT_DEL(_SwRedlineTbl) to o3tl::sorted_vector Change-Id: Ie7edc6b32b373619d4c0ac154da93650743049cf otherwise that p = nullptr line at the end doesn't make sense Change-Id: Ibd5230beb87240cba4b3896dfa2217e25a4db697 Reviewed-on: https://gerrit.libreoffice.org/37769 Reviewed-by: Caolán McNamara <[email protected]> Tested-by: Caolán McNamara <[email protected]> diff --git a/sw/inc/docary.hxx b/sw/inc/docary.hxx index de663f105075..424680b329c6 100644 --- a/sw/inc/docary.hxx +++ b/sw/inc/docary.hxx @@ -318,6 +318,8 @@ struct CompareSwRedlineTable // Notification type for notifying about redlines to LOK clients enum class RedlineNotification { Add, Remove, Modify }; +typedef SwRangeRedline* SwRangeRedlinePtr; + class SwRedlineTable { public: @@ -333,9 +335,9 @@ public: bool Contains(const SwRangeRedline* p) const { return maVector.find(const_cast<SwRangeRedline* const>(p)) != maVector.end(); } size_type GetPos(const SwRangeRedline* p) const; - bool Insert( SwRangeRedline* p ); - bool Insert( SwRangeRedline* p, size_type& rInsPos ); - bool InsertWithValidRanges( SwRangeRedline* p, size_type* pInsPos = nullptr ); + bool Insert(SwRangeRedlinePtr& p); + bool Insert(SwRangeRedlinePtr& p, size_type& rInsPos); + bool InsertWithValidRanges(SwRangeRedlinePtr& p, size_type* pInsPos = nullptr); void Remove( size_type nPos ); bool Remove( const SwRangeRedline* p ); diff --git a/sw/source/core/doc/DocumentRedlineManager.cxx b/sw/source/core/doc/DocumentRedlineManager.cxx index 047d345a1d6c..0736482f1d69 100644 --- a/sw/source/core/doc/DocumentRedlineManager.cxx +++ b/sw/source/core/doc/DocumentRedlineManager.cxx @@ -1228,9 +1228,10 @@ bool DocumentRedlineManager::AppendRedline( SwRangeRedline* pNewRedl, bool bCall if( bCallDelete ) { ::comphelper::FlagGuard g(m_isForbidCompressRedlines); + //Insert may delete pNewRedl, in which case it sets pNewRedl to nullptr mpRedlineTable->Insert( pNewRedl ); m_rDoc.getIDocumentContentOperations().DeleteAndJoin( *pRedl ); - if( !mpRedlineTable->Remove( pNewRedl ) ) + if (pNewRedl && !mpRedlineTable->Remove(pNewRedl)) { assert(false); // can't happen pNewRedl = nullptr; @@ -1260,9 +1261,10 @@ bool DocumentRedlineManager::AppendRedline( SwRangeRedline* pNewRedl, bool bCall // We insert temporarily so that pNew is // also dealt with when moving the indices. ::comphelper::FlagGuard g(m_isForbidCompressRedlines); + //Insert may delete pNewRedl, in which case it sets pNewRedl to nullptr mpRedlineTable->Insert( pNewRedl ); m_rDoc.getIDocumentContentOperations().DeleteAndJoin( aPam ); - if( !mpRedlineTable->Remove( pNewRedl ) ) + if (pNewRedl && !mpRedlineTable->Remove(pNewRedl)) { assert(false); // can't happen pNewRedl = nullptr; @@ -1291,9 +1293,10 @@ bool DocumentRedlineManager::AppendRedline( SwRangeRedline* pNewRedl, bool bCall // We insert temporarily so that pNew is // also dealt with when moving the indices. ::comphelper::FlagGuard g(m_isForbidCompressRedlines); + //Insert may delete pNewRedl, in which case it sets pNewRedl to nullptr mpRedlineTable->Insert( pNewRedl ); m_rDoc.getIDocumentContentOperations().DeleteAndJoin( aPam ); - if( !mpRedlineTable->Remove( pNewRedl ) ) + if (pNewRedl && !mpRedlineTable->Remove(pNewRedl)) { assert(false); // can't happen pNewRedl = nullptr; diff --git a/sw/source/core/doc/docredln.cxx b/sw/source/core/doc/docredln.cxx index 0490bd63ff7e..1955953b2f4e 100644 --- a/sw/source/core/doc/docredln.cxx +++ b/sw/source/core/doc/docredln.cxx @@ -409,7 +409,7 @@ void SwRedlineTable::LOKRedlineNotification(RedlineNotification nType, SwRangeRe } } -bool SwRedlineTable::Insert( SwRangeRedline* p ) +bool SwRedlineTable::Insert(SwRangeRedlinePtr& p) { if( p->HasValidRange() ) { @@ -422,7 +422,7 @@ bool SwRedlineTable::Insert( SwRangeRedline* p ) return InsertWithValidRanges( p ); } -bool SwRedlineTable::Insert( SwRangeRedline* p, size_type& rP ) +bool SwRedlineTable::Insert(SwRangeRedlinePtr& p, size_type& rP) { if( p->HasValidRange() ) { @@ -434,7 +434,7 @@ bool SwRedlineTable::Insert( SwRangeRedline* p, size_type& rP ) return InsertWithValidRanges( p, &rP ); } -bool SwRedlineTable::InsertWithValidRanges( SwRangeRedline* p, size_type* pInsPos ) +bool SwRedlineTable::InsertWithValidRanges(SwRangeRedlinePtr& p, size_type* pInsPos) { // Create valid "sub-ranges" from the Selection bool bAnyIns = false; commit c56aebee2f11a6a638fd8480eeb8f2328483df9b Author: Eike Rathke <[email protected]> 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 (cherry picked from commit 1469a83ca1d712e30131597d70dad1b3eb322175) Reviewed-on: https://gerrit.libreoffice.org/37768 Reviewed-by: Eike Rathke <[email protected]> Tested-by: Eike Rathke <[email protected]> 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 3290a7eb89a3..46fcdf05de68 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 552f73e83c32..51ccd9a63769 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 1c140744cfc8c481ca65f3e6d8960970c6765593 Author: Eike Rathke <[email protected]> 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 (cherry picked from commit 47a0e1554add5cc10c068275697108a663cd7a9a) Reviewed-on: https://gerrit.libreoffice.org/37767 Reviewed-by: Eike Rathke <[email protected]> Tested-by: Eike Rathke <[email protected]> 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 b7cec1a5cf0d3077ca965a09bd1a7ba77a4ae860 Author: Caolán McNamara <[email protected]> Date: Mon May 15 11:17:57 2017 +0100 ofz#1605 check multiply and shift Change-Id: I6aad9ad23e7bf080b3b610223f92df7074530beb Reviewed-on: https://gerrit.libreoffice.org/37764 Reviewed-by: Caolán McNamara <[email protected]> Tested-by: Caolán McNamara <[email protected]> diff --git a/vcl/headless/svpbmp.cxx b/vcl/headless/svpbmp.cxx index 3091dfba888c..5be976fc9e74 100644 --- a/vcl/headless/svpbmp.cxx +++ b/vcl/headless/svpbmp.cxx @@ -27,7 +27,7 @@ #include <basegfx/vector/b2ivector.hxx> #include <basegfx/range/b2ibox.hxx> - +#include <o3tl/safeint.hxx> #include <vcl/salbtype.hxx> #include <vcl/bitmap.hxx> @@ -112,7 +112,21 @@ BitmapBuffer* ImplCreateDIB( pDIB->mnFormat |= ScanlineFormat::TopDown; pDIB->mnWidth = rSize.Width(); pDIB->mnHeight = rSize.Height(); - pDIB->mnScanlineSize = AlignedWidth4Bytes( pDIB->mnWidth * nBitCount ); + long nScanlineBase; + bool bFail = o3tl::checked_multiply<long>(pDIB->mnWidth, nBitCount, nScanlineBase); + if (bFail) + { + SAL_WARN("vcl.gdi", "checked multiply failed"); + delete pDIB; + return nullptr; + } + pDIB->mnScanlineSize = AlignedWidth4Bytes(nScanlineBase); + if (pDIB->mnScanlineSize < nScanlineBase/8) + { + SAL_WARN("vcl.gdi", "scanline calculation wraparound"); + delete pDIB; + return nullptr; + } pDIB->mnBitCount = nBitCount; if( nColors ) diff --git a/vcl/source/gdi/salmisc.cxx b/vcl/source/gdi/salmisc.cxx index ffde759517fa..4f239efb95c6 100644 --- a/vcl/source/gdi/salmisc.cxx +++ b/vcl/source/gdi/salmisc.cxx @@ -20,6 +20,7 @@ #include <vcl/bitmapaccess.hxx> #include <vcl/salbtype.hxx> #include <bmpfast.hxx> +#include <o3tl/safeint.hxx> #include <osl/diagnose.h> #include <memory> @@ -328,7 +329,23 @@ BitmapBuffer* StretchAndConvert( pDstBuffer->mnFormat = nDstBitmapFormat; pDstBuffer->mnWidth = rTwoRect.mnDestWidth; pDstBuffer->mnHeight = rTwoRect.mnDestHeight; - pDstBuffer->mnScanlineSize = AlignedWidth4Bytes( pDstBuffer->mnBitCount * pDstBuffer->mnWidth ); + long nScanlineBase; + bool bFail = o3tl::checked_multiply<long>(pDstBuffer->mnBitCount, pDstBuffer->mnWidth, nScanlineBase); + if (bFail) + { + SAL_WARN("vcl.gdi", "checked multiply failed"); + pDstBuffer->mpBits = nullptr; + delete pDstBuffer; + return nullptr; + } + pDstBuffer->mnScanlineSize = AlignedWidth4Bytes(nScanlineBase); + if (pDstBuffer->mnScanlineSize < nScanlineBase/8) + { + SAL_WARN("vcl.gdi", "scanline calculation wraparound"); + pDstBuffer->mpBits = nullptr; + delete pDstBuffer; + return nullptr; + } try { pDstBuffer->mpBits = new sal_uInt8[ pDstBuffer->mnScanlineSize * pDstBuffer->mnHeight ]; diff --git a/vcl/unx/generic/gdi/salbmp.cxx b/vcl/unx/generic/gdi/salbmp.cxx index 73fc5a424152..00043d5e783e 100644 --- a/vcl/unx/generic/gdi/salbmp.cxx +++ b/vcl/unx/generic/gdi/salbmp.cxx @@ -41,6 +41,7 @@ #include <unx/salinst.h> #include <unx/x11/xlimits.hxx> +#include <o3tl/safeint.hxx> #include <opengl/salbmp.hxx> #include <vcl/opengl/OpenGLHelper.hxx> @@ -193,7 +194,21 @@ BitmapBuffer* X11SalBitmap::ImplCreateDIB( pDIB->mnWidth = rSize.Width(); pDIB->mnHeight = rSize.Height(); - pDIB->mnScanlineSize = AlignedWidth4Bytes( pDIB->mnWidth * nBitCount ); + long nScanlineBase; + bool bFail = o3tl::checked_multiply<long>(pDIB->mnWidth, nBitCount, nScanlineBase); + if (bFail) + { + SAL_WARN("vcl.gdi", "checked multiply failed"); + delete pDIB; + return nullptr; + } + pDIB->mnScanlineSize = AlignedWidth4Bytes(nScanlineBase); + if (pDIB->mnScanlineSize < nScanlineBase/8) + { + SAL_WARN("vcl.gdi", "scanline calculation wraparound"); + delete pDIB; + return nullptr; + } pDIB->mnBitCount = nBitCount; if( nColors )
_______________________________________________ Libreoffice-commits mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits
