1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
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 INCLUDED_STARMATH_SOURCE_MATHTYPE_HXX
21 #define INCLUDED_STARMATH_SOURCE_MATHTYPE_HXX
23 #include <rtl/ustring.hxx>
24 #include <rtl/ustrbuf.hxx>
40 MathTypeFont() : nTface(0),nStyle(0) {}
41 explicit MathTypeFont(sal_uInt8 nFace
) : nTface(nFace
),nStyle(0) {}
42 void AppendStyleToText(OUString
&rS
);
45 struct LessMathTypeFont
47 bool operator() (const MathTypeFont
&rValue1
,
48 const MathTypeFont
&rValue2
) const
50 return rValue1
.nTface
< rValue2
.nTface
;
54 typedef ::std::set
< MathTypeFont
, LessMathTypeFont
> MathTypeFontSet
;
59 explicit MathType(OUStringBuffer
&rIn
)
65 , nPendingAttributes(0)
72 , bIsReInterpBrace(false)
80 MathType(OUStringBuffer
&rIn
,SmNode
*pIn
)
86 , nPendingAttributes(0)
93 , bIsReInterpBrace(false)
101 bool Parse(SotStorage
* pStor
);
102 bool Parse(SvStream
* pStream
);
103 bool ConvertFromStarMath( SfxMedium
& rMedium
);
113 bool HandleRecords(int nLevel
, sal_uInt8 nSelector
=0xFF,
114 sal_uInt8 nVariation
=0xFF, int nRows
=0, int nCols
=0);
115 bool HandleSize(sal_Int16 nLSize
, sal_Int16 nDSize
, int &rSetSize
);
116 void HandleAlign(sal_uInt8 nHAlign
, int &rSetAlign
);
117 bool HandlePile(int &rSetAlign
, int nLevel
, sal_uInt8 nSelector
, sal_uInt8 nVariation
);
118 bool HandleMatrix(int nLevel
, sal_uInt8 nSelector
, sal_uInt8 nVariarion
);
119 void HandleMatrixSeparator(int nMatrixRows
, int nMatrixCols
, int &rCurCol
, int &rCurRow
);
120 bool HandleTemplate(int nLevel
, sal_uInt8
&rSelector
, sal_uInt8
&rVariation
,
121 sal_Int32
&rLastTemplateBracket
);
122 void HandleEmblishments();
123 void HandleSetSize();
124 bool HandleChar(sal_Int32
&rTextStart
, int &rSetSize
, int nLevel
,
125 sal_uInt8 nTag
, sal_uInt8 nSelector
, sal_uInt8 nVariation
, bool bSilent
);
128 static int xfLMOVE(sal_uInt8 nTest
) {return nTest
&0x80;}
129 static int xfAUTO(sal_uInt8 nTest
) {return nTest
&0x10;}
130 static int xfEMBELL(sal_uInt8 nTest
) {return nTest
&0x20;}
131 static int xfNULL(sal_uInt8 nTest
) {return nTest
&0x10;}
133 void HandleNodes(SmNode
*pNode
,int nLevel
);
134 int StartTemplate(sal_uInt16 nSelector
,sal_uInt16 nVariation
=0);
135 void EndTemplate(int nOldPendingAttributes
);
136 void HandleSmMatrix(SmMatrixNode
*pMatrix
,int nLevel
);
137 void HandleTable(SmNode
*pNode
,int nLevel
);
138 void HandleRoot(SmNode
*pNode
,int nLevel
);
139 void HandleSubSupScript(SmNode
*pNode
,int nLevel
);
140 sal_uInt8
HandleCScript(SmNode
*pNode
,SmNode
*pContent
,int nLevel
,
141 sal_uInt64
*pPos
=nullptr,bool bTest
=true);
142 void HandleFractions(SmNode
*pNode
,int nLevel
);
143 void HandleBrace(SmNode
*pNode
,int nLevel
);
144 void HandleVerticalBrace(SmNode
*pNode
,int nLevel
);
145 void HandleOperator(SmNode
*pNode
,int nLevel
);
146 bool HandleLim(SmNode
*pNode
,int nLevel
);
147 void HandleMAlign(SmNode
*pNode
,int nLevel
);
148 void HandleMath(SmNode
*pNode
);
149 void HandleText(SmNode
*pNode
);
150 void HandleAttributes(SmNode
*pNode
,int nLevel
);
151 void TypeFaceToString(OUString
&rRet
,sal_uInt8 nFace
);
153 OUStringBuffer
&rRet
;
158 int nPendingAttributes
;
159 sal_uInt64 nInsertion
;
161 std::vector
<sal_Int16
> aSizeTable
;
167 bool bIsReInterpBrace
;
168 OUStringBuffer sPost
;
172 MathTypeFontSet aUserStyles
;
174 enum MTOKENS
{END
,LINE
,CHAR
,TMPL
,PILE
,MATRIX
,EMBEL
,RULER
,FONT
,SIZE
};
177 tmANGLE
,tmPAREN
,tmBRACE
,tmBRACK
,tmBAR
,tmDBAR
,tmFLOOR
,tmCEILING
,
178 tmLBLB
,tmRBRB
,tmRBLB
,tmLBRP
,tmLPRB
,tmROOT
,tmFRACT
,tmSCRIPT
,tmUBAR
,
179 tmOBAR
,tmLARROW
,tmRARROW
,tmBARROW
,tmSINT
,tmDINT
,tmTINT
,tmSSINT
,
180 tmDSINT
,tmTSINT
,tmUHBRACE
,tmLHBRACE
,tmSUM
,tmISUM
,tmPROD
,tmIPROD
,
181 tmCOPROD
,tmICOPROD
,tmUNION
,tmIUNION
,tmINTER
,tmIINTER
,tmLIM
,tmLDIV
,
182 tmSLFRACT
,tmINTOP
,tmSUMOP
,tmLSCRIPT
,tmDIRAC
,tmUARROW
,tmOARROW
,
186 static bool LookupChar(sal_Unicode nChar
,OUStringBuffer
&rRet
,
187 sal_uInt8 nVersion
,sal_uInt8 nTypeFace
=0);
193 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */