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 .
24 #include <o3tl/sorted_vector.hxx>
35 MathTypeFont() : nTface(0),nStyle(0) {}
36 explicit MathTypeFont(sal_uInt8 nFace
) : nTface(nFace
),nStyle(0) {}
37 void AppendStyleToText(OUString
&rS
);
40 struct LessMathTypeFont
42 bool operator() (const MathTypeFont
&rValue1
,
43 const MathTypeFont
&rValue2
) const
45 return rValue1
.nTface
< rValue2
.nTface
;
49 typedef o3tl::sorted_vector
< MathTypeFont
, LessMathTypeFont
> MathTypeFontSet
;
54 explicit MathType(OUStringBuffer
&rIn
)
60 , nPendingAttributes(0)
67 , bIsReInterpBrace(false)
75 MathType(OUStringBuffer
&rIn
,SmNode
*pIn
)
81 , nPendingAttributes(0)
88 , bIsReInterpBrace(false)
96 bool Parse(SotStorage
* pStor
);
97 bool Parse(SvStream
* pStream
);
98 bool ConvertFromStarMath( SfxMedium
& rMedium
);
108 bool HandleRecords(int nLevel
, sal_uInt8 nSelector
=0xFF,
109 sal_uInt8 nVariation
=0xFF, int nRows
=0, int nCols
=0);
110 bool HandleSize(sal_Int16 nLSize
, sal_Int16 nDSize
, int &rSetSize
);
111 void HandleAlign(sal_uInt8 nHAlign
, int &rSetAlign
);
112 bool HandlePile(int &rSetAlign
, int nLevel
, sal_uInt8 nSelector
, sal_uInt8 nVariation
);
113 bool HandleMatrix(int nLevel
, sal_uInt8 nSelector
, sal_uInt8 nVariarion
);
114 void HandleMatrixSeparator(int nMatrixRows
, int nMatrixCols
, int &rCurCol
, int &rCurRow
);
115 bool HandleTemplate(int nLevel
, sal_uInt8
&rSelector
, sal_uInt8
&rVariation
,
116 sal_Int32
&rLastTemplateBracket
);
117 void HandleEmblishments();
118 void HandleSetSize();
119 bool HandleChar(sal_Int32
&rTextStart
, int &rSetSize
, int nLevel
,
120 sal_uInt8 nTag
, sal_uInt8 nSelector
, sal_uInt8 nVariation
, bool bSilent
);
123 static int xfLMOVE(sal_uInt8 nTest
) {return nTest
&0x80;}
124 static int xfAUTO(sal_uInt8 nTest
) {return nTest
&0x10;}
125 static int xfEMBELL(sal_uInt8 nTest
) {return nTest
&0x20;}
126 static int xfNULL(sal_uInt8 nTest
) {return nTest
&0x10;}
128 void HandleNodes(SmNode
*pNode
,int nLevel
);
129 int StartTemplate(sal_uInt16 nSelector
,sal_uInt16 nVariation
=0);
130 void EndTemplate(int nOldPendingAttributes
);
131 void HandleSmMatrix(SmMatrixNode
*pMatrix
,int nLevel
);
132 void HandleTable(SmNode
*pNode
,int nLevel
);
133 void HandleRoot(SmNode
*pNode
,int nLevel
);
134 void HandleSubSupScript(SmNode
*pNode
,int nLevel
);
135 sal_uInt8
HandleCScript(SmNode
*pNode
,SmNode
*pContent
,int nLevel
,
136 sal_uInt64
*pPos
=nullptr,bool bTest
=true);
137 void HandleFractions(SmNode
*pNode
,int nLevel
);
138 void HandleBrace(SmNode
*pNode
,int nLevel
);
139 void HandleVerticalBrace(SmNode
*pNode
,int nLevel
);
140 void HandleOperator(SmNode
*pNode
,int nLevel
);
141 bool HandleLim(SmNode
*pNode
,int nLevel
);
142 void HandleMAlign(SmNode
*pNode
,int nLevel
);
143 void HandleMath(SmNode
*pNode
);
144 void HandleText(SmNode
*pNode
);
145 void HandleAttributes(SmNode
*pNode
,int nLevel
);
146 void TypeFaceToString(OUString
&rRet
,sal_uInt8 nFace
);
148 OUStringBuffer
&rRet
;
153 int nPendingAttributes
;
154 sal_uInt64 nInsertion
;
161 bool bIsReInterpBrace
;
162 OUStringBuffer sPost
;
166 MathTypeFontSet aUserStyles
;
168 enum MTOKENS
{END
,LINE
,CHAR
,TMPL
,PILE
,MATRIX
,EMBEL
,RULER
,FONT
,SIZE
};
171 tmANGLE
,tmPAREN
,tmBRACE
,tmBRACK
,tmBAR
,tmDBAR
,tmFLOOR
,tmCEILING
,
172 tmLBLB
,tmRBRB
,tmRBLB
,tmLBRP
,tmLPRB
,tmROOT
,tmFRACT
,tmSCRIPT
,tmUBAR
,
173 tmOBAR
,tmLARROW
,tmRARROW
,tmBARROW
,tmSINT
,tmDINT
,tmTINT
,tmSSINT
,
174 tmDSINT
,tmTSINT
,tmUHBRACE
,tmLHBRACE
,tmSUM
,tmISUM
,tmPROD
,tmIPROD
,
175 tmCOPROD
,tmICOPROD
,tmUNION
,tmIUNION
,tmINTER
,tmIINTER
,tmLIM
,tmLDIV
,
176 tmSLFRACT
,tmINTOP
,tmSUMOP
,tmLSCRIPT
,tmDIRAC
,tmUARROW
,tmOARROW
,
180 static bool LookupChar(sal_Unicode nChar
,OUStringBuffer
&rRet
,
181 sal_uInt8 nVersion
,sal_uInt8 nTypeFace
=0);
184 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */