diff options
Diffstat (limited to 'starmath/inc/token.hxx')
-rw-r--r-- | starmath/inc/token.hxx | 187 |
1 files changed, 91 insertions, 96 deletions
diff --git a/starmath/inc/token.hxx b/starmath/inc/token.hxx index a1cbe95d214c..cc295cc5fe28 100644 --- a/starmath/inc/token.hxx +++ b/starmath/inc/token.hxx @@ -17,7 +17,7 @@ * the License at http://www.apache.org/licenses/LICENSE-2.0 . */ - /** The tokens contain the information gathered by the parser. +/** The tokens contain the information gathered by the parser. * * They contain: * the data type (~ mathematical operation). @@ -36,29 +36,33 @@ #include <tools/color.hxx> // TokenGroups -enum class TG { - NONE = 0x000000, - Oper = 0x000001, - Relation = 0x000002, - Sum = 0x000004, - Product = 0x000008, - UnOper = 0x000010, - Power = 0x000020, - Attribute = 0x000040, - Align = 0x000080, - Function = 0x000100, - Blank = 0x000200, - LBrace = 0x000400, - RBrace = 0x000800, - Color = 0x001000, - Font = 0x002000, - Standalone = 0x004000, - Limit = 0x010000, - FontAttr = 0x020000 +enum class TG +{ + NONE = 0x000000, + Oper = 0x000001, + Relation = 0x000002, + Sum = 0x000004, + Product = 0x000008, + UnOper = 0x000010, + Power = 0x000020, + Attribute = 0x000040, + Align = 0x000080, + Function = 0x000100, + Blank = 0x000200, + LBrace = 0x000400, + RBrace = 0x000800, + Color = 0x001000, + Font = 0x002000, + Standalone = 0x004000, + Limit = 0x010000, + FontAttr = 0x020000 }; -namespace o3tl { - template<> struct typed_flags<TG> : is_typed_flags<TG, 0x037fff> {}; +namespace o3tl +{ +template <> struct typed_flags<TG> : is_typed_flags<TG, 0x037fff> +{ +}; } // Tokens identifiers. Allow to know what kind of information the node contains. @@ -145,101 +149,93 @@ enum SmTokenType struct SmTokenTableEntry { - const char* pIdent; - SmTokenType eType; - sal_Unicode cMathChar; - TG nGroup; - sal_uInt16 nLevel; + const char* pIdent; + SmTokenType eType; + sal_Unicode cMathChar; + TG nGroup; + sal_uInt16 nLevel; }; struct SmColorTokenTableEntry { - const char* pIdent; - const char* cIdent; - SmTokenType eType; - Color cColor; + const char* pIdent; + const char* cIdent; + SmTokenType eType; + Color cColor; SmColorTokenTableEntry() - : pIdent("") - , cIdent("") - , eType(TERROR) - , cColor() - {} - - SmColorTokenTableEntry( const SmColorTokenTableEntry * amColorTokenTableEntry ) - : pIdent(amColorTokenTableEntry->pIdent) - , cIdent(amColorTokenTableEntry->cIdent) - , eType(amColorTokenTableEntry->eType) - , cColor(amColorTokenTableEntry->cColor) - {} - - SmColorTokenTableEntry( const std::unique_ptr<SmColorTokenTableEntry> amColorTokenTableEntry ) - : pIdent(amColorTokenTableEntry->pIdent) - , cIdent(amColorTokenTableEntry->cIdent) - , eType(amColorTokenTableEntry->eType) - , cColor(amColorTokenTableEntry->cColor) - {} - - SmColorTokenTableEntry( const char* name, const char* codename, SmTokenType ctype, Color ncolor) - : pIdent(name) - , cIdent(codename) - , eType(ctype) - , cColor(ncolor) - {} - - SmColorTokenTableEntry( const char* name, const char* codename, SmTokenType ctype, sal_uInt32 ncolor) - : pIdent(name) - , cIdent(codename) - , eType(ctype) - , cColor(ncolor) - {} + : pIdent("") + , cIdent("") + , eType(TERROR) + , cColor() + { + } - bool operator == ( const OUString & colorname ) const + SmColorTokenTableEntry(const SmColorTokenTableEntry* amColorTokenTableEntry) + : pIdent(amColorTokenTableEntry->pIdent) + , cIdent(amColorTokenTableEntry->cIdent) + , eType(amColorTokenTableEntry->eType) + , cColor(amColorTokenTableEntry->cColor) { - return colorname.compareToIgnoreAsciiCaseAscii( pIdent ) == 0; } - bool operator == ( sal_uInt32 colorcode ) const + SmColorTokenTableEntry(const std::unique_ptr<SmColorTokenTableEntry> amColorTokenTableEntry) + : pIdent(amColorTokenTableEntry->pIdent) + , cIdent(amColorTokenTableEntry->cIdent) + , eType(amColorTokenTableEntry->eType) + , cColor(amColorTokenTableEntry->cColor) { - return colorcode == cColor.mValue; } - bool operator == ( Color colorcode ) const + SmColorTokenTableEntry(const char* name, const char* codename, SmTokenType ctype, Color ncolor) + : pIdent(name) + , cIdent(codename) + , eType(ctype) + , cColor(ncolor) { - return colorcode == cColor; } - bool equals( const OUString & colorname ) const + SmColorTokenTableEntry(const char* name, const char* codename, SmTokenType ctype, + sal_uInt32 ncolor) + : pIdent(name) + , cIdent(codename) + , eType(ctype) + , cColor(ncolor) { - return colorname.compareToIgnoreAsciiCaseAscii( pIdent ) == 0; } - bool equals( sal_uInt32 colorcode ) const + bool operator==(const OUString& colorname) const { - return colorcode == cColor.mValue; + return colorname.compareToIgnoreAsciiCaseAscii(pIdent) == 0; } - bool equals( Color colorcode ) const + bool operator==(sal_uInt32 colorcode) const { return colorcode == cColor.mValue; } + + bool operator==(Color colorcode) const { return colorcode == cColor; } + + bool equals(const OUString& colorname) const { - return colorcode == cColor; + return colorname.compareToIgnoreAsciiCaseAscii(pIdent) == 0; } + bool equals(sal_uInt32 colorcode) const { return colorcode == cColor.mValue; } + + bool equals(Color colorcode) const { return colorcode == cColor; } }; struct SmToken { - - OUString aText; // token text - SmTokenType eType; // token info + OUString aText; // token text + SmTokenType eType; // token info sal_Unicode cMathChar; // parse-help info - TG nGroup; - sal_uInt16 nLevel; + TG nGroup; + sal_uInt16 nLevel; // token position - sal_Int32 nRow; // 1-based - sal_Int32 nCol; // 1-based + sal_Int32 nRow; // 1-based + sal_Int32 nCol; // 1-based SmToken() : eType(TUNKNOWN) @@ -247,12 +243,11 @@ struct SmToken , nGroup(TG::NONE) , nLevel(0) , nRow(0) - , nCol(0) {} + , nCol(0) + { + } - SmToken(SmTokenType eTokenType, - sal_Unicode cMath, - const char* pText, - TG nTokenGroup = TG::NONE, + SmToken(SmTokenType eTokenType, sal_Unicode cMath, const char* pText, TG nTokenGroup = TG::NONE, sal_uInt16 nTokenLevel = 0) : aText(OUString::createFromAscii(pText)) , eType(eTokenType) @@ -260,9 +255,11 @@ struct SmToken , nGroup(nTokenGroup) , nLevel(nTokenLevel) , nRow(0) - , nCol(0){} + , nCol(0) + { + } - void operator = (const SmTokenTableEntry & aTokenTableEntry) + void operator=(const SmTokenTableEntry& aTokenTableEntry) { aText = OUString::createFromAscii(aTokenTableEntry.pIdent); eType = aTokenTableEntry.eType; @@ -273,7 +270,7 @@ struct SmToken nCol = 0; } - void operator = (const SmTokenTableEntry * aTokenTableEntry) + void operator=(const SmTokenTableEntry* aTokenTableEntry) { aText = OUString::createFromAscii(aTokenTableEntry->pIdent); eType = aTokenTableEntry->eType; @@ -284,7 +281,7 @@ struct SmToken nCol = 0; } - void operator = (const SmColorTokenTableEntry & aTokenTableEntry) + void operator=(const SmColorTokenTableEntry& aTokenTableEntry) { aText = OUString::number(aTokenTableEntry.cColor.mValue, 16); eType = aTokenTableEntry.eType; @@ -295,7 +292,7 @@ struct SmToken nCol = 0; } - void operator = (const SmColorTokenTableEntry * aTokenTableEntry) + void operator=(const SmColorTokenTableEntry* aTokenTableEntry) { aText = OUString::number(aTokenTableEntry->cColor.mValue, 16); eType = aTokenTableEntry->eType; @@ -306,7 +303,7 @@ struct SmToken nCol = 0; } - void operator = (const std::unique_ptr<SmColorTokenTableEntry> & aTokenTableEntry) + void operator=(const std::unique_ptr<SmColorTokenTableEntry>& aTokenTableEntry) { aText = OUString::number(aTokenTableEntry->cColor.mValue, 16); eType = aTokenTableEntry->eType; @@ -316,8 +313,6 @@ struct SmToken nRow = 0; nCol = 0; } - - }; #endif |