Line data Source code
1 : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 : /*
3 : * This file is part of the LibreOffice project.
4 : *
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/.
8 : *
9 : * This file incorporates work covered by the following license notice:
10 : *
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 .
18 : */
19 :
20 : #ifndef MATHTYPE_HXX
21 : #define MATHTYPE_HXX
22 :
23 : #include "node.hxx"
24 : #include "eqnolefilehdr.hxx"
25 :
26 : #include <sot/storage.hxx>
27 :
28 : #include <set>
29 :
30 : class SfxMedium;
31 :
32 : class MathTypeFont
33 : {
34 : public:
35 : sal_uInt8 nTface;
36 : sal_uInt8 nStyle;
37 0 : MathTypeFont() : nTface(0),nStyle(0) {}
38 0 : MathTypeFont(sal_uInt8 nFace) : nTface(nFace),nStyle(0) {}
39 : void AppendStyleToText(String &rS);
40 : };
41 :
42 : struct LessMathTypeFont
43 : {
44 0 : sal_Bool operator() (const MathTypeFont &rValue1,
45 : const MathTypeFont &rValue2) const
46 : {
47 0 : return rValue1.nTface < rValue2.nTface;
48 : }
49 : };
50 :
51 : typedef ::std::set< MathTypeFont, LessMathTypeFont > MathTypeFontSet;
52 :
53 0 : class MathType
54 : {
55 : public:
56 0 : MathType(String &rIn) :
57 : rRet(rIn), nHAlign(0), nVAlign(0), nDefaultSize(12),
58 : nLSize(0), nDSize(0), nCurSize(0), nLastSize(0), bIsSilent(sal_False),
59 0 : nTypeFace(0)
60 : {
61 0 : Init();
62 0 : }
63 :
64 0 : MathType(String &rIn,SmNode *pIn) :
65 : rRet(rIn), pTree(pIn), nHAlign(2), nVAlign(0), nInsertion(0), nDefaultSize(12),
66 : nLSize(0), nDSize(0), nCurSize(0), nLastSize(0), nSpec(0), bIsSilent(sal_False),
67 0 : nTypeFace(0)
68 : {
69 0 : Init();
70 0 : }
71 :
72 : int Parse( SotStorage* pStor );
73 : int ConvertFromStarMath( SfxMedium& rMedium );
74 :
75 : private:
76 : /*Ver 2 Header*/
77 : sal_uInt8 nVersion;
78 : sal_uInt8 nPlatform;
79 : sal_uInt8 nProduct;
80 : sal_uInt8 nProdVersion;
81 : sal_uInt8 nProdSubVersion;
82 :
83 : SvStorageStream *pS;
84 :
85 : void Init();
86 :
87 : int HandleRecords(int nLevel=0,sal_uInt8 nSelector=0xFF,
88 : sal_uInt8 nVariation=0xFF,int nRows=0,int nCols=0);
89 : sal_Bool HandleSize(sal_Int16 nLSize,sal_Int16 nDSize, int &rSetSize);
90 : void HandleAlign(sal_uInt8 nHAlign,sal_uInt8 nVAlign, int &rSetAlign);
91 : int HandlePile(int &rSetAlign,int nLevel,sal_uInt8 nSelector,
92 : sal_uInt8 nVariation);
93 : int HandleMatrix(int nLevel,sal_uInt8 nSelector,sal_uInt8 nVariarion);
94 : void HandleMatrixSeperator(int nMatrixRows,int nMatrixCols,int &rCurCol,
95 : int &rCurRow);
96 : int HandleTemplate(int nLevel,sal_uInt8 &rSelector,sal_uInt8 &rVariation,
97 : xub_StrLen &rLastTemplateBracket);
98 : void HandleEmblishments();
99 : void HandleSetSize();
100 : int HandleChar(xub_StrLen &rTextStart,int &rSetSize,int nLevel,
101 : sal_uInt8 nTag,sal_uInt8 nSelector,sal_uInt8 nVariation,
102 : sal_Bool bSilent);
103 : void HandleNudge();
104 0 : int xfLMOVE(sal_uInt8 nTest) const {return nTest&0x80;}
105 0 : int xfAUTO(sal_uInt8 nTest) const {return nTest&0x10;}
106 0 : int xfEMBELL(sal_uInt8 nTest) const {return nTest&0x20;}
107 0 : int xfNULL(sal_uInt8 nTest) const {return nTest&0x10;}
108 : int xfLSPACE(sal_uInt8 nTest) const {return nTest&0x40;}
109 : int xfRULER(sal_uInt8 nTest) const {return nTest&0x20;}
110 :
111 : sal_uInt8 HandleNodes(SmNode *pNode,int nLevel=0);
112 : int StartTemplate(sal_uInt16 nSelector,sal_uInt16 nVariation=0);
113 : void EndTemplate(int nOldPendingAttributes);
114 : void HandleSmMatrix(SmMatrixNode *pMatrix,int nLevel);
115 : void HandleTable(SmNode *pNode,int nLevel);
116 : void HandleRoot(SmNode *pNode,int nLevel);
117 : void HandleSubSupScript(SmNode *pNode,int nLevel);
118 : sal_uInt8 HandleCScript(SmNode *pNode,SmNode *pContent,int nLevel,
119 : sal_uLong *pPos=NULL,sal_Bool bTest=sal_True);
120 : void HandleFractions(SmNode *pNode,int nLevel);
121 : void HandleBrace(SmNode *pNode,int nLevel);
122 : void HandleVerticalBrace(SmNode *pNode,int nLevel);
123 : void HandleOperator(SmNode *pNode,int nLevel);
124 : sal_Bool HandleLim(SmNode *pNode,int nLevel);
125 : void HandleMAlign(SmNode *pNode,int nLevel);
126 : void HandleMath(SmNode *pNode,int nLevel);
127 : void HandleText(SmNode *pNode,int nLevel);
128 : void HandleAttributes(SmNode *pNode,int nLevel);
129 : void TypeFaceToString(String &rRet,sal_uInt8 nFace);
130 :
131 : String &rRet;
132 : SmNode *pTree;
133 :
134 : sal_uInt8 nHAlign;
135 : sal_uInt8 nVAlign;
136 :
137 : int nPendingAttributes;
138 : sal_uLong nInsertion;
139 :
140 : sal_Int16 aSizeTable[7];
141 : sal_Int16 nDefaultSize;
142 : sal_Int16 nLSize;
143 : sal_Int16 nDSize;
144 : sal_Int16 nCurSize;
145 : sal_Int16 nLastSize;
146 : sal_uInt8 nSpec;
147 : sal_Bool bIsSilent, bIsReInterpBrace;
148 : String sPost;
149 : xub_StrLen nPostSup;
150 : xub_StrLen nPostlSup;
151 : sal_uInt8 nTypeFace;
152 : MathTypeFontSet aUserStyles;
153 :
154 : enum MTOKENS {END,LINE,CHAR,TMPL,PILE,MATRIX,EMBEL,RULER,FONT,SIZE};
155 : enum MTEMPLATES
156 : {
157 : tmANGLE,tmPAREN,tmBRACE,tmBRACK,tmBAR,tmDBAR,tmFLOOR,tmCEILING,
158 : tmLBLB,tmRBRB,tmRBLB,tmLBRP,tmLPRB,tmROOT,tmFRACT,tmSCRIPT,tmUBAR,
159 : tmOBAR,tmLARROW,tmRARROW,tmBARROW,tmSINT,tmDINT,tmTINT,tmSSINT,
160 : tmDSINT,tmTSINT,tmUHBRACE,tmLHBRACE,tmSUM
161 : };
162 : public:
163 : static sal_Bool LookupChar(sal_Unicode nChar,String &rRet,
164 : sal_uInt8 nVersion=3,sal_uInt8 nTypeFace=0);
165 : };
166 :
167 :
168 : #endif
169 :
170 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|