diff options
Diffstat (limited to 'sc')
-rw-r--r-- | sc/inc/funcdesc.hxx | 10 | ||||
-rw-r--r-- | sc/source/core/data/funcdesc.cxx | 56 | ||||
-rw-r--r-- | sc/source/ui/src/scfuncs.src | 14 |
3 files changed, 64 insertions, 16 deletions
diff --git a/sc/inc/funcdesc.hxx b/sc/inc/funcdesc.hxx index cda94fac37b3..1c2bccda5bc6 100644 --- a/sc/inc/funcdesc.hxx +++ b/sc/inc/funcdesc.hxx @@ -105,11 +105,18 @@ public: /** Returns number of arguments - @return help id of the function + @return number of arguments */ virtual sal_uInt32 getParameterCount() const override ; /** + Returns start of variable arguments + + @return start of variable arguments + */ + virtual sal_uInt32 getVarArgsStart() const override ; + + /** Returns description of parameter at given position @param _nPos @@ -205,6 +212,7 @@ public: sal_uInt16 nFIndex; /**< Unique function index */ sal_uInt16 nCategory; /**< Function category */ sal_uInt16 nArgCount; /**< All parameter count, suppressed and unsuppressed */ + sal_uInt16 nVarArgsStart; /**< Start of variable arguments, for numbering */ OString sHelpId; /**< HelpId of function */ bool bIncomplete :1; /**< Incomplete argument info (set for add-in info from configuration) */ bool bHasSuppressedArgs :1; /**< Whether there is any suppressed parameter. */ diff --git a/sc/source/core/data/funcdesc.cxx b/sc/source/core/data/funcdesc.cxx index b9c6e30b6f0a..729590b07694 100644 --- a/sc/source/core/data/funcdesc.cxx +++ b/sc/source/core/data/funcdesc.cxx @@ -67,6 +67,7 @@ ScFuncDesc::ScFuncDesc() : nFIndex (0), nCategory (0), nArgCount (0), + nVarArgsStart (0), bIncomplete (false), bHasSuppressedArgs(false) {} @@ -88,6 +89,7 @@ void ScFuncDesc::Clear() delete [] pDefArgFlags; } nArgCount = 0; + nVarArgsStart = 0; maDefArgNames.clear(); maDefArgDescs.clear(); pDefArgFlags = nullptr; @@ -140,8 +142,7 @@ OUString ScFuncDesc::GetParamList() const } else if ( nArgCount < PAIRED_VAR_ARGS) { - sal_uInt16 nFix = nArgCount - VAR_ARGS; - for ( sal_uInt16 nArg = 0; nArg < nFix; nArg++ ) + for ( sal_uInt16 nArg = 0; nArg < nVarArgsStart; nArg++ ) { if (!pDefArgFlags[nArg].bSuppress) { @@ -154,19 +155,18 @@ OUString ScFuncDesc::GetParamList() const * there were, we'd have to cope with it here and above for the fix * parameters. For now parameters are always added, so no special * treatment of a trailing "; " necessary. */ - aSig.append(maDefArgNames[nFix]); + aSig.append(maDefArgNames[nVarArgsStart]); aSig.append('1'); aSig.append(sep); aSig.append(' '); - aSig.append(maDefArgNames[nFix]); + aSig.append(maDefArgNames[nVarArgsStart]); aSig.append('2'); aSig.append(sep); aSig.append(" ... "); } else { - sal_uInt16 nFix = nArgCount - PAIRED_VAR_ARGS; - for ( sal_uInt16 nArg = 0; nArg < nFix; nArg++ ) + for ( sal_uInt16 nArg = 0; nArg < nVarArgsStart; nArg++ ) { if (!pDefArgFlags[nArg].bSuppress) { @@ -176,17 +176,17 @@ OUString ScFuncDesc::GetParamList() const } } - aSig.append(maDefArgNames[nFix]); + aSig.append(maDefArgNames[nVarArgsStart]); aSig.append('1'); aSig.append(sep); - aSig.append(maDefArgNames[nFix+1]); + aSig.append(maDefArgNames[nVarArgsStart+1]); aSig.append('1'); aSig.append(sep); aSig.append( " " ); - aSig.append(maDefArgNames[nFix]); + aSig.append(maDefArgNames[nVarArgsStart]); aSig.append('2'); aSig.append(sep); - aSig.append(maDefArgNames[nFix+1]); + aSig.append(maDefArgNames[nVarArgsStart+1]); aSig.append('2'); aSig.append(sep); aSig.append( " ... " ); @@ -359,6 +359,11 @@ sal_uInt32 ScFuncDesc::getParameterCount() const return nArgCount; } +sal_uInt32 ScFuncDesc::getVarArgsStart() const +{ + return nVarArgsStart; +} + OUString ScFuncDesc::getParameterName(sal_uInt32 _nPos) const { return maDefArgNames[_nPos]; @@ -799,12 +804,20 @@ ScFuncRes::ScFuncRes( ResId &aRes, ScFuncDesc* pDesc, bool & rbSuppressed ) pDesc->sHelpId = ReadByteStringRes(); pDesc->nArgCount = GetNum(); sal_uInt16 nArgs = pDesc->nArgCount; + sal_uInt16 nVarArgsSet = 0; if (nArgs >= PAIRED_VAR_ARGS) - nArgs -= PAIRED_VAR_ARGS - 2; + { + nVarArgsSet = 2; + nArgs -= PAIRED_VAR_ARGS - nVarArgsSet; + } else if (nArgs >= VAR_ARGS) - nArgs -= VAR_ARGS - 1; + { + nVarArgsSet = 1; + nArgs -= VAR_ARGS - nVarArgsSet; + } if (nArgs) { + pDesc->nVarArgsStart = nArgs - nVarArgsSet; pDesc->pDefArgFlags = new ScFuncDesc::ParameterFlags[nArgs]; for (sal_uInt16 i = 0; i < nArgs; ++i) { @@ -864,6 +877,25 @@ ScFuncRes::ScFuncRes( ResId &aRes, ScFuncDesc* pDesc, bool & rbSuppressed ) { pDesc->maDefArgNames[i] = SC_RESSTR(2*(i+1) ); pDesc->maDefArgDescs[i] = SC_RESSTR(2*(i+1)+1); + // If empty and variable number of arguments and last parameter and + // parameter is optional and the previous is not optional, repeat + // previous parameter name and description. + if ((pDesc->maDefArgNames[i].isEmpty() || pDesc->maDefArgDescs[i].isEmpty()) && + nVarArgsSet > 0 && i > nVarArgsSet && (i == nArgs-1 || i == nArgs-2) && + pDesc->pDefArgFlags[i].bOptional) + { + sal_uInt16 nPrev = i - nVarArgsSet; + if (!pDesc->pDefArgFlags[nPrev].bOptional) + { + if (pDesc->maDefArgNames[i].isEmpty()) + pDesc->maDefArgNames[i] = pDesc->maDefArgNames[nPrev]; + if (pDesc->maDefArgDescs[i].isEmpty()) + pDesc->maDefArgDescs[i] = pDesc->maDefArgDescs[nPrev]; + // This also means that variable arguments start one + // parameter set earlier. + pDesc->nVarArgsStart -= nVarArgsSet; + } + } } } diff --git a/sc/source/ui/src/scfuncs.src b/sc/source/ui/src/scfuncs.src index 7a8d30f521b2..e8f67e4de2f5 100644 --- a/sc/source/ui/src/scfuncs.src +++ b/sc/source/ui/src/scfuncs.src @@ -12392,7 +12392,7 @@ Resource RID_SC_FUNCTION_DESCRIPTIONS2 }; String 2 // Name of Parameter 1 { - Text [ en-US ] = "number" ; + Text [ en-US ] = "minuend" ; }; String 3 // Description of Parameter 1 { @@ -12400,11 +12400,19 @@ Resource RID_SC_FUNCTION_DESCRIPTIONS2 }; String 4 // Name of Parameter 2 { - Text [ en-US ] = "number " ; + Text [ en-US ] = "subtrahend " ; }; String 5 // Description of Parameter 2 { - Text [ en-US ] = "Number 2, number 3, ... are arguments subtracted from first number." ; + Text [ en-US ] = "Subtrahend 1, subtrahend 2, ... are numerical arguments subtracted from the minuend." ; + }; + String 6 // Name of Parameter 3, empty dummy to repeat Parameter 2, now optional + { + Text = "" ; + }; + String 7 // Description of Parameter 3, empty dummy to repeat Parameter 2, now optional + { + Text = "" ; }; }; }; |