update credits
[LibreOffice.git] / starmath / source / mathtype.hxx
blob0d3e298ea66fcf75ef9fc5a2f8e3efc5c6eb4b6b
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
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 #ifndef MATHTYPE_HXX
21 #define MATHTYPE_HXX
23 #include "node.hxx"
24 #include "eqnolefilehdr.hxx"
26 #include <sot/storage.hxx>
28 #include <set>
30 class SfxMedium;
32 class MathTypeFont
34 public:
35 sal_uInt8 nTface;
36 sal_uInt8 nStyle;
37 MathTypeFont() : nTface(0),nStyle(0) {}
38 MathTypeFont(sal_uInt8 nFace) : nTface(nFace),nStyle(0) {}
39 void AppendStyleToText(String &rS);
42 struct LessMathTypeFont
44 sal_Bool operator() (const MathTypeFont &rValue1,
45 const MathTypeFont &rValue2) const
47 return rValue1.nTface < rValue2.nTface;
51 typedef ::std::set< MathTypeFont, LessMathTypeFont > MathTypeFontSet;
53 class MathType
55 public:
56 MathType(String &rIn) :
57 rRet(rIn), nHAlign(0), nVAlign(0), nDefaultSize(12),
58 nLSize(0), nDSize(0), nCurSize(0), nLastSize(0), bIsSilent(sal_False),
59 nTypeFace(0)
61 Init();
64 MathType(String &rIn,SmNode *pIn) :
65 rRet(rIn), pTree(pIn), nHAlign(2), nVAlign(0), nInsertion(0), nDefaultSize(12),
66 nLSize(0), nDSize(0), nCurSize(0), nLastSize(0), nSpec(0), bIsSilent(sal_False),
67 nTypeFace(0)
69 Init();
72 int Parse( SotStorage* pStor );
73 int ConvertFromStarMath( SfxMedium& rMedium );
75 private:
76 /*Ver 2 Header*/
77 sal_uInt8 nVersion;
78 sal_uInt8 nPlatform;
79 sal_uInt8 nProduct;
80 sal_uInt8 nProdVersion;
81 sal_uInt8 nProdSubVersion;
83 SvStorageStream *pS;
85 void Init();
87 int HandleRecords(int nLevel=0,sal_uInt8 nSelector=0xFF,
88 sal_uInt8 nVariation=0xFF,int nRows=0,int nCols=0);
89 sal_Bool HandleSize(sal_Int16 nLSize,sal_Int16 nDSize, int &rSetSize);
90 void HandleAlign(sal_uInt8 nHAlign,sal_uInt8 nVAlign, int &rSetAlign);
91 int HandlePile(int &rSetAlign,int nLevel,sal_uInt8 nSelector,
92 sal_uInt8 nVariation);
93 int HandleMatrix(int nLevel,sal_uInt8 nSelector,sal_uInt8 nVariarion);
94 void HandleMatrixSeparator(int nMatrixRows,int nMatrixCols,int &rCurCol,
95 int &rCurRow);
96 int HandleTemplate(int nLevel,sal_uInt8 &rSelector,sal_uInt8 &rVariation,
97 xub_StrLen &rLastTemplateBracket);
98 void HandleEmblishments();
99 void HandleSetSize();
100 int HandleChar(xub_StrLen &rTextStart,int &rSetSize,int nLevel,
101 sal_uInt8 nTag,sal_uInt8 nSelector,sal_uInt8 nVariation,
102 sal_Bool bSilent);
103 void HandleNudge();
104 int xfLMOVE(sal_uInt8 nTest) const {return nTest&0x80;}
105 int xfAUTO(sal_uInt8 nTest) const {return nTest&0x10;}
106 int xfEMBELL(sal_uInt8 nTest) const {return nTest&0x20;}
107 int xfNULL(sal_uInt8 nTest) const {return nTest&0x10;}
108 int xfLSPACE(sal_uInt8 nTest) const {return nTest&0x40;}
109 int xfRULER(sal_uInt8 nTest) const {return nTest&0x20;}
111 sal_uInt8 HandleNodes(SmNode *pNode,int nLevel=0);
112 int StartTemplate(sal_uInt16 nSelector,sal_uInt16 nVariation=0);
113 void EndTemplate(int nOldPendingAttributes);
114 void HandleSmMatrix(SmMatrixNode *pMatrix,int nLevel);
115 void HandleTable(SmNode *pNode,int nLevel);
116 void HandleRoot(SmNode *pNode,int nLevel);
117 void HandleSubSupScript(SmNode *pNode,int nLevel);
118 sal_uInt8 HandleCScript(SmNode *pNode,SmNode *pContent,int nLevel,
119 sal_uLong *pPos=NULL,sal_Bool bTest=sal_True);
120 void HandleFractions(SmNode *pNode,int nLevel);
121 void HandleBrace(SmNode *pNode,int nLevel);
122 void HandleVerticalBrace(SmNode *pNode,int nLevel);
123 void HandleOperator(SmNode *pNode,int nLevel);
124 sal_Bool HandleLim(SmNode *pNode,int nLevel);
125 void HandleMAlign(SmNode *pNode,int nLevel);
126 void HandleMath(SmNode *pNode,int nLevel);
127 void HandleText(SmNode *pNode,int nLevel);
128 void HandleAttributes(SmNode *pNode,int nLevel);
129 void TypeFaceToString(String &rRet,sal_uInt8 nFace);
131 String &rRet;
132 SmNode *pTree;
134 sal_uInt8 nHAlign;
135 sal_uInt8 nVAlign;
137 int nPendingAttributes;
138 sal_uLong nInsertion;
140 sal_Int16 aSizeTable[7];
141 sal_Int16 nDefaultSize;
142 sal_Int16 nLSize;
143 sal_Int16 nDSize;
144 sal_Int16 nCurSize;
145 sal_Int16 nLastSize;
146 sal_uInt8 nSpec;
147 sal_Bool bIsSilent, bIsReInterpBrace;
148 String sPost;
149 xub_StrLen nPostSup;
150 xub_StrLen nPostlSup;
151 sal_uInt8 nTypeFace;
152 MathTypeFontSet aUserStyles;
154 enum MTOKENS {END,LINE,CHAR,TMPL,PILE,MATRIX,EMBEL,RULER,FONT,SIZE};
155 enum MTEMPLATES
157 tmANGLE,tmPAREN,tmBRACE,tmBRACK,tmBAR,tmDBAR,tmFLOOR,tmCEILING,
158 tmLBLB,tmRBRB,tmRBLB,tmLBRP,tmLPRB,tmROOT,tmFRACT,tmSCRIPT,tmUBAR,
159 tmOBAR,tmLARROW,tmRARROW,tmBARROW,tmSINT,tmDINT,tmTINT,tmSSINT,
160 tmDSINT,tmTSINT,tmUHBRACE,tmLHBRACE,tmSUM
162 public:
163 static sal_Bool LookupChar(sal_Unicode nChar,String &rRet,
164 sal_uInt8 nVersion=3,sal_uInt8 nTypeFace=0);
168 #endif
170 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */