sc/source/core/tool/parclass.cxx | 100 ++++++++++++++++++++++++++------------- 1 file changed, 67 insertions(+), 33 deletions(-)
New commits: commit edea6e1ea5fc172e1177a7d2fe727bc11481af71 Author: Eike Rathke <[email protected]> Date: Fri Jun 2 23:07:17 2017 +0200 Output return type and use Bounds for OpCodes without return Could be further refined to use Array for functions that are capable to return one, and even ForceArray if always an array is returned, which then could be used by FormulaCompiler::IsMatrixFunction() instead of the switch cases. Change-Id: I099f9632dd0f206f3e5c07799b1ad73a67dee44f diff --git a/sc/source/core/tool/parclass.cxx b/sc/source/core/tool/parclass.cxx index 8da7305aa7cc..d4b425a905f1 100644 --- a/sc/source/core/tool/parclass.cxx +++ b/sc/source/core/tool/parclass.cxx @@ -59,40 +59,40 @@ const ScParameterClassification::RawData ScParameterClassification::pRawData[] = { ocIfNA, {{ Array, Reference }, 0, Value }}, { ocChoose, {{ Array, Reference }, 1, Value }}, // Other specials. - { ocArrayClose, {{ Bounds }, 0, Value }}, - { ocArrayColSep, {{ Bounds }, 0, Value }}, - { ocArrayOpen, {{ Bounds }, 0, Value }}, - { ocArrayRowSep, {{ Bounds }, 0, Value }}, - { ocBad, {{ Bounds }, 0, Value }}, - { ocClose, {{ Bounds }, 0, Value }}, - { ocColRowName, {{ Bounds }, 0, Value }}, - { ocColRowNameAuto, {{ Bounds }, 0, Value }}, - { ocDBArea, {{ Bounds }, 0, Value }}, + { ocArrayClose, {{ Bounds }, 0, Bounds }}, + { ocArrayColSep, {{ Bounds }, 0, Bounds }}, + { ocArrayOpen, {{ Bounds }, 0, Bounds }}, + { ocArrayRowSep, {{ Bounds }, 0, Bounds }}, + { ocBad, {{ Bounds }, 0, Bounds }}, + { ocClose, {{ Bounds }, 0, Bounds }}, + { ocColRowName, {{ Bounds }, 0, Value }}, // or Reference? + { ocColRowNameAuto, {{ Bounds }, 0, Value }}, // or Reference? + { ocDBArea, {{ Bounds }, 0, Value }}, // or Reference? { ocMatRef, {{ Bounds }, 0, Value }}, { ocMissing, {{ Bounds }, 0, Value }}, - { ocNoName, {{ Bounds }, 0, Value }}, - { ocOpen, {{ Bounds }, 0, Value }}, - { ocSep, {{ Bounds }, 0, Value }}, - { ocSkip, {{ Bounds }, 0, Value }}, - { ocSpaces, {{ Bounds }, 0, Value }}, - { ocStop, {{ Bounds }, 0, Value }}, - { ocStringXML, {{ Bounds }, 0, Value }}, - { ocTableRef, {{ Bounds }, 0, Value }}, - { ocTableRefClose, {{ Bounds }, 0, Value }}, - { ocTableRefItemAll, {{ Bounds }, 0, Value }}, - { ocTableRefItemData, {{ Bounds }, 0, Value }}, - { ocTableRefItemHeaders, {{ Bounds }, 0, Value }}, - { ocTableRefItemThisRow, {{ Bounds }, 0, Value }}, - { ocTableRefItemTotals, {{ Bounds }, 0, Value }}, - { ocTableRefOpen, {{ Bounds }, 0, Value }}, + { ocNoName, {{ Bounds }, 0, Bounds }}, + { ocOpen, {{ Bounds }, 0, Bounds }}, + { ocSep, {{ Bounds }, 0, Bounds }}, + { ocSkip, {{ Bounds }, 0, Bounds }}, + { ocSpaces, {{ Bounds }, 0, Bounds }}, + { ocStop, {{ Bounds }, 0, Bounds }}, + { ocStringXML, {{ Bounds }, 0, Bounds }}, + { ocTableRef, {{ Bounds }, 0, Value }}, // or Reference? + { ocTableRefClose, {{ Bounds }, 0, Bounds }}, + { ocTableRefItemAll, {{ Bounds }, 0, Bounds }}, + { ocTableRefItemData, {{ Bounds }, 0, Bounds }}, + { ocTableRefItemHeaders, {{ Bounds }, 0, Bounds }}, + { ocTableRefItemThisRow, {{ Bounds }, 0, Bounds }}, + { ocTableRefItemTotals, {{ Bounds }, 0, Bounds }}, + { ocTableRefOpen, {{ Bounds }, 0, Bounds }}, // Error constants. - { ocErrDivZero, {{ Bounds }, 0, Value }}, - { ocErrNA, {{ Bounds }, 0, Value }}, - { ocErrName, {{ Bounds }, 0, Value }}, - { ocErrNull, {{ Bounds }, 0, Value }}, - { ocErrNum, {{ Bounds }, 0, Value }}, - { ocErrRef, {{ Bounds }, 0, Value }}, - { ocErrValue, {{ Bounds }, 0, Value }}, + { ocErrDivZero, {{ Bounds }, 0, Bounds }}, + { ocErrNA, {{ Bounds }, 0, Bounds }}, + { ocErrName, {{ Bounds }, 0, Bounds }}, + { ocErrNull, {{ Bounds }, 0, Bounds }}, + { ocErrNum, {{ Bounds }, 0, Bounds }}, + { ocErrRef, {{ Bounds }, 0, Bounds }}, + { ocErrValue, {{ Bounds }, 0, Bounds }}, // Functions with Value parameters only but not in resource. { ocBackSolver, {{ Value, Value, Value }, 0, Value }}, { ocTableOp, {{ Value, Value, Value, Value, Value }, 0, Value }}, @@ -654,6 +654,31 @@ void ScParameterClassification::GenerateDocumentation() break; default:; } + // Return type. + formula::ParamClass eType = GetParameterType( &aToken, SAL_MAX_UINT16); + switch ( eType ) + { + case Value : + aStr.append(" -> Value"); + break; + case Reference : + aStr.append(" -> Reference"); + break; + case Array : + aStr.append(" -> Array"); + break; + case ForceArray : + aStr.append(" -> ForceArray"); + break; + case ReferenceOrForceArray : + aStr.append(" -> ReferenceOrForceArray"); + break; + case Bounds : + ; // nothing + break; + default: + aStr.append(" (-> ???, classification error?)"); + } /* We could add yet another log domain for this, if we wanted.. but * as it more seldom than rarely used it's not actually necessary, * just grep output. */ commit e3c73fea1a65d42744f60df3f95b047459cf01e0 Author: Eike Rathke <[email protected]> Date: Fri Jun 2 22:42:05 2017 +0200 Add parentheses only for functions and operators Change-Id: Ifdd3b0644c54b93f32e93b9448a4364475027a00 diff --git a/sc/source/core/tool/parclass.cxx b/sc/source/core/tool/parclass.cxx index f53a91895ee7..8da7305aa7cc 100644 --- a/sc/source/core/tool/parclass.cxx +++ b/sc/source/core/tool/parclass.cxx @@ -539,13 +539,14 @@ void ScParameterClassification::GenerateDocumentation() if ( !xMap->getSymbol(eOp).isEmpty() ) { OUStringBuffer aStr(xMap->getSymbol(eOp)); - aStr.append('('); formula::FormulaByteToken aToken( eOp); sal_uInt8 nParams = GetMinimumParameters( eOp); // preset parameter count according to opcode value, with some // special handling + bool bAddParentheses = true; if ( eOp < SC_OPCODE_STOP_DIV ) { + bAddParentheses = false; // will be overridden below if parameters switch ( eOp ) { case ocIf: @@ -563,7 +564,10 @@ void ScParameterClassification::GenerateDocumentation() } } else if ( eOp < SC_OPCODE_STOP_ERRORS ) + { + bAddParentheses = false; aToken.SetByte(0); + } else if ( eOp < SC_OPCODE_STOP_BIN_OP ) { switch ( eOp ) @@ -592,6 +596,10 @@ void ScParameterClassification::GenerateDocumentation() aToken.SetByte( nParams); if ( nParams != aToken.GetParamCount() ) SAL_WARN("sc.core", "(parameter count differs, token ParamCount: " << (int)aToken.GetParamCount() << " classification: " << (int)nParams << ") "); + if (aToken.GetByte()) + bAddParentheses = true; + if (bAddParentheses) + aStr.append('('); for ( sal_uInt16 j=0; j < nParams; ++j ) { if ( j > 0 ) @@ -625,7 +633,8 @@ void ScParameterClassification::GenerateDocumentation() aStr.append(", ..."); if ( nParams ) aStr.append(' '); - aStr.append(')'); + if (bAddParentheses) + aStr.append(')'); switch ( eOp ) { case ocRRI: _______________________________________________ Libreoffice-commits mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits
