1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 * Copyright 2000, 2010 Oracle and/or its affiliates.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * This file is part of OpenOffice.org.
11 * OpenOffice.org is free software: you can redistribute it and/or modify
12 * it under the terms of the GNU Lesser General Public License version 3
13 * only, as published by the Free Software Foundation.
15 * OpenOffice.org is distributed in the hope that it will be useful,
16 * but WITHOUT ANY WARRANTY; without even the implied warranty of
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 * GNU Lesser General Public License version 3 for more details
19 * (a copy is included in the LICENSE file that accompanied this code).
21 * You should have received a copy of the GNU Lesser General Public License
22 * version 3 along with OpenOffice.org. If not, see
23 * <http://www.openoffice.org/license.html>
24 * for a copy of the LGPLv3 License.
26 ************************************************************************/
32 #include "eqnolefilehdr.hxx"
34 #include <sot/storage.hxx>
45 MathTypeFont() : nTface(0),nStyle(0) {}
46 MathTypeFont(sal_uInt8 nFace
) : nTface(nFace
),nStyle(0) {}
47 void AppendStyleToText(String
&rS
);
50 struct LessMathTypeFont
52 sal_Bool
operator() (const MathTypeFont
&rValue1
,
53 const MathTypeFont
&rValue2
) const
55 return rValue1
.nTface
< rValue2
.nTface
;
59 typedef ::std::set
< MathTypeFont
, LessMathTypeFont
> MathTypeFontSet
;
64 MathType(String
&rIn
) :
65 rRet(rIn
), nHAlign(0), nVAlign(0), nDefaultSize(12),
66 nLSize(0), nDSize(0), nCurSize(0), nLastSize(0), bIsSilent(sal_False
)
71 MathType(String
&rIn
,SmNode
*pIn
) :
72 rRet(rIn
), pTree(pIn
), nHAlign(2), nVAlign(0), nInsertion(0), nDefaultSize(12),
73 nLSize(0), nDSize(0), nCurSize(0), nLastSize(0), nSpec(0), bIsSilent(sal_False
)
78 int Parse( SotStorage
* pStor
);
79 int ConvertFromStarMath( SfxMedium
& rMedium
);
86 sal_uInt8 nProdVersion
;
87 sal_uInt8 nProdSubVersion
;
93 int HandleRecords(int nLevel
=0,sal_uInt8 nSelector
=0xFF,
94 sal_uInt8 nVariation
=0xFF,int nRows
=0,int nCols
=0);
95 sal_Bool
HandleSize(sal_Int16 nLSize
,sal_Int16 nDSize
, int &rSetSize
);
96 void HandleAlign(sal_uInt8 nHAlign
,sal_uInt8 nVAlign
, int &rSetAlign
);
97 int HandlePile(int &rSetAlign
,int nLevel
,sal_uInt8 nSelector
,
98 sal_uInt8 nVariation
);
99 int HandleMatrix(int nLevel
,sal_uInt8 nSelector
,sal_uInt8 nVariarion
);
100 void HandleMatrixSeperator(int nMatrixRows
,int nMatrixCols
,int &rCurCol
,
102 int HandleTemplate(int nLevel
,sal_uInt8
&rSelector
,sal_uInt8
&rVariation
,
103 xub_StrLen
&rLastTemplateBracket
);
104 void HandleEmblishments();
105 void HandleSetSize();
106 int HandleChar(xub_StrLen
&rTextStart
,int &rSetSize
,int nLevel
,
107 sal_uInt8 nTag
,sal_uInt8 nSelector
,sal_uInt8 nVariation
,
110 int xfLMOVE(sal_uInt8 nTest
) {return nTest
&0x80;}
111 int xfAUTO(sal_uInt8 nTest
) {return nTest
&0x10;}
112 int xfEMBELL(sal_uInt8 nTest
) {return nTest
&0x20;}
113 int xfNULL(sal_uInt8 nTest
) {return nTest
&0x10;}
114 int xfLSPACE(sal_uInt8 nTest
) {return nTest
&0x40;}
115 int xfRULER(sal_uInt8 nTest
) {return nTest
&0x20;}
117 sal_uInt8
HandleNodes(SmNode
*pNode
,int nLevel
=0);
118 int StartTemplate(sal_uInt16 nSelector
,sal_uInt16 nVariation
=0);
119 void EndTemplate(int nOldPendingAttributes
);
120 void HandleSmMatrix(SmMatrixNode
*pMatrix
,int nLevel
);
121 void HandleTable(SmNode
*pNode
,int nLevel
);
122 void HandleRoot(SmNode
*pNode
,int nLevel
);
123 void HandleSubSupScript(SmNode
*pNode
,int nLevel
);
124 sal_uInt8
HandleCScript(SmNode
*pNode
,SmNode
*pContent
,int nLevel
,
125 ULONG
*pPos
=NULL
,sal_Bool bTest
=TRUE
);
126 void HandleFractions(SmNode
*pNode
,int nLevel
);
127 void HandleBrace(SmNode
*pNode
,int nLevel
);
128 void HandleVerticalBrace(SmNode
*pNode
,int nLevel
);
129 void HandleOperator(SmNode
*pNode
,int nLevel
);
130 sal_Bool
HandleLim(SmNode
*pNode
,int nLevel
);
131 void HandleMAlign(SmNode
*pNode
,int nLevel
);
132 void HandleMath(SmNode
*pNode
,int nLevel
);
133 void HandleText(SmNode
*pNode
,int nLevel
);
134 void HandleAttributes(SmNode
*pNode
,int nLevel
);
135 void TypeFaceToString(String
&rRet
,sal_uInt8 nFace
);
143 int nPendingAttributes
;
146 sal_Int16 aSizeTable
[7];
147 sal_Int16 nDefaultSize
;
153 sal_Bool bIsSilent
, bIsReInterpBrace
;
156 xub_StrLen nPostlSup
;
158 MathTypeFontSet aUserStyles
;
160 enum MTOKENS
{END
,LINE
,CHAR
,TMPL
,PILE
,MATRIX
,EMBEL
,RULER
,FONT
,SIZE
};
163 tmANGLE
,tmPAREN
,tmBRACE
,tmBRACK
,tmBAR
,tmDBAR
,tmFLOOR
,tmCEILING
,
164 tmLBLB
,tmRBRB
,tmRBLB
,tmLBRP
,tmLPRB
,tmROOT
,tmFRACT
,tmSCRIPT
,tmUBAR
,
165 tmOBAR
,tmLARROW
,tmRARROW
,tmBARROW
,tmSINT
,tmDINT
,tmTINT
,tmSSINT
,
166 tmDSINT
,tmTSINT
,tmUHBRACE
,tmLHBRACE
,tmSUM
169 static sal_Bool
LookupChar(sal_Unicode nChar
,String
&rRet
,
170 sal_uInt8 nVersion
=3,sal_uInt8 nTypeFace
=0);