[Libreoffice-commits] core.git: sc/source
Eike Rathke
erack at redhat.com
Sat Nov 2 16:30:14 CET 2013
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 06a5b1ecc39bb50dadc0bcb7378455500943ece3
Author: Eike Rathke <erack at 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.
Change-Id: If37f616a34fdabb3fa971fddad01da3dc1f28ee9
diff --git a/sc/source/filter/excel/xeformula.cxx b/sc/source/filter/excel/xeformula.cxx
index a11c3b2..ba02aef 100644
--- a/sc/source/filter/excel/xeformula.cxx
+++ b/sc/source/filter/excel/xeformula.cxx
@@ -140,6 +140,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; }
@@ -1361,8 +1362,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 );
@@ -1644,8 +1648,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.
@@ -1655,7 +1662,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 064d1ab..78c4438 100644
--- a/sc/source/filter/excel/xlformula.cxx
+++ b/sc/source/filter/excel/xlformula.cxx
@@ -40,6 +40,13 @@ OUString XclFunctionInfo::GetMacroFuncName() const
return OUString();
}
+OUString XclFunctionInfo::GetAddInEquivalentFuncName() const
+{
+ if( IsAddInEquivalent() )
+ return OUString( mpcMacroName, strlen(mpcMacroName), RTL_TEXTENCODING_UTF8 );
+ return OUString();
+}
+
// 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[] =
@@ -313,7 +321,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 50eac34..7688220 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. */
OUString GetMacroFuncName() const;
+ /** Returns the programmatical name of the Add-In function as string. */
+ OUString GetAddInEquivalentFuncName() const;
};
// ----------------------------------------------------------------------------
More information about the Libreoffice-commits
mailing list