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 <svl/hint.hxx>
23 #include <svl/SfxBroadcaster.hxx>
24 #include "utility.hxx"
25 #include "types.hxx"
26
27
28 #define FNTNAME_TIMES "Times New Roman"
29 #define FNTNAME_HELV "Helvetica"
30 #define FNTNAME_COUR "Courier"
31 #define FNTNAME_MATH FONTNAME_MATH
32
33
34 // symbolic names used as array indices
35 #define SIZ_BEGIN 0
36 #define SIZ_TEXT 0
37 #define SIZ_INDEX 1
38 #define SIZ_FUNCTION 2
39 #define SIZ_OPERATOR 3
40 #define SIZ_LIMITS 4
41 #define SIZ_END 4
42
43 // symbolic names used as array indices
44 #define FNT_BEGIN 0
45 #define FNT_VARIABLE 0
46 #define FNT_FUNCTION 1
47 #define FNT_NUMBER 2
48 #define FNT_TEXT 3
49 #define FNT_SERIF 4
50 #define FNT_SANS 5
51 #define FNT_FIXED 6
52 #define FNT_MATH 7
53 #define FNT_END 7
54
55 // symbolic names used as array indices
56 #define DIS_BEGIN 0
57 #define DIS_HORIZONTAL 0
58 #define DIS_VERTICAL 1
59 #define DIS_ROOT 2
60 #define DIS_SUPERSCRIPT 3
61 #define DIS_SUBSCRIPT 4
62 #define DIS_NUMERATOR 5
63 #define DIS_DENOMINATOR 6
64 #define DIS_FRACTION 7
65 #define DIS_STROKEWIDTH 8
66 #define DIS_UPPERLIMIT 9
67 #define DIS_LOWERLIMIT 10
68 #define DIS_BRACKETSIZE 11
69 #define DIS_BRACKETSPACE 12
70 #define DIS_MATRIXROW 13
71 #define DIS_MATRIXCOL 14
72 #define DIS_ORNAMENTSIZE 15
73 #define DIS_ORNAMENTSPACE 16
74 #define DIS_OPERATORSIZE 17
75 #define DIS_OPERATORSPACE 18
76 #define DIS_LEFTSPACE 19
77 #define DIS_RIGHTSPACE 20
78 #define DIS_TOPSPACE 21
79 #define DIS_BOTTOMSPACE 22
80 #define DIS_NORMALBRACKETSIZE 23
81 #define DIS_END 23
82
83
84 enum class SmHorAlign {
85 Left,
86 Center,
87 Right
88 };
89
90 class SmFormat final : public SfxBroadcaster
91 {
92 SmFace vFont[FNT_END + 1];
93 bool bDefaultFont[FNT_END + 1];
94 Size aBaseSize;
95 sal_uInt16 vSize[SIZ_END + 1];
96 sal_uInt16 vDist[DIS_END + 1];
97 SmHorAlign eHorAlign;
98 sal_Int16 nGreekCharStyle;
99 bool bIsTextmode,
100 bScaleNormalBrackets;
101
102 public:
103 SmFormat();
SmFormat(const SmFormat & rFormat)104 SmFormat(const SmFormat &rFormat) : SfxBroadcaster() { *this = rFormat; }
105
GetBaseSize() const106 const Size & GetBaseSize() const { return aBaseSize; }
SetBaseSize(const Size & rSize)107 void SetBaseSize(const Size &rSize) { aBaseSize = rSize; }
108
GetFont(sal_uInt16 nIdent) const109 const SmFace & GetFont(sal_uInt16 nIdent) const { return vFont[nIdent]; }
110 void SetFont(sal_uInt16 nIdent, const SmFace &rFont, bool bDefault = false);
SetFontSize(sal_uInt16 nIdent,const Size & rSize)111 void SetFontSize(sal_uInt16 nIdent, const Size &rSize) { vFont[nIdent].SetSize( rSize ); }
112
SetDefaultFont(sal_uInt16 nIdent,bool bVal)113 void SetDefaultFont(sal_uInt16 nIdent, bool bVal) { bDefaultFont[nIdent] = bVal; }
IsDefaultFont(sal_uInt16 nIdent) const114 bool IsDefaultFont(sal_uInt16 nIdent) const { return bDefaultFont[nIdent]; }
115
GetRelSize(sal_uInt16 nIdent) const116 sal_uInt16 GetRelSize(sal_uInt16 nIdent) const { return vSize[nIdent]; }
SetRelSize(sal_uInt16 nIdent,sal_uInt16 nVal)117 void SetRelSize(sal_uInt16 nIdent, sal_uInt16 nVal) { vSize[nIdent] = nVal;}
118
GetDistance(sal_uInt16 nIdent) const119 sal_uInt16 GetDistance(sal_uInt16 nIdent) const { return vDist[nIdent]; }
SetDistance(sal_uInt16 nIdent,sal_uInt16 nVal)120 void SetDistance(sal_uInt16 nIdent, sal_uInt16 nVal) { vDist[nIdent] = nVal; }
121
GetHorAlign() const122 SmHorAlign GetHorAlign() const { return eHorAlign; }
SetHorAlign(SmHorAlign eAlign)123 void SetHorAlign(SmHorAlign eAlign) { eHorAlign = eAlign; }
124
IsTextmode() const125 bool IsTextmode() const { return bIsTextmode; }
SetTextmode(bool bVal)126 void SetTextmode(bool bVal) { bIsTextmode = bVal; }
127
GetGreekCharStyle() const128 sal_Int16 GetGreekCharStyle() const { return nGreekCharStyle; }
SetGreekCharStyle(sal_Int16 nVal)129 void SetGreekCharStyle(sal_Int16 nVal) { nGreekCharStyle = nVal; }
130
IsScaleNormalBrackets() const131 bool IsScaleNormalBrackets() const { return bScaleNormalBrackets; }
SetScaleNormalBrackets(bool bVal)132 void SetScaleNormalBrackets(bool bVal) { bScaleNormalBrackets = bVal; }
133
134 SmFormat & operator = (const SmFormat &rFormat);
135
136 bool operator == (const SmFormat &rFormat) const;
137 inline bool operator != (const SmFormat &rFormat) const;
138
RequestApplyChanges()139 void RequestApplyChanges()
140 {
141 Broadcast(SfxHint(SfxHintId::MathFormatChanged));
142 }
143
144 };
145
operator !=(const SmFormat & rFormat) const146 inline bool SmFormat::operator != (const SmFormat &rFormat) const
147 {
148 return !(*this == rFormat);
149 }
150
151 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
152