1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: parse.hxx,v $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
34 #include <vcl/svapp.hxx>
35 #include <tools/stack.hxx>
36 #include <tools/list.hxx>
37 #include <tools/string.hxx>
46 #define TGOPER 0x00000001
47 #define TGRELATION 0x00000002
48 #define TGSUM 0x00000004
49 #define TGPRODUCT 0x00000008
50 #define TGUNOPER 0x00000010
51 #define TGPOWER 0x00000020
52 #define TGATTRIBUT 0x00000040
53 #define TGALIGN 0x00000080
54 #define TGFUNCTION 0x00000100
55 #define TGBLANK 0x00000200
56 #define TGLBRACES 0x00000400
57 #define TGRBRACES 0x00000800
58 #define TGCOLOR 0x00001000
59 #define TGFONT 0x00002000
60 #define TGSTANDALONE 0x00004000
61 #define TGDISCARDED 0x00008000
62 #define TGLIMIT 0x00010000
63 #define TGFONTATTR 0x00020000
68 TEND
, TLGROUP
, TRGROUP
, TLPARENT
, TRPARENT
,
69 TLBRACKET
, TRBRACKET
, TPLUS
, TMINUS
, TMULTIPLY
,
70 TDIVIDEBY
, TASSIGN
, TPOUND
, TSPECIAL
, TSLASH
,
71 TBACKSLASH
, TBLANK
, TSBLANK
, TRSUB
, TRSUP
,
72 TCSUB
, TCSUP
, TLSUB
, TLSUP
, TGT
,
73 TLT
, TAND
, TOR
, TINTERSECT
, TUNION
,
74 TNEWLINE
, TBINOM
, TFROM
, TTO
, TINT
,
75 TSUM
, TOPER
, TABS
, TSQRT
, TFACT
,
76 TNROOT
, TOVER
, TTIMES
, TGE
, TLE
,
77 TGG
, TLL
, TDOTSAXIS
, TDOTSLOW
, TDOTSVERT
,
78 TDOTSDIAG
, TDOTSUP
, TDOTSDOWN
, TACUTE
, TBAR
,
79 TBREVE
, TCHECK
, TCIRCLE
, TDOT
, TDDOT
,
80 TDDDOT
, TGRAVE
, THAT
, TTILDE
, TVEC
,
81 TUNDERLINE
, TOVERLINE
, TOVERSTRIKE
, TITALIC
, TNITALIC
,
82 TBOLD
, TNBOLD
, TPHANTOM
, TFONT
, TSIZE
,
83 TCOLOR
, TALIGNL
, TALIGNC
, TALIGNR
, TLEFT
,
84 TRIGHT
, TLANGLE
, TLBRACE
, TLLINE
, TLDLINE
,
85 TLCEIL
, TLFLOOR
, TNONE
, TMLINE
, TRANGLE
,
86 TRBRACE
, TRLINE
, TRDLINE
, TRCEIL
, TRFLOOR
,
87 TSIN
, TCOS
, TTAN
, TCOT
, TFUNC
,
88 TSTACK
, TMATRIX
, TMATFORM
, TDPOUND
, TPLACE
,
89 TTEXT
, TNUMBER
, TCHARACTER
, TIDENT
, TNEQ
,
90 TEQUIV
, TDEF
, TPROP
, TSIM
, TSIMEQ
,
91 TAPPROX
, TPARALLEL
, TORTHO
, TIN
, TNOTIN
,
92 TSUBSET
, TSUBSETEQ
, TSUPSET
, TSUPSETEQ
, TPLUSMINUS
,
93 TMINUSPLUS
, TOPLUS
, TOMINUS
, TDIV
, TOTIMES
,
94 TODIVIDE
, TTRANSL
, TTRANSR
, TIINT
, TIIINT
,
95 TLINT
, TLLINT
, TLLLINT
, TPROD
, TCOPROD
,
96 TFORALL
, TEXISTS
, TLIM
, TNABLA
, TTOWARD
,
97 TSINH
, TCOSH
, TTANH
, TCOTH
, TASIN
,
98 TACOS
, TATAN
, TLN
, TLOG
, TUOPER
,
99 TBOPER
, TBLACK
, TWHITE
, TRED
, TGREEN
,
100 TBLUE
, TCYAN
, TMAGENTA
, TYELLOW
, TFIXED
,
101 TSANS
, TSERIF
, TPOINT
, TASINH
, TACOSH
,
102 TATANH
, TACOTH
, TACOT
, TEXP
, TCDOT
,
103 TODOT
, TLESLANT
, TGESLANT
, TNSUBSET
, TNSUPSET
,
104 TNSUBSETEQ
, TNSUPSETEQ
, TPARTIAL
, TNEG
, TNI
,
105 TBACKEPSILON
, TALEPH
, TIM
, TRE
, TWP
,
106 TEMPTYSET
, TINFINITY
, TESCAPE
, TLIMSUP
, TLIMINF
,
107 TNDIVIDES
, TDRARROW
, TDLARROW
, TDLRARROW
, TUNDERBRACE
,
108 TOVERBRACE
, TCIRC
, TTOP
, THBAR
, TLAMBDABAR
,
109 TLEFTARROW
, TRIGHTARROW
, TUPARROW
, TDOWNARROW
, TDIVIDES
,
110 TNDIBVIDES
, TSETN
, TSETZ
, TSETQ
, TSETR
,
111 TSETC
, TWIDEVEC
, TWIDETILDE
, TWIDEHAT
, TWIDESLASH
,
112 TWIDEBACKSLASH
, TLDBRACKET
, TRDBRACKET
,
123 sal_Unicode cMathChar
;
137 PE_NONE
, PE_UNEXPECTED_END_OF_INPUT
,
138 PE_UNEXPECTED_CHAR
, PE_UNEXPECTED_TOKEN
,
139 PE_FUNC_EXPECTED
, PE_UNOPER_EXPECTED
,
140 PE_BINOPER_EXPECTED
, PE_SYMBOL_EXPECTED
,
141 PE_IDENTIFIER_EXPECTED
, PE_POUND_EXPECTED
,
142 PE_COLOR_EXPECTED
, PE_LGROUP_EXPECTED
,
143 PE_RGROUP_EXPECTED
, PE_LBRACE_EXPECTED
,
144 PE_RBRACE_EXPECTED
, PE_PARENT_MISMATCH
,
145 PE_RIGHT_EXPECTED
, PE_FONT_EXPECTED
,
146 PE_SIZE_EXPECTED
, PE_DOUBLE_ALIGN
,
147 PE_DOUBLE_SUBSUPSCRIPT
158 DECLARE_STACK(SmNodeStack
, SmNode
*)
159 DECLARE_LIST(SmErrDescList
, SmErrorDesc
*)
161 /**************************************************************************/
163 // defines possible conversions of the formula text from the format of
164 // one release to the one of another.
178 SmNodeStack NodeStack
;
179 SmErrDescList ErrDescList
;
182 xub_StrLen BufferIndex
,
186 SmConvert eConversion
;
187 BOOL bImportSymNames
,
190 // declare copy-constructor and assignment-operator private
191 SmParser(const SmParser
&);
192 SmParser
& operator = (const SmParser
&);
196 BOOL
IsDelimiter( const String
&rTxt
, xub_StrLen nPos
);
199 xub_StrLen
GetTokenIndex() const { return nTokenIndex
; }
200 void Insert(const String
&rText
, USHORT nPos
);
201 void Replace( USHORT nPos
, USHORT nLen
, const String
&rText
);
203 inline BOOL
TokenInGroup(ULONG nGroup
);
212 void SubSup(ULONG nActiveGroup
);
228 void Bracebody(BOOL bIsLeftRight
);
237 LanguageType
GetLanguage() const { return nLang
; }
238 void SetLanguage( LanguageType nNewLang
) { nLang
= nNewLang
; }
240 void Error(SmParseError Error
);
245 SmNode
*Parse(const String
&rBuffer
);
247 const String
& GetText() const { return BufferString
; };
249 SmConvert
GetConversion() const { return eConversion
; }
250 void SetConversion(SmConvert eConv
) { eConversion
= eConv
; }
252 BOOL
IsImportSymbolNames() const { return bImportSymNames
; }
253 void SetImportSymbolNames(BOOL bVal
) { bImportSymNames
= bVal
; }
254 BOOL
IsExportSymbolNames() const { return bExportSymNames
; }
255 void SetExportSymbolNames(BOOL bVal
) { bExportSymNames
= bVal
; }
257 USHORT
AddError(SmParseError Type
, SmNode
*pNode
);
259 const SmErrorDesc
* NextError();
260 const SmErrorDesc
* PrevError();
261 const SmErrorDesc
* GetError(USHORT i
= 0xFFFF);
265 inline BOOL
SmParser::TokenInGroup(ULONG nGroup
)
267 return (CurToken
.nGroup
& nGroup
) ? TRUE
: FALSE
;