sync master with lastest vba changes
[ooovba.git] / starmath / source / mathtype.hxx
blobe23ae96640ce0db0d1b7d2cb7102db30b1ff87ab
1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: mathtype.hxx,v $
10 * $Revision: 1.12 $
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 ************************************************************************/
31 #ifndef MATHTYPE_HXX
32 #define MATHTYPE_HXX
34 #include "node.hxx"
35 #include "eqnolefilehdr.hxx"
37 #include <sot/storage.hxx>
39 #include <set>
41 class SfxMedium;
43 class MathTypeFont
45 public:
46 sal_uInt8 nTface;
47 sal_uInt8 nStyle;
48 MathTypeFont() : nTface(0),nStyle(0) {}
49 MathTypeFont(sal_uInt8 nFace) : nTface(nFace),nStyle(0) {}
50 void AppendStyleToText(String &rS);
53 struct LessMathTypeFont
55 sal_Bool operator() (const MathTypeFont &rValue1,
56 const MathTypeFont &rValue2) const
58 return rValue1.nTface < rValue2.nTface;
62 typedef ::std::set< MathTypeFont, LessMathTypeFont > MathTypeFontSet;
64 class MathType
66 public:
67 MathType(String &rIn) :
68 rRet(rIn), nHAlign(0), nVAlign(0), nDefaultSize(12),
69 nLSize(0), nDSize(0), nCurSize(0), nLastSize(0), bIsSilent(sal_False)
71 Init();
74 MathType(String &rIn,SmNode *pIn) :
75 rRet(rIn), pTree(pIn), nHAlign(2), nVAlign(0), nInsertion(0), nDefaultSize(12),
76 nLSize(0), nDSize(0), nCurSize(0), nLastSize(0), nSpec(0), bIsSilent(sal_False)
78 Init();
81 int Parse( SotStorage* pStor );
82 int ConvertFromStarMath( SfxMedium& rMedium );
84 private:
85 /*Ver 2 Header*/
86 sal_uInt8 nVersion;
87 sal_uInt8 nPlatform;
88 sal_uInt8 nProduct;
89 sal_uInt8 nProdVersion;
90 sal_uInt8 nProdSubVersion;
92 SvStorageStream *pS;
94 void Init();
96 int HandleRecords(int nLevel=0,sal_uInt8 nSelector=0xFF,
97 sal_uInt8 nVariation=0xFF,int nRows=0,int nCols=0);
98 sal_Bool HandleSize(sal_Int16 nLSize,sal_Int16 nDSize, int &rSetSize);
99 void HandleAlign(sal_uInt8 nHAlign,sal_uInt8 nVAlign, int &rSetAlign);
100 int HandlePile(int &rSetAlign,int nLevel,sal_uInt8 nSelector,
101 sal_uInt8 nVariation);
102 int HandleMatrix(int nLevel,sal_uInt8 nSelector,sal_uInt8 nVariarion);
103 void HandleMatrixSeperator(int nMatrixRows,int nMatrixCols,int &rCurCol,
104 int &rCurRow);
105 int HandleTemplate(int nLevel,sal_uInt8 &rSelector,sal_uInt8 &rVariation,
106 xub_StrLen &rLastTemplateBracket);
107 void HandleEmblishments();
108 void HandleSetSize();
109 int HandleChar(xub_StrLen &rTextStart,int &rSetSize,int nLevel,
110 sal_uInt8 nTag,sal_uInt8 nSelector,sal_uInt8 nVariation,
111 sal_Bool bSilent);
112 void HandleNudge();
113 int xfLMOVE(sal_uInt8 nTest) {return nTest&0x80;}
114 int xfAUTO(sal_uInt8 nTest) {return nTest&0x10;}
115 int xfEMBELL(sal_uInt8 nTest) {return nTest&0x20;}
116 int xfNULL(sal_uInt8 nTest) {return nTest&0x10;}
117 int xfLSPACE(sal_uInt8 nTest) {return nTest&0x40;}
118 int xfRULER(sal_uInt8 nTest) {return nTest&0x20;}
120 sal_uInt8 HandleNodes(SmNode *pNode,int nLevel=0);
121 int StartTemplate(sal_uInt16 nSelector,sal_uInt16 nVariation=0);
122 void EndTemplate(int nOldPendingAttributes);
123 void HandleSmMatrix(SmMatrixNode *pMatrix,int nLevel);
124 void HandleTable(SmNode *pNode,int nLevel);
125 void HandleRoot(SmNode *pNode,int nLevel);
126 void HandleSubSupScript(SmNode *pNode,int nLevel);
127 sal_uInt8 HandleCScript(SmNode *pNode,SmNode *pContent,int nLevel,
128 ULONG *pPos=NULL,sal_Bool bTest=TRUE);
129 void HandleFractions(SmNode *pNode,int nLevel);
130 void HandleBrace(SmNode *pNode,int nLevel);
131 void HandleVerticalBrace(SmNode *pNode,int nLevel);
132 void HandleOperator(SmNode *pNode,int nLevel);
133 sal_Bool HandleLim(SmNode *pNode,int nLevel);
134 void HandleMAlign(SmNode *pNode,int nLevel);
135 void HandleMath(SmNode *pNode,int nLevel);
136 void HandleText(SmNode *pNode,int nLevel);
137 void HandleAttributes(SmNode *pNode,int nLevel);
138 void TypeFaceToString(String &rRet,sal_uInt8 nFace);
140 String &rRet;
141 SmNode *pTree;
143 sal_uInt8 nHAlign;
144 sal_uInt8 nVAlign;
146 int nPendingAttributes;
147 ULONG nInsertion;
149 sal_Int16 aSizeTable[7];
150 sal_Int16 nDefaultSize;
151 sal_Int16 nLSize;
152 sal_Int16 nDSize;
153 sal_Int16 nCurSize;
154 sal_Int16 nLastSize;
155 sal_uInt8 nSpec;
156 sal_Bool bIsSilent, bIsReInterpBrace;
157 String sPost;
158 xub_StrLen nPostSup;
159 xub_StrLen nPostlSup;
160 sal_uInt8 nTypeFace;
161 MathTypeFontSet aUserStyles;
163 enum MTOKENS {END,LINE,CHAR,TMPL,PILE,MATRIX,EMBEL,RULER,FONT,SIZE};
164 enum MTEMPLATES
166 tmANGLE,tmPAREN,tmBRACE,tmBRACK,tmBAR,tmDBAR,tmFLOOR,tmCEILING,
167 tmLBLB,tmRBRB,tmRBLB,tmLBRP,tmLPRB,tmROOT,tmFRACT,tmSCRIPT,tmUBAR,
168 tmOBAR,tmLARROW,tmRARROW,tmBARROW,tmSINT,tmDINT,tmTINT,tmSSINT,
169 tmDSINT,tmTSINT,tmUHBRACE,tmLHBRACE,tmSUM
171 public:
172 static sal_Bool LookupChar(sal_Unicode nChar,String &rRet,
173 sal_uInt8 nVersion=3,sal_uInt8 nTypeFace=0);
177 #endif