sc/source/filter/excel/xeroot.cxx | 4 - sc/source/filter/inc/formulabase.hxx | 8 -- sc/source/filter/inc/workbookhelper.hxx | 8 -- sc/source/filter/oox/formulabase.cxx | 112 ++++++++++-------------------- sc/source/filter/oox/ooxformulaparser.cxx | 2 5 files changed, 43 insertions(+), 91 deletions(-)
New commits: commit 61fc9da45f845ae98d8e0f159bac6a4c2f39ddd7 Author: Jochen Nitschke <j.nitschke+loger...@ok.de> Date: Fri Jul 15 14:08:12 2016 +0200 sc: FilterType::FILTER_BIFF and FilterType::FILTER_UNKNOWN are never set only value ever set is FilterType::FILTER_OOXML. main user is FunctionProviderImpl ctor, thus used BiffType is always BIFF8, nMaxParam = OOX_MAX_PARAMCOUNT and bCallerKnowsAboutMacroExport is always true. so remove these parameters and the FilterType enum. a follow up should check uses of FUNCFLAG_BIFFEXPORTONLY and FUNCFLAG_BIFFIMPORTONLY as for such functions isSupported() returns always false Change-Id: I0d2941ba10642a86bad36d57b64a2c71517069ab Reviewed-on: https://gerrit.libreoffice.org/27237 Tested-by: Jenkins <c...@libreoffice.org> Reviewed-by: Noel Grandin <noelgran...@gmail.com> diff --git a/sc/source/filter/excel/xeroot.cxx b/sc/source/filter/excel/xeroot.cxx index 05d6fef..e51fa8a 100644 --- a/sc/source/filter/excel/xeroot.cxx +++ b/sc/source/filter/excel/xeroot.cxx @@ -240,9 +240,7 @@ void XclExpRoot::InitializeGlobals() break; } uno::Reference< lang::XMultiServiceFactory > xModelFactory( xComponent, uno::UNO_QUERY); - // OOXML is also BIFF8 function-wise - oox::xls::OpCodeProvider aOpCodeProvider( xModelFactory, - oox::xls::FILTER_OOXML, oox::xls::BIFF8, false); + oox::xls::OpCodeProvider aOpCodeProvider(xModelFactory, false); // Compiler mocks about non-matching ctor or conversion from // Sequence<...> to Sequence<const ...> if directly created or passed, // conversion through Any works around. diff --git a/sc/source/filter/inc/formulabase.hxx b/sc/source/filter/inc/formulabase.hxx index c88d4fb..a5b1e7c 100644 --- a/sc/source/filter/inc/formulabase.hxx +++ b/sc/source/filter/inc/formulabase.hxx @@ -554,8 +554,7 @@ struct FunctionProviderImpl; class FunctionProvider // not derived from WorkbookHelper to make it usable in file dumpers { public: - explicit FunctionProvider( FilterType eFilter, BiffType eBiff, bool bImportFilter, - bool bCallerKnowsAboutMacroExport ); + explicit FunctionProvider(bool bImportFilter); virtual ~FunctionProvider(); /** Returns the function info for an OOXML function name, or 0 on error. */ @@ -594,9 +593,8 @@ struct OpCodeProviderImpl; class OpCodeProvider : public FunctionProvider // not derived from WorkbookHelper to make it usable as UNO service { public: - explicit OpCodeProvider( - const css::uno::Reference< css::lang::XMultiServiceFactory >& rxModelFactory, - FilterType eFilter, BiffType eBiff, bool bImportFilter ); + explicit OpCodeProvider(const css::uno::Reference<css::lang::XMultiServiceFactory>& rxModelFactory, + bool bImportFilter); virtual ~OpCodeProvider(); /** Returns the structure containing all token op-codes for operators and diff --git a/sc/source/filter/inc/workbookhelper.hxx b/sc/source/filter/inc/workbookhelper.hxx index 11b17fb..6ea3007 100644 --- a/sc/source/filter/inc/workbookhelper.hxx +++ b/sc/source/filter/inc/workbookhelper.hxx @@ -66,14 +66,6 @@ namespace xls { class ExcelFilter; -/** An enumeration for all supported spreadsheet filter types. */ -enum FilterType -{ - FILTER_OOXML, /// MS Excel OOXML (Office Open XML) or BIFF12. - FILTER_BIFF, /// MS Excel BIFF2-BIFF8 (Binary Interchange File Format). - FILTER_UNKNOWN /// Unknown filter type. -}; - /** Functor for case-insensitive string comparison, usable in maps etc. */ struct IgnoreCaseCompare { diff --git a/sc/source/filter/oox/formulabase.cxx b/sc/source/filter/oox/formulabase.cxx index 80c277c..6c5cabc 100644 --- a/sc/source/filter/oox/formulabase.cxx +++ b/sc/source/filter/oox/formulabase.cxx @@ -236,21 +236,19 @@ struct FunctionData FunctionParamInfo mpParamInfos[ FUNCINFO_PARAMINFOCOUNT ]; /// Information about all parameters. sal_uInt16 mnFlags; /// Additional flags. - inline bool isSupported( bool bImportFilter, FilterType eFilter ) const; + inline bool isSupported(bool bImportFilter) const; }; -inline bool FunctionData::isSupported( bool bImportFilter, FilterType eFilter ) const +inline bool FunctionData::isSupported(bool bImportFilter) const { - /* For import filters: the FUNCFLAG_EXPORTONLY and FUNCFLAG_BIFFEXPORTONLY flag must not be set. - For OOXML import: the FUNCFLAG_BIFFIMPORTONLY flag must not be set. - For export filters: the FUNCFLAG_IMPORTONLY and FUNCFLAG_BIFFIMPORTONLY flag must not be set. - For OOXML export: the FUNCFLAG_BIFFEXPORTONLY flag must not be set. */ - bool bSupported = !getFlag( mnFlags, static_cast<sal_uInt16>(bImportFilter ? - (FUNCFLAG_EXPORTONLY | FUNCFLAG_BIFFEXPORTONLY) : - (FUNCFLAG_IMPORTONLY | FUNCFLAG_BIFFIMPORTONLY))); - if (bSupported && eFilter == FILTER_OOXML) - bSupported = !getFlag( mnFlags, bImportFilter ? FUNCFLAG_BIFFIMPORTONLY : FUNCFLAG_BIFFEXPORTONLY ); - return bSupported; + /* For import filters: the FUNCFLAG_EXPORTONLY, FUNCFLAG_BIFFEXPORTONLY + and FUNCFLAG_BIFFIMPORTONLY flag must not be set. + For export filters: the FUNCFLAG_IMPORTONLY, FUNCFLAG_BIFFIMPORTONLY + and FUNCFLAG_BIFFEXPORTONLY flag must not be set. */ + if (bImportFilter) + return !(mnFlags & ( FUNCFLAG_EXPORTONLY | FUNCFLAG_BIFFEXPORTONLY | FUNCFLAG_BIFFIMPORTONLY)); + else + return !(mnFlags & ( FUNCFLAG_IMPORTONLY | FUNCFLAG_BIFFIMPORTONLY | FUNCFLAG_BIFFEXPORTONLY)); } const sal_uInt16 NOID = SAL_MAX_UINT16; /// No BIFF function identifier available. @@ -1027,67 +1025,35 @@ struct FunctionProviderImpl FuncIdMap maBiffFuncs; /// Maps BIFF2-BIFF8 function indexes to function data. FuncNameMap maMacroFuncs; /// Maps macro function names to function data. - explicit FunctionProviderImpl( FilterType eFilter, BiffType eBiff, bool bImportFilter, - bool bCallerKnowsAboutMacroExport ); + explicit FunctionProviderImpl(bool bImportFilter); private: /** Creates and inserts a function info struct from the passed function data. */ - void initFunc( const FunctionData& rFuncData, sal_uInt8 nMaxParam ); + void initFunc(const FunctionData& rFuncData); /** Initializes the members from the passed function data list. */ - void initFuncs( - const FunctionData* pBeg, const FunctionData* pEnd, - sal_uInt8 nMaxParam, bool bImportFilter, FilterType eFilter ); + void initFuncs(const FunctionData* pBeg, const FunctionData* pEnd, bool bImportFilter); }; -FunctionProviderImpl::FunctionProviderImpl( FilterType eFilter, BiffType eBiff, bool bImportFilter, - bool bCallerKnowsAboutMacroExport ) -{ - // NOTE: this warning is only applicable if called for not yet existing - // external export filter, not the Calc internal conversion from binary to - // OOXML that also uses this mapping. Which is the only reason for - // bCallerKnowsAboutMacroExport, to suppress this warning then. - OSL_ENSURE( bImportFilter || bCallerKnowsAboutMacroExport, - "FunctionProviderImpl::FunctionProviderImpl - need special handling for macro call functions" ); - (void)bCallerKnowsAboutMacroExport; - sal_uInt8 nMaxParam = 0; - switch( eFilter ) - { - case FILTER_OOXML: - nMaxParam = OOX_MAX_PARAMCOUNT; - eBiff = BIFF8; // insert all BIFF function tables, then the OOXML table - break; - case FILTER_BIFF: - nMaxParam = BIFF_MAX_PARAMCOUNT; - break; - case FILTER_UNKNOWN: - OSL_FAIL( "FunctionProviderImpl::FunctionProviderImpl - invalid filter type" ); - break; - } - OSL_ENSURE( eBiff != BIFF_UNKNOWN, "FunctionProviderImpl::FunctionProviderImpl - invalid BIFF type" ); - +FunctionProviderImpl::FunctionProviderImpl( bool bImportFilter ) +{ /* Add functions supported in the current BIFF version only. Function tables from later BIFF versions may overwrite single functions from earlier tables. */ - if( eBiff >= BIFF2 ) - initFuncs( saFuncTableBiff2, ::std::end( saFuncTableBiff2 ), nMaxParam, bImportFilter, eFilter ); - if( eBiff >= BIFF3 ) - initFuncs( saFuncTableBiff3, ::std::end( saFuncTableBiff3 ), nMaxParam, bImportFilter, eFilter ); - if( eBiff >= BIFF4 ) - initFuncs( saFuncTableBiff4, ::std::end( saFuncTableBiff4 ), nMaxParam, bImportFilter, eFilter ); - if( eBiff >= BIFF5 ) - initFuncs( saFuncTableBiff5, ::std::end( saFuncTableBiff5 ), nMaxParam, bImportFilter, eFilter ); - if( eBiff >= BIFF8 ) - initFuncs( saFuncTableBiff8, ::std::end( saFuncTableBiff8 ), nMaxParam, bImportFilter, eFilter ); - initFuncs( saFuncTableOox, ::std::end( saFuncTableOox ), nMaxParam, bImportFilter, eFilter ); - initFuncs( saFuncTable2010, ::std::end( saFuncTable2010 ), nMaxParam, bImportFilter, eFilter ); - initFuncs( saFuncTable2013, ::std::end( saFuncTable2013 ), nMaxParam, bImportFilter, eFilter ); - initFuncs( saFuncTable2016, ::std::end( saFuncTable2016 ), nMaxParam, bImportFilter, eFilter ); - initFuncs( saFuncTableOdf, ::std::end( saFuncTableOdf ), nMaxParam, bImportFilter, eFilter ); - initFuncs( saFuncTableOOoLO, ::std::end( saFuncTableOOoLO ), nMaxParam, bImportFilter, eFilter ); -} - -void FunctionProviderImpl::initFunc( const FunctionData& rFuncData, sal_uInt8 nMaxParam ) + initFuncs( saFuncTableBiff2, std::end( saFuncTableBiff2 ), bImportFilter ); + initFuncs( saFuncTableBiff3, std::end( saFuncTableBiff3 ), bImportFilter ); + initFuncs( saFuncTableBiff4, std::end( saFuncTableBiff4 ), bImportFilter ); + initFuncs( saFuncTableBiff5, std::end( saFuncTableBiff5 ), bImportFilter ); + initFuncs( saFuncTableBiff8, std::end( saFuncTableBiff8 ), bImportFilter ); + initFuncs( saFuncTableOox, std::end( saFuncTableOox ), bImportFilter ); + initFuncs( saFuncTable2010, std::end( saFuncTable2010 ), bImportFilter ); + initFuncs( saFuncTable2013, std::end( saFuncTable2013 ), bImportFilter ); + initFuncs( saFuncTable2016, std::end( saFuncTable2016 ), bImportFilter ); + initFuncs( saFuncTableOdf, std::end( saFuncTableOdf ), bImportFilter ); + initFuncs( saFuncTableOOoLO, std::end( saFuncTableOOoLO ), bImportFilter ); +} + +void FunctionProviderImpl::initFunc(const FunctionData& rFuncData) { // create a function info object FunctionInfoRef xFuncInfo( new FunctionInfo ); @@ -1117,7 +1083,7 @@ void FunctionProviderImpl::initFunc( const FunctionData& rFuncData, sal_uInt8 nM xFuncInfo->mnBiff12FuncId = rFuncData.mnBiff12FuncId; xFuncInfo->mnBiffFuncId = rFuncData.mnBiffFuncId; xFuncInfo->mnMinParamCount = rFuncData.mnMinParamCount; - xFuncInfo->mnMaxParamCount = (rFuncData.mnMaxParamCount == MX) ? nMaxParam : rFuncData.mnMaxParamCount; + xFuncInfo->mnMaxParamCount = (rFuncData.mnMaxParamCount == MX) ? OOX_MAX_PARAMCOUNT : rFuncData.mnMaxParamCount; xFuncInfo->mnRetClass = rFuncData.mnRetClass; xFuncInfo->mpParamInfos = rFuncData.mpParamInfos; xFuncInfo->mbParamPairs = getFlag( rFuncData.mnFlags, FUNCFLAG_PARAMPAIRS ); @@ -1143,17 +1109,15 @@ void FunctionProviderImpl::initFunc( const FunctionData& rFuncData, sal_uInt8 nM maMacroFuncs[ xFuncInfo->maBiffMacroName ] = xFuncInfo; } -void FunctionProviderImpl::initFuncs( const FunctionData* pBeg, const FunctionData* pEnd, sal_uInt8 nMaxParam, - bool bImportFilter, FilterType eFilter ) +void FunctionProviderImpl::initFuncs(const FunctionData* pBeg, const FunctionData* pEnd, bool bImportFilter) { for( const FunctionData* pIt = pBeg; pIt != pEnd; ++pIt ) - if( pIt->isSupported( bImportFilter, eFilter ) ) - initFunc( *pIt, nMaxParam ); + if( pIt->isSupported(bImportFilter) ) + initFunc(*pIt); } -FunctionProvider::FunctionProvider( FilterType eFilter, BiffType eBiff, bool bImportFilter, - bool bCallerKnowsAboutMacroExport ) : - mxFuncImpl( new FunctionProviderImpl( eFilter, eBiff, bImportFilter, bCallerKnowsAboutMacroExport ) ) +FunctionProvider::FunctionProvider( bool bImportFilter ) : + mxFuncImpl( new FunctionProviderImpl( bImportFilter ) ) { } @@ -1484,8 +1448,8 @@ bool OpCodeProviderImpl::initFuncOpCodes( const ApiTokenMap& rIntFuncTokenMap, c } OpCodeProvider::OpCodeProvider( const Reference< XMultiServiceFactory >& rxModelFactory, - FilterType eFilter, BiffType eBiff, bool bImportFilter ) : - FunctionProvider( eFilter, eBiff, bImportFilter, true/*bCallerKnowsAboutMacroExport*/ ), + bool bImportFilter ) : + FunctionProvider( bImportFilter ), mxOpCodeImpl( new OpCodeProviderImpl( getFuncs(), rxModelFactory ) ) { } @@ -1621,7 +1585,7 @@ TokenToRangeListState lclProcessClose( sal_Int32& ornParenLevel ) } // namespace FormulaProcessorBase::FormulaProcessorBase( const WorkbookHelper& rHelper ) : - OpCodeProvider( rHelper.getBaseFilter().getModelFactory(), FILTER_OOXML, rHelper.getBiff(), rHelper.getBaseFilter().isImportFilter() ), + OpCodeProvider( rHelper.getBaseFilter().getModelFactory(), rHelper.getBaseFilter().isImportFilter() ), ApiOpCodes( getOpCodes() ), WorkbookHelper( rHelper ) { diff --git a/sc/source/filter/oox/ooxformulaparser.cxx b/sc/source/filter/oox/ooxformulaparser.cxx index e298876..fc65fde 100644 --- a/sc/source/filter/oox/ooxformulaparser.cxx +++ b/sc/source/filter/oox/ooxformulaparser.cxx @@ -50,7 +50,7 @@ private: }; OOXMLFormulaParserImpl::OOXMLFormulaParserImpl( const Reference< XMultiServiceFactory >& rxModelFactory ) : - FormulaFinalizer( OpCodeProvider( rxModelFactory, FILTER_OOXML, BIFF_UNKNOWN, true ) ), + FormulaFinalizer( OpCodeProvider( rxModelFactory, true ) ), maApiParser( rxModelFactory, *this ) { } _______________________________________________ Libreoffice-commits mailing list libreoffice-comm...@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits