LibreOffice Module starmath (master) 1
mathtype.hxx
Go to the documentation of this file.
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#pragma once
21
22#include <node.hxx>
23
25
26class SfxMedium;
27class SotStorage;
28class SvStream;
29
31{
32public:
36 explicit MathTypeFont(sal_uInt8 nFace) : nTface(nFace),nStyle(0) {}
37 void AppendStyleToText(OUString &rS);
38};
39
41{
42 bool operator() (const MathTypeFont &rValue1,
43 const MathTypeFont &rValue2) const
44 {
45 return rValue1.nTface < rValue2.nTface;
46 }
47};
48
50
52{
53public:
54 explicit MathType(OUStringBuffer &rIn)
55 : nVersion(0)
56 , pS(nullptr)
57 , rRet(rIn)
58 , pTree(nullptr)
59 , nHAlign(0)
61 , nInsertion(0)
62 , nLSize(0)
63 , nDSize(0)
64 , nCurSize(0)
65 , nLastSize(0)
66 , nSpec(0)
67 , bIsReInterpBrace(false)
68 , nPostSup(0)
69 , nPostlSup(0)
70 , nTypeFace(0)
71 {
72 Init();
73 }
74
75 MathType(OUStringBuffer &rIn,SmNode *pIn)
76 : nVersion(0)
77 , pS(nullptr)
78 , rRet(rIn)
79 , pTree(pIn)
80 , nHAlign(2)
82 , nInsertion(0)
83 , nLSize(0)
84 , nDSize(0)
85 , nCurSize(0)
86 , nLastSize(0)
87 , nSpec(0)
88 , bIsReInterpBrace(false)
89 , nPostSup(0)
90 , nPostlSup(0)
91 , nTypeFace(0)
92 {
93 Init();
94 }
95
96 bool Parse(SotStorage* pStor);
97 bool Parse(SvStream* pStream);
98 bool ConvertFromStarMath( SfxMedium& rMedium );
99
100private:
101/*Ver 2 Header*/
103
105
106 void Init();
107
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);
121 void HandleNudge();
122
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;}
127
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);
147
148 OUStringBuffer &rRet;
150
152
154 sal_uInt64 nInsertion;
155
156 sal_Int16 nLSize;
157 sal_Int16 nDSize;
158 sal_Int16 nCurSize;
159 sal_Int16 nLastSize;
162 OUStringBuffer sPost;
163 sal_Int32 nPostSup;
164 sal_Int32 nPostlSup;
167
170 {
177 tmOARC
178 };
179public:
180 static bool LookupChar(sal_Unicode nChar,OUStringBuffer &rRet,
182};
183
184/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
sal_uInt8 nStyle
Definition: mathtype.hxx:34
MathTypeFont(sal_uInt8 nFace)
Definition: mathtype.hxx:36
void AppendStyleToText(OUString &rS)
Definition: mathtype.cxx:519
sal_uInt8 nTface
Definition: mathtype.hxx:33
void HandleText(SmNode *pNode)
Definition: mathtype.cxx:3279
void HandleNodes(SmNode *pNode, int nLevel)
Definition: mathtype.cxx:1936
static int xfAUTO(sal_uInt8 nTest)
Definition: mathtype.hxx:124
void HandleAttributes(SmNode *pNode, int nLevel)
Definition: mathtype.cxx:3148
sal_uInt64 nInsertion
Definition: mathtype.hxx:154
MathType(OUStringBuffer &rIn, SmNode *pIn)
Definition: mathtype.hxx:75
void HandleOperator(SmNode *pNode, int nLevel)
Definition: mathtype.cxx:2438
bool HandleChar(sal_Int32 &rTextStart, int &rSetSize, int nLevel, sal_uInt8 nTag, sal_uInt8 nSelector, sal_uInt8 nVariation, bool bSilent)
Definition: mathtype.cxx:2835
bool HandleMatrix(int nLevel, sal_uInt8 nSelector, sal_uInt8 nVariarion)
Definition: mathtype.cxx:2649
void HandleEmblishments()
Definition: mathtype.cxx:2730
void HandleSetSize()
Definition: mathtype.cxx:2812
MathTypeFontSet aUserStyles
Definition: mathtype.hxx:166
SmNode * pTree
Definition: mathtype.hxx:149
void Init()
Definition: mathtype.cxx:40
void HandleAlign(sal_uInt8 nHAlign, int &rSetAlign)
Definition: mathtype.cxx:1786
OUStringBuffer & rRet
Definition: mathtype.hxx:148
sal_Int32 nPostlSup
Definition: mathtype.hxx:164
int nPendingAttributes
Definition: mathtype.hxx:153
sal_Int16 nDSize
Definition: mathtype.hxx:157
SvStream * pS
Definition: mathtype.hxx:104
MathType(OUStringBuffer &rIn)
Definition: mathtype.hxx:54
void HandleMAlign(SmNode *pNode, int nLevel)
Definition: mathtype.cxx:3016
sal_Int16 nLastSize
Definition: mathtype.hxx:159
sal_Int32 nPostSup
Definition: mathtype.hxx:163
bool HandleTemplate(int nLevel, sal_uInt8 &rSelector, sal_uInt8 &rVariation, sal_Int32 &rLastTemplateBracket)
Definition: mathtype.cxx:2679
void HandleRoot(SmNode *pNode, int nLevel)
Definition: mathtype.cxx:2117
void HandleSmMatrix(SmMatrixNode *pMatrix, int nLevel)
Definition: mathtype.cxx:2050
bool HandleLim(SmNode *pNode, int nLevel)
Definition: mathtype.cxx:2940
int StartTemplate(sal_uInt16 nSelector, sal_uInt16 nVariation=0)
Definition: mathtype.cxx:2025
bool HandleSize(sal_Int16 nLSize, sal_Int16 nDSize, int &rSetSize)
Definition: mathtype.cxx:1806
bool HandleRecords(int nLevel, sal_uInt8 nSelector=0xFF, sal_uInt8 nVariation=0xFF, int nRows=0, int nCols=0)
Definition: mathtype.cxx:636
void HandleSubSupScript(SmNode *pNode, int nLevel)
Definition: mathtype.cxx:2210
bool HandlePile(int &rSetAlign, int nLevel, sal_uInt8 nSelector, sal_uInt8 nVariation)
Definition: mathtype.cxx:2627
void EndTemplate(int nOldPendingAttributes)
Definition: mathtype.cxx:2042
void HandleVerticalBrace(SmNode *pNode, int nLevel)
Definition: mathtype.cxx:2411
sal_uInt8 nTypeFace
Definition: mathtype.hxx:165
void HandleMath(SmNode *pNode)
Definition: mathtype.cxx:3040
void HandleTable(SmNode *pNode, int nLevel)
Definition: mathtype.cxx:2083
void HandleBrace(SmNode *pNode, int nLevel)
Definition: mathtype.cxx:2328
bool bIsReInterpBrace
Definition: mathtype.hxx:161
sal_uInt8 nSpec
Definition: mathtype.hxx:160
void HandleNudge()
Definition: mathtype.cxx:619
OUStringBuffer sPost
Definition: mathtype.hxx:162
sal_uInt8 nVersion
Definition: mathtype.hxx:102
static int xfEMBELL(sal_uInt8 nTest)
Definition: mathtype.hxx:125
void TypeFaceToString(OUString &rRet, sal_uInt8 nFace)
Definition: mathtype.cxx:541
void HandleFractions(SmNode *pNode, int nLevel)
Definition: mathtype.cxx:2304
sal_uInt8 HandleCScript(SmNode *pNode, SmNode *pContent, int nLevel, sal_uInt64 *pPos=nullptr, bool bTest=true)
Definition: mathtype.cxx:2148
sal_Int16 nCurSize
Definition: mathtype.hxx:158
bool Parse(SotStorage *pStor)
Definition: mathtype.cxx:550
static int xfLMOVE(sal_uInt8 nTest)
Definition: mathtype.hxx:123
static bool LookupChar(sal_Unicode nChar, OUStringBuffer &rRet, sal_uInt8 nVersion, sal_uInt8 nTypeFace=0)
Definition: mathtype.cxx:83
static int xfNULL(sal_uInt8 nTest)
Definition: mathtype.hxx:126
sal_uInt8 nHAlign
Definition: mathtype.hxx:151
bool ConvertFromStarMath(SfxMedium &rMedium)
Definition: mathtype.cxx:1864
sal_Int16 nLSize
Definition: mathtype.hxx:156
void HandleMatrixSeparator(int nMatrixRows, int nMatrixCols, int &rCurCol, int &rCurRow)
Definition: mathtype.cxx:1758
Matrix node.
Definition: node.hxx:2000
Definition: node.hxx:125
o3tl::sorted_vector< MathTypeFont, LessMathTypeFont > MathTypeFontSet
Definition: mathtype.hxx:49
bool operator()(const MathTypeFont &rValue1, const MathTypeFont &rValue2) const
Definition: mathtype.hxx:42
unsigned char sal_uInt8
sal_uInt16 sal_Unicode