Coverage Report

Created: 2026-06-30 11:14

next uncovered line (L), next uncovered region (R), next uncovered branch (B)
/src/libreoffice/starmath/inc/format.hxx
Line
Count
Source
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>
24
#include <svl/SfxBroadcaster.hxx>
25
#include "utility.hxx"
26
#include "types.hxx"
27
28
29
inline constexpr OUString FNTNAME_TIMES = u"Times New Roman"_ustr;
30
inline constexpr OUString FNTNAME_HELV = u"Helvetica"_ustr;
31
inline constexpr OUString FNTNAME_COUR = u"Courier"_ustr;
32
784
#define FNTNAME_MATH    FONTNAME_MATH
33
34
35
// symbolic names used as array indices
36
2.15k
#define SIZ_BEGIN       0
37
662k
#define SIZ_TEXT        0
38
12.4k
#define SIZ_INDEX       1
39
3.40k
#define SIZ_FUNCTION    2
40
131k
#define SIZ_OPERATOR    3
41
1.56k
#define SIZ_LIMITS      4
42
12.9k
#define SIZ_END         4
43
44
// symbolic names used as array indices
45
3.63k
#define FNT_BEGIN       0
46
1.11M
#define FNT_VARIABLE    0
47
268k
#define FNT_FUNCTION    1
48
115k
#define FNT_NUMBER      2
49
68.9k
#define FNT_TEXT        3
50
3.91k
#define FNT_SERIF       4
51
3.91k
#define FNT_SANS        5
52
4.10k
#define FNT_FIXED       6
53
1.25M
#define FNT_MATH        7
54
32.6k
#define FNT_END         7
55
56
// symbolic names used as array indices
57
2.15k
#define DIS_BEGIN                0
58
219k
#define DIS_HORIZONTAL           0
59
3.00k
#define DIS_VERTICAL             1
60
2.32k
#define DIS_ROOT                 2
61
3.04k
#define DIS_SUPERSCRIPT          3
62
5.92k
#define DIS_SUBSCRIPT            4
63
2.06k
#define DIS_NUMERATOR            5
64
2.06k
#define DIS_DENOMINATOR          6
65
2.06k
#define DIS_FRACTION             7
66
2.06k
#define DIS_STROKEWIDTH          8
67
1.56k
#define DIS_UPPERLIMIT           9
68
1.56k
#define DIS_LOWERLIMIT          10
69
1.56k
#define DIS_BRACKETSIZE         11
70
10.8k
#define DIS_BRACKETSPACE        12
71
1.65k
#define DIS_MATRIXROW           13
72
1.65k
#define DIS_MATRIXCOL           14
73
479k
#define DIS_ORNAMENTSIZE        15
74
1.56k
#define DIS_ORNAMENTSPACE       16
75
2.37k
#define DIS_OPERATORSIZE        17
76
2.38k
#define DIS_OPERATORSPACE       18
77
1.65k
#define DIS_LEFTSPACE           19
78
1.65k
#define DIS_RIGHTSPACE          20
79
3.00k
#define DIS_TOPSPACE            21
80
3.00k
#define DIS_BOTTOMSPACE         22
81
10.5k
#define DIS_NORMALBRACKETSIZE   23
82
53.9k
#define DIS_END                 23
83
84
85
enum class SmHorAlign {
86
    Left,
87
    Center,
88
    Right
89
};
90
91
class SM_DLLPUBLIC SmFormat final : public SfxBroadcaster
92
{
93
    SmFace      vFont[FNT_END + 1];
94
    bool        bDefaultFont[FNT_END + 1];
95
    Size        aBaseSize;
96
    sal_uInt16      vSize[SIZ_END + 1];
97
    sal_uInt16      vDist[DIS_END + 1];
98
    SmHorAlign  eHorAlign;
99
    sal_Int16       nGreekCharStyle;
100
    bool        bIsTextmode,
101
                bIsRightToLeft,
102
                bScaleNormalBrackets;
103
104
public:
105
    SmFormat();
106
688
    SmFormat(const SmFormat &rFormat) : SfxBroadcaster() { *this = rFormat; }
107
108
8.00k
    const Size &    GetBaseSize() const             { return aBaseSize; }
109
2.15k
    void            SetBaseSize(const Size &rSize)  { aBaseSize = rSize; }
110
111
1.37M
    const SmFace &  GetFont(sal_uInt16 nIdent) const { return vFont[nIdent]; }
112
    void            SetFont(sal_uInt16 nIdent, const SmFace &rFont, bool bDefault = false);
113
0
    void            SetFontSize(sal_uInt16 nIdent, const Size &rSize)   { vFont[nIdent].SetSize( rSize ); }
114
115
17.2k
    void            SetDefaultFont(sal_uInt16 nIdent, bool bVal)    { bDefaultFont[nIdent] = bVal; }
116
17.2k
    bool            IsDefaultFont(sal_uInt16 nIdent) const   { return bDefaultFont[nIdent]; }
117
118
549k
    sal_uInt16      GetRelSize(sal_uInt16 nIdent) const         { return vSize[nIdent]; }
119
10.7k
    void            SetRelSize(sal_uInt16 nIdent, sal_uInt16 nVal)  { vSize[nIdent] = nVal;}
120
121
776k
    sal_uInt16      GetDistance(sal_uInt16 nIdent) const            { return vDist[nIdent]; }
122
51.7k
    void            SetDistance(sal_uInt16 nIdent, sal_uInt16 nVal) { vDist[nIdent] = nVal; }
123
124
719k
    SmHorAlign      GetHorAlign() const             { return eHorAlign; }
125
2.15k
    void            SetHorAlign(SmHorAlign eAlign)  { eHorAlign = eAlign; }
126
127
15.1k
    bool            IsTextmode() const     { return bIsTextmode; }
128
2.15k
    void            SetTextmode(bool bVal) { bIsTextmode = bVal; }
129
130
3.59k
    bool            IsRightToLeft() const     { return bIsRightToLeft; }
131
2.15k
    void            SetRightToLeft(bool bVal) { bIsRightToLeft = bVal; }
132
133
2.15k
    sal_Int16       GetGreekCharStyle() const     { return nGreekCharStyle; }
134
2.15k
    void            SetGreekCharStyle(sal_Int16 nVal) { nGreekCharStyle = nVal; }
135
136
11.4k
    bool            IsScaleNormalBrackets() const     { return bScaleNormalBrackets; }
137
2.15k
    void            SetScaleNormalBrackets(bool bVal) { bScaleNormalBrackets = bVal; }
138
139
    SmFormat &      operator = (const SmFormat &rFormat);
140
141
    bool            operator == (const SmFormat &rFormat) const;
142
    inline bool     operator != (const SmFormat &rFormat) const;
143
144
    void RequestApplyChanges()
145
0
    {
146
0
        Broadcast(SfxHint(SfxHintId::MathFormatChanged));
147
0
    }
148
149
};
150
151
inline bool    SmFormat::operator != (const SmFormat &rFormat) const
152
0
{
153
0
    return !(*this == rFormat);
154
0
}
155
156
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */