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/source/ui | |
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/source/ui')
-rw-r--r-- | sc/source/ui/app/inputhdl.cxx | 3 | ||||
-rw-r--r-- | sc/source/ui/condformat/condformatdlgentry.cxx | 3 | ||||
-rw-r--r-- | sc/source/ui/docshell/docfunc.cxx | 3 | ||||
-rw-r--r-- | sc/source/ui/docshell/impex.cxx | 3 | ||||
-rw-r--r-- | sc/source/ui/formdlg/formula.cxx | 3 | ||||
-rw-r--r-- | sc/source/ui/miscdlgs/anyrefdg.cxx | 3 | ||||
-rw-r--r-- | sc/source/ui/namedlg/namedefdlg.cxx | 3 | ||||
-rw-r--r-- | sc/source/ui/namedlg/namedlg.cxx | 3 | ||||
-rw-r--r-- | sc/source/ui/unoobj/chart2uno.cxx | 6 | ||||
-rw-r--r-- | sc/source/ui/unoobj/funcuno.cxx | 3 | ||||
-rw-r--r-- | sc/source/ui/unoobj/servuno.cxx | 3 | ||||
-rw-r--r-- | sc/source/ui/unoobj/tokenuno.cxx | 12 | ||||
-rw-r--r-- | sc/source/ui/vba/vbaname.cxx | 3 | ||||
-rw-r--r-- | sc/source/ui/vba/vbanames.cxx | 3 | ||||
-rw-r--r-- | sc/source/ui/vba/vbarange.cxx | 6 | ||||
-rw-r--r-- | sc/source/ui/view/tabvwsha.cxx | 3 | ||||
-rw-r--r-- | sc/source/ui/view/viewfun2.cxx | 3 | ||||
-rw-r--r-- | sc/source/ui/view/viewfun4.cxx | 3 | ||||
-rw-r--r-- | sc/source/ui/view/viewfunc.cxx | 3 |
19 files changed, 24 insertions, 48 deletions
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] == '-' ) |