26#include <osl/diagnose.h>
30#if DEBUG_SC_PARCLASSDOC
32#include <com/sun/star/sheet/FormulaLanguage.hpp>
33#include <rtl/strbuf.hxx>
35#include "compiler.hxx"
143 {
ocForecast_ETS_PIA, {{
ForceArray,
ForceArray,
ForceArray,
Value,
Value,
Value,
Value }, 0,
Value }},
144 {
ocForecast_ETS_PIM, {{
ForceArray,
ForceArray,
ForceArray,
Value,
Value,
Value,
Value }, 0,
Value }},
298 OSL_ENSURE( pRaw->
eOp ==
ocNone,
"RawData OpCode error");
311 pRun->
nMinParams = sal::static_int_cast<sal_uInt8>( j+1 );
318 "bad classification: eOp " << +pRaw->
eOp
319 <<
", repeated param " << j
320 <<
" negative offset");
332 pRun->
nMinParams = sal::static_int_cast<sal_uInt8>( j );
351#if DEBUG_SC_PARCLASSDOC
352 GenerateDocumentation();
385 else if ( (nRepeat =
pData[eOp].
aData.nRepeatLast) > 0 )
389 sal_uInt16 nParam = (nRepeat > 1 ?
392 pData[eOp].nMinParams);
403 sal_uInt16 nParameter)
410 OUString aFuncName = pToken->
GetExternal().toAsciiUpperCase();
437 if (!aUnoName.isEmpty())
450 if ( nParameter >=
nCount &&
457 if ( nParameter >=
nCount )
461 switch ( pArgs[nParameter].
eType )
479#if DEBUG_SC_PARCLASSDOC
482void ScParameterClassification::MergeArgumentsFromFunctionResource()
486 pDesc = pFuncList->
Next() )
488 if ( pDesc->nFIndex > SC_OPCODE_LAST_OPCODE_ID ||
492 RunData* pRun = &
pData[ pDesc->nFIndex ];
493 sal_uInt16 nArgs = pDesc->GetSuppressedArgCount();
494 if ( nArgs >= PAIRED_VAR_ARGS )
497 pRun->aData.nRepeatLast = 2;
499 else if ( nArgs >= VAR_ARGS )
502 pRun->aData.nRepeatLast = 1;
506 SAL_WARN(
"sc",
"ScParameterClassification::Init: too many arguments in listed function: "
507 << *(pDesc->pFuncName)
510 pRun->aData.nRepeatLast = 1;
512 pRun->nMinParams =
static_cast< sal_uInt8 >( nArgs );
513 for ( sal_Int32 j=0; j < nArgs; ++j )
515 pRun->aData.nParam[j] =
Value;
517 if ( pRun->aData.nRepeatLast )
521 pRun->aData.nParam[j] =
Value;
528 pRun->aData.nParam[j] =
Bounds;
534void ScParameterClassification::GenerateDocumentation()
536 static const char aEnvVarName[] =
"OOO_CALC_GENPARCLASSDOC";
537 if ( !getenv( aEnvVarName) )
539 MergeArgumentsFromFunctionResource();
546 size_t nCount = xMap->getSymbolCount();
550 if ( !xMap->getSymbol(eOp).isEmpty() )
552 OUStringBuffer
aStr(xMap->getSymbol(eOp));
554 sal_uInt8 nParams = GetMinimumParameters( eOp);
557 bool bAddParentheses =
true;
558 if ( eOp < SC_OPCODE_STOP_DIV )
560 bAddParentheses =
false;
577 else if ( eOp < SC_OPCODE_STOP_ERRORS )
579 bAddParentheses =
false;
582 else if ( eOp < SC_OPCODE_STOP_BIN_OP )
594 else if ( eOp < SC_OPCODE_STOP_UN_OP )
596 else if ( eOp < SC_OPCODE_STOP_NO_PAR )
598 else if ( eOp < SC_OPCODE_STOP_1_PAR )
601 aToken.SetByte( nParams);
605 if ( nParams != aToken.GetByte() )
606 SAL_WARN(
"sc.core",
"(parameter count differs, token Byte: " << (
int)aToken.GetByte() <<
" classification: " << (
int)nParams <<
") ");
607 aToken.SetByte( nParams);
608 if ( nParams != aToken.GetParamCount() )
609 SAL_WARN(
"sc.core",
"(parameter count differs, token ParamCount: " << (
int)aToken.GetParamCount() <<
" classification: " << (
int)nParams <<
") ");
610 if (aToken.GetByte())
611 bAddParentheses =
true;
614 for ( sal_uInt16 j=0; j < nParams; ++j )
622 aStr.append(
" Value");
625 aStr.append(
" Reference");
628 aStr.append(
" ReferenceOrRefArray");
631 aStr.append(
" Array");
634 aStr.append(
" ForceArray");
637 aStr.append(
" ReferenceOrForceArray");
640 aStr.append(
" (Bounds, classification error?)");
643 aStr.append(
" (???, classification error?)");
646 if ( HasRepeatParameters( eOp) )
647 aStr.append(
", ...");
655 aStr.append(
" // RRI in English resource, but ZGZ in English-only section");
658 aStr.append(
" // e.g. combined first parameter of INDEX() function, not a real function");
661 aStr.append(
" // goal seek via menu, not a real function");
664 aStr.append(
" // MULTIPLE.OPERATIONS in English resource, but TABLE in English-only section");
667 aStr.append(
" // error function, not a real function");
676 aStr.append(
" -> Value");
679 aStr.append(
" -> Reference");
682 aStr.append(
" -> ReferenceOrRefArray");
685 aStr.append(
" -> Array");
688 aStr.append(
" -> ForceArray");
691 aStr.append(
" -> ReferenceOrForceArray");
697 aStr.append(
" (-> ???, classification error?)");
702 SAL_INFO(
"sc.core",
"CALC_GENPARCLASSDOC: " <<
aStr.makeStringAndClear());
@ SC_ADDINARG_INTEGER
long
@ SC_ADDINARG_STRING
string
@ SC_ADDINARG_VARARGS
sequence<any>
@ SC_ADDINARG_DOUBLE
double
const LegacyFuncData * findByName(const OUString &rName) const
ParamType GetParamType(sal_uInt16 nIndex) const
sal_uInt16 GetParamCount() const
Stores and generates human readable descriptions for spreadsheet-functions, e.g. functions used in fo...
List of spreadsheet functions.
const ScFuncDesc * First()
const ScFuncDesc * Next()
static LegacyFuncCollection * GetLegacyFuncCollection()
static SC_DLLPUBLIC ScUnoAddInCollection * GetAddInCollection()
static ScFunctionList * GetStarCalcFunctionList()
static formula::ParamClass GetParameterType(const formula::FormulaToken *pToken, sal_uInt16 nParameter)
Get one parameter type for function eOp.
static void Init()
MUST be called once before any other method.
static formula::ParamClass GetExternalParameterType(const formula::FormulaToken *pToken, sal_uInt16 nParameter)
static const RawData pRawData[]
const ScUnoAddInFuncData * GetFuncData(const OUString &rName, bool bComplete=false)
Only if bComplete is set, the function reference and argument types are initialized (component may ha...
OUString FindFunction(const OUString &rUpperName, bool bLocalFirst)
User entered name. rUpperName MUST already be upper case!
const ScAddInArgDesc * GetArguments() const
tools::Long GetArgumentCount() const
#define SC_OPCODE_LAST_OPCODE_ID
#define SAL_WARN_IF(condition, area, stream)
#define SAL_WARN(area, stream)
#define SAL_INFO(area, stream)
constexpr OUStringLiteral aData
static const sal_Int32 nMaxParams
formula::ParamClass eReturn
formula::ParamClass nParam[nMaxParams]