sc/source/filter/excel/xeformula.cxx | 16 +++++++++++++--- sc/source/filter/excel/xlformula.cxx | 24 +++++++++++++++++++++++- sc/source/filter/inc/xlformula.hxx | 13 +++++++++++-- 3 files changed, 47 insertions(+), 6 deletions(-)
New commits: commit db0d51e647e01d852ef95e46e12f1dba2d09be2b Author: Eike Rathke <er...@redhat.com> Date: Sat Nov 2 16:25:42 2013 +0100 resolved fdo#67536 export internal equivalents as add-in to .xls For BIFF .xls export the internal functions that are equivalents of known add-in functions as those add-in functions. (cherry picked from commit 06a5b1ecc39bb50dadc0bcb7378455500943ece3) Conflicts: sc/source/filter/inc/xlformula.hxx Change-Id: If37f616a34fdabb3fa971fddad01da3dc1f28ee9 Reviewed-on: https://gerrit.libreoffice.org/6525 Reviewed-by: Markus Mohrhard <markus.mohrh...@googlemail.com> Tested-by: Markus Mohrhard <markus.mohrh...@googlemail.com> diff --git a/sc/source/filter/excel/xeformula.cxx b/sc/source/filter/excel/xeformula.cxx index 5265bd1..d58e0ba 100644 --- a/sc/source/filter/excel/xeformula.cxx +++ b/sc/source/filter/excel/xeformula.cxx @@ -139,6 +139,7 @@ public: inline sal_uInt16 GetXclFuncIdx() const { return mrFuncInfo.mnXclFunc; } inline bool IsVolatile() const { return mrFuncInfo.IsVolatile(); } inline bool IsFixedParamCount() const { return mrFuncInfo.IsFixedParamCount(); } + inline bool IsAddInEquivalent() const { return mrFuncInfo.IsAddInEquivalent(); } inline bool IsMacroFunc() const { return mrFuncInfo.IsMacroFunc(); } inline sal_uInt8 GetSpaces() const { return mrTokData.mnSpaces; } inline const XclExpExtFuncData& GetExtFuncData() const { return maExtFuncData; } @@ -1360,8 +1361,11 @@ void XclExpFmlaCompImpl::ProcessFunction( const XclExpScToken& rTokData ) mxData->mbOk = pFuncInfo != 0; if( !mxData->mbOk ) return; + // internal functions equivalent to an existing add-in + if( pFuncInfo->IsAddInEquivalent() ) + aExtFuncData.Set( pFuncInfo->GetAddInEquivalentFuncName(), true, false ); // functions simulated by a macro call in file format - if( pFuncInfo->IsMacroFunc() ) + else if( pFuncInfo->IsMacroFunc() ) aExtFuncData.Set( pFuncInfo->GetMacroFuncName(), false, true ); XclExpFuncData aFuncData( rTokData, *pFuncInfo, aExtFuncData ); @@ -1643,8 +1647,11 @@ void XclExpFmlaCompImpl::AppendDefaultParam( XclExpFuncData& rFuncData ) break; default: { - OSL_ENSURE( rFuncData.IsMacroFunc(), "XclExpFmlaCompImpl::AppendDefaultParam - unknown opcode" ); - if( rFuncData.IsMacroFunc() ) + if( rFuncData.IsAddInEquivalent() ) + { + AppendAddInCallToken( rFuncData.GetExtFuncData() ); + } + else if( rFuncData.IsMacroFunc() ) { // Do not write the OOXML <definedName> element for new _xlfn. // prefixed functions. @@ -1654,7 +1661,10 @@ void XclExpFmlaCompImpl::AppendDefaultParam( XclExpFuncData& rFuncData ) AppendMacroCallToken( rFuncData.GetExtFuncData() ); } else + { + SAL_WARN( "sc.filter", "XclExpFmlaCompImpl::AppendDefaultParam - unknown opcode" ); AppendMissingToken(); // to keep parameter count valid + } } } diff --git a/sc/source/filter/excel/xlformula.cxx b/sc/source/filter/excel/xlformula.cxx index d4bdc86..a04a101 100644 --- a/sc/source/filter/excel/xlformula.cxx +++ b/sc/source/filter/excel/xlformula.cxx @@ -40,6 +40,13 @@ String XclFunctionInfo::GetMacroFuncName() const return EMPTY_STRING; } +String XclFunctionInfo::GetAddInEquivalentFuncName() const +{ + if( IsAddInEquivalent() ) + return String( mpcMacroName, strlen(mpcMacroName), RTL_TEXTENCODING_UTF8 ); + return EMPTY_STRING; +} + // abbreviations for function return token class const sal_uInt8 R = EXC_TOKCLASS_REF; const sal_uInt8 V = EXC_TOKCLASS_VAL; @@ -64,6 +71,7 @@ const sal_uInt8 MX = 30; /// Maximum parameter count. #define EXC_FUNCNAME( ascii ) "_xlfn." ascii #define EXC_FUNCNAME_ODF( ascii ) "_xlfnodf." ascii +#define EXC_FUNCNAME_ADDIN( ascii ) "com.sun.star.sheet.addin." ascii /** Functions new in BIFF2. */ static const XclFunctionInfo saFuncTable_2[] = @@ -309,7 +317,21 @@ static const XclFunctionInfo saFuncTable_4[] = { ocPercentrank, 329, 2, 3, V, { RX, VR, VR_E }, 0, 0 }, { ocModalValue, 330, 1, MX, V, { VA }, 0, 0 }, { ocTrimMean, 331, 2, 2, V, { RX, VR }, 0, 0 }, - { ocTInv, 332, 2, 2, V, { VR }, 0, 0 } + { ocTInv, 332, 2, 2, V, { VR }, 0, 0 }, + // Functions equivalent to add-in functions, use same parameters as + // ocExternal but add programmatical function name (here without + // "com.sun.star.sheet.addin.") so it can be looked up and stored as + // add-in, as older Excel versions only know them as add-in. + // These are the functions flagged as AddInMap::bMapDupToInternal=true in + // sc/source/core/tool/odffmap.cxx + { ocIsEven, 255, 1, MX, R, { RO_E, RO }, EXC_FUNCFLAG_EXPORTONLY | EXC_FUNCFLAG_ADDINEQUIV, EXC_FUNCNAME_ADDIN( "Analysis.getIseven" ) }, + { ocIsOdd, 255, 1, MX, R, { RO_E, RO }, EXC_FUNCFLAG_EXPORTONLY | EXC_FUNCFLAG_ADDINEQUIV, EXC_FUNCNAME_ADDIN( "Analysis.getIsodd" ) }, + { ocGCD, 255, 1, MX, R, { RO_E, RO }, EXC_FUNCFLAG_EXPORTONLY | EXC_FUNCFLAG_ADDINEQUIV, EXC_FUNCNAME_ADDIN( "Analysis.getGcd" ) }, + { ocLCM, 255, 1, MX, R, { RO_E, RO }, EXC_FUNCFLAG_EXPORTONLY | EXC_FUNCFLAG_ADDINEQUIV, EXC_FUNCNAME_ADDIN( "Analysis.getLcm" ) }, + { ocEffektiv, 255, 1, MX, R, { RO_E, RO }, EXC_FUNCFLAG_EXPORTONLY | EXC_FUNCFLAG_ADDINEQUIV, EXC_FUNCNAME_ADDIN( "Analysis.getEffect" ) }, + { ocKumKapZ, 255, 1, MX, R, { RO_E, RO }, EXC_FUNCFLAG_EXPORTONLY | EXC_FUNCFLAG_ADDINEQUIV, EXC_FUNCNAME_ADDIN( "Analysis.getCumprinc" ) }, + { ocKumZinsZ, 255, 1, MX, R, { RO_E, RO }, EXC_FUNCFLAG_EXPORTONLY | EXC_FUNCFLAG_ADDINEQUIV, EXC_FUNCNAME_ADDIN( "Analysis.getCumipmt" ) }, + { ocNominal, 255, 1, MX, R, { RO_E, RO }, EXC_FUNCFLAG_EXPORTONLY | EXC_FUNCFLAG_ADDINEQUIV, EXC_FUNCNAME_ADDIN( "Analysis.getNominal" ) } }; /** Functions new in BIFF5/BIFF7. Unsupported functions: DATESTRING, NUMBERSTRING. */ diff --git a/sc/source/filter/inc/xlformula.hxx b/sc/source/filter/inc/xlformula.hxx index 7768769..78b5405 100644 --- a/sc/source/filter/inc/xlformula.hxx +++ b/sc/source/filter/inc/xlformula.hxx @@ -285,6 +285,7 @@ const sal_uInt8 EXC_FUNCFLAG_VOLATILE = 0x01; /// Result is volatile ( const sal_uInt8 EXC_FUNCFLAG_IMPORTONLY = 0x02; /// Only used in import filter. const sal_uInt8 EXC_FUNCFLAG_EXPORTONLY = 0x04; /// Only used in export filter. const sal_uInt8 EXC_FUNCFLAG_PARAMPAIRS = 0x08; /// Optional parameters are expected to appear in pairs. +const sal_uInt8 EXC_FUNCFLAG_ADDINEQUIV = 0x10; /// Function is an add-in equivalent // selected function IDs const sal_uInt16 EXC_FUNCID_IF = 1; @@ -311,7 +312,11 @@ struct XclFunctionInfo sal_uInt8 mnRetClass; /// Token class of the return value. XclFuncParamInfo mpParamInfos[ EXC_FUNCINFO_PARAMINFO_COUNT ]; /// Information for all parameters. sal_uInt8 mnFlags; /// Additional flags (EXC_FUNCFLAG_* constants). - const sal_Char* mpcMacroName; /// Function name, if simulated by a macro call (UTF-8). + const sal_Char* mpcMacroName; /** Function name, if simulated by + a macro call (UTF-8) EXC_FUNCFLAG_ADDINEQUIV is 0; + or programmatical add-in name + if stored as such and + EXC_FUNCFLAG_ADDINEQUIV is set. */ /** Returns true, if the function is volatile. */ inline bool IsVolatile() const { return ::get_flag( mnFlags, EXC_FUNCFLAG_VOLATILE ); } @@ -320,9 +325,13 @@ struct XclFunctionInfo /** Returns true, if the function parameter count is fixed. */ inline bool IsFixedParamCount() const { return (mnXclFunc != EXC_FUNCID_EXTERNCALL) && (mnMinParamCount == mnMaxParamCount); } /** Returns true, if the function is simulated by a macro call. */ - inline bool IsMacroFunc() const { return mpcMacroName != 0; } + inline bool IsMacroFunc() const { return mpcMacroName != 0 && !(mnFlags & EXC_FUNCFLAG_ADDINEQUIV); } + /** Returns true, if the function is stored as an add-in call. */ + inline bool IsAddInEquivalent() const { return mpcMacroName != 0 && (mnFlags & EXC_FUNCFLAG_ADDINEQUIV); } /** Returns the name of the external function as string. */ String GetMacroFuncName() const; + /** Returns the programmatical name of the Add-In function as string. */ + String GetAddInEquivalentFuncName() const; }; // ---------------------------------------------------------------------------- _______________________________________________ Libreoffice-commits mailing list libreoffice-comm...@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/libreoffice-commits