formula/source/core/api/FormulaCompiler.cxx | 16 ++++---------- formula/source/core/api/grammar.cxx | 3 +- include/formula/grammar.hxx | 5 ++++ offapi/com/sun/star/sheet/FormulaLanguage.idl | 13 ++++++++++++ sc/source/ui/docshell/docfunc.cxx | 6 ++--- sc/source/ui/docshell/impex.cxx | 6 +++-- sc/source/ui/unoobj/cellsuno.cxx | 18 ++++++++-------- sc/source/ui/unoobj/fmtuno.cxx | 4 +-- sc/source/ui/unoobj/funcuno.cxx | 4 +-- sc/source/ui/unoobj/nameuno.cxx | 28 +++++++++++++------------- sc/source/ui/vba/vbarange.cxx | 8 +++---- 11 files changed, 63 insertions(+), 48 deletions(-)
New commits: commit 569825ea2b64f3682932cd07dae2b244854f4157 Author: Eike Rathke <[email protected]> Date: Wed Aug 3 15:15:58 2016 +0200 comment about using GRAM_ENGLISH_XL_R1C1 ... found when looking for GRAM_PODF_A1. Change-Id: I175f92f297c8720c2d0736d3a30815217e334276 diff --git a/sc/source/ui/docshell/impex.cxx b/sc/source/ui/docshell/impex.cxx index 5abc8a8..15b4102 100644 --- a/sc/source/ui/docshell/impex.cxx +++ b/sc/source/ui/docshell/impex.cxx @@ -1831,7 +1831,8 @@ bool ScImportExport::Sylk2Doc( SvStream& rStrm ) ScAddress aPos( nCol, nRow, aRange.aStart.Tab() ); /* FIXME: do we want GRAM_ODFF_A1 instead? At the * end it probably should be GRAM_ODFF_R1C1, since - * R1C1 is what Excel writes in SYLK. */ + * 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); @@ -2035,7 +2036,8 @@ bool ScImportExport::Doc2Sylk( SvStream& rStrm ) /* FIXME: do we want GRAM_ODFF_A1 instead? At * the end it probably should be * GRAM_ODFF_R1C1, since R1C1 is what Excel - * writes in SYLK. */ + * writes in SYLK, or even better + * GRAM_ENGLISH_XL_R1C1. */ } if ( pFCell->GetMatrixFlag() != MM_NONE && aCellStr.startsWith("{") && commit 4afd35f691ffbf369e90e031b17379f52a31c510 Author: Eike Rathke <[email protected]> Date: Wed Aug 3 15:14:34 2016 +0200 use GRAM_API instead of GRAM_PODF_A1 in API context ... which right now is identical but may get corrections in future. Change-Id: Id4e1707afb32a3d8e073705072e5e65105f2a14a diff --git a/formula/source/core/api/grammar.cxx b/formula/source/core/api/grammar.cxx index c013f26..cc2aec2 100644 --- a/formula/source/core/api/grammar.cxx +++ b/formula/source/core/api/grammar.cxx @@ -28,7 +28,7 @@ FormulaGrammar::Grammar FormulaGrammar::mapAPItoGrammar( const bool bEnglish, co if (bEnglish && bXML) eGrammar = GRAM_PODF; else if (bEnglish && !bXML) - eGrammar = GRAM_PODF_A1; + eGrammar = GRAM_API; else if (!bEnglish && bXML) eGrammar = GRAM_NATIVE_ODF; else // (!bEnglish && !bXML) diff --git a/sc/source/ui/docshell/docfunc.cxx b/sc/source/ui/docshell/docfunc.cxx index 6e533db..46f18cd 100644 --- a/sc/source/ui/docshell/docfunc.cxx +++ b/sc/source/ui/docshell/docfunc.cxx @@ -5225,11 +5225,11 @@ void ScDocFunc::ResizeMatrix( const ScRange& rOldRange, const ScAddress& rNewEnd if ( DeleteContents( aMark, InsertDeleteFlags::CONTENTS, true, false/*bApi*/ ) ) { - // GRAM_PODF_A1 for API compatibility. - if (!EnterMatrix( aNewRange, &aMark, nullptr, aFormula, false/*bApi*/, false, EMPTY_OUSTRING, formula::FormulaGrammar::GRAM_PODF_A1 )) + // GRAM_API for API compatibility. + if (!EnterMatrix( aNewRange, &aMark, nullptr, aFormula, false/*bApi*/, false, EMPTY_OUSTRING, formula::FormulaGrammar::GRAM_API )) { // versuchen, alten Zustand wiederherzustellen - EnterMatrix( rOldRange, &aMark, nullptr, aFormula, false/*bApi*/, false, EMPTY_OUSTRING, formula::FormulaGrammar::GRAM_PODF_A1 ); + EnterMatrix( rOldRange, &aMark, nullptr, aFormula, false/*bApi*/, false, EMPTY_OUSTRING, formula::FormulaGrammar::GRAM_API ); } } diff --git a/sc/source/ui/unoobj/cellsuno.cxx b/sc/source/ui/unoobj/cellsuno.cxx index 9162faa..182f8ea 100644 --- a/sc/source/ui/unoobj/cellsuno.cxx +++ b/sc/source/ui/unoobj/cellsuno.cxx @@ -5129,8 +5129,8 @@ void SAL_CALL ScCellRangeObj::setArrayFormula( const OUString& aFormula ) throw(uno::RuntimeException, std::exception) { SolarMutexGuard aGuard; - // GRAM_PODF_A1 for API compatibility. - SetArrayFormula_Impl( aFormula, OUString(), formula::FormulaGrammar::GRAM_PODF_A1); + // GRAM_API for API compatibility. + SetArrayFormula_Impl( aFormula, OUString(), formula::FormulaGrammar::GRAM_API); } // XArrayFormulaTokens @@ -5186,10 +5186,10 @@ void SAL_CALL ScCellRangeObj::setArrayTokens( const uno::Sequence<sheet::Formula ScTokenArray aTokenArray; (void)ScTokenConversion::ConvertToTokenArray( rDoc, aTokenArray, rTokens ); - // Actually GRAM_PODF_A1 is a don't-care here because of the token + // Actually GRAM_API is a don't-care here because of the token // array being set, it fits with other API compatibility grammars // though. - pDocSh->GetDocFunc().EnterMatrix( aRange, nullptr, &aTokenArray, EMPTY_OUSTRING, true, true, EMPTY_OUSTRING, formula::FormulaGrammar::GRAM_PODF_A1 ); + pDocSh->GetDocFunc().EnterMatrix( aRange, nullptr, &aTokenArray, EMPTY_OUSTRING, true, true, EMPTY_OUSTRING, formula::FormulaGrammar::GRAM_API ); } else { @@ -5304,8 +5304,8 @@ void SAL_CALL ScCellRangeObj::setFormulaArray( { ScExternalRefManager::ApiGuard aExtRefGuard(&pDocSh->GetDocument()); - // GRAM_PODF_A1 for API compatibility. - bDone = lcl_PutFormulaArray( *pDocSh, aRange, aArray, formula::FormulaGrammar::GRAM_PODF_A1 ); + // GRAM_API for API compatibility. + bDone = lcl_PutFormulaArray( *pDocSh, aRange, aArray, formula::FormulaGrammar::GRAM_API ); } if (!bDone) @@ -6188,9 +6188,9 @@ void ScCellObj::SetString_Impl(const OUString& rString, bool bInterpret, bool bE ScDocShell* pDocSh = GetDocShell(); if ( pDocSh ) { - // GRAM_PODF_A1 for API compatibility. + // GRAM_API for API compatibility. (void)pDocSh->GetDocFunc().SetCellText( - aCellPos, rString, bInterpret, bEnglish, true, formula::FormulaGrammar::GRAM_PODF_A1 ); + aCellPos, rString, bInterpret, bEnglish, true, formula::FormulaGrammar::GRAM_API ); } } @@ -6256,7 +6256,7 @@ void ScCellObj::InputEnglishString( const OUString& rText ) case ScInputStringType::Formula: rFunc.SetFormulaCell( aCellPos, - new ScFormulaCell(&rDoc, aCellPos, aRes.maText, formula::FormulaGrammar::GRAM_PODF_A1), + new ScFormulaCell(&rDoc, aCellPos, aRes.maText, formula::FormulaGrammar::GRAM_API), false); break; case ScInputStringType::Number: diff --git a/sc/source/ui/unoobj/fmtuno.cxx b/sc/source/ui/unoobj/fmtuno.cxx index 417c97b..edc5e48 100644 --- a/sc/source/ui/unoobj/fmtuno.cxx +++ b/sc/source/ui/unoobj/fmtuno.cxx @@ -182,8 +182,8 @@ FormulaGrammar::Grammar lclResolveGrammar( FormulaGrammar::Grammar eExtGrammar, { if( eExtGrammar != FormulaGrammar::GRAM_UNSPECIFIED ) return eExtGrammar; - OSL_ENSURE( eIntGrammar != FormulaGrammar::GRAM_UNSPECIFIED, "lclResolveGrammar - unspecified grammar, using GRAM_PODF_A1" ); - return (eIntGrammar == FormulaGrammar::GRAM_UNSPECIFIED) ? FormulaGrammar::GRAM_PODF_A1 : eIntGrammar; + OSL_ENSURE( eIntGrammar != FormulaGrammar::GRAM_UNSPECIFIED, "lclResolveGrammar - unspecified grammar, using GRAM_API" ); + return (eIntGrammar == FormulaGrammar::GRAM_UNSPECIFIED) ? FormulaGrammar::GRAM_API : eIntGrammar; } } // namespace diff --git a/sc/source/ui/unoobj/funcuno.cxx b/sc/source/ui/unoobj/funcuno.cxx index 24af421..23ff3d5 100644 --- a/sc/source/ui/unoobj/funcuno.cxx +++ b/sc/source/ui/unoobj/funcuno.cxx @@ -610,10 +610,10 @@ uno::Any SAL_CALL ScFunctionAccess::callFunction( const OUString& aName, if ( !bArgErr && !bOverflow && nDocRow <= MAXROWCOUNT ) { ScAddress aFormulaPos( 0, 0, nTempSheet ); - // GRAM_PODF_A1 doesn't really matter for the token array but fits with + // GRAM_API doesn't really matter for the token array but fits with // other API compatibility grammars. ScFormulaCell* pFormula = new ScFormulaCell( - pDoc, aFormulaPos, aTokenArr, formula::FormulaGrammar::GRAM_PODF_A1, + pDoc, aFormulaPos, aTokenArr, formula::FormulaGrammar::GRAM_API, (sal_uInt8)(mbArray ? MM_FORMULA : MM_NONE) ); pFormula = pDoc->SetFormulaCell(aFormulaPos, pFormula); diff --git a/sc/source/ui/unoobj/nameuno.cxx b/sc/source/ui/unoobj/nameuno.cxx index df1c88d..fa61a67 100644 --- a/sc/source/ui/unoobj/nameuno.cxx +++ b/sc/source/ui/unoobj/nameuno.cxx @@ -224,8 +224,8 @@ void SAL_CALL ScNamedRangeObj::setName( const OUString& aNewName ) //! adapt formulas ????? OUString aNewStr(aNewName); - // GRAM_PODF_A1 for API compatibility. - Modify_Impl( &aNewStr, nullptr, nullptr, nullptr, nullptr,formula::FormulaGrammar::GRAM_PODF_A1 ); + // GRAM_API for API compatibility. + Modify_Impl( &aNewStr, nullptr, nullptr, nullptr, nullptr,formula::FormulaGrammar::GRAM_API ); if ( aName != aNewStr ) // some error occurred... throw uno::RuntimeException(); // no other exceptions specified @@ -237,8 +237,8 @@ OUString SAL_CALL ScNamedRangeObj::getContent() throw(uno::RuntimeException, std OUString aContent; ScRangeData* pData = GetRangeData_Impl(); if (pData) - // GRAM_PODF_A1 for API compatibility. - pData->GetSymbol( aContent,formula::FormulaGrammar::GRAM_PODF_A1); + // GRAM_API for API compatibility. + pData->GetSymbol( aContent,formula::FormulaGrammar::GRAM_API); return aContent; } @@ -247,8 +247,8 @@ void SAL_CALL ScNamedRangeObj::setContent( const OUString& aContent ) { SolarMutexGuard aGuard; OUString aContStr(aContent); - // GRAM_PODF_A1 for API compatibility. - Modify_Impl( nullptr, nullptr, &aContStr, nullptr, nullptr,formula::FormulaGrammar::GRAM_PODF_A1 ); + // GRAM_API for API compatibility. + Modify_Impl( nullptr, nullptr, &aContStr, nullptr, nullptr,formula::FormulaGrammar::GRAM_API ); } table::CellAddress SAL_CALL ScNamedRangeObj::getReferencePosition() @@ -282,8 +282,8 @@ void SAL_CALL ScNamedRangeObj::setReferencePosition( const table::CellAddress& a { SolarMutexGuard aGuard; ScAddress aPos( (SCCOL)aReferencePosition.Column, (SCROW)aReferencePosition.Row, aReferencePosition.Sheet ); - // GRAM_PODF_A1 for API compatibility. - Modify_Impl( nullptr, nullptr, nullptr, &aPos, nullptr,formula::FormulaGrammar::GRAM_PODF_A1 ); + // GRAM_API for API compatibility. + Modify_Impl( nullptr, nullptr, nullptr, &aPos, nullptr,formula::FormulaGrammar::GRAM_API ); } sal_Int32 SAL_CALL ScNamedRangeObj::getType() throw(uno::RuntimeException, std::exception) @@ -312,8 +312,8 @@ void SAL_CALL ScNamedRangeObj::setType( sal_Int32 nUnoType ) if ( nUnoType & sheet::NamedRangeFlag::COLUMN_HEADER ) nNewType |= ScRangeData::Type::ColHeader; if ( nUnoType & sheet::NamedRangeFlag::ROW_HEADER ) nNewType |= ScRangeData::Type::RowHeader; - // GRAM_PODF_A1 for API compatibility. - Modify_Impl( nullptr, nullptr, nullptr, nullptr, &nNewType,formula::FormulaGrammar::GRAM_PODF_A1 ); + // GRAM_API for API compatibility. + Modify_Impl( nullptr, nullptr, nullptr, nullptr, &nNewType,formula::FormulaGrammar::GRAM_API ); } // XFormulaTokens @@ -341,8 +341,8 @@ void SAL_CALL ScNamedRangeObj::setTokens( const uno::Sequence<sheet::FormulaToke { ScTokenArray aTokenArray; (void)ScTokenConversion::ConvertToTokenArray( pDocShell->GetDocument(), aTokenArray, rTokens ); - // GRAM_PODF_A1 for API compatibility. - Modify_Impl( nullptr, &aTokenArray, nullptr, nullptr, nullptr, formula::FormulaGrammar::GRAM_PODF_A1 ); + // GRAM_API for API compatibility. + Modify_Impl( nullptr, &aTokenArray, nullptr, nullptr, nullptr, formula::FormulaGrammar::GRAM_API ); } } @@ -515,9 +515,9 @@ void SAL_CALL ScNamedRangesObj::addNewByName( const OUString& aName, if (pNames && !pNames->findByUpperName(ScGlobal::pCharClass->uppercase(aName))) { ScRangeName* pNewRanges = new ScRangeName( *pNames ); - // GRAM_PODF_A1 for API compatibility. + // GRAM_API for API compatibility. ScRangeData* pNew = new ScRangeData( &rDoc, aName, aContent, - aPos, nNewType,formula::FormulaGrammar::GRAM_PODF_A1 ); + aPos, nNewType,formula::FormulaGrammar::GRAM_API ); if ( pNewRanges->insert(pNew) ) { pDocShell->GetDocFunc().SetNewRangeNames(pNewRanges, mbModifyAndBroadcast, GetTab_Impl()); diff --git a/sc/source/ui/vba/vbarange.cxx b/sc/source/ui/vba/vbarange.cxx index 48524fd..1f7cec9 100644 --- a/sc/source/ui/vba/vbarange.cxx +++ b/sc/source/ui/vba/vbarange.cxx @@ -875,11 +875,11 @@ protected: double aDblValue = 0.0; if ( aValue >>= sFormula ) { - // convert to GRAM_PODF_A1 style grammar because XCell::setFormula + // convert to GRAM_API style grammar because XCell::setFormula // always compile it in that grammar. Perhaps // css.sheet.FormulaParser should be used in future to directly // pass formula tokens when that API stabilizes. - if ( m_eGrammar != formula::FormulaGrammar::GRAM_PODF_A1 && ( sFormula.trim().startsWith("=") ) ) + if ( m_eGrammar != formula::FormulaGrammar::GRAM_API && ( sFormula.trim().startsWith("=") ) ) { uno::Reference< uno::XInterface > xIf( xCell, uno::UNO_QUERY_THROW ); ScCellRangesBase* pUnoRangesBase = dynamic_cast< ScCellRangesBase* >( xIf.get() ); @@ -891,7 +891,7 @@ protected: // compile the string in the format passed in std::unique_ptr<ScTokenArray> pArray(aCompiler.CompileString(sFormula)); // set desired convention to that of the document - aCompiler.SetGrammar( formula::FormulaGrammar::GRAM_PODF_A1 ); + aCompiler.SetGrammar( formula::FormulaGrammar::GRAM_API ); OUString sConverted; aCompiler.CreateStringFromTokenArray(sConverted); sFormula = EQUALS + sConverted; @@ -2001,7 +2001,7 @@ ScVbaRange::setFormulaArray(const uno::Any& rFormula) throw (uno::RuntimeExcepti ScTokenArray aTokenArray; (void)ScTokenConversion::ConvertToTokenArray( getScDocument(), aTokenArray, aTokens ); - getScDocShell()->GetDocFunc().EnterMatrix( *getScRangeList()[0], nullptr, &aTokenArray, OUString(), true, true, EMPTY_OUSTRING, formula::FormulaGrammar::GRAM_PODF_A1 ); + getScDocShell()->GetDocFunc().EnterMatrix( *getScRangeList()[0], nullptr, &aTokenArray, OUString(), true, true, EMPTY_OUSTRING, formula::FormulaGrammar::GRAM_API ); } OUString commit f21a73bc5b1f13708e0f3ccd2c9d654c3ddc76be Author: Eike Rathke <[email protected]> Date: Wed Aug 3 15:11:54 2016 +0200 InitSymbolsAPI() for FormulaLanguage::API Change-Id: I203557ed50d0d54fe9977e3d51e7f979551b472b diff --git a/formula/source/core/api/FormulaCompiler.cxx b/formula/source/core/api/FormulaCompiler.cxx index dd728de..86ac30a 100644 --- a/formula/source/core/api/FormulaCompiler.cxx +++ b/formula/source/core/api/FormulaCompiler.cxx @@ -692,19 +692,8 @@ FormulaCompiler::OpCodeMapPtr FormulaCompiler::GetOpCodeMap( const sal_Int32 nLa case FormulaLanguage::ODF_11 : if (!mxSymbolsPODF) InitSymbolsPODF(); - /* FIXME: only temporarily init mxSymbolsAPI here */ - if (!mxSymbolsAPI) - InitSymbolsAPI(); xMap = mxSymbolsPODF; break; -/* FIXME: add FormulaLanguage::API constant */ -#if 0 - case FormulaLanguage::API : - if (!mxSymbolsAPI) - InitSymbolsAPI(); - xMap = mxSymbolsAPI; - break; -#endif case FormulaLanguage::ENGLISH : if (!mxSymbolsEnglish) InitSymbolsEnglish(); @@ -725,6 +714,11 @@ FormulaCompiler::OpCodeMapPtr FormulaCompiler::GetOpCodeMap( const sal_Int32 nLa InitSymbolsOOXML(); xMap = mxSymbolsOOXML; break; + case FormulaLanguage::API : + if (!mxSymbolsAPI) + InitSymbolsAPI(); + xMap = mxSymbolsAPI; + break; default: ; // nothing, NULL map returned } commit 41eb7eef764d32b4e210a2ec5a745535418fb870 Author: Eike Rathke <[email protected]> Date: Wed Aug 3 15:10:56 2016 +0200 introduce formula::FormulaGrammar::Grammar::GRAM_API Change-Id: Iceaf114847129f0b014ffd61d547e131baf1f07b diff --git a/formula/source/core/api/grammar.cxx b/formula/source/core/api/grammar.cxx index f99bbdd..c013f26 100644 --- a/formula/source/core/api/grammar.cxx +++ b/formula/source/core/api/grammar.cxx @@ -56,6 +56,7 @@ bool FormulaGrammar::isSupported( const Grammar eGrammar ) case GRAM_ENGLISH_XL_R1C1: case GRAM_ENGLISH_XL_OOX : case GRAM_OOXML : + case GRAM_API : return true; default: return extractFormulaLanguage( eGrammar) == GRAM_EXTERNAL; diff --git a/include/formula/grammar.hxx b/include/formula/grammar.hxx index 9dea4fb..2bd6585 100644 --- a/include/formula/grammar.hxx +++ b/include/formula/grammar.hxx @@ -143,6 +143,11 @@ public: ((CONV_XL_OOX + kConventionOffset) << kConventionShift) | kEnglishBit, + /// API English with A1 reference style, unbracketed. + GRAM_API = css::sheet::FormulaLanguage::API | + ((CONV_OOO + + kConventionOffset) << kConventionShift) | + kEnglishBit, /// Central definition of the default grammar to be used. GRAM_DEFAULT = GRAM_NATIVE_UI, commit f85991efc2ef6a624360ce6225f5ad50f7fd4034 Author: Eike Rathke <[email protected]> Date: Wed Aug 3 15:07:57 2016 +0200 introduce css::sheet::FormulaLanguage::API Change-Id: I70624ded4060f50ad820a9590cb461fe58abceb9 diff --git a/offapi/com/sun/star/sheet/FormulaLanguage.idl b/offapi/com/sun/star/sheet/FormulaLanguage.idl index aaea388..f6b810f 100644 --- a/offapi/com/sun/star/sheet/FormulaLanguage.idl +++ b/offapi/com/sun/star/sheet/FormulaLanguage.idl @@ -60,6 +60,19 @@ constants FormulaLanguage @since LibreOffice 4.2 */ const long OOXML = 5; + + /** Function names and operators as used with XFunctionAccess and + other API context. + + Names are mostly identical to ENGLISH and ODF_11, but while + ENGLISH names can be adapted to UI needs and ODF_11 has to stay + error compatible, the API names strive to stay compatible but + may get corrected in case of errors. Earlier versions than + LibreOffice 5.3 always used ODF_11 in API context. + + @since LibreOffice 5.3 + */ + const long API = 6; }; _______________________________________________ Libreoffice-commits mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits
