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