xref: /trunk/main/sc/inc/compiler.hxx (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 #ifndef SC_COMPILER_HXX
25 #define SC_COMPILER_HXX
26 
27 #ifndef INCLUDED_STRING_H
28 #include <string.h>
29 #define INCLUDED_STRING_H
30 #endif
31 #include <tools/mempool.hxx>
32 #include "scdllapi.h"
33 #include "global.hxx"
34 #include "refdata.hxx"
35 #include "formula/token.hxx"
36 #include "formula/intruref.hxx"
37 #include "formula/grammar.hxx"
38 #include <unotools/charclass.hxx>
39 #include <rtl/ustrbuf.hxx>
40 #include <com/sun/star/sheet/ExternalLinkInfo.hpp>
41 #include <vector>
42 
43 #include <formula/FormulaCompiler.hxx>
44 
45 
46 #ifndef BOOST_SHARED_PTR_HPP_INCLUDED
47 #include <boost/shared_ptr.hpp>
48 #endif
49 
50 #ifndef INCLUDED_HASH_MAP
51 #include <unordered_map>
52 #define INCLUDED_HASH_MAP
53 #endif
54 
55 //-----------------------------------------------
56 
57 // constants and data types also for external modules (ScInterpreter et al)
58 
59 #define MAXCODE      2048   /* maximum number of tokens in formula */
60 #define MAXSTRLEN    1024   /* maximum length of input string of one symbol */
61 #define MAXSTRLITLEN 32767  /* maximum length of a string literal in a formula */
62 #define MAXSYMLEN    (MAXSTRLITLEN+3)   /* symbol buffer: quote, literal, quote, 0 */
63 #define MAXJUMPCOUNT 32     /* maximum number of jumps (ocChose) */
64 
65 // flag values of CharTable
66 #define SC_COMPILER_C_ILLEGAL         0x00000000
67 #define SC_COMPILER_C_CHAR            0x00000001
68 #define SC_COMPILER_C_CHAR_BOOL       0x00000002
69 #define SC_COMPILER_C_CHAR_WORD       0x00000004
70 #define SC_COMPILER_C_CHAR_VALUE      0x00000008
71 #define SC_COMPILER_C_CHAR_STRING     0x00000010
72 #define SC_COMPILER_C_CHAR_DONTCARE   0x00000020
73 #define SC_COMPILER_C_BOOL            0x00000040
74 #define SC_COMPILER_C_WORD            0x00000080
75 #define SC_COMPILER_C_WORD_SEP        0x00000100
76 #define SC_COMPILER_C_VALUE           0x00000200
77 #define SC_COMPILER_C_VALUE_SEP       0x00000400
78 #define SC_COMPILER_C_VALUE_EXP       0x00000800
79 #define SC_COMPILER_C_VALUE_SIGN      0x00001000
80 #define SC_COMPILER_C_VALUE_VALUE     0x00002000
81 #define SC_COMPILER_C_STRING_SEP      0x00004000
82 #define SC_COMPILER_C_NAME_SEP        0x00008000  // there can be only one! '\''
83 #define SC_COMPILER_C_CHAR_IDENT      0x00010000  // identifier (built-in function) or reference start
84 #define SC_COMPILER_C_IDENT           0x00020000  // identifier or reference continuation
85 #define SC_COMPILER_C_ODF_LBRACKET    0x00040000  // ODF '[' reference bracket
86 #define SC_COMPILER_C_ODF_RBRACKET    0x00080000  // ODF ']' reference bracket
87 #define SC_COMPILER_C_ODF_LABEL_OP    0x00100000  // ODF '!!' automatic intersection of labels
88 #define SC_COMPILER_C_ODF_NAME_MARKER 0x00200000  // ODF '$$' marker that starts a defined (range) name
89 #define SC_COMPILER_C_CHAR_NAME       0x00400000  // start character of a defined name
90 #define SC_COMPILER_C_NAME            0x00800000  // continuation character of a defined name
91 
92 #define SC_COMPILER_FILE_TAB_SEP      '#'         // 'Doc'#Tab
93 
94 
95 class ScDocument;
96 class ScMatrix;
97 class ScRangeData;
98 class ScExternalRefManager;
99 class ScTokenArray;
100 
101 // constants and data types internal to compiler
102 
103 #if 0
104 /*
105     OpCode   eOp;           // OpCode
106     formula::StackVar eType;         // type of data
107     sal_uInt16   nRefCnt;       // reference count
108     sal_Bool     bRaw;          // not cloned yet and trimmed to real size
109  */
110 #endif
111 
112 #define SC_TOKEN_FIX_MEMBERS    \
113     OpCode   eOp;               \
114     formula::StackVar eType;    \
115     sal_uInt16   nRefCnt;           \
116     sal_Bool     bRaw;
117 
118 struct ScDoubleRawToken
119 {
120 private:
121     // SC_TOKEN_FIX_MEMBERS
122     OpCode  SAL_UNUSED_MEMBER       eOp;
123     formula::StackVar SAL_UNUSED_MEMBER eType;
124     sal_uInt16 SAL_UNUSED_MEMBER    nRefCnt;
125     sal_Bool SAL_UNUSED_MEMBER      bRaw;
126 public:
127     union
128     {   // union only to assure alignment identical to ScRawToken
129         double      nValue;
130         struct {
131             sal_uInt8        cByte;
132             bool        bHasForceArray;
133         } sbyte;
134     };
135                 DECL_FIXEDMEMPOOL_NEWDEL( ScDoubleRawToken );
136 };
137 
138 struct ScRawToken
139 {
140     friend class ScCompiler;
141     // Friends that use a temporary ScRawToken on the stack (and therefor need
142     // the private dtor) and know what they're doing..
143     friend class ScTokenArray;
144     friend sal_uInt16 lcl_ScRawTokenOffset();
145 private:
146     SC_TOKEN_FIX_MEMBERS
147 public:
148     union {
149         double       nValue;
150         struct {
151             sal_uInt8        cByte;
152             bool        bHasForceArray;
153         } sbyte;
154         ScComplexRefData aRef;
155         struct {
156             sal_uInt16      nFileId;
157             sal_Unicode     cTabName[MAXSTRLEN+1];
158             ScComplexRefData    aRef;
159         } extref;
160         struct {
161             sal_uInt16  nFileId;
162             sal_Unicode cName[MAXSTRLEN+1];
163         } extname;
164         ScMatrix*    pMat;
165         sal_uInt16       nIndex;                // index into name collection
166         sal_Unicode  cStr[ MAXSTRLEN+1 ];   // string (up to 255 characters + 0)
167         short        nJump[MAXJUMPCOUNT+1]; // If/Chose token
168     };
169 
170                 //! other members not initialized
ScRawTokenScRawToken171                 ScRawToken() : bRaw( sal_True ) {}
172 private:
~ScRawTokenScRawToken173                 ~ScRawToken() {}                //! only delete via Delete()
174 public:
175                 DECL_FIXEDMEMPOOL_NEWDEL( ScRawToken );
GetTypeScRawToken176     formula::StackVar    GetType()   const       { return (formula::StackVar) eType; }
GetOpCodeScRawToken177     OpCode      GetOpCode() const       { return (OpCode)   eOp;   }
NewOpCodeScRawToken178     void        NewOpCode( OpCode e )   { eOp = e; }
IncRefScRawToken179     void        IncRef()                { nRefCnt++;       }
DecRefScRawToken180     void        DecRef()                { if( !--nRefCnt ) Delete(); }
GetRefScRawToken181     sal_uInt16      GetRef() const          { return nRefCnt; }
182     SC_DLLPUBLIC void       Delete();
183 
184     // Use these methods only on tokens that are not part of a token array,
185     // since the reference count is cleared!
186     void SetOpCode( OpCode eCode );
187     void SetString( const sal_Unicode* pStr );
188     void SetSingleReference( const ScSingleRefData& rRef );
189     void SetDoubleReference( const ScComplexRefData& rRef );
190     void SetDouble( double fVal );
191 //UNUSED2008-05  void SetInt( int nVal );
192 //UNUSED2008-05  void SetMatrix( ScMatrix* p );
193 
194     // These methods are ok to use, reference count not cleared.
195 //UNUSED2008-05  ScComplexRefData& GetReference();
196 //UNUSED2008-05  void SetReference( ScComplexRefData& rRef );
197     void SetName( sal_uInt16 n );
198     void SetExternalSingleRef( sal_uInt16 nFileId, const String& rTabName, const ScSingleRefData& rRef );
199     void SetExternalDoubleRef( sal_uInt16 nFileId, const String& rTabName, const ScComplexRefData& rRef );
200     void SetExternalName( sal_uInt16 nFileId, const String& rName );
201     void SetMatrix( ScMatrix* p );
202     void SetExternal(const sal_Unicode* pStr);
203 
204     ScRawToken* Clone() const;      // real copy!
205     // Heap token sized to the string, so it may exceed MAXSTRLEN; free with Delete().
206     static ScRawToken* NewString( const sal_Unicode* pStr, xub_StrLen nLen );
207     formula::FormulaToken* CreateToken() const;   // create typified token
208     void Load( SvStream&, sal_uInt16 nVer );
209 
210     static xub_StrLen GetStrLen( const sal_Unicode* pStr ); // as long as a "string" is an array
GetStrLenBytesScRawToken211     static size_t GetStrLenBytes( xub_StrLen nLen )
212         { return nLen * sizeof(sal_Unicode); }
GetStrLenBytesScRawToken213     static size_t GetStrLenBytes( const sal_Unicode* pStr )
214         { return GetStrLenBytes( GetStrLen( pStr ) ); }
215 };
216 
217 
218 typedef formula::SimpleIntrusiveReference< struct ScRawToken > ScRawTokenRef;
219 
220 class SC_DLLPUBLIC ScCompiler : public formula::FormulaCompiler
221 {
222 public:
223 
224     enum EncodeUrlMode
225     {
226         ENCODE_BY_GRAMMAR,
227         ENCODE_ALWAYS,
228         ENCODE_NEVER,
229     };
230 
231     struct Convention
232     {
233         const formula::FormulaGrammar::AddressConvention meConv;
234         const sal_uLong*                mpCharTable;
235 
236 
237         Convention( formula::FormulaGrammar::AddressConvention eConvP );
238         virtual ~Convention();
239 
240         virtual void MakeRefStr( rtl::OUStringBuffer&   rBuffer,
241                                  const ScCompiler&      rCompiler,
242                                  const ScComplexRefData&    rRef,
243                                  sal_Bool bSingleRef ) const = 0;
244         virtual ::com::sun::star::i18n::ParseResult
245                     parseAnyToken( const String& rFormula,
246                                    xub_StrLen nSrcPos,
247                                    const CharClass* pCharClass) const = 0;
248 
249         /**
250          * Parse the symbol string and pick up the file name and the external
251          * range name.
252          *
253          * @return true on successful parse, or false otherwise.
254          */
255         virtual bool parseExternalName( const String& rSymbol, String& rFile, String& rName,
256                 const ScDocument* pDoc,
257                 const ::com::sun::star::uno::Sequence<
258                     const ::com::sun::star::sheet::ExternalLinkInfo > * pExternalLinks ) const = 0;
259 
260         virtual String makeExternalNameStr( const String& rFile, const String& rName ) const = 0;
261 
262         virtual void makeExternalRefStr( ::rtl::OUStringBuffer& rBuffer, const ScCompiler& rCompiler,
263                                          sal_uInt16 nFileId, const String& rTabName, const ScSingleRefData& rRef,
264                                          ScExternalRefManager* pRefMgr ) const = 0;
265 
266         virtual void makeExternalRefStr( ::rtl::OUStringBuffer& rBuffer, const ScCompiler& rCompiler,
267                                          sal_uInt16 nFileId, const String& rTabName, const ScComplexRefData& rRef,
268                                          ScExternalRefManager* pRefMgr ) const = 0;
269 
270         enum SpecialSymbolType
271         {
272             /**
273              * Character between sheet name and address.  In OOO A1 this is
274              * '.', while XL A1 and XL R1C1 this is '!'.
275              */
276             SHEET_SEPARATOR,
277 
278             /**
279              * In OOO A1, a sheet name may be prefixed with '$' to indicate an
280              * absolute sheet position.
281              */
282             ABS_SHEET_PREFIX
283         };
284         virtual sal_Unicode getSpecialSymbol( SpecialSymbolType eSymType ) const = 0;
285     };
286     friend struct Convention;
287 
288 private:
289 
290 
291     static CharClass            *pCharClassEnglish;                      // character classification for en_US locale
292     static const Convention     *pConventions[ formula::FormulaGrammar::CONV_LAST ];
293 
294     static const Convention * const pConvOOO_A1;
295     static const Convention * const pConvOOO_A1_ODF;
296     static const Convention * const pConvXL_A1;
297     static const Convention * const pConvXL_R1C1;
298     static const Convention * const pConvXL_OOX;
299 
300     static struct AddInMap
301     {
302         const char* pODFF;
303         const char* pEnglish;
304         bool        bMapDupToInternal;      // when writing ODFF
305         const char* pOriginal;              // programmatical name
306         const char* pUpper;                 // upper case programmatical name
307     } maAddInMap[];
308     static const AddInMap* GetAddInMap();
309     static size_t GetAddInMapCount();
310 
311     ScDocument* pDoc;
312     ScAddress   aPos;
313 
314     // For CONV_XL_OOX, may be set via API by MOOXML filter.
315     ::com::sun::star::uno::Sequence< const ::com::sun::star::sheet::ExternalLinkInfo > maExternalLinks;
316 
317     sal_Unicode* cSymbol;                           // current Symbol, MAXSYMLEN characters
318     String      aFormula;                           // formula source code
319     xub_StrLen  nSrcPos;                            // tokenizer position (source code)
320     ScRawTokenRef   pRawToken;
321 
322     const CharClass*    pCharClass;         // which character classification is used for parseAnyToken
323     sal_uInt16      mnPredetectedReference;     // reference when reading ODF, 0 (none), 1 (single) or 2 (double)
324     SCsTAB      nMaxTab;                    // last sheet in document
325     sal_Int32   mnRangeOpPosInSymbol;       // if and where a range operator is in symbol
326     const Convention *pConv;
327     EncodeUrlMode   meEncodeUrlMode;
328     bool        mbCloseBrackets;            // whether to close open brackets automatically, default TRUE
329     bool        mbExtendedErrorDetection;
330     bool        mbRewind;                   // whether symbol is to be rewound to some step during lexical analysis
331 
332     sal_Bool   NextNewToken(bool bInArray = false);
333 
334     virtual void SetError(sal_uInt16 nError);
335     xub_StrLen NextSymbol(bool bInArray);
336     sal_Bool IsValue( const String& );
337     sal_Bool IsOpCode( const String&, bool bInArray );
338     sal_Bool IsOpCode2( const String& );
339     sal_Bool IsString();
340     sal_Bool IsReference( const String& );
341     sal_Bool IsSingleReference( const String& );
342     sal_Bool IsPredetectedReference( const String& );
343     sal_Bool IsDoubleReference( const String& );
344     sal_Bool IsMacro( const String& );
345     sal_Bool IsNamedRange( const String& );
346     bool IsExternalNamedRange( const String& rSymbol );
347     sal_Bool IsDBRange( const String& );
348     sal_Bool IsColRowName( const String& );
349     sal_Bool IsBoolean( const String& );
350     void AutoCorrectParsedSymbol();
351 
352     void SetRelNameReference();
353 
354     static void InitCharClassEnglish();
355 
356 public:
357     ScCompiler( ScDocument* pDocument, const ScAddress&);
358 
359     ScCompiler( ScDocument* pDocument, const ScAddress&,ScTokenArray& rArr);
360 
361     virtual ~ScCompiler();
362 
363 private:
364     ScCompiler( const ScCompiler& );            // not implemented
365     ScCompiler& operator=( const ScCompiler& ); // not implemented
366 
367 public:
368     static void DeInit();               /// all
369 
370     // for ScAddress::Format()
371     static void CheckTabQuotes( String& aTabName,
372                                 const formula::FormulaGrammar::AddressConvention eConv = formula::FormulaGrammar::CONV_OOO );
373 
374     /** Analyzes a string for a 'Doc'#Tab construct, or 'Do''c'#Tab etc..
375 
376         @returns the position of the unquoted # hash mark in 'Doc'#Tab, or
377                  STRING_NOTFOUND if none. */
378     static xub_StrLen GetDocTabPos( const String& rString );
379 
380     static sal_Bool EnQuote( String& rStr );
381     sal_Unicode GetNativeAddressSymbol( Convention::SpecialSymbolType eType ) const;
382 
383 
384     // Check if it is a valid english function name
385     bool IsEnglishSymbol( const String& rName );
386 
387     //! _either_ CompileForFAP _or_ AutoCorrection, _not_ both
388     // #i101512# SetCompileForFAP is in formula::FormulaCompiler
SetAutoCorrection(sal_Bool bVal)389     void            SetAutoCorrection( sal_Bool bVal )
390                         { bAutoCorrect = bVal; bIgnoreErrors = bVal; }
SetCloseBrackets(bool bVal)391     void            SetCloseBrackets( bool bVal ) { mbCloseBrackets = bVal; }
392     void            SetRefConvention( const Convention *pConvP );
393     void            SetRefConvention( const formula::FormulaGrammar::AddressConvention eConv );
394 
395     /// Set symbol map if not empty.
396     void            SetFormulaLanguage( const OpCodeMapPtr & xMap );
397 
398     void            SetGrammar( const formula::FormulaGrammar::Grammar eGrammar );
399 
400     void            SetEncodeUrlMode( EncodeUrlMode eMode );
401     EncodeUrlMode   GetEncodeUrlMode() const;
402 private:
403     /** Set grammar and reference convention from within SetFormulaLanguage()
404         or SetGrammar().
405 
406         @param eNewGrammar
407             The new grammar to be set and the associated reference convention.
408 
409         @param eOldGrammar
410             The previous grammar that was active before SetFormulaLanguage().
411      */
412     void            SetGrammarAndRefConvention(
413                         const formula::FormulaGrammar::Grammar eNewGrammar,
414                         const formula::FormulaGrammar::Grammar eOldGrammar );
415 public:
416 
417     /// Set external link info for ScAddress::CONV_XL_OOX.
SetExternalLinks(const::com::sun::star::uno::Sequence<const::com::sun::star::sheet::ExternalLinkInfo> & rLinks)418     inline  void    SetExternalLinks(
419             const ::com::sun::star::uno::Sequence<
420             const ::com::sun::star::sheet::ExternalLinkInfo > & rLinks )
421     {
422         maExternalLinks = rLinks;
423     }
424 
425     void            CreateStringFromXMLTokenArray( String& rFormula, String& rFormulaNmsp );
426 
SetExtendedErrorDetection(bool bVal)427     void            SetExtendedErrorDetection( bool bVal ) { mbExtendedErrorDetection = bVal; }
428 
IsCorrected()429     sal_Bool            IsCorrected() { return bCorrected; }
GetCorrectedFormula()430     const String&   GetCorrectedFormula() { return aCorrectedFormula; }
431 
432     // Use convention from this->aPos by default
433     ScTokenArray* CompileString( const String& rFormula );
434     ScTokenArray* CompileString( const String& rFormula, const String& rFormulaNmsp );
GetDoc() const435     const ScDocument* GetDoc() const { return pDoc; }
GetPos() const436     const ScAddress& GetPos() const { return aPos; }
437 
438     void MoveRelWrap( SCCOL nMaxCol, SCROW nMaxRow );
439     static void MoveRelWrap( ScTokenArray& rArr, ScDocument* pDoc, const ScAddress& rPos,
440                              SCCOL nMaxCol, SCROW nMaxRow );
441 
442     sal_Bool UpdateNameReference( UpdateRefMode eUpdateRefMode,
443                               const ScRange&,
444                               SCsCOL nDx, SCsROW nDy, SCsTAB nDz,
445                               sal_Bool& rChanged, sal_Bool bSharedFormula = sal_False);
446 
447     ScRangeData* UpdateReference( UpdateRefMode eUpdateRefMode,
448                                   const ScAddress& rOldPos, const ScRange&,
449                                   SCsCOL nDx, SCsROW nDy, SCsTAB nDz,
450                                   sal_Bool& rChanged, sal_Bool& rRefSizeChanged );
451 
452     /// Only once for converted shared formulas,
453     /// token array has to be compiled afterwards.
454     void UpdateSharedFormulaReference( UpdateRefMode eUpdateRefMode,
455                                   const ScAddress& rOldPos, const ScRange&,
456                                   SCsCOL nDx, SCsROW nDy, SCsTAB nDz );
457 
458     ScRangeData* UpdateInsertTab(SCTAB nTable, sal_Bool bIsName );
459     ScRangeData* UpdateDeleteTab(SCTAB nTable, sal_Bool bIsMove, sal_Bool bIsName, sal_Bool& bCompile);
460     // the last parameter is true only when copying a sheet, to update the range name's address
461     ScRangeData* UpdateMoveTab(SCTAB nOldPos, SCTAB nNewPos, bool bIsName, bool bOnlyUpdateOwnTab = false );
462 
463     sal_Bool HasModifiedRange();
464 
465     /** If the character is allowed as first character in sheet names or
466         references, includes '$' and '?'. */
IsCharWordChar(String const & rStr,xub_StrLen nPos,const formula::FormulaGrammar::AddressConvention eConv=formula::FormulaGrammar::CONV_OOO)467     static inline sal_Bool IsCharWordChar( String const & rStr,
468                                        xub_StrLen nPos,
469                                        const formula::FormulaGrammar::AddressConvention eConv = formula::FormulaGrammar::CONV_OOO )
470         {
471             sal_Unicode c = rStr.GetChar( nPos );
472             if (c < 128)
473             {
474                 return pConventions[eConv] ? static_cast<sal_Bool>(
475                         (pConventions[eConv]->mpCharTable[ sal_uInt8(c) ] & SC_COMPILER_C_CHAR_WORD) == SC_COMPILER_C_CHAR_WORD) :
476                     sal_False;   // no convention => assume invalid
477             }
478             else
479                 return ScGlobal::pCharClass->isLetterNumeric( rStr, nPos );
480         }
481 
482     /** If the character is allowed in sheet names, thus may be part of a
483         reference, includes '$' and '?' and such. */
IsWordChar(String const & rStr,xub_StrLen nPos,const formula::FormulaGrammar::AddressConvention eConv=formula::FormulaGrammar::CONV_OOO)484     static inline sal_Bool IsWordChar( String const & rStr,
485                                    xub_StrLen nPos,
486                                    const formula::FormulaGrammar::AddressConvention eConv = formula::FormulaGrammar::CONV_OOO )
487         {
488             sal_Unicode c = rStr.GetChar( nPos );
489             if (c < 128)
490             {
491                 return pConventions[eConv] ? static_cast<sal_Bool>(
492                         (pConventions[eConv]->mpCharTable[ sal_uInt8(c) ] & SC_COMPILER_C_WORD) == SC_COMPILER_C_WORD) :
493                     sal_False;   // convention not known => assume invalid
494             }
495             else
496                 return ScGlobal::pCharClass->isLetterNumeric( rStr, nPos );
497         }
498 
499     /** If the character is allowed as tested by nFlags (SC_COMPILER_C_...
500         bits) for all known address conventions. If more than one bit is given
501         in nFlags, all bits must match. If bTestLetterNumeric is sal_False and
502         char>=128, no LetterNumeric test is done and sal_False is returned. */
IsCharFlagAllConventions(String const & rStr,xub_StrLen nPos,sal_uLong nFlags,bool bTestLetterNumeric=true)503     static inline bool IsCharFlagAllConventions( String const & rStr,
504                                                  xub_StrLen nPos,
505                                                  sal_uLong nFlags,
506                                                  bool bTestLetterNumeric = true )
507         {
508             sal_Unicode c = rStr.GetChar( nPos );
509             if (c < 128)
510             {
511                 for ( int nConv = formula::FormulaGrammar::CONV_UNSPECIFIED;
512                         ++nConv < formula::FormulaGrammar::CONV_LAST; )
513                 {
514                     if (pConventions[nConv] &&
515                             ((pConventions[nConv]->mpCharTable[ sal_uInt8(c) ] & nFlags) != nFlags))
516                         return false;
517                     // convention not known => assume valid
518                 }
519                 return true;
520             }
521             else if (bTestLetterNumeric)
522                 return ScGlobal::pCharClass->isLetterNumeric( rStr, nPos );
523             else
524                 return false;
525         }
526 
527 private:
528     // FormulaCompiler
529     virtual String FindAddInFunction( const String& rUpperName, sal_Bool bLocalFirst ) const;
530     virtual void fillFromAddInCollectionUpperName( NonConstOpCodeMapPtr xMap ) const;
531     virtual void fillFromAddInCollectionEnglishName( NonConstOpCodeMapPtr xMap ) const;
532     virtual void fillFromAddInMap( NonConstOpCodeMapPtr xMap, formula::FormulaGrammar::Grammar _eGrammar ) const;
533     virtual void fillAddInToken(::std::vector< ::com::sun::star::sheet::FormulaOpCodeMapEntry >& _rVec,bool _bIsEnglish) const;
534 
535     virtual sal_Bool HandleExternalReference(const formula::FormulaToken& _aToken);
536     virtual sal_Bool HandleRange();
537     virtual sal_Bool HandleSingleRef();
538     virtual sal_Bool HandleDbData();
539 
540     virtual formula::FormulaTokenRef ExtendRangeReference( formula::FormulaToken & rTok1, formula::FormulaToken & rTok2, bool bReuseDoubleRef );
541     virtual void CreateStringFromExternal(rtl::OUStringBuffer& rBuffer, formula::FormulaToken* pTokenP);
542     virtual void CreateStringFromSingleRef(rtl::OUStringBuffer& rBuffer,formula::FormulaToken* _pTokenP);
543     virtual void CreateStringFromDoubleRef(rtl::OUStringBuffer& rBuffer,formula::FormulaToken* _pTokenP);
544     virtual void CreateStringFromMatrix( rtl::OUStringBuffer& rBuffer, formula::FormulaToken* _pTokenP);
545     virtual void CreateStringFromIndex(rtl::OUStringBuffer& rBuffer,formula::FormulaToken* _pTokenP);
546     virtual void LocalizeString( String& rName );   // modify rName - input: exact name
547     virtual sal_Bool IsImportingXML() const;
548 
549     /// Access the CharTable flags
GetCharTableFlags(sal_Unicode c)550     inline sal_uLong GetCharTableFlags( sal_Unicode c )
551         { return c < 128 ? pConv->mpCharTable[ sal_uInt8(c) ] : 0; }
552 };
553 
554 SC_DLLPUBLIC String GetScCompilerNativeSymbol( OpCode eOp ); //CHINA001
555 
556 #endif
557