00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036 #ifndef MATHTYPE_HXX
00037 #define MATHTYPE_HXX
00038
00039 #ifndef NODE_HXX
00040 #include "node.hxx"
00041 #endif
00042 #ifndef __EQNOLEFILEHDR_HXX__
00043 #include "eqnolefilehdr.hxx"
00044 #endif
00045
00046 #include <sot/storage.hxx>
00047
00048 #include <set>
00049
00050 class SfxMedium;
00051
00052 class MathTypeFont
00053 {
00054 public:
00055 sal_uInt8 nTface;
00056 sal_uInt8 nStyle;
00057 MathTypeFont() : nTface(0),nStyle(0) {}
00058 MathTypeFont(sal_uInt8 nFace) : nTface(nFace),nStyle(0) {}
00059 void AppendStyleToText(String &rS);
00060 };
00061
00062 struct LessMathTypeFont
00063 {
00064 sal_Bool operator() (const MathTypeFont &rValue1,
00065 const MathTypeFont &rValue2) const
00066 {
00067 return rValue1.nTface < rValue2.nTface;
00068 }
00069 };
00070
00071 typedef ::std::set< MathTypeFont, LessMathTypeFont > MathTypeFontSet;
00072
00073 class MathType
00074 {
00075 public:
00076 MathType(String &rIn) :
00077 rRet(rIn), nHAlign(0), nVAlign(0), nDefaultSize(12),
00078 nLSize(0), nDSize(0), nCurSize(0), nLastSize(0), bIsSilent(sal_False)
00079 {
00080 Init();
00081 }
00082
00083 MathType(String &rIn,SmNode *pIn) :
00084 rRet(rIn), pTree(pIn), nHAlign(2), nVAlign(0), nInsertion(0), nDefaultSize(12),
00085 nLSize(0), nDSize(0), nCurSize(0), nLastSize(0), nSpec(0), bIsSilent(sal_False)
00086 {
00087 Init();
00088 }
00089
00090 int Parse( SotStorage* pStor );
00091 int ConvertFromStarMath( SfxMedium& rMedium );
00092
00093 private:
00094
00095 sal_uInt8 nVersion;
00096 sal_uInt8 nPlatform;
00097 sal_uInt8 nProduct;
00098 sal_uInt8 nProdVersion;
00099 sal_uInt8 nProdSubVersion;
00100
00101 SvStorageStream *pS;
00102
00103 void Init();
00104
00105 int HandleRecords(int nLevel=0,sal_uInt8 nSelector=0xFF,
00106 sal_uInt8 nVariation=0xFF,int nRows=0,int nCols=0);
00107 sal_Bool HandleSize(sal_Int16 nLSize,sal_Int16 nDSize, int &rSetSize);
00108 void HandleAlign(sal_uInt8 nHAlign,sal_uInt8 nVAlign, int &rSetAlign);
00109 int HandlePile(int &rSetAlign,int nLevel,sal_uInt8 nSelector,
00110 sal_uInt8 nVariation);
00111 int HandleMatrix(int nLevel,sal_uInt8 nSelector,sal_uInt8 nVariarion);
00112 void HandleMatrixSeperator(int nMatrixRows,int nMatrixCols,int &rCurCol,
00113 int &rCurRow);
00114 int HandleTemplate(int nLevel,sal_uInt8 &rSelector,sal_uInt8 &rVariation,
00115 xub_StrLen &rLastTemplateBracket);
00116 void HandleEmblishments();
00117 void HandleSetSize();
00118 int HandleChar(xub_StrLen &rTextStart,int &rSetSize,int nLevel,
00119 sal_uInt8 nTag,sal_uInt8 nSelector,sal_uInt8 nVariation,
00120 sal_Bool bSilent);
00121 void HandleNudge();
00122 int xfLMOVE(sal_uInt8 nTest) {return nTest&0x80;}
00123 int xfAUTO(sal_uInt8 nTest) {return nTest&0x10;}
00124 int xfEMBELL(sal_uInt8 nTest) {return nTest&0x20;}
00125 int xfNULL(sal_uInt8 nTest) {return nTest&0x10;}
00126 int xfLSPACE(sal_uInt8 nTest) {return nTest&0x40;}
00127 int xfRULER(sal_uInt8 nTest) {return nTest&0x20;}
00128
00129 sal_uInt8 HandleNodes(SmNode *pNode,int nLevel=0);
00130 int StartTemplate(sal_uInt16 nSelector,sal_uInt16 nVariation=0);
00131 void EndTemplate(int nOldPendingAttributes);
00132 void HandleSmMatrix(SmMatrixNode *pMatrix,int nLevel);
00133 void HandleTable(SmNode *pNode,int nLevel);
00134 void HandleRoot(SmNode *pNode,int nLevel);
00135 void HandleSubSupScript(SmNode *pNode,int nLevel);
00136 sal_uInt8 HandleCScript(SmNode *pNode,SmNode *pContent,int nLevel,
00137 ULONG *pPos=NULL,sal_Bool bTest=TRUE);
00138 void HandleFractions(SmNode *pNode,int nLevel);
00139 void HandleBrace(SmNode *pNode,int nLevel);
00140 void HandleVerticalBrace(SmNode *pNode,int nLevel);
00141 void HandleOperator(SmNode *pNode,int nLevel);
00142 sal_Bool HandleLim(SmNode *pNode,int nLevel);
00143 void HandleMAlign(SmNode *pNode,int nLevel);
00144 void HandleMath(SmNode *pNode,int nLevel);
00145 void HandleText(SmNode *pNode,int nLevel);
00146 void HandleAttributes(SmNode *pNode,int nLevel);
00147 void TypeFaceToString(String &rRet,sal_uInt8 nFace);
00148
00149 String &rRet;
00150 SmNode *pTree;
00151
00152 sal_uInt8 nHAlign;
00153 sal_uInt8 nVAlign;
00154
00155 int nPendingAttributes;
00156 ULONG nInsertion;
00157
00158 sal_Int16 aSizeTable[7];
00159 sal_Int16 nDefaultSize;
00160 sal_Int16 nLSize;
00161 sal_Int16 nDSize;
00162 sal_Int16 nCurSize;
00163 sal_Int16 nLastSize;
00164 sal_uInt8 nSpec;
00165 sal_Bool bIsSilent, bIsReInterpBrace;
00166 String sPost;
00167 xub_StrLen nPostSup;
00168 xub_StrLen nPostlSup;
00169 sal_uInt8 nTypeFace;
00170 MathTypeFontSet aUserStyles;
00171
00172 enum MTOKENS {END,LINE,CHAR,TMPL,PILE,MATRIX,EMBEL,RULER,FONT,SIZE};
00173 enum MTEMPLATES
00174 {
00175 tmANGLE,tmPAREN,tmBRACE,tmBRACK,tmBAR,tmDBAR,tmFLOOR,tmCEILING,
00176 tmLBLB,tmRBRB,tmRBLB,tmLBRP,tmLPRB,tmROOT,tmFRACT,tmSCRIPT,tmUBAR,
00177 tmOBAR,tmLARROW,tmRARROW,tmBARROW,tmSINT,tmDINT,tmTINT,tmSSINT,
00178 tmDSINT,tmTSINT,tmUHBRACE,tmLHBRACE,tmSUM
00179 };
00180 public:
00181 static sal_Bool LookupChar(sal_Unicode nChar,String &rRet,
00182 sal_uInt8 nVersion=3,sal_uInt8 nTypeFace=0);
00183 };
00184
00185
00186 #endif