diff options
author | Marina Plakalovic <makkica@openoffice.org> | 2012-12-14 23:40:18 +0100 |
---|---|---|
committer | Eike Rathke <erack@redhat.com> | 2012-12-15 21:42:39 +0100 |
commit | f2cb873631b8b21b54a55beaba532f4bd616a9c6 (patch) | |
tree | 09c0fecd4bd9b265069dc512cd67db4674626220 /formula | |
parent | ef54346f1912c635d74c7dee8703f5f46647881d (diff) |
calcishmakkica: #i90269# #i95144# #i101466# implement SUMIFS, AVERAGEIFS, COUNTIFS
Merged from Apache OO with adaptions.
http://svn.apache.org/viewvc?rev=1381447&view=rev
Original Apache OO committer: Andrew Rist <arist@apache.org>
Original Author: Marina Plakalovic <makkica@openoffice.org>
Original Committer: Eike Rathke [er] <eike.rathke@oracle.com>
# HG changeset patch
# User Eike Rathke [er] <eike.rathke@oracle.com>
# Date 1288810126 -3600
# Node ID 02cf226fcde498f6fd926d45df497e9fb412fe0f
# Parent 528da6bfd0daed4355d745590d5ac3a319b08fb4
Change-Id: I08754653cd2ff20536ad3e9f260f747cb127ccdd
Diffstat (limited to 'formula')
-rw-r--r-- | formula/inc/formula/compiler.hrc | 7 | ||||
-rw-r--r-- | formula/inc/formula/opcode.hxx | 5 | ||||
-rw-r--r-- | formula/source/core/resource/core_resource.src | 18 | ||||
-rw-r--r-- | formula/source/ui/dlg/parawin.cxx | 45 |
4 files changed, 70 insertions, 5 deletions
diff --git a/formula/inc/formula/compiler.hrc b/formula/inc/formula/compiler.hrc index 9ae1c1850a08..582e3a589c93 100644 --- a/formula/inc/formula/compiler.hrc +++ b/formula/inc/formula/compiler.hrc @@ -393,8 +393,11 @@ #define SC_OPCODE_GET_DATEDIF 400 #define SC_OPCODE_XOR 401 #define SC_OPCODE_AVERAGE_IF 402 -#define SC_OPCODE_STOP_2_PAR 403 -#define SC_OPCODE_LAST_OPCODE_ID 403 /* last OpCode */ +#define SC_OPCODE_SUM_IFS 403 +#define SC_OPCODE_AVERAGE_IFS 404 +#define SC_OPCODE_COUNT_IFS 405 +#define SC_OPCODE_STOP_2_PAR 406 +#define SC_OPCODE_LAST_OPCODE_ID 405 /* last OpCode */ /*** Internal ***/ #define SC_OPCODE_INTERNAL_BEGIN 9999 diff --git a/formula/inc/formula/opcode.hxx b/formula/inc/formula/opcode.hxx index 046d25b752ad..cd1831b89637 100644 --- a/formula/inc/formula/opcode.hxx +++ b/formula/inc/formula/opcode.hxx @@ -274,7 +274,10 @@ enum OpCodeEnum ocCountEmptyCells = SC_OPCODE_COUNT_EMPTY_CELLS, ocCountIf = SC_OPCODE_COUNT_IF, ocSumIf = SC_OPCODE_SUM_IF, - ocAverageIf = SC_OPCODE_AVERAGE_IF, + ocAverageIf = SC_OPCODE_AVERAGE_IF, + ocSumIfs = SC_OPCODE_SUM_IFS, + ocAverageIfs = SC_OPCODE_AVERAGE_IFS, + ocCountIfs = SC_OPCODE_COUNT_IFS, ocLookup = SC_OPCODE_LOOKUP, ocVLookup = SC_OPCODE_V_LOOKUP, ocHLookup = SC_OPCODE_H_LOOKUP, diff --git a/formula/source/core/resource/core_resource.src b/formula/source/core/resource/core_resource.src index 1c165d023d1a..c552eb1f7062 100644 --- a/formula/source/core/resource/core_resource.src +++ b/formula/source/core/resource/core_resource.src @@ -238,6 +238,9 @@ Resource RID_STRLIST_FUNCTION_NAMES_ENGLISH_ODFF String SC_OPCODE_COUNT_IF { Text = "COUNTIF" ; }; String SC_OPCODE_SUM_IF { Text = "SUMIF" ; }; String SC_OPCODE_AVERAGE_IF { Text = "AVERAGEIF" ; }; + String SC_OPCODE_SUM_IFS { Text = "SUMIFS" ; }; + String SC_OPCODE_AVERAGE_IFS { Text = "AVERAGEIFS" ; }; + String SC_OPCODE_COUNT_IFS { Text = "COUNTIFS" ; }; String SC_OPCODE_LOOKUP { Text = "LOOKUP" ; }; String SC_OPCODE_V_LOOKUP { Text = "VLOOKUP" ; }; String SC_OPCODE_H_LOOKUP { Text = "HLOOKUP" ; }; @@ -572,6 +575,9 @@ Resource RID_STRLIST_FUNCTION_NAMES_ENGLISH String SC_OPCODE_COUNT_IF { Text = "COUNTIF" ; }; String SC_OPCODE_SUM_IF { Text = "SUMIF" ; }; String SC_OPCODE_AVERAGE_IF { Text = "AVERAGEIF" ; }; + String SC_OPCODE_SUM_IFS { Text = "SUMIFS" ; }; + String SC_OPCODE_AVERAGE_IFS { Text = "AVERAGEIFS" ; }; + String SC_OPCODE_COUNT_IFS { Text = "COUNTIFS" ; }; String SC_OPCODE_LOOKUP { Text = "LOOKUP" ; }; String SC_OPCODE_V_LOOKUP { Text = "VLOOKUP" ; }; String SC_OPCODE_H_LOOKUP { Text = "HLOOKUP" ; }; @@ -1479,6 +1485,18 @@ Resource RID_STRLIST_FUNCTION_NAMES { Text [ en-US ] = "AVERAGEIF" ; }; + String SC_OPCODE_SUM_IFS + { + Text [ en-US ] = "SUMIFS" ; + }; + String SC_OPCODE_AVERAGE_IFS + { + Text [ en-US ] = "AVERAGEIFS" ; + }; + String SC_OPCODE_COUNT_IFS + { + Text [ en-US ] = "COUNTIFS" ; + }; String SC_OPCODE_LOOKUP { Text [ en-US ] = "LOOKUP" ; diff --git a/formula/source/ui/dlg/parawin.cxx b/formula/source/ui/dlg/parawin.cxx index d51f4dcf4980..23d8ec862420 100644 --- a/formula/source/ui/dlg/parawin.cxx +++ b/formula/source/ui/dlg/parawin.cxx @@ -30,6 +30,7 @@ #include "ForResId.hrc" #define VAR_ARGS 30 +#define PAIRED_VAR_ARGS (VAR_ARGS + VAR_ARGS) namespace formula { //============================================================================ @@ -109,7 +110,7 @@ void ParaWin::UpdateArgDesc( sal_uInt16 nArg ) aArgName += ' '; aArgName += (pFuncDesc->isParameterOptional(nRealArg)) ? m_sOptional : m_sRequired ; } - else + else if ( nArgs < PAIRED_VAR_ARGS ) { sal_uInt16 nFix = nArgs - VAR_ARGS; sal_uInt16 nPos = ( nArg < nFix ? nArg : nFix ); @@ -123,6 +124,24 @@ void ParaWin::UpdateArgDesc( sal_uInt16 nArg ) aArgName += (nArg > nFix || pFuncDesc->isParameterOptional(nRealArg)) ? m_sOptional : m_sRequired ; } + else + { + sal_uInt16 nFix = nArgs - PAIRED_VAR_ARGS; + sal_uInt16 nPos; + if ( nArg < nFix ) + nPos = nArg; + else + nPos = nFix + ( (nArg-nFix) % 2); + sal_uInt16 nRealArg = (nPos < aVisibleArgMapping.size() ? + aVisibleArgMapping[nPos] : aVisibleArgMapping.back()); + aArgDesc = pFuncDesc->getParameterDescription(nRealArg); + aArgName = pFuncDesc->getParameterName(nRealArg); + if ( nArg >= nFix ) + aArgName += String::CreateFromInt32((nArg-nFix)/2 + 1); + aArgName += ' '; + + aArgName += (nArg > (nFix+1) || pFuncDesc->isParameterOptional(nRealArg)) ? m_sOptional : m_sRequired ; + } SetArgumentDesc(aArgDesc); SetArgumentText(aArgName); @@ -142,7 +161,7 @@ void ParaWin::UpdateArgInput( sal_uInt16 nOffset, sal_uInt16 i ) SetArgName (i,pFuncDesc->getParameterName(nRealArg)); } } - else + else if ( nArgs < PAIRED_VAR_ARGS) { sal_uInt16 nFix = nArgs - VAR_ARGS; sal_uInt16 nPos = ( nArg < nFix ? nArg : nFix ); @@ -160,6 +179,28 @@ void ParaWin::UpdateArgInput( sal_uInt16 nOffset, sal_uInt16 i ) else SetArgName( i, pFuncDesc->getParameterName(nRealArg) ); } + else + { + sal_uInt16 nFix = nArgs - PAIRED_VAR_ARGS; + sal_uInt16 nPos; + if ( nArg < nFix ) + nPos = nArg; + else + nPos = nFix + ( (nArg-nFix) % 2); + sal_uInt16 nRealArg = (nPos < aVisibleArgMapping.size() ? + aVisibleArgMapping[nPos] : aVisibleArgMapping.back()); + SetArgNameFont( i, + (nArg > (nFix+1) || pFuncDesc->isParameterOptional(nRealArg)) ? + aFntLight : aFntBold ); + if ( nArg >= nFix ) + { + String aArgName( pFuncDesc->getParameterName(nRealArg) ); + aArgName += String::CreateFromInt32((nArg-nFix)/2 + 1); + SetArgName( i, aArgName ); + } + else + SetArgName( i, pFuncDesc->getParameterName(nRealArg) ); + } if(nArg<nArgs) SetArgVal(i,aParaArray[nArg]); } |