xref: /trunk/main/sc/source/core/tool/parclass.cxx (revision 1354dfcdad4129e7cc561fdcfbb4f6c8958f0428)
1 /**************************************************************
2  *
3  * Licensed to the Apache Software Foundation (ASF) under one
4  * or more contributor license agreements.  See the NOTICE file
5  * distributed with this work for additional information
6  * regarding copyright ownership.  The ASF licenses this file
7  * to you under the Apache License, Version 2.0 (the
8  * "License"); you may not use this file except in compliance
9  * with the License.  You may obtain a copy of the License at
10  *
11  *   http://www.apache.org/licenses/LICENSE-2.0
12  *
13  * Unless required by applicable law or agreed to in writing,
14  * software distributed under the License is distributed on an
15  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16  * KIND, either express or implied.  See the License for the
17  * specific language governing permissions and limitations
18  * under the License.
19  *
20  *************************************************************/
21 
22 
23 
24 // MARKER(update_precomp.py): autogen include statement, do not remove
25 #include "precompiled_sc.hxx"
26 
27 
28 #include "parclass.hxx"
29 #include "token.hxx"
30 #include "global.hxx"
31 #include "callform.hxx"
32 #include "addincol.hxx"
33 #include "funcdesc.hxx"
34 #include <unotools/charclass.hxx>
35 #include <tools/debug.hxx>
36 #include <string.h>
37 
38 #if OSL_DEBUG_LEVEL > 1
39 // the documentation thingy
40 #include <stdio.h>
41 #include <com/sun/star/sheet/FormulaLanguage.hpp>
42 #include "compiler.hxx"
43 #include "sc.hrc"   // VAR_ARGS
44 #endif
45 
46 
47 /* Following assumptions are made:
48  * - OpCodes not specified at all will have at least one and only parameters of
49  *   type Value, no check is done on the count of parameters => no Bounds type
50  *   is returned.
51  * - For OpCodes with a variable number of parameters the type(s) of the last
52  *   repeated parameter(s) specified determine(s) the type(s) of all following
53  *   parameters.
54  */
55 
56 const ScParameterClassification::RawData ScParameterClassification::pRawData[] =
57 {
58     // { OpCode, {{ Type, ... }, nRepeatLast }},
59 
60     // IF() and CHOOSE() are somewhat special, since the ScJumpMatrix is
61     // created inside those functions and ConvertMatrixParameters() is not
62     // called for them. The same goes for IFNA().
63     { ocIf,              {{ Array, Reference, Reference                          }, 0 }},
64     { ocChose,           {{ Array, Reference                                     }, 1 }},
65     { ocIfna,            {{ Reference, Reference                                 }, 0 }},
66     { ocIfError,         {{ Reference, Reference                                 }, 0 }},
67     // Other specials.
68     { ocOpen,            {{ Bounds                                               }, 0 }},
69     { ocClose,           {{ Bounds                                               }, 0 }},
70     { ocSep,             {{ Bounds                                               }, 0 }},
71     { ocNoName,          {{ Bounds                                               }, 0 }},
72     { ocErrCell,         {{ Bounds                                               }, 0 }},
73     { ocStop,            {{ Bounds                                               }, 0 }},
74     { ocUnion,           {{ Reference, Reference                                 }, 0 }},
75     { ocRange,           {{ Reference, Reference                                 }, 0 }},
76     // Functions with Value parameters only but not in resource.
77     { ocBackSolver,      {{ Value, Value, Value                                  }, 0 }},
78     { ocTableOp,         {{ Value, Value, Value, Value, Value                    }, 0 }},
79     // Operators and functions.
80     { ocAdd,             {{ Array, Array                                         }, 0 }},
81     { ocAmpersand,       {{ Array, Array                                         }, 0 }},
82     { ocAnd,             {{ Reference                                            }, 1 }},
83     { ocAreas,           {{ Reference                                            }, 0 }},
84     { ocAveDev,          {{ Reference                                            }, 1 }},
85     { ocAverage,         {{ Reference                                            }, 1 }},
86     { ocAverageA,        {{ Reference                                            }, 1 }},
87     { ocAverageIf,       {{ Reference, Value, Reference                          }, 0 }},
88     { ocAverageIfs,      {{ Reference, Reference, Value                          }, 2 }},
89     { ocCell,            {{ Value, Reference                                     }, 0 }},
90     { ocColumn,          {{ Reference                                            }, 0 }},
91     { ocColumns,         {{ Reference                                            }, 1 }},
92     { ocCorrel,          {{ ForceArray, ForceArray                               }, 0 }},
93     { ocCount,           {{ Reference                                            }, 1 }},
94     { ocCount2,          {{ Reference                                            }, 1 }},
95     { ocCountEmptyCells, {{ Reference                                            }, 0 }},
96     { ocCountIf,         {{ Reference, Value                                     }, 0 }},
97     { ocCountIfs,        {{ Reference, Value                                     }, 2 }},
98     { ocCovar,           {{ ForceArray, ForceArray                               }, 0 }},
99     { ocDBAverage,       {{ Reference, Reference, Reference                      }, 0 }},
100     { ocDBCount,         {{ Reference, Reference, Reference                      }, 0 }},
101     { ocDBCount2,        {{ Reference, Reference, Reference                      }, 0 }},
102     { ocDBGet,           {{ Reference, Reference, Reference                      }, 0 }},
103     { ocDBMax,           {{ Reference, Reference, Reference                      }, 0 }},
104     { ocDBMin,           {{ Reference, Reference, Reference                      }, 0 }},
105     { ocDBProduct,       {{ Reference, Reference, Reference                      }, 0 }},
106     { ocDBStdDev,        {{ Reference, Reference, Reference                      }, 0 }},
107     { ocDBStdDevP,       {{ Reference, Reference, Reference                      }, 0 }},
108     { ocDBSum,           {{ Reference, Reference, Reference                      }, 0 }},
109     { ocDBVar,           {{ Reference, Reference, Reference                      }, 0 }},
110     { ocDBVarP,          {{ Reference, Reference, Reference                      }, 0 }},
111     { ocDevSq,           {{ Reference                                            }, 1 }},
112     { ocDiv,             {{ Array, Array                                         }, 0 }},
113     { ocEqual,           {{ Array, Array                                         }, 0 }},
114     { ocForecast,        {{ Value, ForceArray, ForceArray                        }, 0 }},
115     { ocFrequency,       {{ Reference, Reference                                 }, 0 }},
116     { ocFTest,           {{ ForceArray, ForceArray                               }, 0 }},
117     { ocGeoMean,         {{ Reference                                            }, 1 }},
118     { ocGCD,             {{ Reference                                            }, 1 }},
119     { ocGreater,         {{ Array, Array                                         }, 0 }},
120     { ocGreaterEqual,    {{ Array, Array                                         }, 0 }},
121     { ocGrowth,          {{ Reference, Reference, Reference, Value               }, 0 }},
122     { ocHarMean,         {{ Reference                                            }, 1 }},
123     { ocHLookup,         {{ Value, Reference, Value, Value                       }, 0 }},
124     { ocIRR,             {{ Reference, Value                                     }, 0 }},
125     { ocIndex,           {{ Reference, Value, Value, Value                       }, 0 }},
126     { ocIntercept,       {{ ForceArray, ForceArray                               }, 0 }},
127     { ocIntersect,       {{ Reference, Reference                                 }, 0 }},
128     { ocIsRef,           {{ Reference                                            }, 0 }},
129     { ocLCM,             {{ Reference                                            }, 1 }},
130     { ocKurt,            {{ Reference                                            }, 1 }},
131     { ocLarge,           {{ Reference, Value                                     }, 0 }},
132     { ocLess,            {{ Array, Array                                         }, 0 }},
133     { ocLessEqual,       {{ Array, Array                                         }, 0 }},
134     { ocLookup,          {{ Value, ReferenceOrForceArray, ReferenceOrForceArray  }, 0 }},
135     { ocMatch,           {{ Value, Reference, Reference                          }, 0 }},
136     { ocMatDet,          {{ ForceArray                                           }, 0 }},
137     { ocMatInv,          {{ ForceArray                                           }, 0 }},
138     { ocMatMult,         {{ ForceArray, ForceArray                               }, 0 }},
139     { ocMatTrans,        {{ Array                                                }, 0 }}, // strange, but Xcl doesn't force MatTrans array
140     { ocMatValue,        {{ Reference, Value, Value                              }, 0 }},
141     { ocMax,             {{ Reference                                            }, 1 }},
142     { ocMaxA,            {{ Reference                                            }, 1 }},
143     { ocMedian,          {{ Reference                                            }, 1 }},
144     { ocMin,             {{ Reference                                            }, 1 }},
145     { ocMinA,            {{ Reference                                            }, 1 }},
146     { ocMIRR,            {{ Reference, Value, Value                              }, 0 }},
147     { ocModalValue,      {{ ForceArray                                           }, 1 }},
148     { ocMul,             {{ Array, Array                                         }, 0 }},
149     { ocMultiArea,       {{ Reference                                            }, 1 }},
150     { ocN,               {{ Reference                                            }, 0 }},
151     { ocNPV,             {{ Value, Reference                                     }, 1 }},
152     { ocNeg,             {{ Array                                                }, 0 }},
153     { ocNegSub,          {{ Array                                                }, 0 }},
154     { ocNot,             {{ Array                                                }, 0 }},
155     { ocNotEqual,        {{ Array, Array                                         }, 0 }},
156     { ocOffset,          {{ Reference, Value, Value, Value, Value                }, 0 }},
157     { ocOr,              {{ Reference                                            }, 1 }},
158     { ocPearson,         {{ ForceArray, ForceArray                               }, 0 }},
159     { ocPercentile,      {{ Reference, Value                                     }, 0 }},
160     { ocPercentrank,     {{ Reference, Value                                     }, 0 }},
161     { ocPow,             {{ Array, Array                                         }, 0 }},
162     { ocPower,           {{ Array, Array                                         }, 0 }},
163     { ocProb,            {{ ForceArray, ForceArray, Value, Value                 }, 0 }},
164     { ocProduct,         {{ Reference                                            }, 1 }},
165     { ocQuartile,        {{ Reference, Value                                     }, 0 }},
166     { ocRank,            {{ Value, Reference, Value                              }, 0 }},
167     { ocRGP,             {{ Reference, Reference, Value, Value                   }, 0 }},
168     { ocRKP,             {{ Reference, Reference, Value, Value                   }, 0 }},
169     { ocRow,             {{ Reference                                            }, 0 }},
170     { ocRows,            {{ Reference                                            }, 1 }},
171     { ocRSQ,             {{ ForceArray, ForceArray                               }, 0 }},
172     { ocSchiefe,         {{ Reference                                            }, 1 }},
173     { ocSlope,           {{ ForceArray, ForceArray                               }, 0 }},
174     { ocSmall,           {{ Reference, Value                                     }, 0 }},
175     { ocStDev,           {{ Reference                                            }, 1 }},
176     { ocStDevA,          {{ Reference                                            }, 1 }},
177     { ocStDevP,          {{ Reference                                            }, 1 }},
178     { ocStDevPA,         {{ Reference                                            }, 1 }},
179     { ocSTEYX,           {{ ForceArray, ForceArray                               }, 0 }},
180     { ocSub,             {{ Array, Array                                         }, 0 }},
181     { ocSubTotal,        {{ Value, Reference                                     }, 1 }},
182     { ocSum,             {{ Reference                                            }, 1 }},
183     { ocSumIf,           {{ Reference, Value, Reference                          }, 0 }},
184     { ocSumIfs,          {{ Reference, Reference, Value                          }, 2 }},
185     { ocSumProduct,      {{ ForceArray                                           }, 1 }},
186     { ocSumSQ,           {{ Reference                                            }, 1 }},
187     { ocSumX2MY2,        {{ ForceArray, ForceArray                               }, 0 }},
188     { ocSumX2DY2,        {{ ForceArray, ForceArray                               }, 0 }},
189     { ocSumXMY2,         {{ ForceArray, ForceArray                               }, 0 }},
190     { ocTable,           {{ Reference                                            }, 0 }},
191     { ocTables,          {{ Reference                                            }, 1 }},
192     { ocTrend,           {{ Reference, Reference, Reference, Value               }, 0 }},
193     { ocTrimMean,        {{ Reference, Value                                     }, 0 }},
194     { ocTTest,           {{ ForceArray, ForceArray, Value, Value                 }, 0 }},
195     { ocVar,             {{ Reference                                            }, 1 }},
196     { ocVarA,            {{ Reference                                            }, 1 }},
197     { ocVarP,            {{ Reference                                            }, 1 }},
198     { ocVarPA,           {{ Reference                                            }, 1 }},
199     { ocVLookup,         {{ Value, Reference, Value, Value                       }, 0 }},
200     { ocXor,             {{ Reference                                            }, 1 }},
201     { ocZTest,           {{ Reference, Value, Value                              }, 0 }},
202     // Excel doubts:
203     // ocT: Excel says (and handles) Reference, error? This means no position
204     // dependent SingleRef if DoubleRef, and no array calculation, just the
205     // upper left corner. We never did that.
206     { ocT, {{ Value }, 0 }},
207     // The stopper.
208     { ocNone, {{ Bounds }, 0 } }
209 };
210 
211 ScParameterClassification::RunData * ScParameterClassification::pData = NULL;
212 
213 
Init()214 void ScParameterClassification::Init()
215 {
216     if ( pData )
217         return;
218     pData = new RunData[ SC_OPCODE_LAST_OPCODE_ID + 1 ];
219     memset( pData, 0, sizeof(RunData) * (SC_OPCODE_LAST_OPCODE_ID + 1));
220 
221     // init from specified static data above
222     for ( size_t i=0; i < sizeof(pRawData) / sizeof(RawData); ++i )
223     {
224         const RawData* pRaw = &pRawData[i];
225         if ( pRaw->eOp > SC_OPCODE_LAST_OPCODE_ID )
226         {
227             DBG_ASSERT( pRaw->eOp == ocNone, "RawData OpCode error");
228         }
229         else
230         {
231             RunData* pRun = &pData[ pRaw->eOp ];
232 #ifdef DBG_UTIL
233             if ( pRun->aData.nParam[0] != Unknown )
234             {
235                 DBG_ERROR1( "already assigned: %d", pRaw->eOp);
236             }
237 #endif
238             memcpy( &(pRun->aData), &(pRaw->aData), sizeof(CommonData));
239             // fill 0-initialized fields with real values
240             if ( pRun->aData.nRepeatLast )
241             {
242                 for ( size_t j=0; j < CommonData::nMaxParams; ++j )
243                 {
244                     if ( pRun->aData.nParam[j] )
245                         pRun->nMinParams = sal::static_int_cast<sal_uInt8>( j+1 );
246                     else if (j >= pRun->aData.nRepeatLast)
247                         pRun->aData.nParam[j] =  pRun->aData.nParam[j - pRun->aData.nRepeatLast];
248                     else
249                     {
250                         DBG_ERROR2( "bad classification: eOp %d, repeated param %d negative offset", pRaw->eOp, j);
251                         pRun->aData.nParam[j] =  Unknown;
252                     }
253                 }
254             }
255             else
256             {
257                 for ( size_t j=0; j < CommonData::nMaxParams; ++j )
258                 {
259                     if ( !pRun->aData.nParam[j] )
260                     {
261                         if ( j == 0 || pRun->aData.nParam[j-1] != Bounds )
262                             pRun->nMinParams = sal::static_int_cast<sal_uInt8>( j );
263                         pRun->aData.nParam[j] = Bounds;
264                     }
265                 }
266                 if ( !pRun->nMinParams &&
267                         pRun->aData.nParam[CommonData::nMaxParams-1] != Bounds)
268                     pRun->nMinParams = CommonData::nMaxParams;
269             }
270             for ( size_t j=0; j < CommonData::nMaxParams; ++j )
271             {
272                 if ( pRun->aData.nParam[j] == ForceArray || pRun->aData.nParam[j] == ReferenceOrForceArray )
273                 {
274                     pRun->bHasForceArray = true;
275                     break;  // for
276                 }
277             }
278         }
279     }
280 
281 #if OSL_DEBUG_LEVEL > 1
282     GenerateDocumentation();
283 #endif
284 }
285 
286 
Exit()287 void ScParameterClassification::Exit()
288 {
289     delete [] pData;
290     pData = NULL;
291 }
292 
293 
GetParameterType(const formula::FormulaToken * pToken,sal_uInt16 nParameter)294 ScParameterClassification::Type ScParameterClassification::GetParameterType(
295         const formula::FormulaToken* pToken, sal_uInt16 nParameter)
296 {
297     OpCode eOp = pToken->GetOpCode();
298     switch ( eOp )
299     {
300         case ocExternal:
301             return GetExternalParameterType( pToken, nParameter);
302         //break;
303         case ocMacro:
304             return Reference;
305         //break;
306         default:
307         {
308             // added to avoid warnings
309         }
310     }
311     if ( 0 <= (short)eOp && eOp <= SC_OPCODE_LAST_OPCODE_ID )
312     {
313         sal_uInt8 nRepeat;
314         Type eType;
315         if ( nParameter < CommonData::nMaxParams )
316             eType = pData[eOp].aData.nParam[nParameter];
317         else if ( (nRepeat = pData[eOp].aData.nRepeatLast) > 0 )
318         {
319             // The usual case is 1 repeated parameter, we don't need to
320             // calculate that on each call.
321             sal_uInt16 nParam = (nRepeat > 1 ?
322                     (pData[eOp].nMinParams -
323                      ((nParameter - pData[eOp].nMinParams) % nRepeat)) :
324                     pData[eOp].nMinParams);
325             return pData[eOp].aData.nParam[nParam];
326         }
327         else
328             eType = Bounds;
329         return eType == Unknown ? Value : eType;
330     }
331     return Unknown;
332 }
333 
334 
335 ScParameterClassification::Type
GetExternalParameterType(const formula::FormulaToken * pToken,sal_uInt16 nParameter)336 ScParameterClassification::GetExternalParameterType( const formula::FormulaToken* pToken,
337         sal_uInt16 nParameter)
338 {
339     Type eRet = Unknown;
340     // similar to ScInterpreter::ScExternal()
341     sal_uInt16 nIndex;
342     String aUnoName;
343     String aFuncName( ScGlobal::pCharClass->upper( pToken->GetExternal()));
344     if ( ScGlobal::GetFuncCollection()->SearchFunc( aFuncName, nIndex) )
345     {
346         FuncData* pFuncData = (FuncData*)ScGlobal::GetFuncCollection()->At(
347                 nIndex);
348         if ( nParameter >= pFuncData->GetParamCount() )
349             eRet = Bounds;
350         else
351         {
352             switch ( pFuncData->GetParamType( nParameter) )
353             {
354                 case PTR_DOUBLE:
355                 case PTR_STRING:
356                     eRet = Value;
357                 break;
358                 default:
359                     eRet = Reference;
360                     // also array types are created using an area reference
361             }
362         }
363     }
364     else if ( (aUnoName = ScGlobal::GetAddInCollection()->FindFunction(
365                     aFuncName, sal_False)).Len() )
366     {
367         // the relevant parts of ScUnoAddInCall without having to create one
368         const ScUnoAddInFuncData* pFuncData =
369             ScGlobal::GetAddInCollection()->GetFuncData( aUnoName, true );      // need fully initialized data
370         if ( pFuncData )
371         {
372             long nCount = pFuncData->GetArgumentCount();
373             if ( nCount <= 0 )
374                 eRet = Bounds;
375             else
376             {
377                 const ScAddInArgDesc* pArgs = pFuncData->GetArguments();
378                 if ( nParameter >= nCount &&
379                         pArgs[nCount-1].eType == SC_ADDINARG_VARARGS )
380                     eRet = Value;
381                     // last arg is sequence, optional "any"s, we simply can't
382                     // determine the type
383                 if ( eRet == Unknown )
384                 {
385                     if ( nParameter >= nCount )
386                         eRet = Bounds;
387                     else
388                     {
389                         switch ( pArgs[nParameter].eType )
390                         {
391                             case SC_ADDINARG_INTEGER:
392                             case SC_ADDINARG_DOUBLE:
393                             case SC_ADDINARG_STRING:
394                                 eRet = Value;
395                             break;
396                             default:
397                                 eRet = Reference;
398                         }
399                     }
400                 }
401             }
402         }
403     }
404     return eRet;
405 }
406 
407 //-----------------------------------------------------------------------------
408 
409 #if OSL_DEBUG_LEVEL > 1
410 
411 // add remaining functions, all Value parameters
MergeArgumentsFromFunctionResource()412 void ScParameterClassification::MergeArgumentsFromFunctionResource()
413 {
414     ScFunctionList* pFuncList = ScGlobal::GetStarCalcFunctionList();
415     for ( const ScFuncDesc* pDesc = pFuncList->First(); pDesc;
416             pDesc = pFuncList->Next() )
417     {
418         if ( pDesc->nFIndex > SC_OPCODE_LAST_OPCODE_ID ||
419                 pData[pDesc->nFIndex].aData.nParam[0] != Unknown )
420             continue;   // not an internal opcode or already done
421 
422         RunData* pRun = &pData[ pDesc->nFIndex ];
423         sal_uInt16 nArgs = pDesc->GetSuppressedArgCount();
424         if ( nArgs >= PAIRED_VAR_ARGS )
425         {
426             nArgs -= PAIRED_VAR_ARGS - 2;
427             pRun->aData.nRepeatLast = 2;
428         }
429         else if ( nArgs >= VAR_ARGS )
430         {
431             nArgs -= VAR_ARGS - 1;
432             pRun->aData.nRepeatLast = 1;
433         }
434         if ( nArgs > CommonData::nMaxParams )
435         {
436             DBG_ERROR2( "ScParameterClassification::Init: too many arguments in listed function: %s: %d",
437                     ByteString( *(pDesc->pFuncName),
438                         RTL_TEXTENCODING_UTF8).GetBuffer(), nArgs);
439             nArgs = CommonData::nMaxParams - 1;
440             pRun->aData.nRepeatLast = 1;
441         }
442         pRun->nMinParams = static_cast< sal_uInt8 >( nArgs );
443         for ( size_t j=0; j < nArgs; ++j )
444         {
445             pRun->aData.nParam[j] = Value;
446         }
447         if ( pRun->aData.nRepeatLast )
448         {
449             for ( size_t j = nArgs; j < CommonData::nMaxParams; ++j )
450             {
451                 pRun->aData.nParam[j] = Value;
452             }
453         }
454         else
455         {
456             for ( size_t j = nArgs; j < CommonData::nMaxParams; ++j )
457             {
458                 pRun->aData.nParam[j] = Bounds;
459             }
460         }
461     }
462 }
463 
464 
GenerateDocumentation()465 void ScParameterClassification::GenerateDocumentation()
466 {
467     static const sal_Char aEnvVarName[] = "OOO_CALC_GENPARCLASSDOC";
468     if ( !getenv( aEnvVarName) )
469         return;
470     MergeArgumentsFromFunctionResource();
471     ScAddress aAddress;
472     ScCompiler aComp(NULL,aAddress);
473     ScCompiler::OpCodeMapPtr xMap( aComp.GetOpCodeMap(::com::sun::star::sheet::FormulaLanguage::ENGLISH));
474     if (!xMap)
475         return;
476     fflush( stderr);
477     size_t nCount = xMap->getSymbolCount();
478     for ( size_t i=0; i<nCount; ++i )
479     {
480         OpCode eOp = OpCode(i);
481         if ( xMap->getSymbol(eOp).Len() )
482         {
483             fprintf( stdout, "%s: ", aEnvVarName);
484             ByteString aStr( xMap->getSymbol(eOp), RTL_TEXTENCODING_UTF8);
485             aStr += "(";
486             formula::FormulaByteToken aToken( eOp);
487             sal_uInt8 nParams = GetMinimumParameters( eOp);
488             // preset parameter count according to opcode value, with some
489             // special handling
490             if ( eOp < SC_OPCODE_STOP_DIV )
491             {
492                 switch ( eOp )
493                 {
494                     case ocIf:
495                         aToken.SetByte(3);
496                     break;
497                     case ocChose:
498                         aToken.SetByte(2);
499                     break;
500                     case ocPercentSign:
501                         aToken.SetByte(1);
502                     break;
503                     default:;
504                 }
505             }
506             else if ( eOp < SC_OPCODE_STOP_ERRORS )
507                 aToken.SetByte(0);
508             else if ( eOp < SC_OPCODE_STOP_BIN_OP )
509             {
510                 switch ( eOp )
511                 {
512                     case ocAnd:
513                     case ocOr:
514                         aToken.SetByte(1);  // (r1)AND(r2) --> AND( r1, ...)
515                     break;
516                     default:
517                         aToken.SetByte(2);
518                 }
519             }
520             else if ( eOp < SC_OPCODE_STOP_UN_OP )
521                 aToken.SetByte(1);
522             else if ( eOp < SC_OPCODE_STOP_NO_PAR )
523                 aToken.SetByte(0);
524             else if ( eOp < SC_OPCODE_STOP_1_PAR )
525                 aToken.SetByte(1);
526             else
527                 aToken.SetByte( nParams);
528             // compare (this is a mere test for opcode order Div, BinOp, UnOp,
529             // NoPar, 1Par, ...) and override parameter count with
530             // classification
531             if ( nParams != aToken.GetByte() )
532                 fprintf( stdout, "(parameter count differs, token Byte: %d  classification: %d) ",
533                         aToken.GetByte(), nParams);
534             aToken.SetByte( nParams);
535             if ( nParams != aToken.GetParamCount() )
536                 fprintf( stdout, "(parameter count differs, token ParamCount: %d  classification: %d) ",
537                         aToken.GetParamCount(), nParams);
538             for ( sal_uInt16 j=0; j < nParams; ++j )
539             {
540                 if ( j > 0 )
541                     aStr += ",";
542                 Type eType = GetParameterType( &aToken, j);
543                 switch ( eType )
544                 {
545                     case Value :
546                         aStr += " Value";
547                     break;
548                     case Reference :
549                         aStr += " Reference";
550                     break;
551                     case Array :
552                         aStr += " Array";
553                     break;
554                     case ForceArray :
555                         aStr += " ForceArray";
556                     break;
557                     case ReferenceOrForceArray :
558                         aStr += " ReferenceOrForceArray";
559                     break;
560                     case Bounds :
561                         aStr += " (Bounds, classification error?)";
562                     break;
563                     default:
564                         aStr += " (???, classification error?)";
565                 }
566             }
567             if ( HasRepeatParameters( eOp) )
568                 aStr += ", ...";
569             if ( nParams )
570                 aStr += " ";
571             aStr += ")";
572             switch ( eOp )
573             {
574                 case ocZGZ:
575                     aStr += "   // RRI in English resource, but ZGZ in English-only section";
576                 break;
577                 case ocMultiArea:
578                     aStr += "   // e.g. combined first parameter of INDEX() function, not a real function";
579                 break;
580                 case ocBackSolver:
581                     aStr += "   // goal seek via menu, not a real function";
582                 break;
583                 case ocTableOp:
584                     aStr += "   // MULTIPLE.OPERATIONS in English resource, but TABLE in English-only section";
585                 break;
586                 case ocNoName:
587                     aStr += "   // error function, not a real function";
588                 break;
589                 default:;
590             }
591             fprintf( stdout, "%s\n", aStr.GetBuffer());
592         }
593     }
594     fflush( stdout);
595 }
596 
597 #endif // OSL_DEBUG_LEVEL
598