[Libreoffice-commits] core.git: sc/inc sc/source

Noel Grandin noel at peralex.com
Fri May 20 08:06:42 UTC 2016


 sc/inc/compiler.hxx                |   69 ++++++-----
 sc/source/core/tool/compiler.cxx   |  230 ++++++++++++++++++-------------------
 sc/source/core/tool/rangenam.cxx   |   10 -
 sc/source/filter/ftools/ftools.cxx |    4 
 4 files changed, 160 insertions(+), 153 deletions(-)

New commits:
commit aad5eced795c60f873b67fe97baeefb9ef1bfef8
Author: Noel Grandin <noel at peralex.com>
Date:   Wed May 18 09:34:13 2016 +0200

    convert SC_COMPILER to scoped enum
    
    Change-Id: Ib8fdce056847b2b2514f61da18c106bb3e78631c
    Reviewed-on: https://gerrit.libreoffice.org/25079
    Tested-by: Jenkins <ci at libreoffice.org>
    Reviewed-by: Noel Grandin <noelgrandin at gmail.com>

diff --git a/sc/inc/compiler.hxx b/sc/inc/compiler.hxx
index abc41e5..5f89b97 100644
--- a/sc/inc/compiler.hxx
+++ b/sc/inc/compiler.hxx
@@ -35,38 +35,45 @@
 #include <vector>
 
 #include <formula/FormulaCompiler.hxx>
+#include <o3tl/typed_flags_set.hxx>
 
 // constants and data types also for external modules (ScInterpreter et al)
 
 #define MAXSTRLEN    1024   /* maximum length of input string of one symbol */
 
 // flag values of CharTable
-#define SC_COMPILER_C_ILLEGAL         0x00000000
-#define SC_COMPILER_C_CHAR            0x00000001
-#define SC_COMPILER_C_CHAR_BOOL       0x00000002
-#define SC_COMPILER_C_CHAR_WORD       0x00000004
-#define SC_COMPILER_C_CHAR_VALUE      0x00000008
-#define SC_COMPILER_C_CHAR_STRING     0x00000010
-#define SC_COMPILER_C_CHAR_DONTCARE   0x00000020
-#define SC_COMPILER_C_BOOL            0x00000040
-#define SC_COMPILER_C_WORD            0x00000080
-#define SC_COMPILER_C_WORD_SEP        0x00000100
-#define SC_COMPILER_C_VALUE           0x00000200
-#define SC_COMPILER_C_VALUE_SEP       0x00000400
-#define SC_COMPILER_C_VALUE_EXP       0x00000800
-#define SC_COMPILER_C_VALUE_SIGN      0x00001000
-#define SC_COMPILER_C_VALUE_VALUE     0x00002000
-#define SC_COMPILER_C_STRING_SEP      0x00004000
-#define SC_COMPILER_C_NAME_SEP        0x00008000  // there can be only one! '\''
-#define SC_COMPILER_C_CHAR_IDENT      0x00010000  // identifier (built-in function) or reference start
-#define SC_COMPILER_C_IDENT           0x00020000  // identifier or reference continuation
-#define SC_COMPILER_C_ODF_LBRACKET    0x00040000  // ODF '[' reference bracket
-#define SC_COMPILER_C_ODF_RBRACKET    0x00080000  // ODF ']' reference bracket
-#define SC_COMPILER_C_ODF_LABEL_OP    0x00100000  // ODF '!!' automatic intersection of labels
-#define SC_COMPILER_C_ODF_NAME_MARKER 0x00200000  // ODF '$$' marker that starts a defined (range) name
-#define SC_COMPILER_C_CHAR_NAME       0x00400000  // start character of a defined name
-#define SC_COMPILER_C_NAME            0x00800000  // continuation character of a defined name
-#define SC_COMPILER_C_CHAR_ERRCONST   0x01000000  // start character of an error constant ('#')
+enum class ScCharFlags : sal_uInt32 {
+    NONE            = 0x00000000,
+    Illegal         = 0x00000000,
+    Char            = 0x00000001,
+    CharBool        = 0x00000002,
+    CharWord        = 0x00000004,
+    CharValue       = 0x00000008,
+    CharString      = 0x00000010,
+    CharDontCare    = 0x00000020,
+    Bool            = 0x00000040,
+    Word            = 0x00000080,
+    WordSep         = 0x00000100,
+    Value           = 0x00000200,
+    ValueSep        = 0x00000400,
+    ValueExp        = 0x00000800,
+    ValueSign       = 0x00001000,
+    ValueValue      = 0x00002000,
+    StringSep       = 0x00004000,
+    NameSep         = 0x00008000,  // there can be only one! '\''
+    CharIdent       = 0x00010000,  // identifier (built-in function) or reference start
+    Ident           = 0x00020000,  // identifier or reference continuation
+    OdfLBracket     = 0x00040000,  // ODF '[' reference bracket
+    OdfRBracket     = 0x00080000,  // ODF ']' reference bracket
+    OdfLabelOp      = 0x00100000,  // ODF '!!' automatic intersection of labels
+    OdfNameMarker   = 0x00200000,  // ODF '$$' marker that starts a defined (range) name
+    CharName        = 0x00400000,  // start character of a defined name
+    Name            = 0x00800000,  // continuation character of a defined name
+    CharErrConst    = 0x01000000,  // start character of an error constant ('#')
+};
+namespace o3tl {
+    template<> struct typed_flags<ScCharFlags> : is_typed_flags<ScCharFlags, 0x01ffffff> {};
+}
 
 #define SC_COMPILER_FILE_TAB_SEP      '#'         // 'Doc'#Tab
 
@@ -245,10 +252,10 @@ public:
         };
         virtual sal_Unicode getSpecialSymbol( SpecialSymbolType eSymType ) const = 0;
 
-        virtual sal_uLong getCharTableFlags( sal_Unicode c, sal_Unicode cLast ) const = 0;
+        virtual ScCharFlags getCharTableFlags( sal_Unicode c, sal_Unicode cLast ) const = 0;
 
     protected:
-        const sal_uLong* mpCharTable;
+        const ScCharFlags* mpCharTable;
     };
     friend struct Convention;
 
@@ -441,7 +448,7 @@ public:
         bits) for all known address conventions. If more than one bit is given
         in nFlags, all bits must match. */
     static bool IsCharFlagAllConventions(
-        OUString const & rStr, sal_Int32 nPos, sal_uLong nFlags );
+        OUString const & rStr, sal_Int32 nPos, ScCharFlags nFlags );
 
 private:
     // FormulaCompiler
@@ -468,8 +475,8 @@ private:
     virtual bool IsForceArrayParameter( const formula::FormulaToken* pToken, sal_uInt16 nParam ) const override;
 
     /// Access the CharTable flags
-    inline sal_uLong GetCharTableFlags( sal_Unicode c, sal_Unicode cLast )
-        { return c < 128 ? pConv->getCharTableFlags(c, cLast) : 0; }
+    inline ScCharFlags GetCharTableFlags( sal_Unicode c, sal_Unicode cLast )
+        { return c < 128 ? pConv->getCharTableFlags(c, cLast) : ScCharFlags::NONE; }
 };
 
 #endif
diff --git a/sc/source/core/tool/compiler.cxx b/sc/source/core/tool/compiler.cxx
index cc2ddfb..eb00c65 100644
--- a/sc/source/core/tool/compiler.cxx
+++ b/sc/source/core/tool/compiler.cxx
@@ -305,87 +305,87 @@ ScCompiler::Convention::Convention( FormulaGrammar::AddressConvention eConv )
     meConv( eConv )
 {
     int i;
-    sal_uLong *t= new sal_uLong [128];
+    ScCharFlags *t= new ScCharFlags [128];
 
     ScCompiler::pConventions[ meConv ] = this;
     mpCharTable = t;
 
     for (i = 0; i < 128; i++)
-        t[i] = SC_COMPILER_C_ILLEGAL;
+        t[i] = ScCharFlags::Illegal;
 
 // tdf#56036: Allow tabs/newlines in imported formulas (for now simply treat them as (and convert to) space)
 // TODO: tdf#76310: allow saving newlines as is (as per OpenFormula specification v.1.2, clause 5.14 "Whitespace")
 // This is compliant with the OASIS decision (see https://issues.oasis-open.org/browse/OFFICE-701)
 // Also, this would enable correct roundtrip from/to OOXML without losing tabs/newlines
 // This requires saving actual space characters in ocSpaces token, using them in UI and saving
-/* tab */   t[ 9] = SC_COMPILER_C_CHAR_DONTCARE | SC_COMPILER_C_WORD_SEP | SC_COMPILER_C_VALUE_SEP;
-/* lf  */   t[10] = SC_COMPILER_C_CHAR_DONTCARE | SC_COMPILER_C_WORD_SEP | SC_COMPILER_C_VALUE_SEP;
-/* cr  */   t[13] = SC_COMPILER_C_CHAR_DONTCARE | SC_COMPILER_C_WORD_SEP | SC_COMPILER_C_VALUE_SEP;
+/* tab */   t[ 9] = ScCharFlags::CharDontCare | ScCharFlags::WordSep | ScCharFlags::ValueSep;
+/* lf  */   t[10] = ScCharFlags::CharDontCare | ScCharFlags::WordSep | ScCharFlags::ValueSep;
+/* cr  */   t[13] = ScCharFlags::CharDontCare | ScCharFlags::WordSep | ScCharFlags::ValueSep;
 
-/*   */     t[32] = SC_COMPILER_C_CHAR_DONTCARE | SC_COMPILER_C_WORD_SEP | SC_COMPILER_C_VALUE_SEP;
-/* ! */     t[33] = SC_COMPILER_C_CHAR | SC_COMPILER_C_WORD_SEP | SC_COMPILER_C_VALUE_SEP;
+/*   */     t[32] = ScCharFlags::CharDontCare | ScCharFlags::WordSep | ScCharFlags::ValueSep;
+/* ! */     t[33] = ScCharFlags::Char | ScCharFlags::WordSep | ScCharFlags::ValueSep;
             if (FormulaGrammar::CONV_ODF == meConv)
-/* ! */         t[33] |= SC_COMPILER_C_ODF_LABEL_OP;
-/* " */     t[34] = SC_COMPILER_C_CHAR_STRING | SC_COMPILER_C_STRING_SEP;
-/* # */     t[35] = SC_COMPILER_C_WORD_SEP | SC_COMPILER_C_CHAR_ERRCONST;
-/* $ */     t[36] = SC_COMPILER_C_CHAR_WORD | SC_COMPILER_C_WORD | SC_COMPILER_C_CHAR_IDENT | SC_COMPILER_C_IDENT;
+/* ! */         t[33] |= ScCharFlags::OdfLabelOp;
+/* " */     t[34] = ScCharFlags::CharString | ScCharFlags::StringSep;
+/* # */     t[35] = ScCharFlags::WordSep | ScCharFlags::CharErrConst;
+/* $ */     t[36] = ScCharFlags::CharWord | ScCharFlags::Word | ScCharFlags::CharIdent | ScCharFlags::Ident;
             if (FormulaGrammar::CONV_ODF == meConv)
-/* $ */         t[36] |= SC_COMPILER_C_ODF_NAME_MARKER;
-/* % */     t[37] = SC_COMPILER_C_VALUE;
-/* & */     t[38] = SC_COMPILER_C_CHAR | SC_COMPILER_C_WORD_SEP | SC_COMPILER_C_VALUE_SEP;
-/* ' */     t[39] = SC_COMPILER_C_NAME_SEP;
-/* ( */     t[40] = SC_COMPILER_C_CHAR | SC_COMPILER_C_WORD_SEP | SC_COMPILER_C_VALUE_SEP;
-/* ) */     t[41] = SC_COMPILER_C_CHAR | SC_COMPILER_C_WORD_SEP | SC_COMPILER_C_VALUE_SEP;
-/* * */     t[42] = SC_COMPILER_C_CHAR | SC_COMPILER_C_WORD_SEP | SC_COMPILER_C_VALUE_SEP;
-/* + */     t[43] = SC_COMPILER_C_CHAR | SC_COMPILER_C_WORD_SEP | SC_COMPILER_C_VALUE_EXP | SC_COMPILER_C_VALUE_SIGN;
-/* , */     t[44] = SC_COMPILER_C_CHAR_VALUE | SC_COMPILER_C_VALUE;
-/* - */     t[45] = SC_COMPILER_C_CHAR | SC_COMPILER_C_WORD_SEP | SC_COMPILER_C_VALUE_EXP | SC_COMPILER_C_VALUE_SIGN;
-/* . */     t[46] = SC_COMPILER_C_WORD | SC_COMPILER_C_CHAR_VALUE | SC_COMPILER_C_VALUE | SC_COMPILER_C_IDENT | SC_COMPILER_C_NAME;
-/* / */     t[47] = SC_COMPILER_C_CHAR | SC_COMPILER_C_WORD_SEP | SC_COMPILER_C_VALUE_SEP;
+/* $ */         t[36] |= ScCharFlags::OdfNameMarker;
+/* % */     t[37] = ScCharFlags::Value;
+/* & */     t[38] = ScCharFlags::Char | ScCharFlags::WordSep | ScCharFlags::ValueSep;
+/* ' */     t[39] = ScCharFlags::NameSep;
+/* ( */     t[40] = ScCharFlags::Char | ScCharFlags::WordSep | ScCharFlags::ValueSep;
+/* ) */     t[41] = ScCharFlags::Char | ScCharFlags::WordSep | ScCharFlags::ValueSep;
+/* * */     t[42] = ScCharFlags::Char | ScCharFlags::WordSep | ScCharFlags::ValueSep;
+/* + */     t[43] = ScCharFlags::Char | ScCharFlags::WordSep | ScCharFlags::ValueExp | ScCharFlags::ValueSign;
+/* , */     t[44] = ScCharFlags::CharValue | ScCharFlags::Value;
+/* - */     t[45] = ScCharFlags::Char | ScCharFlags::WordSep | ScCharFlags::ValueExp | ScCharFlags::ValueSign;
+/* . */     t[46] = ScCharFlags::Word | ScCharFlags::CharValue | ScCharFlags::Value | ScCharFlags::Ident | ScCharFlags::Name;
+/* / */     t[47] = ScCharFlags::Char | ScCharFlags::WordSep | ScCharFlags::ValueSep;
 
             for (i = 48; i < 58; i++)
-/* 0-9 */       t[i] = SC_COMPILER_C_CHAR_VALUE | SC_COMPILER_C_WORD | SC_COMPILER_C_VALUE | SC_COMPILER_C_VALUE_EXP | SC_COMPILER_C_VALUE_VALUE | SC_COMPILER_C_IDENT | SC_COMPILER_C_NAME;
-
-/* : */     t[58] = SC_COMPILER_C_CHAR | SC_COMPILER_C_WORD;
-/* ; */     t[59] = SC_COMPILER_C_CHAR | SC_COMPILER_C_WORD_SEP | SC_COMPILER_C_VALUE_SEP;
-/* < */     t[60] = SC_COMPILER_C_CHAR_BOOL | SC_COMPILER_C_WORD_SEP | SC_COMPILER_C_VALUE_SEP;
-/* = */     t[61] = SC_COMPILER_C_CHAR | SC_COMPILER_C_BOOL | SC_COMPILER_C_WORD_SEP | SC_COMPILER_C_VALUE_SEP;
-/* > */     t[62] = SC_COMPILER_C_CHAR_BOOL | SC_COMPILER_C_BOOL | SC_COMPILER_C_WORD_SEP | SC_COMPILER_C_VALUE_SEP;
-/* ? */     t[63] = SC_COMPILER_C_CHAR_WORD | SC_COMPILER_C_WORD | SC_COMPILER_C_NAME;
+/* 0-9 */       t[i] = ScCharFlags::CharValue | ScCharFlags::Word | ScCharFlags::Value | ScCharFlags::ValueExp | ScCharFlags::ValueValue | ScCharFlags::Ident | ScCharFlags::Name;
+
+/* : */     t[58] = ScCharFlags::Char | ScCharFlags::Word;
+/* ; */     t[59] = ScCharFlags::Char | ScCharFlags::WordSep | ScCharFlags::ValueSep;
+/* < */     t[60] = ScCharFlags::CharBool | ScCharFlags::WordSep | ScCharFlags::ValueSep;
+/* = */     t[61] = ScCharFlags::Char | ScCharFlags::Bool | ScCharFlags::WordSep | ScCharFlags::ValueSep;
+/* > */     t[62] = ScCharFlags::CharBool | ScCharFlags::Bool | ScCharFlags::WordSep | ScCharFlags::ValueSep;
+/* ? */     t[63] = ScCharFlags::CharWord | ScCharFlags::Word | ScCharFlags::Name;
 /* @ */     // FREE
 
     for (i = 65; i < 91; i++)
-/* A-Z */   t[i] = SC_COMPILER_C_CHAR_WORD | SC_COMPILER_C_WORD | SC_COMPILER_C_CHAR_IDENT | SC_COMPILER_C_IDENT | SC_COMPILER_C_CHAR_NAME | SC_COMPILER_C_NAME;
+/* A-Z */   t[i] = ScCharFlags::CharWord | ScCharFlags::Word | ScCharFlags::CharIdent | ScCharFlags::Ident | ScCharFlags::CharName | ScCharFlags::Name;
 
     if (FormulaGrammar::CONV_ODF == meConv)
     {
-/* [ */     t[91] = SC_COMPILER_C_ODF_LBRACKET;
+/* [ */     t[91] = ScCharFlags::OdfLBracket;
 /* \ */     // FREE
-/* ] */     t[93] = SC_COMPILER_C_ODF_RBRACKET;
+/* ] */     t[93] = ScCharFlags::OdfRBracket;
     }
     else if (FormulaGrammar::CONV_OOO == meConv)
     {
-/* [ */     t[91] = SC_COMPILER_C_CHAR;
+/* [ */     t[91] = ScCharFlags::Char;
 /* \ */     // FREE
-/* ] */     t[93] = SC_COMPILER_C_CHAR;
+/* ] */     t[93] = ScCharFlags::Char;
     }
     else if (FormulaGrammar::CONV_XL_OOX == meConv)
     {
-/* [ */     t[91] = SC_COMPILER_C_CHAR | SC_COMPILER_C_CHAR_IDENT;
+/* [ */     t[91] = ScCharFlags::Char | ScCharFlags::CharIdent;
 /* \ */     // FREE
-/* ] */     t[93] = SC_COMPILER_C_CHAR | SC_COMPILER_C_IDENT;
+/* ] */     t[93] = ScCharFlags::Char | ScCharFlags::Ident;
     }
     else if (FormulaGrammar::CONV_XL_A1 == meConv)
     {
-/* [ */     t[91] = SC_COMPILER_C_CHAR;
+/* [ */     t[91] = ScCharFlags::Char;
 /* \ */     // FREE
-/* ] */     t[93] = SC_COMPILER_C_CHAR;
+/* ] */     t[93] = ScCharFlags::Char;
     }
     else if( FormulaGrammar::CONV_XL_R1C1 == meConv )
     {
-/* [ */     t[91] = SC_COMPILER_C_IDENT;
+/* [ */     t[91] = ScCharFlags::Ident;
 /* \ */     // FREE
-/* ] */     t[93] = SC_COMPILER_C_IDENT;
+/* ] */     t[93] = ScCharFlags::Ident;
     }
     else
     {
@@ -394,55 +394,55 @@ ScCompiler::Convention::Convention( FormulaGrammar::AddressConvention eConv )
 /* ] */     // FREE
     }
 
-/* ^ */     t[94] = SC_COMPILER_C_CHAR | SC_COMPILER_C_WORD_SEP | SC_COMPILER_C_VALUE_SEP;
-/* _ */     t[95] = SC_COMPILER_C_CHAR_WORD | SC_COMPILER_C_WORD | SC_COMPILER_C_CHAR_IDENT | SC_COMPILER_C_IDENT | SC_COMPILER_C_CHAR_NAME | SC_COMPILER_C_NAME;
+/* ^ */     t[94] = ScCharFlags::Char | ScCharFlags::WordSep | ScCharFlags::ValueSep;
+/* _ */     t[95] = ScCharFlags::CharWord | ScCharFlags::Word | ScCharFlags::CharIdent | ScCharFlags::Ident | ScCharFlags::CharName | ScCharFlags::Name;
 /* ` */     // FREE
 
             for (i = 97; i < 123; i++)
-/* a-z */       t[i] = SC_COMPILER_C_CHAR_WORD | SC_COMPILER_C_WORD | SC_COMPILER_C_CHAR_IDENT | SC_COMPILER_C_IDENT | SC_COMPILER_C_CHAR_NAME | SC_COMPILER_C_NAME;
+/* a-z */       t[i] = ScCharFlags::CharWord | ScCharFlags::Word | ScCharFlags::CharIdent | ScCharFlags::Ident | ScCharFlags::CharName | ScCharFlags::Name;
 
-/* { */     t[123] = SC_COMPILER_C_CHAR | SC_COMPILER_C_WORD_SEP | SC_COMPILER_C_VALUE_SEP; // array open
-/* | */     t[124] = SC_COMPILER_C_CHAR | SC_COMPILER_C_WORD_SEP | SC_COMPILER_C_VALUE_SEP; // array row sep (Should be OOo specific)
-/* } */     t[125] = SC_COMPILER_C_CHAR | SC_COMPILER_C_WORD_SEP | SC_COMPILER_C_VALUE_SEP; // array close
-/* ~ */     t[126] = SC_COMPILER_C_CHAR;        // OOo specific
+/* { */     t[123] = ScCharFlags::Char | ScCharFlags::WordSep | ScCharFlags::ValueSep; // array open
+/* | */     t[124] = ScCharFlags::Char | ScCharFlags::WordSep | ScCharFlags::ValueSep; // array row sep (Should be OOo specific)
+/* } */     t[125] = ScCharFlags::Char | ScCharFlags::WordSep | ScCharFlags::ValueSep; // array close
+/* ~ */     t[126] = ScCharFlags::Char;        // OOo specific
 /* 127 */   // FREE
 
     if( FormulaGrammar::CONV_XL_A1 == meConv || FormulaGrammar::CONV_XL_R1C1 == meConv || FormulaGrammar::CONV_XL_OOX == meConv )
     {
-/*   */     t[32] |=   SC_COMPILER_C_WORD;
-/* ! */     t[33] |=   SC_COMPILER_C_IDENT | SC_COMPILER_C_WORD;
-/* " */     t[34] |=   SC_COMPILER_C_WORD;
-/* # */     t[35] &= (~SC_COMPILER_C_WORD_SEP);
-/* # */     t[35] |=   SC_COMPILER_C_WORD;
-/* % */     t[37] |=   SC_COMPILER_C_WORD;
-/* ' */     t[39] |=   SC_COMPILER_C_WORD;
-
-/* % */     t[37] |=   SC_COMPILER_C_WORD;
-/* & */     t[38] |=   SC_COMPILER_C_WORD;
-/* ' */     t[39] |=   SC_COMPILER_C_WORD;
-/* ( */     t[40] |=   SC_COMPILER_C_WORD;
-/* ) */     t[41] |=   SC_COMPILER_C_WORD;
-/* * */     t[42] |=   SC_COMPILER_C_WORD;
-/* + */     t[43] |=   SC_COMPILER_C_WORD;
+/*   */     t[32] |=   ScCharFlags::Word;
+/* ! */     t[33] |=   ScCharFlags::Ident | ScCharFlags::Word;
+/* " */     t[34] |=   ScCharFlags::Word;
+/* # */     t[35] &= (~ScCharFlags::WordSep);
+/* # */     t[35] |=   ScCharFlags::Word;
+/* % */     t[37] |=   ScCharFlags::Word;
+/* ' */     t[39] |=   ScCharFlags::Word;
+
+/* % */     t[37] |=   ScCharFlags::Word;
+/* & */     t[38] |=   ScCharFlags::Word;
+/* ' */     t[39] |=   ScCharFlags::Word;
+/* ( */     t[40] |=   ScCharFlags::Word;
+/* ) */     t[41] |=   ScCharFlags::Word;
+/* * */     t[42] |=   ScCharFlags::Word;
+/* + */     t[43] |=   ScCharFlags::Word;
 #if 0 /* this really needs to be locale specific. */
-/* , */     t[44]  =   SC_COMPILER_C_CHAR | SC_COMPILER_C_WORD_SEP | SC_COMPILER_C_VALUE_SEP;
+/* , */     t[44]  =   ScCharFlags::Char | ScCharFlags::WordSep | ScCharFlags::ValueSep;
 #else
-/* , */     t[44] |=   SC_COMPILER_C_WORD;
+/* , */     t[44] |=   ScCharFlags::Word;
 #endif
-/* - */     t[45] |=   SC_COMPILER_C_WORD;
+/* - */     t[45] |=   ScCharFlags::Word;
 
-/* ; */     t[59] |=   SC_COMPILER_C_WORD;
-/* < */     t[60] |=   SC_COMPILER_C_WORD;
-/* = */     t[61] |=   SC_COMPILER_C_WORD;
-/* > */     t[62] |=   SC_COMPILER_C_WORD;
+/* ; */     t[59] |=   ScCharFlags::Word;
+/* < */     t[60] |=   ScCharFlags::Word;
+/* = */     t[61] |=   ScCharFlags::Word;
+/* > */     t[62] |=   ScCharFlags::Word;
 /* ? */     // question really is not permitted in sheet name
-/* @ */     t[64] |=   SC_COMPILER_C_WORD;
-/* [ */     t[91] |=   SC_COMPILER_C_WORD;
-/* ] */     t[93] |=   SC_COMPILER_C_WORD;
-/* { */     t[123]|=   SC_COMPILER_C_WORD;
-/* | */     t[124]|=   SC_COMPILER_C_WORD;
-/* } */     t[125]|=   SC_COMPILER_C_WORD;
-/* ~ */     t[126]|=   SC_COMPILER_C_WORD;
+/* @ */     t[64] |=   ScCharFlags::Word;
+/* [ */     t[91] |=   ScCharFlags::Word;
+/* ] */     t[93] |=   ScCharFlags::Word;
+/* { */     t[123]|=   ScCharFlags::Word;
+/* | */     t[124]|=   ScCharFlags::Word;
+/* } */     t[125]|=   ScCharFlags::Word;
+/* ~ */     t[126]|=   ScCharFlags::Word;
     }
 }
 
@@ -726,7 +726,7 @@ struct Convention_A1 : public ScCompiler::Convention
                 nSrcPos, nStartFlags, aAddAllowed, nContFlags, aAddAllowed );
     }
 
-    virtual sal_uLong getCharTableFlags( sal_Unicode c, sal_Unicode /*cLast*/ ) const override
+    virtual ScCharFlags getCharTableFlags( sal_Unicode c, sal_Unicode /*cLast*/ ) const override
     {
         return mpCharTable[static_cast<sal_uInt8>(c)];
     }
@@ -1706,12 +1706,12 @@ struct ConventionXL_R1C1 : public ScCompiler::Convention, public ConventionXL
         r1c1_add_col(rBuffer, rRef.Ref2, aAbsRef.aEnd);
     }
 
-    virtual sal_uLong getCharTableFlags( sal_Unicode c, sal_Unicode cLast ) const override
+    virtual ScCharFlags getCharTableFlags( sal_Unicode c, sal_Unicode cLast ) const override
     {
-        sal_uLong nFlags = mpCharTable[static_cast<sal_uInt8>(c)];
+        ScCharFlags nFlags = mpCharTable[static_cast<sal_uInt8>(c)];
         if (c == '-' && cLast == '[')
             // '-' can occur within a reference string only after '[' e.g. R[-1]C.
-            nFlags |= SC_COMPILER_C_IDENT;
+            nFlags |= ScCharFlags::Ident;
         return nFlags;
     }
 };
@@ -2011,7 +2011,7 @@ sal_Int32 ScCompiler::NextSymbol(bool bInArray)
     while ((c != 0) && (eState != ssStop) )
     {
         pSrc++;
-        sal_uLong nMask = GetCharTableFlags( c, cLast );
+        ScCharFlags nMask = GetCharTableFlags( c, cLast );
 
         // The parameter separator and the array column and row separators end
         // things unconditionally if not in string or reference.
@@ -2044,10 +2044,10 @@ Label_MaskStateMachine:
                     *pSym++ = c;
                     eState = ssGetTableRefColumn;
                 }
-                else if( nMask & SC_COMPILER_C_ODF_LABEL_OP )
+                else if( nMask & ScCharFlags::OdfLabelOp )
                 {
                     // '!!' automatic intersection
-                    if (GetCharTableFlags( pSrc[0], 0 ) & SC_COMPILER_C_ODF_LABEL_OP)
+                    if (GetCharTableFlags( pSrc[0], 0 ) & ScCharFlags::OdfLabelOp)
                     {
                         /* TODO: For now the UI "space operator" is used, this
                          * could be enhanced using a specialized OpCode to get
@@ -2071,25 +2071,25 @@ Label_MaskStateMachine:
                     }
                     else
                     {
-                        nMask &= ~SC_COMPILER_C_ODF_LABEL_OP;
+                        nMask &= ~ScCharFlags::OdfLabelOp;
                         goto Label_MaskStateMachine;
                     }
                 }
-                else if( nMask & SC_COMPILER_C_ODF_NAME_MARKER )
+                else if( nMask & ScCharFlags::OdfNameMarker )
                 {
                     // '$$' defined name marker
-                    if (GetCharTableFlags( pSrc[0], 0 ) & SC_COMPILER_C_ODF_NAME_MARKER)
+                    if (GetCharTableFlags( pSrc[0], 0 ) & ScCharFlags::OdfNameMarker)
                     {
                         // both eaten, not added to pSym
                         ++pSrc;
                     }
                     else
                     {
-                        nMask &= ~SC_COMPILER_C_ODF_NAME_MARKER;
+                        nMask &= ~ScCharFlags::OdfNameMarker;
                         goto Label_MaskStateMachine;
                     }
                 }
-                else if( nMask & SC_COMPILER_C_CHAR )
+                else if( nMask & ScCharFlags::Char )
                 {
                     // '[' is a special case in OOXML, it can start an external
                     // reference ID like [1]Sheet1!A1 that needs to be scanned
@@ -2097,7 +2097,7 @@ Label_MaskStateMachine:
                     // transforms an ocDBArea into an ocTableRef.
                     if (c == '[' && FormulaGrammar::isOOXML( meGrammar) && eLastOp != ocDBArea && maTableRefs.empty())
                     {
-                        nMask &= ~SC_COMPILER_C_CHAR;
+                        nMask &= ~ScCharFlags::Char;
                         goto Label_MaskStateMachine;
                     }
                     else
@@ -2106,28 +2106,28 @@ Label_MaskStateMachine:
                         eState = ssStop;
                     }
                 }
-                else if( nMask & SC_COMPILER_C_ODF_LBRACKET )
+                else if( nMask & ScCharFlags::OdfLBracket )
                 {
                     // eaten, not added to pSym
                     eState = ssGetReference;
                     mnPredetectedReference = 1;
                 }
-                else if( nMask & SC_COMPILER_C_CHAR_BOOL )
+                else if( nMask & ScCharFlags::CharBool )
                 {
                     *pSym++ = c;
                     eState = ssGetBool;
                 }
-                else if( nMask & SC_COMPILER_C_CHAR_VALUE )
+                else if( nMask & ScCharFlags::CharValue )
                 {
                     *pSym++ = c;
                     eState = ssGetValue;
                 }
-                else if( nMask & SC_COMPILER_C_CHAR_STRING )
+                else if( nMask & ScCharFlags::CharString )
                 {
                     *pSym++ = c;
                     eState = ssGetString;
                 }
-                else if( nMask & SC_COMPILER_C_CHAR_ERRCONST )
+                else if( nMask & ScCharFlags::CharErrConst )
                 {
                     *pSym++ = c;
                     if (!maTableRefs.empty() && maTableRefs.back().mnLevel == 2)
@@ -2135,11 +2135,11 @@ Label_MaskStateMachine:
                     else
                         eState = ssGetErrorConstant;
                 }
-                else if( nMask & SC_COMPILER_C_CHAR_DONTCARE )
+                else if( nMask & ScCharFlags::CharDontCare )
                 {
                     nSpaces++;
                 }
-                else if( nMask & SC_COMPILER_C_CHAR_IDENT )
+                else if( nMask & ScCharFlags::CharIdent )
                 {   // try to get a simple ASCII identifier before calling
                     // i18n, to gain performance during import
                     *pSym++ = c;
@@ -2154,7 +2154,7 @@ Label_MaskStateMachine:
             break;
             case ssGetIdent:
             {
-                if ( nMask & SC_COMPILER_C_IDENT )
+                if ( nMask & ScCharFlags::Ident )
                 {   // This catches also $Sheet1.A$1, for example.
                     if( pSym == &cSymbol[ MAXSTRLEN-1 ] )
                     {
@@ -2220,7 +2220,7 @@ Label_MaskStateMachine:
             break;
             case ssGetBool :
             {
-                if( nMask & SC_COMPILER_C_BOOL )
+                if( nMask & ScCharFlags::Bool )
                 {
                     *pSym++ = c;
                     eState = ssStop;
@@ -2250,16 +2250,16 @@ Label_MaskStateMachine:
                     else
                         *pSym++ = c;
                 }
-                else if( nMask & SC_COMPILER_C_VALUE )
+                else if( nMask & ScCharFlags::Value )
                     *pSym++ = c;
-                else if( nMask & SC_COMPILER_C_VALUE_SEP )
+                else if( nMask & ScCharFlags::ValueSep )
                 {
                     pSrc--;
                     eState = ssStop;
                 }
                 else if (c == 'E' || c == 'e')
                 {
-                    if (GetCharTableFlags( pSrc[0], 0 ) & SC_COMPILER_C_VALUE_EXP)
+                    if (GetCharTableFlags( pSrc[0], 0 ) & ScCharFlags::ValueExp)
                         *pSym++ = c;
                     else
                     {
@@ -2268,10 +2268,10 @@ Label_MaskStateMachine:
                         eState = ssStop;
                     }
                 }
-                else if( nMask & SC_COMPILER_C_VALUE_SIGN )
+                else if( nMask & ScCharFlags::ValueSign )
                 {
                     if (((cLast == 'E') || (cLast == 'e')) &&
-                            (GetCharTableFlags( pSrc[0], 0 ) & SC_COMPILER_C_VALUE_VALUE))
+                            (GetCharTableFlags( pSrc[0], 0 ) & ScCharFlags::ValueValue))
                     {
                         *pSym++ = c;
                     }
@@ -2291,7 +2291,7 @@ Label_MaskStateMachine:
             break;
             case ssGetString :
             {
-                if( nMask & SC_COMPILER_C_STRING_SEP )
+                if( nMask & ScCharFlags::StringSep )
                 {
                     if ( !bQuote )
                     {
@@ -2316,7 +2316,7 @@ Label_MaskStateMachine:
             }
             break;
             case ssSkipString:
-                if( nMask & SC_COMPILER_C_STRING_SEP )
+                if( nMask & ScCharFlags::StringSep )
                     eState = ssStop;
                 break;
             case ssGetErrorConstant:
@@ -2338,7 +2338,7 @@ Label_MaskStateMachine:
                         // Check if this is #REF! that starts an invalid reference.
                         // Note we have an implicit '!' here at the end.
                         if (pSym - &cSymbol[0] == 4 && lcl_isUnicodeIgnoreAscii( cSymbol, "#REF", 4) &&
-                                ((GetCharTableFlags( *pSrc, c) & SC_COMPILER_C_IDENT) != 0))
+                                (GetCharTableFlags( *pSrc, c) & ScCharFlags::Ident))
                             eState = ssGetIdent;
                         else
                             eState = ssStop;
@@ -2353,7 +2353,7 @@ Label_MaskStateMachine:
                             eState = ssStop;
                         }
                     }
-                    else if ((nMask & SC_COMPILER_C_WORD_SEP) ||
+                    else if ((nMask & ScCharFlags::WordSep) ||
                             (c < 128 && !rtl::isAsciiAlphanumeric( c)))
                     {
                         bAdd = false;
@@ -2465,7 +2465,7 @@ Label_MaskStateMachine:
                     static const int kRefErr    = (1 << 10);
 
                     bool bAddToSymbol = true;
-                    if ((nMask & SC_COMPILER_C_ODF_RBRACKET) && !(nRefInName & kOpen))
+                    if ((nMask & ScCharFlags::OdfRBracket) && !(nRefInName & kOpen))
                     {
                         OSL_ENSURE( nRefInName & (kPast | kDefName | kRefErr),
                                 "ScCompiler::NextSymbol: reference: "
@@ -3091,7 +3091,7 @@ bool ScCompiler::IsReference( const OUString& rName, const OUString* pErrRef )
             if ( !(ch2 == '$' || rtl::isAsciiAlpha( ch2 )) )
                 return false;
             if ( cDecSep == '.' && (ch2 == 'E' || ch2 == 'e')   // E + - digit
-                    && (GetCharTableFlags( pTabSep[2], pTabSep[1] ) & SC_COMPILER_C_VALUE_EXP) )
+                    && (GetCharTableFlags( pTabSep[2], pTabSep[1] ) & ScCharFlags::ValueExp) )
             {
                 // If it is an 1.E2 expression check if "1" is an existent sheet
                 // name. If so, a desired value 1.E2 would have to be entered as
@@ -3769,7 +3769,7 @@ void ScCompiler::AutoCorrectParsedSymbol()
             // Don't be pedantic: c < 128 should be sufficient here.
             while ( nPos && ((aCorrectedSymbol[nPos] < 128) &&
                     ((GetCharTableFlags(aCorrectedSymbol[nPos], aCorrectedSymbol[nPos-1]) &
-                    (SC_COMPILER_C_WORD | SC_COMPILER_C_CHAR_DONTCARE)) == 0)) )
+                    (ScCharFlags::Word | ScCharFlags::CharDontCare)) == ScCharFlags::NONE)) )
                 nPos--;
             if ( nPos == MAXSTRLEN - 2 )
                 aCorrectedSymbol = aCorrectedSymbol.replaceAt( nPos, 1, OUString(cQuote) );   // '"' the 255th character
@@ -3787,8 +3787,8 @@ void ScCompiler::AutoCorrectParsedSymbol()
             aCorrectedSymbol = mxSymbols->getSymbol(ocMul);
             bCorrected = true;
         }
-        else if ( (GetCharTableFlags( c1, 0 ) & SC_COMPILER_C_CHAR_VALUE)
-               && (GetCharTableFlags( c2, c2p ) & SC_COMPILER_C_CHAR_VALUE) )
+        else if ( (GetCharTableFlags( c1, 0 ) & ScCharFlags::CharValue)
+               && (GetCharTableFlags( c2, c2p ) & ScCharFlags::CharValue) )
         {
             if ( comphelper::string::getTokenCount(aCorrectedSymbol, cx) > 1 )
             {   // x => *
@@ -4719,7 +4719,7 @@ void ScCompiler::MoveRelWrap( ScTokenArray& rArr, ScDocument* pDoc, const ScAddr
 }
 
 bool ScCompiler::IsCharFlagAllConventions(
-    OUString const & rStr, sal_Int32 nPos, sal_uLong nFlags )
+    OUString const & rStr, sal_Int32 nPos, ScCharFlags nFlags )
 {
     sal_Unicode c = rStr[ nPos ];
     sal_Unicode cLast = nPos > 0 ? rStr[ nPos-1 ] : 0;
diff --git a/sc/source/core/tool/rangenam.cxx b/sc/source/core/tool/rangenam.cxx
index 62b90c7..7626e16 100644
--- a/sc/source/core/tool/rangenam.cxx
+++ b/sc/source/core/tool/rangenam.cxx
@@ -437,20 +437,20 @@ void ScRangeData::MakeValidName( OUString& rName )
     // strip leading invalid characters
     sal_Int32 nPos = 0;
     sal_Int32 nLen = rName.getLength();
-    while ( nPos < nLen && !ScCompiler::IsCharFlagAllConventions( rName, nPos, SC_COMPILER_C_NAME) )
+    while ( nPos < nLen && !ScCompiler::IsCharFlagAllConventions( rName, nPos, ScCharFlags::Name) )
         ++nPos;
     if ( nPos>0 )
         rName = rName.copy(nPos);
 
     // if the first character is an invalid start character, precede with '_'
-    if ( !rName.isEmpty() && !ScCompiler::IsCharFlagAllConventions( rName, 0, SC_COMPILER_C_CHAR_NAME ) )
+    if ( !rName.isEmpty() && !ScCompiler::IsCharFlagAllConventions( rName, 0, ScCharFlags::CharName ) )
         rName = "_" + rName;
 
     // replace invalid with '_'
     nLen = rName.getLength();
     for (nPos=0; nPos<nLen; nPos++)
     {
-        if ( !ScCompiler::IsCharFlagAllConventions( rName, nPos, SC_COMPILER_C_NAME) )
+        if ( !ScCompiler::IsCharFlagAllConventions( rName, nPos, ScCharFlags::Name) )
             rName = rName.replaceAt( nPos, 1, "_" );
     }
 
@@ -485,11 +485,11 @@ bool ScRangeData::IsNameValid( const OUString& rName, ScDocument* pDoc )
         return false;
     sal_Int32 nPos = 0;
     sal_Int32 nLen = rName.getLength();
-    if ( !nLen || !ScCompiler::IsCharFlagAllConventions( rName, nPos++, SC_COMPILER_C_CHAR_NAME ) )
+    if ( !nLen || !ScCompiler::IsCharFlagAllConventions( rName, nPos++, ScCharFlags::CharName ) )
         return false;
     while ( nPos < nLen )
     {
-        if ( !ScCompiler::IsCharFlagAllConventions( rName, nPos++, SC_COMPILER_C_NAME ) )
+        if ( !ScCompiler::IsCharFlagAllConventions( rName, nPos++, ScCharFlags::Name ) )
             return false;
     }
     ScAddress aAddr;
diff --git a/sc/source/filter/ftools/ftools.cxx b/sc/source/filter/ftools/ftools.cxx
index fde80bd..e40967b 100644
--- a/sc/source/filter/ftools/ftools.cxx
+++ b/sc/source/filter/ftools/ftools.cxx
@@ -155,10 +155,10 @@ OUString ScfTools::ConvertToScDefinedName(const OUString& rName )
     OUString sName = rName.replace(static_cast<sal_Unicode>('.'),
         static_cast<sal_Unicode>('_'));
     sal_Int32 nLen = sName.getLength();
-    if( nLen && !ScCompiler::IsCharFlagAllConventions( sName, 0, SC_COMPILER_C_CHAR_NAME ) )
+    if( nLen && !ScCompiler::IsCharFlagAllConventions( sName, 0, ScCharFlags::CharName ) )
         sName = sName.replaceAt( 0, 1, "_" );
     for( sal_Int32 nPos = 1; nPos < nLen; ++nPos )
-        if( !ScCompiler::IsCharFlagAllConventions( sName, nPos, SC_COMPILER_C_NAME ) )
+        if( !ScCompiler::IsCharFlagAllConventions( sName, nPos, ScCharFlags::Name ) )
             sName = sName.replaceAt( nPos, 1, "_" );
     return sName;
 }


More information about the Libreoffice-commits mailing list