1*f6a9d5caSAndrew Rist /************************************************************** 2cdf0e10cSrcweir * 3*f6a9d5caSAndrew Rist * Licensed to the Apache Software Foundation (ASF) under one 4*f6a9d5caSAndrew Rist * or more contributor license agreements. See the NOTICE file 5*f6a9d5caSAndrew Rist * distributed with this work for additional information 6*f6a9d5caSAndrew Rist * regarding copyright ownership. The ASF licenses this file 7*f6a9d5caSAndrew Rist * to you under the Apache License, Version 2.0 (the 8*f6a9d5caSAndrew Rist * "License"); you may not use this file except in compliance 9*f6a9d5caSAndrew Rist * with the License. You may obtain a copy of the License at 10cdf0e10cSrcweir * 11*f6a9d5caSAndrew Rist * http://www.apache.org/licenses/LICENSE-2.0 12cdf0e10cSrcweir * 13*f6a9d5caSAndrew Rist * Unless required by applicable law or agreed to in writing, 14*f6a9d5caSAndrew Rist * software distributed under the License is distributed on an 15*f6a9d5caSAndrew Rist * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 16*f6a9d5caSAndrew Rist * KIND, either express or implied. See the License for the 17*f6a9d5caSAndrew Rist * specific language governing permissions and limitations 18*f6a9d5caSAndrew Rist * under the License. 19cdf0e10cSrcweir * 20*f6a9d5caSAndrew Rist *************************************************************/ 21*f6a9d5caSAndrew Rist 22*f6a9d5caSAndrew Rist 23cdf0e10cSrcweir 24cdf0e10cSrcweir #ifndef MATHTYPE_HXX 25cdf0e10cSrcweir #define MATHTYPE_HXX 26cdf0e10cSrcweir 27cdf0e10cSrcweir #include "node.hxx" 28cdf0e10cSrcweir #include "eqnolefilehdr.hxx" 29cdf0e10cSrcweir 30cdf0e10cSrcweir #include <sot/storage.hxx> 31cdf0e10cSrcweir 32cdf0e10cSrcweir #include <set> 33cdf0e10cSrcweir 34cdf0e10cSrcweir class SfxMedium; 35cdf0e10cSrcweir 36cdf0e10cSrcweir class MathTypeFont 37cdf0e10cSrcweir { 38cdf0e10cSrcweir public: 39cdf0e10cSrcweir sal_uInt8 nTface; 40cdf0e10cSrcweir sal_uInt8 nStyle; MathTypeFont()41cdf0e10cSrcweir MathTypeFont() : nTface(0),nStyle(0) {} MathTypeFont(sal_uInt8 nFace)42cdf0e10cSrcweir MathTypeFont(sal_uInt8 nFace) : nTface(nFace),nStyle(0) {} 43cdf0e10cSrcweir void AppendStyleToText(String &rS); 44cdf0e10cSrcweir }; 45cdf0e10cSrcweir 46cdf0e10cSrcweir struct LessMathTypeFont 47cdf0e10cSrcweir { operator ()LessMathTypeFont48cdf0e10cSrcweir sal_Bool operator() (const MathTypeFont &rValue1, 49cdf0e10cSrcweir const MathTypeFont &rValue2) const 50cdf0e10cSrcweir { 51cdf0e10cSrcweir return rValue1.nTface < rValue2.nTface; 52cdf0e10cSrcweir } 53cdf0e10cSrcweir }; 54cdf0e10cSrcweir 55cdf0e10cSrcweir typedef ::std::set< MathTypeFont, LessMathTypeFont > MathTypeFontSet; 56cdf0e10cSrcweir 57cdf0e10cSrcweir class MathType 58cdf0e10cSrcweir { 59cdf0e10cSrcweir public: MathType(String & rIn)60cdf0e10cSrcweir MathType(String &rIn) : 61cdf0e10cSrcweir rRet(rIn), nHAlign(0), nVAlign(0), nDefaultSize(12), 62cdf0e10cSrcweir nLSize(0), nDSize(0), nCurSize(0), nLastSize(0), bIsSilent(sal_False) 63cdf0e10cSrcweir { 64cdf0e10cSrcweir Init(); 65cdf0e10cSrcweir } 66cdf0e10cSrcweir MathType(String & rIn,SmNode * pIn)67cdf0e10cSrcweir MathType(String &rIn,SmNode *pIn) : 68cdf0e10cSrcweir rRet(rIn), pTree(pIn), nHAlign(2), nVAlign(0), nInsertion(0), nDefaultSize(12), 69cdf0e10cSrcweir nLSize(0), nDSize(0), nCurSize(0), nLastSize(0), nSpec(0), bIsSilent(sal_False) 70cdf0e10cSrcweir { 71cdf0e10cSrcweir Init(); 72cdf0e10cSrcweir } 73cdf0e10cSrcweir 74cdf0e10cSrcweir int Parse( SotStorage* pStor ); 75cdf0e10cSrcweir int ConvertFromStarMath( SfxMedium& rMedium ); 76cdf0e10cSrcweir 77cdf0e10cSrcweir private: 78cdf0e10cSrcweir /*Ver 2 Header*/ 79cdf0e10cSrcweir sal_uInt8 nVersion; 80cdf0e10cSrcweir sal_uInt8 nPlatform; 81cdf0e10cSrcweir sal_uInt8 nProduct; 82cdf0e10cSrcweir sal_uInt8 nProdVersion; 83cdf0e10cSrcweir sal_uInt8 nProdSubVersion; 84cdf0e10cSrcweir 85cdf0e10cSrcweir SvStorageStream *pS; 86cdf0e10cSrcweir 87cdf0e10cSrcweir void Init(); 88cdf0e10cSrcweir 89cdf0e10cSrcweir int HandleRecords(int nLevel=0,sal_uInt8 nSelector=0xFF, 90cdf0e10cSrcweir sal_uInt8 nVariation=0xFF,int nRows=0,int nCols=0); 91cdf0e10cSrcweir sal_Bool HandleSize(sal_Int16 nLSize,sal_Int16 nDSize, int &rSetSize); 92cdf0e10cSrcweir void HandleAlign(sal_uInt8 nHAlign,sal_uInt8 nVAlign, int &rSetAlign); 93cdf0e10cSrcweir int HandlePile(int &rSetAlign,int nLevel,sal_uInt8 nSelector, 94cdf0e10cSrcweir sal_uInt8 nVariation); 95cdf0e10cSrcweir int HandleMatrix(int nLevel,sal_uInt8 nSelector,sal_uInt8 nVariarion); 96cdf0e10cSrcweir void HandleMatrixSeperator(int nMatrixRows,int nMatrixCols,int &rCurCol, 97cdf0e10cSrcweir int &rCurRow); 98cdf0e10cSrcweir int HandleTemplate(int nLevel,sal_uInt8 &rSelector,sal_uInt8 &rVariation, 99cdf0e10cSrcweir xub_StrLen &rLastTemplateBracket); 100cdf0e10cSrcweir void HandleEmblishments(); 101cdf0e10cSrcweir void HandleSetSize(); 102cdf0e10cSrcweir int HandleChar(xub_StrLen &rTextStart,int &rSetSize,int nLevel, 103cdf0e10cSrcweir sal_uInt8 nTag,sal_uInt8 nSelector,sal_uInt8 nVariation, 104cdf0e10cSrcweir sal_Bool bSilent); 105cdf0e10cSrcweir void HandleNudge(); xfLMOVE(sal_uInt8 nTest)106cdf0e10cSrcweir int xfLMOVE(sal_uInt8 nTest) {return nTest&0x80;} xfAUTO(sal_uInt8 nTest)107cdf0e10cSrcweir int xfAUTO(sal_uInt8 nTest) {return nTest&0x10;} xfEMBELL(sal_uInt8 nTest)108cdf0e10cSrcweir int xfEMBELL(sal_uInt8 nTest) {return nTest&0x20;} xfNULL(sal_uInt8 nTest)109cdf0e10cSrcweir int xfNULL(sal_uInt8 nTest) {return nTest&0x10;} xfLSPACE(sal_uInt8 nTest)110cdf0e10cSrcweir int xfLSPACE(sal_uInt8 nTest) {return nTest&0x40;} xfRULER(sal_uInt8 nTest)111cdf0e10cSrcweir int xfRULER(sal_uInt8 nTest) {return nTest&0x20;} 112cdf0e10cSrcweir 113cdf0e10cSrcweir sal_uInt8 HandleNodes(SmNode *pNode,int nLevel=0); 114cdf0e10cSrcweir int StartTemplate(sal_uInt16 nSelector,sal_uInt16 nVariation=0); 115cdf0e10cSrcweir void EndTemplate(int nOldPendingAttributes); 116cdf0e10cSrcweir void HandleSmMatrix(SmMatrixNode *pMatrix,int nLevel); 117cdf0e10cSrcweir void HandleTable(SmNode *pNode,int nLevel); 118cdf0e10cSrcweir void HandleRoot(SmNode *pNode,int nLevel); 119cdf0e10cSrcweir void HandleSubSupScript(SmNode *pNode,int nLevel); 120cdf0e10cSrcweir sal_uInt8 HandleCScript(SmNode *pNode,SmNode *pContent,int nLevel, 121cdf0e10cSrcweir sal_uLong *pPos=NULL,sal_Bool bTest=sal_True); 122cdf0e10cSrcweir void HandleFractions(SmNode *pNode,int nLevel); 123cdf0e10cSrcweir void HandleBrace(SmNode *pNode,int nLevel); 124cdf0e10cSrcweir void HandleVerticalBrace(SmNode *pNode,int nLevel); 125cdf0e10cSrcweir void HandleOperator(SmNode *pNode,int nLevel); 126cdf0e10cSrcweir sal_Bool HandleLim(SmNode *pNode,int nLevel); 127cdf0e10cSrcweir void HandleMAlign(SmNode *pNode,int nLevel); 128cdf0e10cSrcweir void HandleMath(SmNode *pNode,int nLevel); 129cdf0e10cSrcweir void HandleText(SmNode *pNode,int nLevel); 130cdf0e10cSrcweir void HandleAttributes(SmNode *pNode,int nLevel); 131cdf0e10cSrcweir void TypeFaceToString(String &rRet,sal_uInt8 nFace); 132cdf0e10cSrcweir 133cdf0e10cSrcweir String &rRet; 134cdf0e10cSrcweir SmNode *pTree; 135cdf0e10cSrcweir 136cdf0e10cSrcweir sal_uInt8 nHAlign; 137cdf0e10cSrcweir sal_uInt8 nVAlign; 138cdf0e10cSrcweir 139cdf0e10cSrcweir int nPendingAttributes; 140cdf0e10cSrcweir sal_uLong nInsertion; 141cdf0e10cSrcweir 142cdf0e10cSrcweir sal_Int16 aSizeTable[7]; 143cdf0e10cSrcweir sal_Int16 nDefaultSize; 144cdf0e10cSrcweir sal_Int16 nLSize; 145cdf0e10cSrcweir sal_Int16 nDSize; 146cdf0e10cSrcweir sal_Int16 nCurSize; 147cdf0e10cSrcweir sal_Int16 nLastSize; 148cdf0e10cSrcweir sal_uInt8 nSpec; 149cdf0e10cSrcweir sal_Bool bIsSilent, bIsReInterpBrace; 150cdf0e10cSrcweir String sPost; 151cdf0e10cSrcweir xub_StrLen nPostSup; 152cdf0e10cSrcweir xub_StrLen nPostlSup; 153cdf0e10cSrcweir sal_uInt8 nTypeFace; 154cdf0e10cSrcweir MathTypeFontSet aUserStyles; 155cdf0e10cSrcweir 156cdf0e10cSrcweir enum MTOKENS {END,LINE,CHAR,TMPL,PILE,MATRIX,EMBEL,RULER,FONT,SIZE}; 157cdf0e10cSrcweir enum MTEMPLATES 158cdf0e10cSrcweir { 159cdf0e10cSrcweir tmANGLE,tmPAREN,tmBRACE,tmBRACK,tmBAR,tmDBAR,tmFLOOR,tmCEILING, 160cdf0e10cSrcweir tmLBLB,tmRBRB,tmRBLB,tmLBRP,tmLPRB,tmROOT,tmFRACT,tmSCRIPT,tmUBAR, 161cdf0e10cSrcweir tmOBAR,tmLARROW,tmRARROW,tmBARROW,tmSINT,tmDINT,tmTINT,tmSSINT, 162cdf0e10cSrcweir tmDSINT,tmTSINT,tmUHBRACE,tmLHBRACE,tmSUM 163cdf0e10cSrcweir }; 164cdf0e10cSrcweir public: 165cdf0e10cSrcweir static sal_Bool LookupChar(sal_Unicode nChar,String &rRet, 166cdf0e10cSrcweir sal_uInt8 nVersion=3,sal_uInt8 nTypeFace=0); 167cdf0e10cSrcweir }; 168cdf0e10cSrcweir 169cdf0e10cSrcweir 170cdf0e10cSrcweir #endif 171