1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
3 * This file is part of the LibreOffice project.
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/.
9 * This file incorporates work covered by the following license notice:
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 .
20 /** The tokens contain the information gathered by the parser.
23 * the data type (~ mathematical operation).
24 * The mathematical char.
25 * The corresponding code or information to recreate it.
26 * Location of the token in the starmath code.
31 #include <tools/color.hxx>
32 #include <o3tl/string_view.hxx>
33 #include <o3tl/typed_flags_set.hxx>
57 Standalone
= 0x004000,
64 template <> struct typed_flags
<TG
> : is_typed_flags
<TG
, 0x037fff>
69 // Tokens identifiers. Allow to know what kind of information the node contains.
74 TEND
, TSPECIAL
, TNONE
, TESCAPE
, TUNKNOWN
,
75 TBLANK
, TSBLANK
, TPLACE
, TNOSPACE
, TDOTSDOWN
,
76 TNEWLINE
, TDOTSAXIS
, TDOTSLOW
, TDOTSVERT
, TBACKEPSILON
,
77 TDOTSDIAG
, TDOTSUP
, TERROR
,
79 TPLUS
, TMINUS
, TMULTIPLY
, TDIVIDEBY
, // +-*/
80 TGT
, TLT
, TGE
, TLE
, // > < >= <=
81 TASSIGN
, TNEQ
, TGG
, TLL
, // = != >>> <<<
82 TPARALLEL
, TORTHO
, TEQUIV
, // Geometry
83 TOPER
, TSUM
, TPROD
, TCOPROD
, // Operators
84 TIM
, TRE
, THBAR
, TLAMBDABAR
, // Complex and constants
85 TPLUSMINUS
, TMINUSPLUS
, TSIM
, TSIMEQ
, // +- -+ ~ ~=
86 TLIM
, TLIMSUP
, TLIMINF
, TTOWARD
, // Limits
88 TOVER
, TTIMES
, TCDOT
, TDIV
, // Product type
89 TSLASH
, TBACKSLASH
, TWIDESLASH
, TWIDEBACKSLASH
, //Slash
90 TFRAC
, TIT
, // mathml related
92 TMATRIX
, TPOUND
, TDPOUND
, TSTACK
, TBINOM
,
94 TAND
, TOR
, TNEG
, // && || !
95 TPRECEDES
, TSUCCEEDS
, TNOTPRECEDES
, TNOTSUCCEEDS
, // Order
96 TPRECEDESEQUAL
, TSUCCEEDSEQUAL
, TPRECEDESEQUIV
, TSUCCEEDSEQUIV
, // Order eq
97 TLEFTARROW
, TRIGHTARROW
, TUPARROW
, TDOWNARROW
, // Arrows
98 TDRARROW
, TDLARROW
, TDLRARROW
, TDEF
, // Double arrows, definition
99 TPROP
, TNDIVIDES
, TDIVIDES
, TAPPROX
, // Proportions, approximation
100 TLESLANT
, TGESLANT
, TTRANSL
, TTRANSR
, // <= >= corresponds
102 TOPLUS
, TOMINUS
, TOTIMES
, TODIVIDE
, TODOT
,
105 TRSUB
, TRSUP
, TCSUB
, TCSUP
, TLSUB
,
106 TLSUP
, TFROM
, TTO
, TUOPER
, TBOPER
,
108 TSETN
, TSETZ
, TSETQ
, TSETR
, TSETC
,
109 TIN
, TNOTIN
, TNI
, TEMPTYSET
, // Insideout
110 TSUBSET
, TSUBSETEQ
, TSUPSET
, TSUPSETEQ
, // Subsupset
111 TNSUBSET
, TNSUPSET
, TNSUBSETEQ
, TNSUPSETEQ
, // Not subsupset
112 TINTERSECT
, TUNION
, TSETMINUS
, TSETQUOTIENT
, // +-/
113 TALEPH
, TWP
, TINFINITY
, // Abstract sets
114 TFORALL
, TEXISTS
, TNOTEXISTS
, // Existential
116 TFONT
, TSIZE
, TCOLOR
, TPHANTOM
, // Basic
117 TITALIC
, TNITALIC
, TBOLD
, TNBOLD
, // Bold ital
118 TALIGNL
, TALIGNC
, TALIGNR
, // Align
119 TUNDERLINE
, TOVERLINE
, TOVERSTRIKE
, TBAR
, // Lines
120 TFIXED
, TSANS
, TSERIF
, // Types
121 TACUTE
, TGRAVE
, THAT
, TBREVE
, // Accents
122 TWIDEVEC
, TWIDEHARPOON
, TWIDETILDE
, TWIDEHAT
, // Wide math
123 TVEC
, THARPOON
, TTILDE
, TCIRCLE
, // math
125 TTEXT
, TNUMBER
, TCHARACTER
, TIDENT
, // Content type
127 TLEFT
, TRIGHT
, TUNDERBRACE
, TOVERBRACE
, // Scalable, upsidedown
128 TLGROUP
, TRGROUP
, TLPARENT
, TRPARENT
, // Structural
129 TLBRACKET
, TRBRACKET
, TLDBRACKET
, TRDBRACKET
, // Bracket x1 & x2
130 TLCEIL
, TRCEIL
, TLFLOOR
, TRFLOOR
, // Reals -> Wholes
131 TLANGLE
, TRANGLE
, TLBRACE
, TRBRACE
, // <x> {x}
132 TLLINE
, TRLINE
, TLDLINE
, TRDLINE
, // Lines x1 x2
133 TMLINE
, TEVALUATE
, TLRLINE
, TLRDLINE
, // Custom
134 // Differential calculus
135 TNABLA
, TPARTIAL
, TFOURIER
, TLAPLACE
, // Derivative, Transformation
136 TINTD
, TINT
, TIINT
, TIIINT
, // Integral
137 TLINT
, TLLINT
, TLLLINT
, // Circuit integral
138 TDOT
, TDDOT
, TDDDOT
, // Derivative dots
140 TFUNC
, TLN
, TLOG
, TEXP
, // Exp - Log
141 TSIN
, TCOS
, TTAN
, TCOT
, // Trigo
142 TSEC
, TCSC
, TSECH
, TCSCH
,
143 TSINH
, TCOSH
, TTANH
, TCOTH
, // Trigo hyperbolic
144 TASIN
, TACOS
, TATAN
, TACOT
, // Arctrigo
145 TASINH
, TACOSH
, TATANH
, TACOTH
, // Arctrigo hyperbolic
146 TSQRT
, TNROOT
, TFACT
, TABS
, // roots, n! |z|
148 TRGB
, TRGBA
, THEX
, THTMLCOL
, TDVIPSNAMESCOL
,
149 TICONICCOL
, TMATHMLCOL
153 struct SmTokenTableEntry
157 sal_uInt32 cMathChar
;
162 struct SmColorTokenTableEntry
168 SmColorTokenTableEntry()
174 explicit SmColorTokenTableEntry(const SmColorTokenTableEntry
* amColorTokenTableEntry
)
175 : aIdent(amColorTokenTableEntry
->aIdent
)
176 , eType(amColorTokenTableEntry
->eType
)
177 , cColor(amColorTokenTableEntry
->cColor
)
181 explicit SmColorTokenTableEntry(
182 const std::unique_ptr
<SmColorTokenTableEntry
> amColorTokenTableEntry
)
183 : aIdent(amColorTokenTableEntry
->aIdent
)
184 , eType(amColorTokenTableEntry
->eType
)
185 , cColor(amColorTokenTableEntry
->cColor
)
189 SmColorTokenTableEntry(OUString name
, SmTokenType ctype
, Color ncolor
)
190 : aIdent(std::move(name
))
196 SmColorTokenTableEntry(OUString name
, SmTokenType ctype
, sal_uInt32 ncolor
)
197 : aIdent(std::move(name
))
199 , cColor(ColorTransparency
, ncolor
)
203 bool equals(std::u16string_view colorname
) const
205 return o3tl::compareToIgnoreAsciiCase(colorname
, aIdent
) == 0;
208 bool equals(sal_uInt32 colorcode
) const { return colorcode
== static_cast<sal_uInt32
>(cColor
); }
210 bool equals(Color colorcode
) const { return colorcode
== cColor
; }
215 OUString aText
; // token text
216 SmTokenType eType
; // token info
231 SmToken(SmTokenType eTokenType
, sal_uInt32 cMath
, OUString rText
, TG nTokenGroup
= TG::NONE
,
232 sal_uInt16 nTokenLevel
= 0)
233 : aText(std::move(rText
))
235 , cMathChar(&cMath
, 1)
236 , nGroup(nTokenGroup
)
237 , nLevel(nTokenLevel
)
241 void operator=(const SmTokenTableEntry
& aTokenTableEntry
)
243 aText
= aTokenTableEntry
.aIdent
;
244 eType
= aTokenTableEntry
.eType
;
245 cMathChar
= OUString(&aTokenTableEntry
.cMathChar
, 1);
246 nGroup
= aTokenTableEntry
.nGroup
;
247 nLevel
= aTokenTableEntry
.nLevel
;
250 void operator=(const SmTokenTableEntry
* aTokenTableEntry
)
252 aText
= aTokenTableEntry
->aIdent
;
253 eType
= aTokenTableEntry
->eType
;
254 cMathChar
= OUString(&aTokenTableEntry
->cMathChar
, 1);
255 nGroup
= aTokenTableEntry
->nGroup
;
256 nLevel
= aTokenTableEntry
->nLevel
;
259 void operator=(const SmColorTokenTableEntry
& aTokenTableEntry
)
262 eType
= aTokenTableEntry
.eType
;
263 cMathChar
= OUString::number(static_cast<sal_uInt32
>(aTokenTableEntry
.cColor
), 16);
268 void operator=(const SmColorTokenTableEntry
* aTokenTableEntry
)
271 eType
= aTokenTableEntry
->eType
;
272 cMathChar
= OUString::number(static_cast<sal_uInt32
>(aTokenTableEntry
->cColor
), 16);
277 void operator=(const std::unique_ptr
<SmColorTokenTableEntry
>& aTokenTableEntry
)
280 eType
= aTokenTableEntry
->eType
;
281 cMathChar
= OUString::number(static_cast<sal_uInt32
>(aTokenTableEntry
->cColor
), 16);
286 void setChar(sal_uInt32 cChar
) { cMathChar
= OUString(&cChar
, 1); }
287 void setChar(const OUString
& rText
) { cMathChar
= rText
; }
290 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */