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 }},
292 for (
const auto &
i : pRawData)
297 OSL_ENSURE( pRaw->
eOp ==
ocNone,
"RawData OpCode error");
307 for ( sal_Int32 j=0; j < CommonData::nMaxParams; ++j )
317 "bad classification: eOp " << +pRaw->
eOp
318 <<
", repeated param " << j
319 <<
" negative offset");
326 for ( sal_Int32 j=0; j < CommonData::nMaxParams; ++j )
350 #if DEBUG_SC_PARCLASSDOC
351 GenerateDocumentation();
368 return GetExternalParameterType( pToken, nParameter);
381 eType =
pData[eOp].aData.eReturn;
382 else if ( nParameter < CommonData::nMaxParams )
383 eType =
pData[eOp].aData.nParam[nParameter];
384 else if ( (nRepeat =
pData[eOp].
aData.nRepeatLast) > 0 )
388 sal_uInt16
nParam = (nRepeat > 1 ?
389 (
pData[eOp].nMinParams -
390 ((nParameter -
pData[eOp].nMinParams) % nRepeat)) :
391 pData[eOp].nMinParams);
402 sal_uInt16 nParameter)
436 if (!aUnoName.isEmpty())
449 if ( nParameter >= nCount &&
456 if ( nParameter >= nCount )
460 switch ( pArgs[nParameter].
eType )
478 #if DEBUG_SC_PARCLASSDOC
481 void ScParameterClassification::MergeArgumentsFromFunctionResource()
487 if (
pDesc->nFIndex > SC_OPCODE_LAST_OPCODE_ID ||
492 sal_uInt16 nArgs =
pDesc->GetSuppressedArgCount();
493 if ( nArgs >= PAIRED_VAR_ARGS )
496 pRun->aData.nRepeatLast = 2;
498 else if ( nArgs >= VAR_ARGS )
501 pRun->aData.nRepeatLast = 1;
503 if ( nArgs > CommonData::nMaxParams )
505 SAL_WARN(
"sc",
"ScParameterClassification::Init: too many arguments in listed function: "
506 << *(
pDesc->pFuncName)
508 nArgs = CommonData::nMaxParams - 1;
509 pRun->aData.nRepeatLast = 1;
511 pRun->nMinParams =
static_cast< sal_uInt8 >( nArgs );
512 for ( sal_Int32 j=0; j < nArgs; ++j )
514 pRun->aData.nParam[j] =
Value;
516 if ( pRun->aData.nRepeatLast )
518 for ( sal_Int32 j = nArgs; j < CommonData::nMaxParams; ++j )
520 pRun->aData.nParam[j] =
Value;
525 for ( sal_Int32 j = nArgs; j < CommonData::nMaxParams; ++j )
527 pRun->aData.nParam[j] =
Bounds;
533 void ScParameterClassification::GenerateDocumentation()
535 static const char aEnvVarName[] =
"OOO_CALC_GENPARCLASSDOC";
536 if ( !getenv( aEnvVarName) )
538 MergeArgumentsFromFunctionResource();
545 size_t nCount = xMap->getSymbolCount();
546 for (
size_t i=0;
i<nCount; ++
i )
549 if ( !xMap->getSymbol(eOp).isEmpty() )
551 OUStringBuffer
aStr(xMap->getSymbol(eOp));
553 sal_uInt8 nParams = GetMinimumParameters( eOp);
556 bool bAddParentheses =
true;
557 if ( eOp < SC_OPCODE_STOP_DIV )
559 bAddParentheses =
false;
576 else if ( eOp < SC_OPCODE_STOP_ERRORS )
578 bAddParentheses =
false;
581 else if ( eOp < SC_OPCODE_STOP_BIN_OP )
593 else if ( eOp < SC_OPCODE_STOP_UN_OP )
595 else if ( eOp < SC_OPCODE_STOP_NO_PAR )
597 else if ( eOp < SC_OPCODE_STOP_1_PAR )
600 aToken.SetByte( nParams);
604 if ( nParams != aToken.GetByte() )
605 SAL_WARN(
"sc.core",
"(parameter count differs, token Byte: " << (
int)aToken.GetByte() <<
" classification: " << (
int)nParams <<
") ");
606 aToken.SetByte( nParams);
607 if ( nParams != aToken.GetParamCount() )
608 SAL_WARN(
"sc.core",
"(parameter count differs, token ParamCount: " << (
int)aToken.GetParamCount() <<
" classification: " << (
int)nParams <<
") ");
609 if (aToken.GetByte())
610 bAddParentheses =
true;
613 for ( sal_uInt16 j=0; j < nParams; ++j )
621 aStr.append(
" Value");
624 aStr.append(
" Reference");
627 aStr.append(
" ReferenceOrRefArray");
630 aStr.append(
" Array");
633 aStr.append(
" ForceArray");
636 aStr.append(
" ReferenceOrForceArray");
639 aStr.append(
" (Bounds, classification error?)");
642 aStr.append(
" (???, classification error?)");
645 if ( HasRepeatParameters( eOp) )
646 aStr.append(
", ...");
654 aStr.append(
" // RRI in English resource, but ZGZ in English-only section");
657 aStr.append(
" // e.g. combined first parameter of INDEX() function, not a real function");
660 aStr.append(
" // goal seek via menu, not a real function");
663 aStr.append(
" // MULTIPLE.OPERATIONS in English resource, but TABLE in English-only section");
666 aStr.append(
" // error function, not a real function");
675 aStr.append(
" -> Value");
678 aStr.append(
" -> Reference");
681 aStr.append(
" -> ReferenceOrRefArray");
684 aStr.append(
" -> Array");
687 aStr.append(
" -> ForceArray");
690 aStr.append(
" -> ReferenceOrForceArray");
696 aStr.append(
" (-> ???, classification error?)");
701 SAL_INFO(
"sc.core",
"CALC_GENPARCLASSDOC: " <<
aStr.makeStringAndClear());
707 #endif // OSL_DEBUG_LEVEL
List of spreadsheet functions.
static const RawData pRawData[]
static SC_DLLPUBLIC ScUnoAddInCollection * GetAddInCollection()
sal_uInt16 GetParamCount() const
std::unique_ptr< ContentProperties > pData
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...
const wchar_t *typedef int(__stdcall *DllNativeUnregProc)(int
const LegacyFuncData * findByName(const OUString &rName) const
const ScFuncDesc * First()
formula::ParamClass nParam[nMaxParams]
constexpr OUStringLiteral aData
static formula::ParamClass GetParameterType(const formula::FormulaToken *pToken, sal_uInt16 nParameter)
Get one parameter type for function eOp.
const OUString & FindFunction(const OUString &rUpperName, bool bLocalFirst)
User entered name. rUpperName MUST already be upper case!
ParamType GetParamType(sal_uInt16 nIndex) const
OUString uppercase(const OUString &rStr, sal_Int32 nPos, sal_Int32 nCount) const
static void Init()
MUST be called once before any other method.
const ScAddInArgDesc * GetArguments() const
static ScFunctionList * GetStarCalcFunctionList()
#define SC_OPCODE_LAST_OPCODE_ID
static LegacyFuncCollection * GetLegacyFuncCollection()
#define SAL_WARN_IF(condition, area, stream)
#define SAL_INFO(area, stream)
tools::Long GetArgumentCount() const
const ScFuncDesc * Next()
static SC_DLLPUBLIC const CharClass * getCharClassPtr()
static formula::ParamClass GetExternalParameterType(const formula::FormulaToken *pToken, sal_uInt16 nParameter)
#define SAL_WARN(area, stream)
Stores and generates human readable descriptions for spreadsheet-functions, e.g. functions used in fo...