tdf#130857 qt weld: Implement QtInstanceWidget::get_text_height
[LibreOffice.git] / starmath / source / format.cxx
blob9440ffb6b1d6eb75fbad9a6745b65cfe09a392ff
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, o3tl::convert(12, o3tl::Length::pt, SmO3tlLengthUnit()))
26 eHorAlign = SmHorAlign::Center;
27 nGreekCharStyle = 0;
28 bIsTextmode = bIsRightToLeft = 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] = 0;
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 SetRightToLeft(rFormat.IsRightToLeft());
106 SetGreekCharStyle(rFormat.GetGreekCharStyle());
107 SetScaleNormalBrackets(rFormat.IsScaleNormalBrackets());
109 sal_uInt16 i;
110 for (i = FNT_BEGIN; i <= FNT_END; i++)
112 SetFont(i, rFormat.GetFont(i));
113 SetDefaultFont(i, rFormat.IsDefaultFont(i));
115 for (i = SIZ_BEGIN; i <= SIZ_END; i++)
116 SetRelSize(i, rFormat.GetRelSize(i));
117 for (i = DIS_BEGIN; i <= DIS_END; i++)
118 SetDistance(i, rFormat.GetDistance(i));
120 return *this;
124 bool SmFormat::operator == (const SmFormat &rFormat) const
126 bool bRes = aBaseSize == rFormat.aBaseSize &&
127 eHorAlign == rFormat.eHorAlign &&
128 nGreekCharStyle == rFormat.nGreekCharStyle &&
129 bIsTextmode == rFormat.bIsTextmode &&
130 bIsRightToLeft == rFormat.bIsRightToLeft &&
131 bScaleNormalBrackets == rFormat.bScaleNormalBrackets;
133 sal_uInt16 i;
134 for (i = 0; i <= SIZ_END && bRes; ++i)
136 if (vSize[i] != rFormat.vSize[i])
137 bRes = false;
139 for (i = 0; i <= DIS_END && bRes; ++i)
141 if (vDist[i] != rFormat.vDist[i])
142 bRes = false;
144 for (i = 0; i <= FNT_END && bRes; ++i)
146 if (vFont[i] != rFormat.vFont[i] ||
147 bDefaultFont[i] != rFormat.bDefaultFont[i])
148 bRes = false;
151 return bRes;
155 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */