Bump version to 21.06.18.1
[LibreOffice.git] / starmath / source / format.cxx
bloba4bf960fd5834c3f65ccaba66abda00c283bd70c
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
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 #include <format.hxx>
23 SmFormat::SmFormat()
24 : aBaseSize(0, SmPtsTo100th_mm(12))
26 eHorAlign = SmHorAlign::Center;
27 nGreekCharStyle = 0;
28 bIsTextmode = bScaleNormalBrackets = false;
30 vSize[SIZ_TEXT] = 100;
31 vSize[SIZ_INDEX] = 60;
32 vSize[SIZ_FUNCTION] =
33 vSize[SIZ_OPERATOR] = 100;
34 vSize[SIZ_LIMITS] = 60;
36 vDist[DIS_HORIZONTAL] = 10;
37 vDist[DIS_VERTICAL] = 5;
38 vDist[DIS_ROOT] = 0;
39 vDist[DIS_SUPERSCRIPT] =
40 vDist[DIS_SUBSCRIPT] = 20;
41 vDist[DIS_NUMERATOR] =
42 vDist[DIS_DENOMINATOR] = 0;
43 vDist[DIS_FRACTION] = 10;
44 vDist[DIS_STROKEWIDTH] = 5;
45 vDist[DIS_UPPERLIMIT] =
46 vDist[DIS_LOWERLIMIT] = 0;
47 vDist[DIS_BRACKETSIZE] =
48 vDist[DIS_BRACKETSPACE] = 5;
49 vDist[DIS_MATRIXROW] = 3;
50 vDist[DIS_MATRIXCOL] = 30;
51 vDist[DIS_ORNAMENTSIZE] =
52 vDist[DIS_ORNAMENTSPACE] = 0;
53 vDist[DIS_OPERATORSIZE] = 50;
54 vDist[DIS_OPERATORSPACE] = 20;
55 vDist[DIS_LEFTSPACE] =
56 vDist[DIS_RIGHTSPACE] = 100;
57 vDist[DIS_TOPSPACE] =
58 vDist[DIS_BOTTOMSPACE] =
59 vDist[DIS_NORMALBRACKETSIZE] = 0;
61 vFont[FNT_VARIABLE] =
62 vFont[FNT_FUNCTION] =
63 vFont[FNT_NUMBER] =
64 vFont[FNT_TEXT] =
65 vFont[FNT_SERIF] = SmFace(FNTNAME_TIMES, aBaseSize);
66 vFont[FNT_SANS] = SmFace(FNTNAME_HELV, aBaseSize);
67 vFont[FNT_FIXED] = SmFace(FNTNAME_COUR, aBaseSize);
68 vFont[FNT_MATH] = SmFace(FNTNAME_MATH, aBaseSize);
70 vFont[FNT_MATH].SetCharSet( RTL_TEXTENCODING_UNICODE );
72 vFont[FNT_VARIABLE].SetItalic(ITALIC_NORMAL);
73 vFont[FNT_FUNCTION].SetItalic(ITALIC_NONE);
74 vFont[FNT_NUMBER] .SetItalic(ITALIC_NONE);
75 vFont[FNT_TEXT] .SetItalic(ITALIC_NONE);
76 vFont[FNT_SERIF] .SetItalic(ITALIC_NONE);
77 vFont[FNT_SANS] .SetItalic(ITALIC_NONE);
78 vFont[FNT_FIXED] .SetItalic(ITALIC_NONE);
80 for ( sal_uInt16 i = FNT_BEGIN; i <= FNT_END; i++ )
82 SmFace &rFace = vFont[i];
83 rFace.SetTransparent( true );
84 rFace.SetAlignment( ALIGN_BASELINE );
85 rFace.SetColor( COL_AUTO );
86 bDefaultFont[i] = false;
91 void SmFormat::SetFont(sal_uInt16 nIdent, const SmFace &rFont, bool bDefault )
93 vFont[nIdent] = rFont;
94 vFont[nIdent].SetTransparent( true );
95 vFont[nIdent].SetAlignment( ALIGN_BASELINE );
97 bDefaultFont[nIdent] = bDefault;
100 SmFormat & SmFormat::operator = (const SmFormat &rFormat)
102 SetBaseSize(rFormat.GetBaseSize());
103 SetHorAlign(rFormat.GetHorAlign());
104 SetTextmode(rFormat.IsTextmode());
105 SetGreekCharStyle(rFormat.GetGreekCharStyle());
106 SetScaleNormalBrackets(rFormat.IsScaleNormalBrackets());
108 sal_uInt16 i;
109 for (i = FNT_BEGIN; i <= FNT_END; i++)
111 SetFont(i, rFormat.GetFont(i));
112 SetDefaultFont(i, rFormat.IsDefaultFont(i));
114 for (i = SIZ_BEGIN; i <= SIZ_END; i++)
115 SetRelSize(i, rFormat.GetRelSize(i));
116 for (i = DIS_BEGIN; i <= DIS_END; i++)
117 SetDistance(i, rFormat.GetDistance(i));
119 return *this;
123 bool SmFormat::operator == (const SmFormat &rFormat) const
125 bool bRes = aBaseSize == rFormat.aBaseSize &&
126 eHorAlign == rFormat.eHorAlign &&
127 nGreekCharStyle == rFormat.nGreekCharStyle &&
128 bIsTextmode == rFormat.bIsTextmode &&
129 bScaleNormalBrackets == rFormat.bScaleNormalBrackets;
131 sal_uInt16 i;
132 for (i = 0; i <= SIZ_END && bRes; ++i)
134 if (vSize[i] != rFormat.vSize[i])
135 bRes = false;
137 for (i = 0; i <= DIS_END && bRes; ++i)
139 if (vDist[i] != rFormat.vDist[i])
140 bRes = false;
142 for (i = 0; i <= FNT_END && bRes; ++i)
144 if (vFont[i] != rFormat.vFont[i] ||
145 bDefaultFont[i] != rFormat.bDefaultFont[i])
146 bRes = false;
149 return bRes;
153 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */