incubator-ooo-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ar...@apache.org
Subject svn commit: r1381452 - in /incubator/ooo/trunk/main: oox/source/xls/ sc/source/filter/excel/ sc/source/filter/inc/
Date Thu, 06 Sep 2012 00:48:05 GMT
Author: arist
Date: Thu Sep  6 00:48:03 2012
New Revision: 1381452

URL: http://svn.apache.org/viewvc?rev=1381452&view=rev
Log:
calcishmakkica: #i117283# support new functions AVERAGEIF, AVERAGEIFS, COUNTIFS, SUMIFS, XOR
in Excel filters

From: Eike Rathke <erack@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

Modified:
    incubator/ooo/trunk/main/oox/source/xls/formulabase.cxx
    incubator/ooo/trunk/main/sc/source/filter/excel/excform.cxx
    incubator/ooo/trunk/main/sc/source/filter/excel/excform8.cxx
    incubator/ooo/trunk/main/sc/source/filter/excel/xeformula.cxx
    incubator/ooo/trunk/main/sc/source/filter/excel/xicontent.cxx
    incubator/ooo/trunk/main/sc/source/filter/excel/xlformula.cxx
    incubator/ooo/trunk/main/sc/source/filter/inc/formel.hxx
    incubator/ooo/trunk/main/sc/source/filter/inc/xlformula.hxx

Modified: incubator/ooo/trunk/main/oox/source/xls/formulabase.cxx
URL: http://svn.apache.org/viewvc/incubator/ooo/trunk/main/oox/source/xls/formulabase.cxx?rev=1381452&r1=1381451&r2=1381452&view=diff
==============================================================================
--- incubator/ooo/trunk/main/oox/source/xls/formulabase.cxx (original)
+++ incubator/ooo/trunk/main/oox/source/xls/formulabase.cxx Thu Sep  6 00:48:03 2012
@@ -724,10 +724,10 @@ static const FunctionData saFuncTableOox
     { 0,                        "CUBESET",              478,    NOID,   2,  5,  V, { VR,
RX, VR }, 0 },
     { 0,                        "CUBESETCOUNT",         479,    NOID,   1,  1,  V, { VR },
0 },
     { 0,                        "IFERROR",              480,    NOID,   2,  2,  V, { VO,
RO }, 0 },
-    { 0,                        "COUNTIFS",             481,    NOID,   2,  MX, V, { RO,
VR }, FUNCFLAG_PARAMPAIRS },
-    { 0,                        "SUMIFS",               482,    NOID,   3,  MX, V, { RO,
RO, VR }, FUNCFLAG_PARAMPAIRS },
-    { 0,                        "AVERAGEIF",            483,    NOID,   2,  3,  V, { RO,
VR, RO }, 0 },
-    { 0,                        "AVERAGEIFS",           484,    NOID,   3,  MX, V, { RO,
RO, VR }, 0 }
+    { "COUNTIFS",               "COUNTIFS",             481,    NOID,   2,  MX, V, { RO,
VR }, FUNCFLAG_MACROCALL | FUNCFLAG_PARAMPAIRS },
+    { "SUMIFS",                 "SUMIFS",               482,    NOID,   3,  MX, V, { RO,
RO, VR }, FUNCFLAG_MACROCALL | FUNCFLAG_PARAMPAIRS },
+    { "AVERAGEIF",              "AVERAGEIF",            483,    NOID,   2,  3,  V, { RO,
VR, RO }, FUNCFLAG_MACROCALL },
+    { "AVERAGEIFS",             "AVERAGEIFS",           484,    NOID,   3,  MX, V, { RO,
RO, VR }, FUNCFLAG_MACROCALL | FUNCFLAG_PARAMPAIRS }
 };
 
 /** Functions defined by OpenFormula, but not supported by Calc or by Excel. */
@@ -788,8 +788,6 @@ FunctionParamInfoIterator::FunctionParam
     mpParamInfoEnd( rFuncInfo.mpParamInfos + FUNCINFO_PARAMINFOCOUNT ),
     mbParamPairs( rFuncInfo.mbParamPairs )
 {
-    OSL_ENSURE( !mbParamPairs || (mpParamInfo + 1 < mpParamInfoEnd),
-        "FunctionParamInfoIterator::FunctionParamInfoIterator - expecting at least 2 infos
for paired parameters" );
 }
 
 const FunctionParamInfo& FunctionParamInfoIterator::getParamInfo() const
@@ -815,12 +813,12 @@ FunctionParamInfoIterator& FunctionParam
         // move pointer to next entry, if something explicit follows
         if( (mpParamInfo + 1 < mpParamInfoEnd) && (mpParamInfo[ 1 ].meValid !=
FUNC_PARAM_NONE) )
             ++mpParamInfo;
-        // points to last info, but parameter pairs expected, move to previous info
-        else if( mbParamPairs )
-            --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( mbParamPairs )
+            --mpParamInfo;
         // otherwise: repeat last parameter class
     }
     return *this;
@@ -886,8 +884,7 @@ FunctionProviderImpl::FunctionProviderIm
         initFuncs( saFuncTableBiff5, STATIC_ARRAY_END( saFuncTableBiff5 ), nMaxParam, bImportFilter
);
     if( eBiff >= BIFF8 )
         initFuncs( saFuncTableBiff8, STATIC_ARRAY_END( saFuncTableBiff8 ), nMaxParam, bImportFilter
);
-    if( eFilter == FILTER_OOXML )
-        initFuncs( saFuncTableOox, STATIC_ARRAY_END( saFuncTableOox ), nMaxParam, bImportFilter
);
+    initFuncs( saFuncTableOox, STATIC_ARRAY_END( saFuncTableOox ), nMaxParam, bImportFilter
);
     initFuncs( saFuncTableOdf, STATIC_ARRAY_END( saFuncTableOdf ), nMaxParam, bImportFilter
);
 }
 

Modified: incubator/ooo/trunk/main/sc/source/filter/excel/excform.cxx
URL: http://svn.apache.org/viewvc/incubator/ooo/trunk/main/sc/source/filter/excel/excform.cxx?rev=1381452&r1=1381451&r2=1381452&view=diff
==============================================================================
--- incubator/ooo/trunk/main/sc/source/filter/excel/excform.cxx (original)
+++ incubator/ooo/trunk/main/sc/source/filter/excel/excform.cxx Thu Sep  6 00:48:03 2012
@@ -202,7 +202,8 @@ ConvErr ExcelToSc::Convert( const ScToke
 	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_Conditional;
+	const sal_Bool		bRNorSF = bRangeName || bSharedFormula || bConditional;
 
 	ScSingleRefData		aSRD;
 	ScComplexRefData		aCRD;

Modified: incubator/ooo/trunk/main/sc/source/filter/excel/excform8.cxx
URL: http://svn.apache.org/viewvc/incubator/ooo/trunk/main/sc/source/filter/excel/excform8.cxx?rev=1381452&r1=1381451&r2=1381452&view=diff
==============================================================================
--- incubator/ooo/trunk/main/sc/source/filter/excel/excform8.cxx (original)
+++ incubator/ooo/trunk/main/sc/source/filter/excel/excform8.cxx Thu Sep  6 00:48:03 2012
@@ -101,7 +101,8 @@ ConvErr ExcelToSc8::Convert( const ScTok
 	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_Conditional;
+	const sal_Bool				bRNorSF = bRangeName || bSharedFormula || bConditional;
 
 	ScSingleRefData			aSRD;
 	ScComplexRefData			aCRD;

Modified: incubator/ooo/trunk/main/sc/source/filter/excel/xeformula.cxx
URL: http://svn.apache.org/viewvc/incubator/ooo/trunk/main/sc/source/filter/excel/xeformula.cxx?rev=1381452&r1=1381451&r2=1381452&view=diff
==============================================================================
--- incubator/ooo/trunk/main/sc/source/filter/excel/xeformula.cxx (original)
+++ incubator/ooo/trunk/main/sc/source/filter/excel/xeformula.cxx Thu Sep  6 00:48:03 2012
@@ -210,11 +210,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
     }
 }

Modified: incubator/ooo/trunk/main/sc/source/filter/excel/xicontent.cxx
URL: http://svn.apache.org/viewvc/incubator/ooo/trunk/main/sc/source/filter/excel/xicontent.cxx?rev=1381452&r1=1381451&r2=1381452&view=diff
==============================================================================
--- incubator/ooo/trunk/main/sc/source/filter/excel/xicontent.cxx (original)
+++ incubator/ooo/trunk/main/sc/source/filter/excel/xicontent.cxx Thu Sep  6 00:48:03 2012
@@ -614,7 +614,7 @@ void XclImpCondFormat::ReadCF( XclImpStr
     {
         const ScTokenArray* pTokArr = 0;
         rFmlaConv.Reset( rPos );
-        rFmlaConv.Convert( pTokArr, rStrm, nFmlaSize1, false, FT_RangeName );
+        rFmlaConv.Convert( pTokArr, rStrm, nFmlaSize1, false, FT_Conditional );
         // formula converter owns pTokArr -> create a copy of the token array
         if( pTokArr )
             xTokArr1.reset( pTokArr->Clone() );
@@ -625,7 +625,7 @@ void XclImpCondFormat::ReadCF( XclImpStr
     {
         const ScTokenArray* pTokArr = 0;
         rFmlaConv.Reset( rPos );
-        rFmlaConv.Convert( pTokArr, rStrm, nFmlaSize2, false, FT_RangeName );
+        rFmlaConv.Convert( pTokArr, rStrm, nFmlaSize2, false, FT_Conditional );
         // formula converter owns pTokArr -> create a copy of the token array
         if( pTokArr )
             pTokArr2.reset( pTokArr->Clone() );
@@ -748,7 +748,7 @@ void XclImpValidation::ReadDV( XclImpStr
         {
             const ScTokenArray* pTokArr = 0;
             rFmlaConv.Reset();
-            rFmlaConv.Convert( pTokArr, rStrm, nLen, false, FT_RangeName );
+            rFmlaConv.Convert( pTokArr, rStrm, nLen, false, FT_Conditional );
             // formula converter owns pTokArr -> create a copy of the token array
             if( pTokArr )
                 xTokArr1.reset( pTokArr->Clone() );
@@ -763,7 +763,7 @@ void XclImpValidation::ReadDV( XclImpStr
         {
             const ScTokenArray* pTokArr = 0;
             rFmlaConv.Reset();
-            rFmlaConv.Convert( pTokArr, rStrm, nLen, false, FT_RangeName );
+            rFmlaConv.Convert( pTokArr, rStrm, nLen, false, FT_Conditional );
             // formula converter owns pTokArr -> create a copy of the token array
             if( pTokArr )
                 xTokArr2.reset( pTokArr->Clone() );

Modified: incubator/ooo/trunk/main/sc/source/filter/excel/xlformula.cxx
URL: http://svn.apache.org/viewvc/incubator/ooo/trunk/main/sc/source/filter/excel/xlformula.cxx?rev=1381452&r1=1381451&r2=1381452&view=diff
==============================================================================
--- incubator/ooo/trunk/main/sc/source/filter/excel/xlformula.cxx (original)
+++ incubator/ooo/trunk/main/sc/source/filter/excel/xlformula.cxx Thu Sep  6 00:48:03 2012
@@ -359,6 +359,19 @@ static const XclFunctionInfo saFuncTable
     { 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 ) }
@@ -398,7 +411,7 @@ static const XclFunctionInfo saFuncTable
     EXC_FUNCENTRY_ODF( ocNoName,        1,  MX, 0,  "SKEWP" ),
     EXC_FUNCENTRY_ODF( ocUnichar,       1,  1,  0,  "UNICHAR" ),
     EXC_FUNCENTRY_ODF( ocUnicode,       1,  1,  0,  "UNICODE" ),
-    EXC_FUNCENTRY_ODF( ocNoName,        1,  MX, 0,  "XOR" )
+    EXC_FUNCENTRY_ODF( ocXor,           1,  MX, 0,  "XOR" )
 };
 
 #undef EXC_FUNCENTRY_ODF
@@ -424,6 +437,7 @@ XclFunctionProvider::XclFunctionProvider
         (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 ) );
 }
 
@@ -457,7 +471,8 @@ void XclFunctionProvider::FillXclFuncMap
     {
         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;
         }

Modified: incubator/ooo/trunk/main/sc/source/filter/inc/formel.hxx
URL: http://svn.apache.org/viewvc/incubator/ooo/trunk/main/sc/source/filter/inc/formel.hxx?rev=1381452&r1=1381451&r2=1381452&view=diff
==============================================================================
--- incubator/ooo/trunk/main/sc/source/filter/inc/formel.hxx (original)
+++ incubator/ooo/trunk/main/sc/source/filter/inc/formel.hxx Thu Sep  6 00:48:03 2012
@@ -60,7 +60,8 @@ enum FORMULA_TYPE
 {
 	FT_CellFormula,
 	FT_RangeName,
-	FT_SharedFormula
+	FT_SharedFormula,
+	FT_Conditional
 };
 
 

Modified: incubator/ooo/trunk/main/sc/source/filter/inc/xlformula.hxx
URL: http://svn.apache.org/viewvc/incubator/ooo/trunk/main/sc/source/filter/inc/xlformula.hxx?rev=1381452&r1=1381451&r2=1381452&view=diff
==============================================================================
--- incubator/ooo/trunk/main/sc/source/filter/inc/xlformula.hxx (original)
+++ incubator/ooo/trunk/main/sc/source/filter/inc/xlformula.hxx Thu Sep  6 00:48:03 2012
@@ -287,6 +287,7 @@ const size_t EXC_FUNCINFO_PARAMINFO_COUN
 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;
@@ -317,6 +318,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. */



Mime
View raw message