diff options
author | Daniel Rentz [dr] <daniel.rentz@oracle.com> | 2012-12-15 00:57:00 +0100 |
---|---|---|
committer | Eike Rathke <erack@redhat.com> | 2012-12-15 21:42:40 +0100 |
commit | ba950a50b0d0863e18ef781214eaaff9a8684790 (patch) | |
tree | c031906c4050212f64bb00e3d17add75c5a47d3a | |
parent | 65721e490a753178c9e90dbe9eecb70124d94117 (diff) |
calcishmakkica: #i117283# support new functions in Excel filters
AVERAGEIF, AVERAGEIFS, COUNTIFS, SUMIFS
Merged from Apache OO with adaptions.
http://svn.apache.org/viewvc?rev=1381452&view=rev
Original Apache OO committer: Andrew Rist <arist@apache.org>
Original Author: Daniel Rentz [dr] <daniel.rentz@oracle.com>
Original Committer: Daniel Rentz [dr] <daniel.rentz@oracle.com>
# HG changeset patch
# User Daniel Rentz [dr] <daniel.rentz@oracle.com>
# Date 1299664669 -3600
# Node ID 89feb2fb2947d76a15e2de8bc1def1edf20e4f88
# Parent 1bf6d73db8a4ee709aa4d9d9d827efafc9c611d2
Change-Id: Ia70075284c5921faea58cae986e4e5eb090b1fab
-rw-r--r-- | sc/source/filter/excel/excform.cxx | 3 | ||||
-rw-r--r-- | sc/source/filter/excel/xeformula.cxx | 5 | ||||
-rw-r--r-- | sc/source/filter/excel/xicontent.cxx | 4 | ||||
-rw-r--r-- | sc/source/filter/excel/xlformula.cxx | 17 | ||||
-rw-r--r-- | sc/source/filter/inc/xlformula.hxx | 3 |
5 files changed, 27 insertions, 5 deletions
diff --git a/sc/source/filter/excel/excform.cxx b/sc/source/filter/excel/excform.cxx index 822f8d19e70b..b66b50725f38 100644 --- a/sc/source/filter/excel/excform.cxx +++ b/sc/source/filter/excel/excform.cxx @@ -191,7 +191,8 @@ ConvErr ExcelToSc::Convert( const ScTokenArray*& pErgebnis, XclImpStream& aIn, s TokenId nMerk0; const sal_Bool bRangeName = eFT == FT_RangeName; const sal_Bool bSharedFormula = eFT == FT_SharedFormula; - const sal_Bool bRNorSF = bRangeName || bSharedFormula; + const sal_Bool bConditional = eFT == FT_CondFormat; + const sal_Bool bRNorSF = bRangeName || bSharedFormula || bConditional; ScSingleRefData aSRD; ScComplexRefData aCRD; diff --git a/sc/source/filter/excel/xeformula.cxx b/sc/source/filter/excel/xeformula.cxx index bc66024db65f..d450dfed4b76 100644 --- a/sc/source/filter/excel/xeformula.cxx +++ b/sc/source/filter/excel/xeformula.cxx @@ -202,11 +202,14 @@ void XclExpFuncData::IncParamInfoIdx() if( mpParamInfo ) { // move pointer to next entry, if something explicit follows - if( (static_cast<size_t>(mpParamInfo - mrFuncInfo.mpParamInfos + 1) < EXC_FUNCINFO_PARAMINFO_COUNT) && (mpParamInfo[ 1 ].meValid != EXC_PARAM_NONE) ) + if( (static_cast< size_t >( mpParamInfo - mrFuncInfo.mpParamInfos + 1 ) < EXC_FUNCINFO_PARAMINFO_COUNT) && (mpParamInfo[ 1 ].meValid != EXC_PARAM_NONE) ) ++mpParamInfo; // if last parameter type is 'Excel-only' or 'Calc-only', do not repeat it else if( IsExcelOnlyParam() || IsCalcOnlyParam() ) mpParamInfo = 0; + // points to last info, but parameter pairs expected, move to previous info + else if( mrFuncInfo.IsParamPairs() ) + --mpParamInfo; // otherwise: repeat last parameter class } } diff --git a/sc/source/filter/excel/xicontent.cxx b/sc/source/filter/excel/xicontent.cxx index f35f53057e30..7e09fb4decce 100644 --- a/sc/source/filter/excel/xicontent.cxx +++ b/sc/source/filter/excel/xicontent.cxx @@ -744,7 +744,7 @@ void XclImpValidationManager::ReadDV( XclImpStream& rStrm ) { const ScTokenArray* pTokArr = 0; rFmlaConv.Reset(); - rFmlaConv.Convert( pTokArr, rStrm, nLen, false, FT_RangeName ); + rFmlaConv.Convert( pTokArr, rStrm, nLen, false, FT_CondFormat ); // formula converter owns pTokArr -> create a copy of the token array if( pTokArr ) xTokArr1.reset( pTokArr->Clone() ); @@ -763,7 +763,7 @@ void XclImpValidationManager::ReadDV( XclImpStream& rStrm ) { const ScTokenArray* pTokArr = 0; rFmlaConv.Reset(); - rFmlaConv.Convert( pTokArr, rStrm, nLen, false, FT_RangeName ); + rFmlaConv.Convert( pTokArr, rStrm, nLen, false, FT_CondFormat ); // formula converter owns pTokArr -> create a copy of the token array if( pTokArr ) xTokArr2.reset( pTokArr->Clone() ); diff --git a/sc/source/filter/excel/xlformula.cxx b/sc/source/filter/excel/xlformula.cxx index 24c8adb4ef8a..58b3aa945985 100644 --- a/sc/source/filter/excel/xlformula.cxx +++ b/sc/source/filter/excel/xlformula.cxx @@ -355,6 +355,19 @@ static const XclFunctionInfo saFuncTable_8[] = { ocEuroConvert, 255, 4, 6, V, { RO_E, RO }, EXC_FUNCFLAG_EXPORTONLY, "EUROCONVERT" } }; +/** Functions new in OOXML. */ +static const XclFunctionInfo saFuncTable_Oox[] = +{ + { ocCountIfs, NOID, 2, MX, V, { RO, VR }, EXC_FUNCFLAG_IMPORTONLY|EXC_FUNCFLAG_PARAMPAIRS, EXC_FUNCNAME( "COUNTIFS" ) }, + { ocCountIfs, 255, 3, MX, V, { RO_E, RO, VR }, EXC_FUNCFLAG_EXPORTONLY|EXC_FUNCFLAG_PARAMPAIRS, EXC_FUNCNAME( "COUNTIFS" ) }, + { ocSumIfs, NOID, 3, MX, V, { RO, RO, VR }, EXC_FUNCFLAG_IMPORTONLY|EXC_FUNCFLAG_PARAMPAIRS, EXC_FUNCNAME( "SUMIFS" ) }, + { ocSumIfs, 255, 4, MX, V, { RO_E, RO, RO, VR }, EXC_FUNCFLAG_EXPORTONLY|EXC_FUNCFLAG_PARAMPAIRS, EXC_FUNCNAME( "SUMIFS" ) }, + { ocAverageIf, NOID, 2, 3, V, { RO, VR, RO }, EXC_FUNCFLAG_IMPORTONLY, EXC_FUNCNAME( "AVERAGEIF" ) }, + { ocAverageIf, 255, 3, 4, V, { RO_E, RO, VR, RO }, EXC_FUNCFLAG_EXPORTONLY, EXC_FUNCNAME( "AVERAGEIF" ) }, + { ocAverageIfs, NOID, 3, MX, V, { RO, RO, VR }, EXC_FUNCFLAG_IMPORTONLY|EXC_FUNCFLAG_PARAMPAIRS, EXC_FUNCNAME( "AVERAGEIFS" ) }, + { ocAverageIfs, 255, 4, MX, V, { RO_E, RO, RO, VR }, EXC_FUNCFLAG_EXPORTONLY|EXC_FUNCFLAG_PARAMPAIRS, EXC_FUNCNAME( "AVERAGEIFS" ) } +}; + #define EXC_FUNCENTRY_ODF( opcode, minparam, maxparam, flags, asciiname ) \ { opcode, NOID, minparam, maxparam, V, { VR }, EXC_FUNCFLAG_IMPORTONLY|(flags), EXC_FUNCNAME_ODF( asciiname ) }, \ { opcode, 255, (minparam)+1, (maxparam)+1, V, { RO_E, RO }, EXC_FUNCFLAG_EXPORTONLY|(flags), EXC_FUNCNAME_ODF( asciiname ) } @@ -420,6 +433,7 @@ XclFunctionProvider::XclFunctionProvider( const XclRoot& rRoot ) (this->*pFillFunc)( saFuncTable_5, STATIC_ARRAY_END( saFuncTable_5 ) ); if( eBiff >= EXC_BIFF8 ) (this->*pFillFunc)( saFuncTable_8, STATIC_ARRAY_END( saFuncTable_8 ) ); + (this->*pFillFunc)( saFuncTable_Oox, STATIC_ARRAY_END( saFuncTable_Oox ) ); (this->*pFillFunc)( saFuncTable_Odf, STATIC_ARRAY_END( saFuncTable_Odf ) ); } @@ -453,7 +467,8 @@ void XclFunctionProvider::FillXclFuncMap( const XclFunctionInfo* pBeg, const Xcl { if( !::get_flag( pIt->mnFlags, EXC_FUNCFLAG_EXPORTONLY ) ) { - maXclFuncMap[ pIt->mnXclFunc ] = pIt; + if( pIt->mnXclFunc != NOID ) + maXclFuncMap[ pIt->mnXclFunc ] = pIt; if( pIt->IsMacroFunc() ) maXclMacroNameMap[ pIt->GetMacroFuncName() ] = pIt; } diff --git a/sc/source/filter/inc/xlformula.hxx b/sc/source/filter/inc/xlformula.hxx index 62c93b6ad2b8..77687691024e 100644 --- a/sc/source/filter/inc/xlformula.hxx +++ b/sc/source/filter/inc/xlformula.hxx @@ -284,6 +284,7 @@ const size_t EXC_FUNCINFO_PARAMINFO_COUNT = 5; /// Number of parameter const sal_uInt8 EXC_FUNCFLAG_VOLATILE = 0x01; /// Result is volatile (e.g. NOW() function). 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. // selected function IDs const sal_uInt16 EXC_FUNCID_IF = 1; @@ -314,6 +315,8 @@ struct XclFunctionInfo /** Returns true, if the function is volatile. */ inline bool IsVolatile() const { return ::get_flag( mnFlags, EXC_FUNCFLAG_VOLATILE ); } + /** Returns true, if optional parameters are expected to appear in pairs. */ + inline bool IsParamPairs() const { return ::get_flag( mnFlags, EXC_FUNCFLAG_PARAMPAIRS ); } /** 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. */ |