1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
3  * This file is part of the LibreOffice project.
4  *
5  * This Source Code Form is subject to the terms of the Mozilla Public
6  * License, v. 2.0. If a copy of the MPL was not distributed with this
7  * file, You can obtain one at http://mozilla.org/MPL/2.0/.
8  *
9  * This file incorporates work covered by the following license notice:
10  *
11  *   Licensed to the Apache Software Foundation (ASF) under one or more
12  *   contributor license agreements. See the NOTICE file distributed
13  *   with this work for additional information regarding copyright
14  *   ownership. The ASF licenses this file to you under the Apache
15  *   License, Version 2.0 (the "License"); you may not use this file
16  *   except in compliance with the License. You may obtain a copy of
17  *   the License at http://www.apache.org/licenses/LICENSE-2.0 .
18  */
19 
20 #include <decl.h>
21 #include <lotform.hxx>
22 #include "lotfilter.hxx"
23 #include <lotrange.hxx>
24 #include <namebuff.hxx>
25 #include <ftools.hxx>
26 #include <tool.h>
27 #include <document.hxx>
28 
29 #include <comphelper/string.hxx>
30 #include <sal/log.hxx>
31 #include <memory>
32 #include <string_view>
33 
34 static const char*      GetAddInName( const sal_uInt8 nIndex );
35 
36 static DefTokenId           lcl_KnownAddIn(std::string_view rTest);
37 
DoFunc(DefTokenId eOc,sal_uInt8 nCnt,const char * pExtString)38 void LotusToSc::DoFunc( DefTokenId eOc, sal_uInt8 nCnt, const char* pExtString )
39 {
40     TokenId                     eParam[ 256 ];
41     sal_Int32                   nPass;
42     TokenId                     nBuf0;
43 
44     bool                        bAddIn = false;
45 
46     SAL_WARN_IF( nCnt > 128, "sc.filter", "-LotusToSc::DoFunc(): Too many (128)!" );
47 
48     if( eOc == ocNoName )
49     {
50         OString t;
51         if( pExtString )
52         {
53             const OString s("@<<@123>>");
54 
55             t = pExtString;
56 
57             sal_Int32 n = t.indexOf(s);
58             if( n != -1 )
59                 t = t.copy(n + s.getLength());
60 
61             t = comphelper::string::stripEnd(t, '(');
62 
63             eOc = lcl_KnownAddIn( t );
64 
65             if( eOc == ocNoName )
66                 t = "L123_" + t;
67         }
68         else
69             t = "#UNKNOWN FUNC NAME#";
70 
71         if( eOc == ocNoName )
72         {
73             bAddIn = true;
74             nBuf0 = aPool.Store(eOc, OStringToOUString(t, eSrcChar));
75 
76             aPool << nBuf0;
77         }
78     }
79 
80     for( nPass = 0 ; nPass < nCnt && aStack.HasMoreTokens() ; nPass++ )
81         aStack >> eParam[ nPass ];
82 
83     if (nPass < nCnt)
84         // Adapt count to reality. All sort of binary crap is possible.
85         nCnt = static_cast<sal_uInt8>(nPass);
86 
87     // special cases...
88     switch( eOc )
89     {
90         case ocIndex:
91             SAL_WARN_IF( nCnt < 2, "sc.filter", "+LotusToSc::DoFunc(): ocIndex needs at least 2 parameters!" );
92             nBuf0 = eParam[ 0 ];
93             eParam[ 0 ] = eParam[ 1 ];
94             eParam[ 1 ] = nBuf0;
95             IncToken( eParam[ 0 ] );
96             IncToken( eParam[ 1 ] );
97             break;
98         case ocIRR:
99         {
100             SAL_WARN_IF( nCnt != 2, "sc.filter", "+LotusToSc::DoFunc(): ocIRR needs 2 parameters!" );
101             nBuf0 = eParam[ 0 ];
102             eParam[ 0 ] = eParam[ 1 ];
103             eParam[ 1 ] = nBuf0;
104         }
105             break;
106         case ocGetYear:
107         {
108             nBuf0 = aPool.Store( 1900.0 );
109             aPool << ocOpen;
110         }
111             break;
112         case ocChoose:
113         {// 1. Parameter ++
114             if (nCnt >= 1)
115                 IncToken( eParam[ nCnt - 1 ] );
116         }
117             break;
118         case ocFind:
119         case ocHLookup:
120         case ocVLookup:
121         {// last parameter ++
122             IncToken( eParam[ 0 ] );
123         }
124             break;
125         case ocMid:
126         case ocReplace:
127         {// 2. Parameter ++
128             if (nCnt >= 2)
129                 IncToken( eParam[ nCnt - 2 ] );
130         }
131             break;
132         case ocRate:
133         {
134             // new quantity = 4!
135             SAL_WARN_IF( nCnt != 3, "sc.filter",
136                 "*LotusToSc::DoFunc(): ZINS() needs 3 parameters!" );
137             nCnt = 4;
138             eParam[ 3 ] = eParam[ 0 ];  // 3. -> 1.
139             eParam[ 0 ] = eParam[ 2 ];  // 1. -> 4.
140             NegToken( eParam[ 1 ] );    // 2. -> -2. (+ 2. -> 3.)
141             eParam[ 2 ] = n0Token;      //    -> 2. as Default
142         }
143             break;
144         case ocNper:
145         {
146             SAL_WARN_IF( nCnt != 3, "sc.filter",
147                 "*LotusToSc::DoFunc(): TERM() or CTERM() need 3 parameters!" );
148             nCnt = 4;
149             if ( pExtString == std::string_view("TERM") )
150             {
151                 // @TERM(pmt,int,fv) -> NPER(int,-pmt,pv=0,fv)
152                 NegToken( eParam[ 2 ] );
153                 eParam[ 3 ] = eParam[ 1 ];
154                 eParam[ 1 ] = aPool.Store( 0.0 );
155             }
156             else //CTERM()
157             {
158                 // @CTERM(int,fv,pv) -> NPER(int,pmt=0,-pv,fv)
159                 NegToken( eParam[ 0 ] );
160                 nBuf0 = eParam[ 1 ];
161                 eParam[ 1 ] = eParam[ 0 ];
162                 eParam[ 0 ] = nBuf0;
163                 eParam[ 3 ] = eParam[ 2 ];
164                 eParam[ 2 ] = aPool.Store( 0.0 );
165             }
166         }
167             break;
168         case ocRoundUp:
169         case ocRoundDown:
170         {
171             // omit optional 3rd parameter
172             if ( nCnt == 3 )
173             {
174                 eParam[ 0 ] = eParam[ 1 ];
175                 eParam[ 1 ] = eParam[ 2 ];
176                 nCnt = 2;
177             }
178 
179         }
180             break;
181         default:;
182     }
183 
184     if( !bAddIn )
185         aPool << eOc;
186 
187     aPool << ocOpen;
188 
189     if( nCnt > 0 )
190     {
191             // ATTENTION: 0 is the last parameter, nCnt-1 the first one
192 
193         sal_Int16 nLast = nCnt - 1;
194 
195         if( eOc == ocPMT )
196         {   // special case ocPMT, negate last parameter!
197             // additionally: 1. -> 3., 3. -> 2., 2. -> 1.
198             SAL_WARN_IF( nCnt != 3, "sc.filter", "+LotusToSc::DoFunc(): ocPMT needs 3 parameters!" );
199             // There should be at least 3 arguments, but with binary crap may not...
200             switch (nCnt)
201             {
202                 case 1:
203                     aPool << eParam[ 1 ];
204                 break;
205                 case 2:
206                     aPool << eParam[ 1 ] << ocSep << eParam[ 0 ];
207                 break;
208                 default:
209                 case 3:
210                     aPool << eParam[ 1 ] << ocSep << eParam[ 0 ] << ocSep << ocNegSub << eParam[ 2 ];
211                 break;
212             }
213         }
214         else
215         {   // default
216             // [Parameter{;Parameter}]
217             aPool << eParam[ nLast ];
218 
219             for( nPass = nLast - 1 ; nPass >= 0 ; nPass-- )
220             {
221                 aPool << ocSep << eParam[nPass];
222             }
223         }
224     }
225 
226     // special cases ...
227     if( eOc == ocGetYear )
228     {
229         aPool << ocClose << ocSub << nBuf0;
230     }
231     else if( eOc == ocFixed )
232     {
233         aPool << ocSep << ocTrue << ocOpen << ocClose;
234     }
235     else if( eOc == ocFind )
236     {
237         TokenId nBuf1 = aPool.Store();
238         DecToken( nBuf1 );
239         aPool << nBuf1;
240     }
241 
242     aPool << ocClose;
243 
244     aPool >> aStack;
245 }
246 
LotusRelToScRel(sal_uInt16 nCol,sal_uInt16 nRow,ScSingleRefData & rSRD)247 void LotusToSc::LotusRelToScRel( sal_uInt16 nCol, sal_uInt16 nRow, ScSingleRefData& rSRD )
248 {
249     // Column
250     if( nCol & 0x8000 )
251     {
252         if( nCol & 0x0080 )
253             nCol |= 0xFF00;
254         else
255             nCol &= 0x00FF;
256         // #i36252# first cast unsigned 16-bit to signed 16-bit, and then to SCCOL
257         rSRD.SetRelCol(static_cast<SCCOL>(static_cast<sal_Int16>(nCol)));
258     }
259     else
260     {
261         rSRD.SetAbsCol(static_cast<SCCOL>(nCol & 0x00FF));
262     }
263 
264     // Row
265     if( nRow & 0x8000 )
266     {
267         rSRD.SetRowRel(true);
268         // sign correct extension
269         switch (m_rContext.eTyp)
270         {
271             // 5432 1098 7654 3210
272             // 8421 8421 8421 8421
273             //       xxx xxxx xxxx
274             case eWK_1:
275                 if( nRow & 0x0400 )
276                     nRow |= 0xF800;
277                 else
278                     nRow &= 0x07FF;
279                 break;
280             // 8421 8421 8421 8421
281             //    x xxxx xxxx xxxx
282             case eWK_2:
283                 if( nRow & 0x1000 )
284                     nRow |= 0xE000;
285                 else
286                     nRow &= 0x1FFF;
287                 break;
288             default:
289                 SAL_WARN( "sc.filter", "*LotusToSc::LotusRelToScRel(): unhandled case? " << m_rContext.eTyp );
290         }
291     }
292     else
293     {
294         rSRD.SetRowRel(false);
295         switch (m_rContext.eTyp)
296         {
297             // 5432 1098 7654 3210
298             // 8421 8421 8421 8421
299             //       xxx xxxx xxxx
300             case eWK_1:
301                 nRow &= 0x07FF;
302                 break;
303             // 8421 8421 8421 8421
304             //   xx xxxx xxxx xxxx
305             case eWK_2:
306                 nRow &= 0x3FFF;
307                 break;
308             default:
309                 SAL_WARN( "sc.filter", "*LotusToSc::LotusRelToScRel(): unhandled case? " << m_rContext.eTyp );
310         }
311     }
312 
313     if( rSRD.IsRowRel() )
314         // #i36252# first cast unsigned 16-bit to signed 16-bit, and then to SCROW
315         rSRD.SetRelRow(static_cast<SCROW>(static_cast<sal_Int16>(nRow)));
316     else
317         rSRD.SetAbsRow(static_cast<SCROW>(nRow));
318 }
319 
ReadSRD(const ScDocument & rDoc,ScSingleRefData & rSRD,sal_uInt8 nRelBit)320 void LotusToSc::ReadSRD( const ScDocument& rDoc, ScSingleRefData& rSRD, sal_uInt8 nRelBit )
321 {
322     sal_uInt8           nTab, nCol;
323     sal_uInt16          nRow;
324 
325     Read( nRow );
326     Read( nTab );
327     Read( nCol );
328 
329     bool b3D = (static_cast<SCTAB>(nTab) != aEingPos.Tab());
330 
331     rSRD.SetColRel( ( nRelBit & 0x01 ) != 0 );
332     rSRD.SetRowRel( ( nRelBit & 0x02 ) != 0 );
333     rSRD.SetTabRel( ( ( nRelBit & 0x04) != 0 ) || !b3D );
334     rSRD.SetFlag3D( b3D );
335 
336     rSRD.SetAddress(rDoc.GetSheetLimits(), ScAddress(nCol, nRow, nTab), aEingPos);
337 }
338 
IncToken(TokenId & rParam)339 void LotusToSc::IncToken( TokenId &rParam )
340 {
341     aPool << ocOpen << rParam << nAddToken;
342     rParam = aPool.Store();
343 }
344 
DecToken(TokenId & rParam)345 void LotusToSc::DecToken( TokenId &rParam )
346 {
347     aPool << ocOpen << rParam << nSubToken;
348     rParam = aPool.Store();
349 }
350 
NegToken(TokenId & rParam)351 void LotusToSc::NegToken( TokenId &rParam )
352 {
353     aPool << ocNegSub << ocOpen << rParam << ocClose;
354     rParam = aPool.Store();
355 }
356 
Reset(const ScAddress & rEingPos)357 void LotusToSc::Reset( const ScAddress& rEingPos )
358 {
359     LotusConverterBase::Reset( rEingPos );
360 
361     TokenId nEins = aPool.Store( 1.0 );
362 
363     aPool << ocClose << ocAdd << nEins;
364     nAddToken = aPool.Store();
365 
366     aPool << ocClose << ocSub << nEins;
367     nSubToken = aPool.Store();
368 
369     n0Token = aPool.Store( 0.0 );
370 }
371 
LotusToSc(LotusContext & rContext,SvStream & rStream,svl::SharedStringPool & rSPool,rtl_TextEncoding e,bool b)372 LotusToSc::LotusToSc(LotusContext &rContext, SvStream &rStream, svl::SharedStringPool& rSPool,
373     rtl_TextEncoding e, bool b)
374     : LotusConverterBase(rStream, rSPool)
375     , m_rContext(rContext)
376 {
377     eSrcChar = e;
378     bWK3 = false;
379     bWK123 = b;
380 }
381 
382 typedef FUNC_TYPE ( FuncType1 ) ( sal_uInt8 );
383 typedef DefTokenId ( FuncType2 ) ( sal_uInt8 );
384 
Convert(std::unique_ptr<ScTokenArray> & rpErg,sal_Int32 & rRest)385 void LotusToSc::Convert( std::unique_ptr<ScTokenArray>& rpErg, sal_Int32& rRest )
386 {
387     sal_uInt8               nOc;
388     sal_uInt8               nCnt;
389     sal_uInt8               nRelBits;
390     sal_uInt16              nStrLen;
391     sal_uInt16              nRngIndex;
392     FUNC_TYPE           eType = FT_NOP;
393     TokenId             nBuf0;
394     DefTokenId          eOc;
395     const char*         pExtName = nullptr;
396     RangeNameBufferWK3& rRangeNameBufferWK3 = *m_rContext.pRngNmBffWK3;
397 
398     ScComplexRefData        aCRD;
399     aCRD.InitFlags();
400     ScSingleRefData&        rR = aCRD.Ref1;
401 
402     LR_ID               nId;
403     TokenId             nNewId;
404 
405     LotusRangeList&     rRangeList = m_rContext.maRangeNames;
406 
407     FuncType1*          pIndexToType;
408     FuncType2*          pIndexToToken;
409 
410     if( bWK3 )
411     {   // for > WK3
412         pIndexToType = IndexToTypeWK123;
413         pIndexToToken = IndexToTokenWK123;
414     }
415     else if( bWK123 )
416     {
417         pIndexToType = IndexToTypeWK123;
418         pIndexToToken = IndexToTokenWK123;
419     }
420     else
421     {
422         pIndexToType = IndexToType;
423         pIndexToToken = IndexToToken;
424 
425         rR.SetRelTab(0);
426         rR.SetFlag3D( false );
427     }
428 
429     aCRD.Ref2 = rR;
430 
431     nBytesLeft = rRest;
432 
433     while( eType )      // != FT_Return (==0)
434     {
435         Read( nOc );
436 
437         if( nBytesLeft < 0 )
438         {
439             rpErg = aPool.GetTokenArray(m_rContext.rDoc, aStack.Get());
440             return;
441         }
442 
443         eType = pIndexToType( nOc );
444         eOc   = pIndexToToken( nOc );
445         if( eOc == ocNoName )
446             pExtName = GetAddInName( nOc );
447 
448         switch( eType )
449         {
450             case FT_Return:
451                 if( bWK3 || bWK123 )
452                     nBytesLeft = 0; // not used for >= WK3
453 
454                 rRest = nBytesLeft;
455                 break;
456             case FT_NotImpl:
457             case FT_FuncFix0:   DoFunc( eOc, 0, pExtName ); break;
458             case FT_FuncFix1:   DoFunc( eOc, 1, pExtName ); break;
459             case FT_FuncFix2:   DoFunc( eOc, 2, pExtName ); break;
460             case FT_FuncFix3:   DoFunc( eOc, 3, pExtName ); break;
461             case FT_FuncFix4:   DoFunc( eOc, 4, pExtName ); break;
462                 case FT_FuncVar:
463                 Read( nCnt );
464                 DoFunc( eOc, nCnt, pExtName );
465                 break;
466             case FT_Neg:
467                 aPool << ocOpen << ocNegSub << aStack << ocClose;
468                 aPool >> aStack;
469                 break;
470             case FT_Op:
471                 aStack >> nBuf0;
472                 aPool << aStack << eOc << nBuf0;
473                 aPool >> aStack;
474                 break;
475             case FT_ConstFloat:
476             {
477                 double  fDouble;
478                 Read( fDouble );
479                 aStack << aPool.Store( fDouble );
480             }
481                 break;
482             case FT_Variable:
483             {
484                 sal_uInt16  nCol, nRow;
485                 Read( nCol );
486                 Read( nRow );
487 
488                 LotusRelToScRel( nCol, nRow, rR );
489 
490                 if( bWK3 )
491                     nNewId = aPool.Store( rR );
492                 else
493                 {
494                     nId = rRangeList.GetIndex(rR.Col(), rR.Row());
495 
496                     if( nId == ID_FAIL )
497                         // missing range
498                         nNewId = aPool.Store( rR );
499                     else
500                         nNewId = aPool.Store( static_cast<sal_uInt16>(nId) );
501                 }
502 
503                 aStack << nNewId;
504             }
505                 break;
506             case FT_Range:
507             {
508                 sal_uInt16  nColS, nRowS, nColE, nRowE;
509                 Read( nColS );
510                 Read( nRowS );
511                 Read( nColE );
512                 Read( nRowE );
513 
514                 LotusRelToScRel( nColS, nRowS, rR );
515                 LotusRelToScRel( nColE, nRowE, aCRD.Ref2 );
516 
517                 if( bWK3 )
518                     nNewId = aPool.Store( aCRD );
519                 else
520                 {
521                     nId = rRangeList.GetIndex(rR.Col(), rR.Row(), aCRD.Ref2.Col(), aCRD.Ref2.Row());
522 
523                     if( nId == ID_FAIL )
524                         // missing range
525                         nNewId = aPool.Store( aCRD );
526                     else
527                         nNewId = aPool.Store( static_cast<sal_uInt16>(nId) );
528                 }
529 
530                 aStack << nNewId;
531             }
532                 break;
533             case FT_Braces:
534                 aPool << ocOpen << aStack << ocClose;
535                 aPool >> aStack;
536                 break;
537             case FT_ConstInt:
538             {
539                 sal_Int16   nVal;
540                 Read( nVal );
541                 aStack << aPool.Store( static_cast<double>(nVal) );
542             }
543                 break;
544             case FT_ConstString:
545             {
546                 OUString  aTmp(ScfTools::read_zeroTerminated_uInt8s_ToOUString(aIn, nBytesLeft, eSrcChar));
547                 aStack << aPool.Store( aTmp );
548             }
549                 break;
550             case FT_NOP:
551                 break;
552             // for > WK3
553             case FT_Cref:
554                 Read( nRelBits );
555                 ReadSRD( m_rContext.rDoc, rR, nRelBits );
556                 aStack << aPool.Store( rR );
557                 break;
558             case FT_Rref:
559                 Read( nRelBits );
560                 ReadCRD( m_rContext.rDoc, aCRD, nRelBits );
561                 aStack << aPool.Store( aCRD );
562                 break;
563             case FT_Nrref:
564             {
565                 OUString  aTmp(ScfTools::read_zeroTerminated_uInt8s_ToOUString(aIn, nBytesLeft, eSrcChar));
566                 if( rRangeNameBufferWK3.FindRel( aTmp, nRngIndex ) )
567                     aStack << aPool.Store( nRngIndex );
568                 else
569             {
570                     OUString aText = "NRREF " + aTmp;
571                     aStack << aPool.Store( aText );
572             }
573             }
574                 break;
575             case FT_Absnref:
576             {
577                 OUString aTmp(ScfTools::read_zeroTerminated_uInt8s_ToOUString(aIn, nBytesLeft, eSrcChar));
578                 if( rRangeNameBufferWK3.FindAbs( aTmp, nRngIndex ) )
579                     aStack << aPool.Store( nRngIndex );
580                 else
581                 {
582                     OUString aText = "ABSNREF " + aTmp;
583                     aStack << aPool.Store( aText );
584                 }
585             }
586                 break;
587             case FT_Erref:
588                 Ignore( 4 );
589                 aPool << ocBad;
590                 aPool >> aStack;
591                 break;
592             case FT_Ecref:
593                 Ignore( 5 );
594                 aPool << ocBad;
595                 aPool >> aStack;
596                 break;
597             case FT_Econstant:
598                 Ignore( 10 );
599                 aPool << ocBad;
600                 aPool >> aStack;
601                 break;
602             case FT_Splfunc:
603             {
604                 Read( nCnt );
605                 Read( nStrLen );
606 
607                 const size_t nMaxEntries = aIn.remainingSize();
608                 if (nStrLen > nMaxEntries)
609                     nStrLen = nMaxEntries;
610 
611                 if( nStrLen )
612                 {
613                     std::unique_ptr<char[]> p(new (::std::nothrow) char[ nStrLen + 1 ]);
614                     if (p)
615                     {
616                         aIn.ReadBytes(p.get(), nStrLen);
617                         p[ nStrLen ] = 0x00;
618 
619                         DoFunc( ocNoName, nCnt, p.get() );
620                     }
621                     else
622                         DoFunc( ocNoName, nCnt, nullptr );
623                 }
624                 else
625                     DoFunc( ocNoName, nCnt, nullptr );
626             }
627                 break;
628             case FT_Const10Float:
629                     if ( bWK123 )
630                     {
631                             double fValue;
632                             Read( fValue );
633                             aStack << aPool.Store( fValue );
634                     }
635                     else aStack << aPool.Store( ScfTools::ReadLongDouble( aIn ) );
636                     break;
637             case FT_Snum:
638                 if ( bWK123 )
639                 {
640                      sal_uInt32   nValue;
641 
642                      Read( nValue );
643                      double  fValue = Snum32ToDouble( nValue );
644                      aStack << aPool.Store( fValue );
645                 }
646                 else
647                 {
648                         sal_Int16 nVal;
649                         Read( nVal );
650                         aStack << aPool.Store( SnumToDouble( nVal ) );
651                 }
652                 break;
653             default:
654                     SAL_WARN( "sc.filter", "*LotusToSc::Convert(): unknown enum!" );
655         }
656     }
657 
658     rpErg = aPool.GetTokenArray( m_rContext.rDoc, aStack.Get());
659 
660     SAL_WARN_IF( nBytesLeft < 0, "sc.filter", "*LotusToSc::Convert(): processed too much!");
661     SAL_WARN_IF( nBytesLeft > 0, "sc.filter", "*LotusToSc::Convert(): what happens with the rest?" );
662 
663     if( rRest )
664         aIn.SeekRel( nBytesLeft );  // Correct any remainder/overflow
665 
666     rRest = 0;
667 }
668 
IndexToType(sal_uInt8 nIndex)669 FUNC_TYPE LotusToSc::IndexToType( sal_uInt8 nIndex )
670 {
671     static const FUNC_TYPE pType[ 256 ] =
672     {                       // Code Description
673         FT_ConstFloat,      //    0 8-Byte-IEEE-Float
674         FT_Variable,        //    1 Variable
675         FT_Range,           //    2 Range
676         FT_Return,          //    3 return
677         FT_Braces,          //    4 Braces
678         FT_ConstInt,        //    5 2-Byte integer
679         FT_ConstString,     //    6 ASCII string
680         FT_NOP,             //    7 NOP
681         FT_Neg,             //    8 Negation
682         FT_Op,              //    9 Addition
683         FT_Op,              //   10 Subtraction
684         FT_Op,              //   11 Multiplication
685         FT_Op,              //   12 Division
686         FT_Op,              //   13 Power of
687         FT_Op,              //   14 equal
688         FT_Op,              //   15 unequal
689         FT_Op,              //   16 <=
690         FT_Op,              //   17 >=
691         FT_Op,              //   18 <
692         FT_Op,              //   19 >
693         FT_Op,              //   20 And (logic)
694         FT_Op,              //   21 Or (logic)
695         FT_FuncFix1,        //   22 Not (logic)
696         FT_NOP,             //   23 unary Plus
697         FT_NotImpl,         //   24
698         FT_NotImpl,         //   25
699         FT_NotImpl,         //   26
700         FT_NotImpl,         //   27
701         FT_NotImpl,         //   28
702         FT_NotImpl,         //   29
703         FT_NotImpl,         //   30
704         FT_FuncFix0,        //   31 Not applicable
705         FT_FuncFix0,        //   32 Error
706         FT_FuncFix1,        //   33 Absolute value ABS()
707         FT_FuncFix1,        //   34 Integer INT()
708         FT_FuncFix1,        //   35 Square Root
709         FT_FuncFix1,        //   36 Log10
710         FT_FuncFix1,        //   37 Natural Logarithm
711         FT_FuncFix0,        //   38 PI
712         FT_FuncFix1,        //   39 Sine
713         FT_FuncFix1,        //   40 Cosine
714         FT_FuncFix1,        //   41 Tangens
715         FT_FuncFix2,        //   42 Arctangens 2 (4.Quadrant) <- TODO: correct?
716         FT_FuncFix1,        //   43 Arctangens (2.Quadrant)
717         FT_FuncFix1,        //   44 Arcsine
718         FT_FuncFix1,        //   45 Arccosine
719         FT_FuncFix1,        //   46 Exponential function
720         FT_FuncFix2,        //   47 Modulo
721         FT_FuncVar,         //   48 Selection
722         FT_FuncFix1,        //   49 Is not applicable?
723         FT_FuncFix1,        //   50 Is Error?
724         FT_FuncFix0,        //   51 FALSE
725         FT_FuncFix0,        //   52 TRUE
726         FT_FuncFix0,        //   53 Random number
727         FT_FuncFix3,        //   54 Date
728         FT_FuncFix0,        //   55 Today
729         FT_FuncFix3,        //   56 Payment
730         FT_FuncFix3,        //   57 Present Value
731         FT_FuncFix3,        //   58 Future Value
732         FT_FuncFix3,        //   59 If ... then ... else ...
733         FT_FuncFix1,        //   60 Day of month
734         FT_FuncFix1,        //   61 Month
735         FT_FuncFix1,        //   62 Year
736         FT_FuncFix2,        //   63 Round
737         FT_FuncFix3,        //   64 Time
738         FT_FuncFix1,        //   65 Hour
739         FT_FuncFix1,        //   66 Minute
740         FT_FuncFix1,        //   67 Second
741         FT_FuncFix1,        //   68 Is Number?
742         FT_FuncFix1,        //   69 Is Text?
743         FT_FuncFix1,        //   70 Len()
744         FT_FuncFix1,        //   71 Val()
745         FT_FuncFix2,        //   72 String()
746         FT_FuncFix3,        //   73 Mid()
747         FT_FuncFix1,        //   74 Char()
748         FT_FuncFix1,        //   75 Ascii()
749         FT_FuncFix3,        //   76 Find()
750         FT_FuncFix1,        //   77 Datevalue
751         FT_FuncFix1,        //   78 Timevalue
752         FT_FuncFix1,        //   79 Cellpointer
753         FT_FuncVar,         //   80 Sum()
754         FT_FuncVar,         //   81 Avg()
755         FT_FuncVar,         //   82 Cnt()
756         FT_FuncVar,         //   83 Min()
757         FT_FuncVar,         //   84 Max()
758         FT_FuncFix3,        //   85 Vlookup()
759         FT_FuncFix2,        //   86 Npv()
760         FT_FuncVar,         //   87 Var()
761         FT_FuncVar,         //   88 Std()
762         FT_FuncFix2,        //   89 Irr()
763         FT_FuncFix3,        //   90 Hlookup()
764         FT_FuncFix3,        //   91 ?
765         FT_FuncFix3,        //   92 ?
766         FT_FuncFix3,        //   93 ?
767         FT_FuncFix3,        //   94 ?
768         FT_FuncFix3,        //   95 ?
769         FT_FuncFix3,        //   96 ?
770         FT_FuncFix3,        //   97 ?
771         FT_FuncFix3,        //   98 Index() <- TODO: correct?
772         FT_FuncFix1,        //   99 Columns()
773         FT_FuncFix1,        //  100 Rows()
774         FT_FuncFix2,        //  101 Repeat()
775         FT_FuncFix1,        //  102 Upper()
776         FT_FuncFix1,        //  103 Lower()
777         FT_FuncFix2,        //  104 Left()
778         FT_FuncFix2,        //  105 Right()
779         FT_FuncFix4,        //  106 Replace()
780         FT_FuncFix1,        //  107 Proper()
781         FT_FuncFix2,        //  108 Cell()
782         FT_FuncFix1,        //  109 Trim()
783         FT_FuncFix1,        //  110 Clean()
784         FT_FuncFix1,        //  111 F()
785         FT_FuncFix1,        //  112 W()
786         FT_FuncFix2,        //  113 Exact()
787         FT_NotImpl,         //  114 Call()
788         FT_FuncFix1,        //  115 @@()
789         FT_FuncFix3,        //  116 Rate()
790         FT_FuncFix3,        //  117 Term()
791         FT_FuncFix3,        //  118 Cterm()
792         FT_FuncFix3,        //  119 Sln()
793         FT_FuncFix4,        //  120 Syd(), Soy()
794         FT_FuncFix4,        //  121 Ddb()
795         FT_NotImpl,         //  122
796         FT_NotImpl,         //  123
797         FT_NotImpl,         //  124
798         FT_NotImpl,         //  125
799         FT_NotImpl,         //  126
800         FT_NotImpl,         //  127
801         FT_NotImpl,         //  128
802         FT_NotImpl,         //  129
803         FT_NotImpl,         //  130
804         FT_NotImpl,         //  131
805         FT_NotImpl,         //  132
806         FT_NotImpl,         //  133
807         FT_NotImpl,         //  134
808         FT_NotImpl,         //  135
809         FT_NotImpl,         //  136
810         FT_NotImpl,         //  137
811         FT_NotImpl,         //  138
812         FT_NotImpl,         //  139
813         FT_NotImpl,         //  140
814         FT_NotImpl,         //  141
815         FT_NotImpl,         //  142
816         FT_NotImpl,         //  143
817         FT_NotImpl,         //  144
818         FT_NotImpl,         //  145
819         FT_NotImpl,         //  146
820         FT_NotImpl,         //  147
821         FT_NotImpl,         //  148
822         FT_NotImpl,         //  149
823         FT_NotImpl,         //  150
824         FT_NotImpl,         //  151
825         FT_NotImpl,         //  152
826         FT_NotImpl,         //  153
827         FT_NotImpl,         //  154
828         FT_NotImpl,         //  155
829         FT_FuncVar,         //  156 TODO: ?
830         FT_NotImpl,         //  157
831         FT_NotImpl,         //  158
832         FT_NotImpl,         //  159
833         FT_NotImpl,         //  160
834         FT_NotImpl,         //  161
835         FT_NotImpl,         //  162
836         FT_NotImpl,         //  163
837         FT_NotImpl,         //  164
838         FT_NotImpl,         //  165
839         FT_NotImpl,         //  166
840         FT_NotImpl,         //  167
841         FT_NotImpl,         //  168
842         FT_NotImpl,         //  169
843         FT_NotImpl,         //  170
844         FT_NotImpl,         //  171
845         FT_NotImpl,         //  172
846         FT_NotImpl,         //  173
847         FT_NotImpl,         //  174
848         FT_NotImpl,         //  175
849         FT_NotImpl,         //  176
850         FT_NotImpl,         //  177
851         FT_NotImpl,         //  178
852         FT_NotImpl,         //  179
853         FT_NotImpl,         //  180
854         FT_NotImpl,         //  181
855         FT_NotImpl,         //  182
856         FT_NotImpl,         //  183
857         FT_NotImpl,         //  184
858         FT_NotImpl,         //  185
859         FT_NotImpl,         //  186
860         FT_NotImpl,         //  187
861         FT_NotImpl,         //  188
862         FT_NotImpl,         //  189
863         FT_NotImpl,         //  190
864         FT_NotImpl,         //  191
865         FT_NotImpl,         //  192
866         FT_NotImpl,         //  193
867         FT_NotImpl,         //  194
868         FT_NotImpl,         //  195
869         FT_NotImpl,         //  196
870         FT_NotImpl,         //  197
871         FT_NotImpl,         //  198
872         FT_NotImpl,         //  199
873         FT_NotImpl,         //  200
874         FT_NotImpl,         //  201
875         FT_NotImpl,         //  202
876         FT_NotImpl,         //  203
877         FT_NotImpl,         //  204
878         FT_NotImpl,         //  205
879         FT_FuncVar,         //  206 TODO: ?
880         FT_NotImpl,         //  207
881         FT_NotImpl,         //  208
882         FT_NotImpl,         //  209
883         FT_NotImpl,         //  210
884         FT_NotImpl,         //  211
885         FT_NotImpl,         //  212
886         FT_NotImpl,         //  213
887         FT_NotImpl,         //  214
888         FT_NotImpl,         //  215
889         FT_NotImpl,         //  216
890         FT_NotImpl,         //  217
891         FT_NotImpl,         //  218
892         FT_NotImpl,         //  219
893         FT_NotImpl,         //  220
894         FT_NotImpl,         //  221
895         FT_NotImpl,         //  222
896         FT_NotImpl,         //  223
897         FT_NotImpl,         //  224
898         FT_NotImpl,         //  225
899         FT_NotImpl,         //  226
900         FT_NotImpl,         //  227
901         FT_NotImpl,         //  228
902         FT_NotImpl,         //  229
903         FT_NotImpl,         //  230
904         FT_NotImpl,         //  231
905         FT_NotImpl,         //  232
906         FT_NotImpl,         //  233
907         FT_NotImpl,         //  234
908         FT_NotImpl,         //  235
909         FT_NotImpl,         //  236
910         FT_NotImpl,         //  237
911         FT_NotImpl,         //  238
912         FT_NotImpl,         //  239
913         FT_NotImpl,         //  240
914         FT_NotImpl,         //  241
915         FT_NotImpl,         //  242
916         FT_NotImpl,         //  243
917         FT_NotImpl,         //  244
918         FT_NotImpl,         //  245
919         FT_NotImpl,         //  246
920         FT_NotImpl,         //  247
921         FT_NotImpl,         //  248
922         FT_NotImpl,         //  249
923         FT_NotImpl,         //  250
924         FT_NotImpl,         //  251
925         FT_NotImpl,         //  252
926         FT_NotImpl,         //  253
927         FT_NotImpl,         //  254
928         FT_FuncVar,         //  255 TODO: ?
929     };
930     return pType[ nIndex ];
931 }
932 
IndexToToken(sal_uInt8 nIndex)933 DefTokenId LotusToSc::IndexToToken( sal_uInt8 nIndex )
934 {
935     static const DefTokenId pToken[ 256 ] =
936     {                       // Code Description
937         ocPush,             //    0 8-Byte-IEEE-Float
938         ocPush,             //    1 Variable
939         ocPush,             //    2 Range
940         ocPush,             //    3 return
941         ocPush,             //    4 Braces
942         ocPush,             //    5 2-Byte integer
943         ocPush,             //    6 ASCII string
944         ocPush,             //    7 NOP
945         ocNegSub,           //    8 Negation
946         ocAdd,              //    9 Addition
947         ocSub,              //   10 Subtraction
948         ocMul,              //   11 Multiplication
949         ocDiv,              //   12 Division
950         ocPow,              //   13 Power of
951         ocEqual,            //   14 equal
952         ocNotEqual,         //   15 unequal
953         ocLessEqual,        //   16 <=
954         ocGreaterEqual,     //   17 >=
955         ocLess,             //   18 <
956         ocGreater,          //   19 >
957         ocAnd,              //   20 And (logic)
958         ocOr,               //   21 Or (logic)
959         ocNot,              //   22 Not (logic)
960         ocPush,             //   23 unary Plus
961         ocNoName,           //   24
962         ocNoName,           //   25
963         ocNoName,           //   26
964         ocNoName,           //   27
965         ocNoName,           //   28
966         ocNoName,           //   29
967         ocNoName,           //   30
968         ocNotAvail,         //   31 Not available
969         ocNoName,           //   32 Error
970         ocAbs,              //   33 Absolute value ABS()
971         ocInt,              //   34 Integer INT()
972         ocSqrt,             //   35 Square Root
973         ocLog10,            //   36 Log10
974         ocLn,               //   37 Natural Logarithm
975         ocPi,               //   38 PI
976         ocSin,              //   39 Sine
977         ocCos,              //   40 Cosine
978         ocTan,              //   41 Tangens
979         ocArcTan2,          //   42 Arctangens 2 (4.Quadrant)
980         ocArcTan,           //   43 Arctangens (2.Quadrant)
981         ocArcSin,           //   44 Arcsine
982         ocArcCos,           //   45 Arccosine
983         ocExp,              //   46 Exponential function
984         ocMod,              //   47 Modulo
985         ocChoose,           //   48 Selection
986         ocIsNA,             //   49 Is not available?
987         ocIsError,          //   50 Is Error?
988         ocFalse,            //   51 FALSE
989         ocTrue,             //   52 TRUE
990         ocRandom,           //   53 Random number
991         ocGetDate,          //   54 Date
992         ocGetActDate,       //   55 Today
993         ocPMT,              //   56 Payment
994         ocPV,               //   57 Present Value
995         ocFV,               //   58 Future Value
996         ocIf,               //   59 If ... then ... else ...
997         ocGetDay,           //   60 Day of month
998         ocGetMonth,         //   61 Month
999         ocGetYear,          //   62 Year
1000         ocRound,            //   63 Round
1001         ocGetTime,          //   64 Time
1002         ocGetHour,          //   65 Hour
1003         ocGetMin,           //   66 Minute
1004         ocGetSec,           //   67 Second
1005         ocIsValue,          //   68 Is Number?
1006         ocIsString,         //   69 Is Text?
1007         ocLen,              //   70 Len()
1008         ocValue,            //   71 Val()
1009         ocFixed,            //   72 String()    ocFixed replacement + special case
1010         ocMid,              //   73 Mid()
1011         ocChar,             //   74 Char()
1012         ocCode,             //   75 Ascii()
1013         ocFind,             //   76 Find()
1014         ocGetDateValue,     //   77 Datevalue
1015         ocGetTimeValue,     //   78 Timevalue
1016         ocNoName,           //   79 Cellpointer
1017         ocSum,              //   80 Sum()
1018         ocAverageA,         //   81 Avg()
1019         ocCount2,           //   82 Cnt()
1020         ocMinA,             //   83 Min()
1021         ocMaxA,             //   84 Max()
1022         ocVLookup,          //   85 Vlookup()
1023         ocNPV,              //   86 Npv()
1024         ocVarPA,            //   87 Var()
1025         ocStDevPA,          //   88 Std()
1026         ocIRR,              //   89 Irr()
1027         ocHLookup,          //   90 Hlookup()
1028         ocDBSum,            //   91 XlfDsum
1029         ocDBAverage,        //   92 XlfDaverage
1030         ocDBCount2,         //   93 XlfDcount
1031         ocDBMin,            //   94 XlfDmin
1032         ocDBMax,            //   95 XlfDmax
1033         ocDBVarP,           //   96 XlfDvar
1034         ocDBStdDevP,        //   97 XlfDstdev
1035         ocIndex,            //   98 Index()
1036         ocColumns,          //   99 Columns()
1037         ocRows,             //  100 Rows()
1038         ocRept,             //  101 Repeat()
1039         ocUpper,            //  102 Upper()
1040         ocLower,            //  103 Lower()
1041         ocLeft,             //  104 Left()
1042         ocRight,            //  105 Right()
1043         ocReplace,          //  106 Replace()
1044         ocProper,           //  107 Proper()
1045         ocNoName,           //  108 Cell()
1046         ocTrim,             //  109 Trim()
1047         ocClean,            //  110 Clean()
1048         ocFalse,            //  111 F()
1049         ocTrue,             //  112 W()
1050         ocExact,            //  113 Exact()
1051         ocNoName,           //  114 Call()
1052         ocIndirect,         //  115 @@()
1053         ocRate,             //  116 Rate()
1054         ocNoName,           //  117 Term()
1055         ocNoName,           //  118 Cterm()
1056         ocSLN,              //  119 Sln()
1057         ocSYD,              //  120 Syd(), Soy()
1058         ocDDB,              //  121 Ddb()
1059         ocNoName,           //  122
1060         ocNoName,           //  123
1061         ocNoName,           //  124
1062         ocNoName,           //  125
1063         ocNoName,           //  126
1064         ocNoName,           //  127
1065         ocNoName,           //  128
1066         ocNoName,           //  129
1067         ocNoName,           //  130
1068         ocNoName,           //  131
1069         ocNoName,           //  132
1070         ocNoName,           //  133
1071         ocNoName,           //  134
1072         ocNoName,           //  135
1073         ocNoName,           //  136
1074         ocNoName,           //  137
1075         ocNoName,           //  138
1076         ocNoName,           //  139
1077         ocNoName,           //  140
1078         ocNoName,           //  141
1079         ocNoName,           //  142
1080         ocNoName,           //  143
1081         ocNoName,           //  144
1082         ocNoName,           //  145
1083         ocNoName,           //  146
1084         ocNoName,           //  147
1085         ocNoName,           //  148
1086         ocNoName,           //  149
1087         ocNoName,           //  150
1088         ocNoName,           //  151
1089         ocNoName,           //  152
1090         ocNoName,           //  153
1091         ocNoName,           //  154
1092         ocNoName,           //  155
1093         ocNoName,           //  156 TODO: ?
1094         ocNoName,           //  157
1095         ocNoName,           //  158
1096         ocNoName,           //  159
1097         ocNoName,           //  160
1098         ocNoName,           //  161
1099         ocNoName,           //  162
1100         ocNoName,           //  163
1101         ocNoName,           //  164
1102         ocNoName,           //  165
1103         ocNoName,           //  166
1104         ocNoName,           //  167
1105         ocNoName,           //  168
1106         ocNoName,           //  169
1107         ocNoName,           //  170
1108         ocNoName,           //  171
1109         ocNoName,           //  172
1110         ocNoName,           //  173
1111         ocNoName,           //  174
1112         ocNoName,           //  175
1113         ocNoName,           //  176
1114         ocNoName,           //  177
1115         ocNoName,           //  178
1116         ocNoName,           //  179
1117         ocNoName,           //  180
1118         ocNoName,           //  181
1119         ocNoName,           //  182
1120         ocNoName,           //  183
1121         ocNoName,           //  184
1122         ocNoName,           //  185
1123         ocNoName,           //  186
1124         ocNoName,           //  187
1125         ocNoName,           //  188
1126         ocNoName,           //  189
1127         ocNoName,           //  190
1128         ocNoName,           //  191
1129         ocNoName,           //  192
1130         ocNoName,           //  193
1131         ocNoName,           //  194
1132         ocNoName,           //  195
1133         ocNoName,           //  196
1134         ocNoName,           //  197
1135         ocNoName,           //  198
1136         ocNoName,           //  199
1137         ocNoName,           //  200
1138         ocNoName,           //  201
1139         ocNoName,           //  202
1140         ocNoName,           //  203
1141         ocNoName,           //  204
1142         ocNoName,           //  205
1143         ocNoName,           //  206 TODO: ?
1144         ocNoName,           //  207
1145         ocNoName,           //  208
1146         ocNoName,           //  209
1147         ocNoName,           //  210
1148         ocNoName,           //  211
1149         ocNoName,           //  212
1150         ocNoName,           //  213
1151         ocNoName,           //  214
1152         ocNoName,           //  215
1153         ocNoName,           //  216
1154         ocNoName,           //  217
1155         ocNoName,           //  218
1156         ocNoName,           //  219
1157         ocNoName,           //  220
1158         ocNoName,           //  221
1159         ocNoName,           //  222
1160         ocNoName,           //  223
1161         ocNoName,           //  224
1162         ocNoName,           //  225
1163         ocNoName,           //  226
1164         ocNoName,           //  227
1165         ocNoName,           //  228
1166         ocNoName,           //  229
1167         ocNoName,           //  230
1168         ocNoName,           //  231
1169         ocNoName,           //  232
1170         ocNoName,           //  233
1171         ocNoName,           //  234
1172         ocNoName,           //  235
1173         ocNoName,           //  236
1174         ocNoName,           //  237
1175         ocNoName,           //  238
1176         ocNoName,           //  239
1177         ocNoName,           //  240
1178         ocNoName,           //  241
1179         ocNoName,           //  242
1180         ocNoName,           //  243
1181         ocNoName,           //  244
1182         ocNoName,           //  245
1183         ocNoName,           //  246
1184         ocNoName,           //  247
1185         ocNoName,           //  248
1186         ocNoName,           //  249
1187         ocNoName,           //  250
1188         ocNoName,           //  251
1189         ocNoName,           //  252
1190         ocNoName,           //  253
1191         ocNoName,           //  254
1192         ocNoName            //  255 TODO: ?
1193     };
1194 
1195     return pToken[ nIndex ];
1196 }
1197 
IndexToTypeWK123(sal_uInt8 nIndex)1198 FUNC_TYPE LotusToSc::IndexToTypeWK123( sal_uInt8 nIndex )
1199 {
1200     static const FUNC_TYPE pType[ 256 ] =
1201     {                       // Code Description
1202         FT_Const10Float,    //    0 8-Byte-IEEE-Long-Number
1203         FT_Cref,            //    1 Cell Reference
1204         FT_Rref,            //    2 Area Reference
1205         FT_Return,          //    3 return
1206         FT_Braces,          //    4 Braces
1207         FT_Snum,            //    5 Short number
1208         FT_ConstString,     //    6 ASCII string
1209         FT_Nrref,           //    7 Named range reference
1210         FT_Absnref,         //    8 Absolute named range
1211         FT_Erref,           //    9 Err range reference
1212         FT_Ecref,           //   10 Err cell reference
1213         FT_Econstant,       //   11 Err constant
1214         FT_NotImpl,         //   12
1215         FT_NotImpl,         //   13
1216         FT_Neg,             //   14 Negation
1217         FT_Op,              //   15 Addition
1218         FT_Op,              //   16 Subtraction
1219         FT_Op,              //   17 Multiplication
1220         FT_Op,              //   18 Division
1221         FT_Op,              //   19 Power of
1222         FT_Op,              //   20 equal
1223         FT_Op,              //   21 unequal
1224         FT_Op,              //   22 <=
1225         FT_Op,              //   23 >=
1226         FT_Op,              //   24 <
1227         FT_Op,              //   25 >
1228         FT_Op,              //   26 And (logical)
1229         FT_Op,              //   27 Or (logical)
1230         FT_FuncFix1,        //   28 Not (logical)
1231         FT_NOP,             //   29 unary plus
1232         FT_Op,              //   30 Concatenation
1233         FT_FuncFix0,        //   31 Not applicable
1234         FT_FuncFix0,        //   32 Error
1235         FT_FuncFix1,        //   33 Absolute value ABS()
1236         FT_FuncFix1,        //   34 Integer INT()
1237         FT_FuncFix1,        //   35 Square root
1238         FT_FuncFix1,        //   36 Log10
1239         FT_FuncFix1,        //   37 Natural Logarithm
1240         FT_FuncFix0,        //   38 PI
1241         FT_FuncFix1,        //   39 Sine
1242         FT_FuncFix1,        //   40 Cosine
1243         FT_FuncFix1,        //   41 Tangens
1244         FT_FuncFix2,        //   42 Arctangens 2 (4.Quadrant)
1245         FT_FuncFix1,        //   43 Arctangens (2.Quadrant)
1246         FT_FuncFix1,        //   44 Arcsine
1247         FT_FuncFix1,        //   45 Arccosine
1248         FT_FuncFix1,        //   46 Exponential function
1249         FT_FuncFix2,        //   47 Modulo
1250         FT_FuncVar,         //   48 Selection
1251         FT_FuncFix1,        //   49 Is not applicable?
1252         FT_FuncFix1,        //   50 Is Error?
1253         FT_FuncFix0,        //   51 FALSE
1254         FT_FuncFix0,        //   52 TRUE
1255         FT_FuncFix0,        //   53 Random number
1256         FT_FuncFix3,        //   54 Date
1257         FT_FuncFix0,        //   55 Today
1258         FT_FuncFix3,        //   56 Payment
1259         FT_FuncFix3,        //   57 Present Value
1260         FT_FuncFix3,        //   58 Future Value
1261         FT_FuncFix3,        //   59 If ... then ... else ...
1262         FT_FuncFix1,        //   60 Day of Month
1263         FT_FuncFix1,        //   61 Month
1264         FT_FuncFix1,        //   62 Year
1265         FT_FuncFix2,        //   63 Round
1266         FT_FuncFix3,        //   64 Time
1267         FT_FuncFix1,        //   65 Hour
1268         FT_FuncFix1,        //   66 Minute
1269         FT_FuncFix1,        //   67 Second
1270         FT_FuncFix1,        //   68 Is Number?
1271         FT_FuncFix1,        //   69 Is Text?
1272         FT_FuncFix1,        //   70 Len()
1273         FT_FuncFix1,        //   71 Val()
1274         FT_FuncFix2,        //   72 String()
1275         FT_FuncFix3,        //   73 Mid()
1276         FT_FuncFix1,        //   74 Char()
1277         FT_FuncFix1,        //   75 Ascii()
1278         FT_FuncFix3,        //   76 Find()
1279         FT_FuncFix1,        //   77 Datevalue
1280         FT_FuncFix1,        //   78 Timevalue
1281         FT_FuncFix1,        //   79 Cellpointer
1282         FT_FuncVar,         //   80 Sum()
1283         FT_FuncVar,         //   81 Avg()
1284         FT_FuncVar,         //   82 Cnt()
1285         FT_FuncVar,         //   83 Min()
1286         FT_FuncVar,         //   84 Max()
1287         FT_FuncFix3,        //   85 Vlookup()
1288         FT_FuncFix2,        //   86 Npv()
1289         FT_FuncVar,         //   87 Var()
1290         FT_FuncVar,         //   88 Std()
1291         FT_FuncFix2,        //   89 Irr()
1292         FT_FuncFix3,        //   90 Hlookup()
1293         FT_FuncVar,         //   91 Dsum                 <- new
1294         FT_FuncVar,         //   92 Davg                 <- new
1295         FT_FuncVar,         //   93 Dcnt                 <- new
1296         FT_FuncVar,         //   94 Dmin                 <- new
1297         FT_FuncVar,         //   95 Dmax                 <- new
1298         FT_FuncVar,         //   96 Dvar                 <- new
1299         FT_FuncVar,         //   97 Dstd                 <- new
1300         FT_FuncVar,         //   98 Index()              <- change!
1301         FT_FuncFix1,        //   99 Columns()             <- new
1302         FT_FuncFix1,        //  100 Rows()               <- new
1303         FT_FuncFix2,        //  101 Repeat()             <- new
1304         FT_FuncFix1,        //  102 Upper()              <- new
1305         FT_FuncFix1,        //  103 Lower()              <- new
1306         FT_FuncFix2,        //  104 Left()               <- new
1307         FT_FuncFix2,        //  105 Right()              <- new
1308         FT_FuncFix4,        //  106 Replace()            <- new
1309         FT_FuncFix1,        //  107 Proper()             <- new
1310         FT_FuncFix2,        //  108 Cell()               <- new
1311         FT_FuncFix1,        //  109 Trim()               <- new
1312         FT_FuncFix1,        //  110 Clean()              <- new
1313         FT_FuncFix1,        //  111 S()                  <- change in name
1314         FT_FuncFix1,        //  112 N()                  <- change in name
1315         FT_FuncFix2,        //  113 Exact()              <- new
1316         FT_NotImpl,         //  114 App                  <- change in name
1317         FT_FuncFix1,        //  115 @@()                 <- new
1318         FT_FuncFix3,        //  116 Rate()               <- new
1319         FT_FuncFix3,        //  117 Term()
1320         FT_FuncFix3,        //  118 Cterm()
1321         FT_FuncFix3,        //  119 Sln()                <- new
1322         FT_FuncFix4,        //  120 Syd()                <- new
1323         FT_FuncFix4,        //  121 Ddb()                <- new
1324         FT_Splfunc,         //  122 Splfunc              <- new
1325         FT_FuncFix1,        //  123 Sheets               <- new
1326         FT_FuncFix1,        //  124 Info                 <- new
1327         FT_FuncVar,         //  125 Sumproduct           <- new
1328         FT_FuncFix1,        //  126 Isrange              <- new
1329         FT_FuncVar,         //  127 Dget                 <- new
1330         FT_FuncVar,         //  128 Dquery               <- new
1331         FT_FuncFix4,        //  129 Coord                <- new
1332         FT_NOP,             //  130 Reserved (internal)  <- new
1333         FT_FuncFix0,        //  131 Today                <- new
1334         FT_FuncVar,         //  132 Vdb                  <- new
1335         FT_FuncVar,         //  133 Dvars                <- new
1336         FT_FuncVar,         //  134 Dstds                <- new
1337         FT_FuncVar,         //  135 Vars                 <- new
1338         FT_FuncVar,         //  136 Stds                 <- new
1339         FT_FuncFix2,        //  137 D360                 <- new
1340         FT_NOP,             //  138 Reserved (internal)  <- new
1341         FT_FuncFix0,        //  139 Isapp                <- new quantity ?
1342         FT_FuncVar,         //  140 Isaaf                <- new quantity ?
1343         FT_FuncFix1,        //  141 Weekday              <- new
1344         FT_FuncFix3,        //  142 Datedif              <- new
1345         FT_FuncVar,         //  143 Rank                 <- new
1346         FT_FuncFix2,        //  144 Numberstring         <- new
1347         FT_FuncFix1,        //  145 Datestring           <- new
1348         FT_FuncFix1,        //  146 Decimal              <- new
1349         FT_FuncFix1,        //  147 Hex                  <- new
1350         FT_FuncFix4,        //  148 Db                   <- new
1351         FT_FuncFix4,        //  149 Pmti                 <- new
1352         FT_FuncFix4,        //  150 Spi                  <- new
1353         FT_FuncFix1,        //  151 Fullp                <- new
1354         FT_FuncFix1,        //  152 Halfp                <- new
1355         FT_FuncVar,         //  153 Pureavg              <- new
1356         FT_FuncVar,         //  154 Purecount            <- new
1357         FT_FuncVar,         //  155 Puremax              <- new
1358         FT_FuncVar,         //  156 Puremin              <- new
1359         FT_FuncVar,         //  157 Purestd              <- new
1360         FT_FuncVar,         //  158 Purevar              <- new
1361         FT_FuncVar,         //  159 Purestds             <- new
1362         FT_FuncVar,         //  160 Purevars             <- new
1363         FT_FuncFix3,        //  161 Pmt2                 <- new
1364         FT_FuncFix3,        //  162 Pv2                  <- new
1365         FT_FuncFix3,        //  163 Fv2                  <- new
1366         FT_FuncFix3,        //  164 Term2                <- new
1367         FT_NotImpl,         //  165--                    <- new quantity ?
1368         FT_FuncFix2,        //  166 D360 (US-Version)
1369         FT_NotImpl,         //  167
1370         FT_NotImpl,         //  168
1371         FT_NotImpl,         //  169
1372         FT_NotImpl,         //  170
1373         FT_NotImpl,         //  171
1374         FT_NotImpl,         //  172
1375         FT_NotImpl,         //  173
1376         FT_NotImpl,         //  174
1377         FT_NotImpl,         //  175
1378         FT_NotImpl,         //  176
1379         FT_NotImpl,         //  177
1380         FT_NotImpl,         //  178
1381         FT_NotImpl,         //  179
1382         FT_NotImpl,         //  180
1383         FT_NotImpl,         //  181
1384         FT_NotImpl,         //  182
1385         FT_NotImpl,         //  183
1386         FT_NotImpl,         //  184
1387         FT_NotImpl,         //  185
1388         FT_FuncVar,         //  186 Solver               <- new
1389         FT_NotImpl,         //  187
1390         FT_NotImpl,         //  188
1391         FT_NotImpl,         //  189
1392         FT_NotImpl,         //  190
1393         FT_NotImpl,         //  191
1394         FT_NotImpl,         //  192
1395         FT_NotImpl,         //  193
1396         FT_NotImpl,         //  194
1397         FT_NotImpl,         //  195
1398         FT_NotImpl,         //  196
1399         FT_NotImpl,         //  197
1400         FT_NotImpl,         //  198
1401         FT_NotImpl,         //  199
1402         FT_NotImpl,         //  200
1403         FT_NotImpl,         //  201
1404         FT_NotImpl,         //  202
1405         FT_NotImpl,         //  203
1406         FT_NotImpl,         //  204
1407         FT_NotImpl,         //  205
1408         FT_NotImpl,         //  206
1409         FT_NotImpl,         //  207
1410         FT_NotImpl,         //  208
1411         FT_NotImpl,         //  209
1412         FT_NotImpl,         //  210
1413         FT_NotImpl,         //  211
1414         FT_NotImpl,         //  212
1415         FT_NotImpl,         //  213
1416         FT_NotImpl,         //  214
1417         FT_NotImpl,         //  215
1418         FT_NotImpl,         //  216
1419         FT_NotImpl,         //  217
1420         FT_NotImpl,         //  218
1421         FT_NotImpl,         //  219
1422         FT_NotImpl,         //  220
1423         FT_NotImpl,         //  221
1424         FT_NotImpl,         //  222
1425         FT_NotImpl,         //  223
1426         FT_NotImpl,         //  224
1427         FT_NotImpl,         //  225
1428         FT_NotImpl,         //  226
1429         FT_NotImpl,         //  227
1430         FT_NotImpl,         //  228
1431         FT_NotImpl,         //  229
1432         FT_NotImpl,         //  230
1433         FT_NotImpl,         //  231
1434         FT_NotImpl,         //  232
1435         FT_NotImpl,         //  233
1436         FT_NotImpl,         //  234
1437         FT_NotImpl,         //  235
1438         FT_NotImpl,         //  236
1439         FT_NotImpl,         //  237
1440         FT_NotImpl,         //  238
1441         FT_NotImpl,         //  239
1442         FT_NotImpl,         //  240
1443         FT_NotImpl,         //  241
1444         FT_NotImpl,         //  242
1445         FT_NotImpl,         //  243
1446         FT_NotImpl,         //  244
1447         FT_NotImpl,         //  245
1448         FT_NotImpl,         //  246
1449         FT_NotImpl,         //  247
1450         FT_NotImpl,         //  248
1451         FT_NotImpl,         //  249
1452         FT_NotImpl,         //  250
1453         FT_NotImpl,         //  251
1454         FT_NotImpl,         //  252
1455         FT_NotImpl,         //  253
1456         FT_NotImpl,         //  254
1457         FT_NotImpl,         //  255
1458     };
1459     return pType[ nIndex ];
1460 }
1461 
IndexToTokenWK123(sal_uInt8 nIndex)1462 DefTokenId LotusToSc::IndexToTokenWK123( sal_uInt8 nIndex )
1463 {
1464     static const DefTokenId pToken[ 256 ] =
1465     {                       // Code Description
1466         ocPush,             //    0 8-Byte-IEEE-Long-Numbers
1467         ocPush,             //    1 Variable
1468         ocPush,             //    2 Range
1469         ocPush,             //    3 return
1470         ocPush,             //    4 Braces
1471         ocPush,             //    5 Numbers
1472         ocPush,             //    6 ASCII string
1473         ocPush,             //    7 Named range reference
1474         ocPush,             //    8 Absolute named range
1475         ocPush,             //    9 Err range reference
1476         ocPush,             //   10 Err cell reference
1477         ocPush,             //   11 Err constant
1478         ocPush,             //   12
1479         ocPush,             //   13
1480         ocNegSub,           //   14 Negation
1481         ocAdd,              //   15 Addition
1482         ocSub,              //   16 Subtraction
1483         ocMul,              //   17 Multiplication
1484         ocDiv,              //   18 Division
1485         ocPow,              //   19 Power of
1486         ocEqual,            //   20 Equality
1487         ocNotEqual,         //   21 Inequality
1488         ocLessEqual,        //   22 <=
1489         ocGreaterEqual,     //   23 >=
1490         ocLess,             //   24 <
1491         ocGreater,          //   25 >
1492         ocAnd,              //   26 And (logic)
1493         ocOr,               //   27 Or (logic)
1494         ocNot,              //   28 Not (logic)
1495         ocPush,             //   29 unary Plus
1496         ocAmpersand,        //   30 Concatenation
1497         ocNotAvail,         //   31 Not available
1498         ocNoName,           //   32 Error
1499         ocAbs,              //   33 Absolute Value ABS()
1500         ocInt,              //   34 Integer INT()
1501         ocSqrt,             //   35 Square Root
1502         ocLog10,            //   36 log10
1503         ocLn,               //   37 Natural logarithm
1504         ocPi,               //   38 Pi
1505         ocSin,              //   39 Sine
1506         ocCos,              //   40 Cosine
1507         ocTan,              //   41 Tangens
1508         ocArcTan2,          //   42 Arctangens 2 (4.Quadrant)
1509         ocArcTan,           //   43 Arctangens (2.Quadrant)
1510         ocArcSin,           //   44 Arcsine
1511         ocArcCos,           //   45 Arccosine
1512         ocExp,              //   46 Exponential function
1513         ocMod,              //   47 Modulo
1514         ocChoose,           //   48 Selection
1515         ocIsNA,             //   49 Is not available?
1516         ocIsError,          //   50 Is Error?
1517         ocFalse,            //   51 FALSE
1518         ocTrue,             //   52 TRUE
1519         ocRandom,           //   53 Random number
1520         ocGetDate,          //   54 Date
1521         ocGetActDate,       //   55 Today
1522         ocPMT,              //   56 Payment
1523         ocPV,               //   57 Present Value
1524         ocFV,               //   58 Future Value
1525         ocIf,               //   59 If... then... else...
1526         ocGetDay,           //   60 Day of Month
1527         ocGetMonth,         //   61 Month
1528         ocGetYear,          //   62 Year
1529         ocRound,            //   63 Round
1530         ocGetTime,          //   64 Time
1531         ocGetHour,          //   65 Hour
1532         ocGetMin,           //   66 Minute
1533         ocGetSec,           //   67 Second
1534         ocIsValue,          //   68 Is number?
1535         ocIsString,         //   69 Is text?
1536         ocLen,              //   70 Len()
1537         ocValue,            //   71 Val()
1538         ocFixed,            //   72 String()    ocFixed alternatively + special case
1539         ocMid,              //   73 Mid()
1540         ocChar,             //   74 Char()
1541         ocCode,             //   75 Ascii()
1542         ocFind,             //   76 Find()
1543         ocGetDateValue,     //   77 Datevalue
1544         ocGetTimeValue,     //   78 Timevalue
1545         ocNoName,           //   79 Cellpointer
1546         ocSum,              //   80 Sum()
1547         ocAverageA,         //   81 Avg()
1548         ocCount2,           //   82 Cnt()
1549         ocMinA,             //   83 Min()
1550         ocMaxA,             //   84 Max()
1551         ocVLookup,          //   85 Vlookup()
1552         ocNPV,              //   86 Npv()
1553         ocVarPA,            //   87 Var()
1554         ocStDevPA,          //   88 Std()
1555         ocIRR,              //   89 Irr()
1556         ocHLookup,          //   90 Hlookup()
1557         ocDBSum,            //   91 XlfDsum
1558         ocDBAverage,        //   92 XlfDaverage
1559         ocDBCount2,         //   93 XlfDcount
1560         ocDBMin,            //   94 XlfDmin
1561         ocDBMax,            //   95 XlfDmax
1562         ocDBVarP,           //   96 XlfDvar
1563         ocDBStdDevP,        //   97 XlfDstdev
1564         ocIndex,            //   98 Index()
1565         ocColumns,          //   99 Cols()
1566         ocRows,             //  100 Rows()
1567         ocRept,             //  101 Repeat()
1568         ocUpper,            //  102 Upper()
1569         ocLower,            //  103 Lower()
1570         ocLeft,             //  104 Left()
1571         ocRight,            //  105 Right()
1572         ocReplace,          //  106 Replace()
1573         ocProper,           //  107 Proper()
1574         ocNoName,           //  108 Cell()
1575         ocTrim,             //  109 Trim()
1576         ocClean,            //  110 Clean()
1577         ocNoName,           //  111 F()     (Excel: T()?)
1578         ocNoName,           //  112 W()
1579         ocExact,            //  113 Exact()
1580         ocNoName,           //  114 Call()
1581         ocIndirect,         //  115 @@()
1582         ocRate,             //  116 Rate()
1583         ocNoName,           //  117 Term()
1584         ocNoName,           //  118 Cterm()
1585         ocSLN,              //  119 Sln()
1586         ocSYD,              //  120 Syd(), Soy()
1587         ocDDB,              //  121 Ddb()
1588         ocNoName,           //  122 Splfunc
1589         ocNoName,           //  123 Sheets
1590         ocNoName,           //  124 Info
1591         ocSumProduct,       //  125 Sumproduct
1592         ocNoName,           //  126 Isrange
1593         ocDBGet,            //  127 Dget
1594         ocNoName,           //  128 Dquery
1595         ocNoName,           //  129 Coord
1596         ocNoName,           //  130 Reserved (internal)
1597         ocGetActDate,       //  131 Today
1598         ocNoName,           //  132 Vdb
1599         ocDBVar,            //  133 Dvars
1600         ocDBStdDev,         //  134 Dstds
1601         ocVarA,             //  135 Vars
1602         ocStDevA,           //  136 Stds
1603         ocGetDiffDate360,   //  137 D360
1604         ocNoName,           //  138 Reserved (internal)
1605         ocNoName,           //  139 Isapp
1606         ocNoName,           //  140 Isaaf
1607         ocGetDayOfWeek,     //  141 Weekday
1608         ocGetDiffDate,      //  142 Datedif
1609         ocRank,             //  143 Rank
1610         ocNoName,           //  144 Numberstring
1611         ocNoName,           //  145 Datestring
1612         ocNoName,           //  146 Decimal
1613         ocNoName,           //  147 Hex
1614         ocNoName,           //  148 Db
1615         ocNoName,           //  149 Pmti
1616         ocNoName,           //  150 Spi
1617         ocNoName,           //  151 Fullp
1618         ocNoName,           //  152 Halfp
1619         ocAverage,          //  153 Pureavg
1620         ocCount,            //  154 Purecount
1621         ocMax,              //  155 Puremax
1622         ocMin,              //  156 Puremin
1623         ocStDevP,           //  157 Purestd
1624         ocVarP,             //  158 Purevar
1625         ocStDev,            //  159 Purestds
1626         ocVar,              //  160 Purevars
1627         ocNoName,           //  161 Pmt2
1628         ocNoName,           //  162 Pv2
1629         ocNoName,           //  163 Fv2
1630         ocNoName,           //  164 Term2
1631         ocNoName,           //  165--                  <- new quantity ?
1632         ocGetDiffDate360,   //  166 D360 (US-Version, alternatively as other D360 function)
1633         ocNoName,           //  167
1634         ocNoName,           //  168
1635         ocNoName,           //  169
1636         ocNoName,           //  170
1637         ocNoName,           //  171
1638         ocNoName,           //  172
1639         ocNoName,           //  173
1640         ocNoName,           //  174
1641         ocNoName,           //  175
1642         ocNoName,           //  176
1643         ocNoName,           //  177
1644         ocNoName,           //  178
1645         ocNoName,           //  179
1646         ocNoName,           //  180
1647         ocNoName,           //  181
1648         ocNoName,           //  182
1649         ocNoName,           //  183
1650         ocNoName,           //  184
1651         ocNoName,           //  185
1652         ocNoName,           //  186
1653         ocNoName,           //  187
1654         ocNoName,           //  188
1655         ocNoName,           //  189
1656         ocNoName,           //  190
1657         ocNoName,           //  191
1658         ocNoName,           //  192
1659         ocNoName,           //  193
1660         ocNoName,           //  194
1661         ocNoName,           //  195
1662         ocNoName,           //  196
1663         ocNoName,           //  197
1664         ocNoName,           //  198
1665         ocNoName,           //  199
1666         ocNoName,           //  200
1667         ocNoName,           //  201
1668         ocNoName,           //  202
1669         ocNoName,           //  203
1670         ocNoName,           //  204
1671         ocNoName,           //  205
1672         ocNoName,           //  206 ?
1673         ocNoName,           //  207
1674         ocNoName,           //  208
1675         ocNoName,           //  209
1676         ocNoName,           //  210
1677         ocNoName,           //  211
1678         ocNoName,           //  212
1679         ocNoName,           //  213
1680         ocNoName,           //  214
1681         ocNoName,           //  215
1682         ocNoName,           //  216
1683         ocNoName,           //  217
1684         ocNoName,           //  218
1685         ocNoName,           //  219
1686         ocNoName,           //  220
1687         ocNoName,           //  221
1688         ocNoName,           //  222
1689         ocNoName,           //  223
1690         ocNoName,           //  224
1691         ocNoName,           //  225
1692         ocNoName,           //  226
1693         ocNoName,           //  227
1694         ocNoName,           //  228
1695         ocNoName,           //  229
1696         ocNoName,           //  230
1697         ocNoName,           //  231
1698         ocNoName,           //  232
1699         ocNoName,           //  233
1700         ocNoName,           //  234
1701         ocNoName,           //  235
1702         ocNoName,           //  236
1703         ocNoName,           //  237
1704         ocNoName,           //  238
1705         ocNoName,           //  239
1706         ocNoName,           //  240
1707         ocNoName,           //  241
1708         ocNoName,           //  242
1709         ocNoName,           //  243
1710         ocNoName,           //  244
1711         ocNoName,           //  245
1712         ocNoName,           //  246
1713         ocNoName,           //  247
1714         ocNoName,           //  248
1715         ocNoName,           //  249
1716         ocNoName,           //  250
1717         ocNoName,           //  251
1718         ocNoName,           //  252
1719         ocNoName,           //  253
1720         ocNoName,           //  254
1721         ocNoName            //  255 ?
1722     };
1723 
1724     return pToken[ nIndex ];
1725 }
1726 
GetAddInName(const sal_uInt8 n)1727 const char* GetAddInName( const sal_uInt8 n )
1728 {
1729     static const char*  pNames[ 256 ] =
1730     {
1731         nullptr,                       //    0 8-Byte-IEEE-Float
1732         nullptr,                       //    1 Variable
1733         nullptr,                       //    2 Range
1734         nullptr,                       //    3 return
1735         nullptr,                       //    4 Braces
1736         nullptr,                       //    5 2-Byte integer
1737         nullptr,                       //    6 ASCII string
1738         nullptr,                       //    7 Named range reference
1739         nullptr,                       //    8 Absolute named range
1740         nullptr,                       //    9 Err range reference
1741         nullptr,                       //   10 Err cell reference
1742         nullptr,                       //   11 Err constant
1743         nullptr,                       //   12
1744         nullptr,                       //   13
1745         nullptr,                       //   14 Negation
1746         nullptr,                       //   15 Addition
1747         nullptr,                       //   16 Subtraction
1748         nullptr,                       //   17 Multiplication
1749         nullptr,                       //   18 Division
1750         nullptr,                       //   19 Power of
1751         nullptr,                       //   20 equal
1752         nullptr,                       //   21 unequal
1753         nullptr,                       //   22 <=
1754         nullptr,                       //   23 >=
1755         nullptr,                       //   24 <
1756         nullptr,                       //   25 >
1757         nullptr,                       //   26 And (logic)
1758         nullptr,                       //   27 Or (logic)
1759         nullptr,                       //   28 Not (logic)
1760         nullptr,                       //   29 unary Plus
1761         nullptr,                       //   30 Concatenation
1762         nullptr,                       //   31 Not applicable
1763         nullptr,                       //   32 Error
1764         nullptr,                       //   33 Absolute Value ABS()
1765         nullptr,                       //   34 Integer INT()
1766         nullptr,                       //   35 Square Root
1767         nullptr,                       //   36 log10
1768         nullptr,                       //   37 Natural logarithm
1769         nullptr,                       //   38 PI
1770         nullptr,                       //   39 Sine
1771         nullptr,                       //   40 Cosine
1772         nullptr,                       //   41 Tangens
1773         nullptr,                       //   42 Arctangens 2 (4.Quadrant)
1774         nullptr,                       //   43 Arctangens (2.Quadrant)
1775         nullptr,                       //   44 Arcsine
1776         nullptr,                       //   45 Arccosine
1777         nullptr,                       //   46 Exponential function
1778         nullptr,                       //   47 Modulo
1779         nullptr,                       //   48 Selection
1780         nullptr,                       //   49 Is not applicable?
1781         nullptr,                       //   50 Is Error?
1782         nullptr,                       //   51 FALSE
1783         nullptr,                       //   52 TRUE
1784         nullptr,                       //   53 Random number
1785         nullptr,                       //   54 Date
1786         nullptr,                       //   55 Today
1787         nullptr,                       //   56 Payment
1788         nullptr,                       //   57 Present Value
1789         nullptr,                       //   58 Future Value
1790         nullptr,                       //   59 If ... then ... else ...
1791         nullptr,                       //   60 Day of Month
1792         nullptr,                       //   61 Month
1793         nullptr,                       //   62 Year
1794         nullptr,                       //   63 Round
1795         nullptr,                       //   64 Time
1796         nullptr,                       //   65 Hour
1797         nullptr,                       //   66 Minute
1798         nullptr,                       //   67 Second
1799         nullptr,                       //   68 Is Number?
1800         nullptr,                       //   69 Is Text?
1801         nullptr,                       //   70 Len()
1802         nullptr,                       //   71 Val()
1803         nullptr,                       //   72 String()    ocFixed as substitute + special case
1804         nullptr,                       //   73 Mid()
1805         nullptr,                       //   74 Char()
1806         nullptr,                       //   75 Ascii()
1807         nullptr,                       //   76 Find()
1808         nullptr,                       //   77 Datevalue
1809         nullptr,                       //   78 Timevalue
1810         "ZELLZEIGER",               //   79 Cellpointer
1811         nullptr,                       //   80 Sum()
1812         nullptr,                       //   81 Avg()
1813         nullptr,                       //   82 Cnt()
1814         nullptr,                       //   83 Min()
1815         nullptr,                       //   84 Max()
1816         nullptr,                       //   85 Vlookup()
1817         nullptr,                       //   86 Npv()
1818         nullptr,                       //   87 Var()
1819         nullptr,                       //   88 Std()
1820         nullptr,                       //   89 Irr()
1821         nullptr,                       //   90 Hlookup()
1822         nullptr,                       //   91 XlfDsum
1823         nullptr,                       //   92 XlfDaverage
1824         nullptr,                       //   93 XlfDcount
1825         nullptr,                       //   94 XlfDmin
1826         nullptr,                       //   95 XlfDmax
1827         nullptr,                       //   96 XlfDvar
1828         nullptr,                       //   97 XlfDstdev
1829         nullptr,                       //   98 Index()
1830         nullptr,                       //   99 Cols()
1831         nullptr,                       //  100 Rows()
1832         nullptr,                       //  101 Repeat()
1833         nullptr,                       //  102 Upper()
1834         nullptr,                       //  103 Lower()
1835         nullptr,                       //  104 Left()
1836         nullptr,                       //  105 Right()
1837         nullptr,                       //  106 Replace()
1838         nullptr,                       //  107 Proper()
1839         "ZELLE",                    //  108 Cell()
1840         nullptr,                       //  109 Trim()
1841         nullptr,                       //  110 Clean()
1842         "F",                        //  111 F()     (Excel: T()?)
1843         "W",                        //  112 W()
1844         nullptr,                       //  113 Exact()
1845         nullptr,                       //  114 Call()
1846         nullptr,                       //  115 @@()
1847         nullptr,                       //  116 Rate()
1848         "TERM",                     //  117 Term()
1849         "CTERM",                    //  118 Cterm()
1850         nullptr,                       //  119 Sln()
1851         nullptr,                       //  120 Syd(), Soy()
1852         nullptr,                       //  121 Ddb()
1853         "SplFunc",                  //  122 Splfunc
1854         "BLAETTER",                 //  123 Sheets
1855         "INFO",                     //  124 Info
1856         nullptr,                       //  125 Sumproduct
1857         "ISTBEREICH",               //  126 Isrange
1858         nullptr,                       //  127 Dget
1859         "DABFRAGE",                 //  128 Dquery
1860         "KOORD",                    //  129 Coord
1861         nullptr,                       //  130 Reserved (internal)
1862         nullptr,                       //  131 Today
1863         nullptr,                       //  132 Vdb
1864         nullptr,                       //  133 Dvars
1865         nullptr,                       //  134 Dstds
1866         nullptr,                       //  135 Vars
1867         nullptr,                       //  136 Stds
1868         nullptr,                       //  137 D360
1869         nullptr,                       //  138 Reserved (internal)
1870         nullptr,                       //  139 Isapp
1871         "ISTDEFZUS",                //  140 Isaaf
1872         nullptr,                       //  141 Weekday
1873         nullptr,                       //  142 Datedif
1874         nullptr,                       //  143 Rank
1875         nullptr,                       //  144 Numberstring
1876         "DATUMFOLGE",               //  145 Datestring
1877         "DEZIMAL",                  //  146 Decimal
1878         "HEX",                      //  147 Hex
1879         nullptr,                       //  148 Db
1880         nullptr,                       //  149 Pmti
1881         nullptr,                       //  150 Spi
1882         nullptr,                       //  151 Fullp
1883         nullptr,                       //  152 Halfp
1884         "PURMITTELWERT",            //  153 Pureavg
1885         "PURquantity",                //  154 Purecount
1886         "PURMAX",                   //  155 Puremax
1887         "PURMIN",                   //  156 Puremin
1888         "PURSTDABW",                //  157 Purestd
1889         "PURVAR",                   //  158 Purevar
1890         "PURSTDABWP",               //  159 Purestds
1891         "PURVARP",                  //  160 Purevars
1892         nullptr,                       //  161 Pmt2
1893         nullptr,                       //  162 Pv2
1894         nullptr,                       //  163 Fv2
1895         nullptr,                       //  164 Term2
1896         nullptr,                       //  165--                  <- new quantity ?
1897         nullptr,                       //  166 D360 (US-Version, alternatively as in D360-function)
1898         nullptr,                       //  167
1899         nullptr,                       //  168
1900         nullptr,                       //  169
1901         nullptr,                       //  170
1902         nullptr,                       //  171
1903         nullptr,                       //  172
1904         nullptr,                       //  173
1905         nullptr,                       //  174
1906         nullptr,                       //  175
1907         nullptr,                       //  176
1908         nullptr,                       //  177
1909         nullptr,                       //  178
1910         nullptr,                       //  179
1911         nullptr,                       //  180
1912         nullptr,                       //  181
1913         nullptr,                       //  182
1914         nullptr,                       //  183
1915         nullptr,                       //  184
1916         nullptr,                       //  185
1917         nullptr,                       //  186
1918         nullptr,                       //  187
1919         nullptr,                       //  188
1920         nullptr,                       //  189
1921         nullptr,                       //  190
1922         nullptr,                       //  191
1923         nullptr,                       //  192
1924         nullptr,                       //  193
1925         nullptr,                       //  194
1926         nullptr,                       //  195
1927         nullptr,                       //  196
1928         nullptr,                       //  197
1929         nullptr,                       //  198
1930         nullptr,                       //  199
1931         nullptr,                       //  200
1932         nullptr,                       //  201
1933         nullptr,                       //  202
1934         nullptr,                       //  203
1935         nullptr,                       //  204
1936         nullptr,                       //  205
1937         nullptr,                       //  206 TODO: ?
1938         nullptr,                       //  207
1939         nullptr,                       //  208
1940         nullptr,                       //  209
1941         nullptr,                       //  210
1942         nullptr,                       //  211
1943         nullptr,                       //  212
1944         nullptr,                       //  213
1945         nullptr,                       //  214
1946         nullptr,                       //  215
1947         nullptr,                       //  216
1948         nullptr,                       //  217
1949         nullptr,                       //  218
1950         nullptr,                       //  219
1951         nullptr,                       //  220
1952         nullptr,                       //  221
1953         nullptr,                       //  222
1954         nullptr,                       //  223
1955         nullptr,                       //  224
1956         nullptr,                       //  225
1957         nullptr,                       //  226
1958         nullptr,                       //  227
1959         nullptr,                       //  228
1960         nullptr,                       //  229
1961         nullptr,                       //  230
1962         nullptr,                       //  231
1963         nullptr,                       //  232
1964         nullptr,                       //  233
1965         nullptr,                       //  234
1966         nullptr,                       //  235
1967         nullptr,                       //  236
1968         nullptr,                       //  237
1969         nullptr,                       //  238
1970         nullptr,                       //  239
1971         nullptr,                       //  240
1972         nullptr,                       //  241
1973         nullptr,                       //  242
1974         nullptr,                       //  243
1975         nullptr,                       //  244
1976         nullptr,                       //  245
1977         nullptr,                       //  246
1978         nullptr,                       //  247
1979         nullptr,                       //  248
1980         nullptr,                       //  249
1981         nullptr,                       //  250
1982         nullptr,                       //  251
1983         nullptr,                       //  252
1984         nullptr,                       //  253
1985         nullptr,                       //  254
1986         nullptr                        //  255 TODO: ?
1987     };
1988 
1989     return pNames[ n ];
1990 }
1991 
lcl_KnownAddIn(std::string_view rTest)1992 static DefTokenId lcl_KnownAddIn( std::string_view rTest )
1993 {
1994     DefTokenId  eId = ocNoName;
1995 
1996     if (rTest == "FACT")
1997             eId = ocFact;
1998     else if (rTest == "ISEMPTY")
1999             eId=ocIsEmpty;
2000     else if (rTest == "DEGTORAD")
2001             eId=ocRad;
2002     else if (rTest == "RADTODEG")
2003             eId=ocDeg;
2004     else if (rTest == "SIGN")
2005             eId=ocPlusMinus;
2006     else if (rTest == "ACOSH")
2007             eId=ocArcCosHyp;
2008     else if (rTest == "ACOTH")
2009             eId=ocArcCotHyp;
2010     else if (rTest == "ASINH")
2011             eId=ocArcSinHyp;
2012     else if (rTest == "ATANH")
2013             eId=ocArcTanHyp;
2014     else if (rTest == "COSH")
2015             eId=ocCosHyp;
2016     else if (rTest == "COTH")
2017             eId=ocCotHyp;
2018     else if (rTest == "SINH")
2019             eId=ocSinHyp;
2020     else if (rTest == "TANH")
2021             eId=ocTanHyp;
2022     else if (rTest == "EVEN")
2023             eId=ocEven;
2024     else if (rTest == "ODD")
2025             eId=ocOdd;
2026     else if (rTest == "ACOT")
2027             eId=ocArcCot;
2028     else if (rTest == "COT")
2029             eId=ocCot;
2030     else if (rTest == "TRUNC")
2031             eId=ocTrunc;
2032     else if (rTest == "GEOMEAN")
2033             eId=ocGeoMean;
2034     else if (rTest == "HARMEAN")
2035             eId=ocHarMean;
2036     else if (rTest == "CORREL")
2037             eId=ocCorrel;
2038     else if (rTest == "MEDIAN")
2039             eId=ocMedian;
2040     else if (rTest == "COV")
2041             eId=ocCovar;
2042     else if (rTest == "SKEWNESS")
2043             eId=ocSkew;
2044     else if (rTest == "CHITEST")
2045             eId=ocChiTest;
2046     else if (rTest == "FTEST")
2047             eId=ocFTest;
2048     else if (rTest == "AVEDEV")
2049             eId=ocAveDev;
2050     else if (rTest == "PRODUCT")
2051             eId=ocProduct;
2052     else if (rTest == "PERMUT")
2053             eId=ocPermut;
2054     else if (rTest == "GAMMALN")
2055             eId=ocGammaLn;
2056     else if (rTest =="POISSON")
2057             eId=ocPoissonDist;
2058     else if (rTest == "NORMAL")
2059             eId=ocNormDist;
2060     else if (rTest == "CRITBINOMIAL")
2061             eId=ocCritBinom;
2062     else if (rTest == "TERM")
2063             eId=ocNper;
2064     else if (rTest == "CTERM")
2065             eId=ocNper;
2066     else if (rTest == "SUMIF")
2067             eId=ocSumIf;
2068     else if (rTest == "COUNTIF")
2069             eId=ocCountIf;
2070     else if (rTest == "DPURECOUNT")
2071             eId=ocDBCount;
2072     else if (rTest == "CSC")
2073             eId=ocCosecant;
2074     else if (rTest == "CSCH")
2075             eId=ocCosecantHyp;
2076     else if (rTest == "LARGE")
2077             eId=ocLarge;
2078     else if (rTest == "SMALL")
2079             eId=ocSmall;
2080     else if (rTest == "MODULO")
2081             eId=ocMod;
2082     else if (rTest == "ROUNDDOWN")
2083             eId=ocRoundDown;
2084     else if (rTest == "ROUNDUP")
2085             eId=ocRoundUp;
2086     else if (rTest == "SEC")
2087             eId=ocSecant;
2088     else if (rTest == "SECH")
2089             eId=ocSecantHyp;
2090     return eId;
2091 }
2092 
2093 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
2094