Coverage Report

Created: 2025-12-08 09:28

next uncovered line (L), next uncovered region (R), next uncovered branch (B)
/src/libreoffice/vcl/inc/impfont.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 <sal/config.h>
23
24
#include <rtl/ustring.hxx>
25
#include <tools/color.hxx>
26
#include <tools/fontenum.hxx>
27
#include <tools/gen.hxx>
28
#include <i18nlangtag/languagetag.hxx>
29
#include <vcl/fntstyle.hxx>
30
#include <vcl/font.hxx>
31
32
/* The following class is extraordinarily similar to FontAttributes. */
33
34
class ImplFont
35
{
36
public:
37
    explicit            ImplFont();
38
    explicit            ImplFont( const ImplFont& );
39
40
    // device independent font functions
41
180M
    const OUString&     GetFamilyName() const                           { return maFamilyName; }
42
1.64M
    FontFamily          GetFamilyType()                                 { if(meFamily==FAMILY_DONTKNOW)  AskConfig(); return meFamily; }
43
956
    const OUString&     GetStyleName() const                            { return maStyleName; }
44
45
86.6k
    FontWeight          GetWeight()                                     { if(meWeight==WEIGHT_DONTKNOW)  AskConfig(); return meWeight; }
46
76.9k
    FontItalic          GetItalic()                                     { if(meItalic==ITALIC_DONTKNOW)  AskConfig(); return meItalic; }
47
1.64M
    FontPitch           GetPitch()                                      { if(mePitch==PITCH_DONTKNOW)    AskConfig(); return mePitch; }
48
0
    FontWidth           GetWidthType()                                  { if(meWidthType==WIDTH_DONTKNOW) AskConfig(); return meWidthType; }
49
123M
    TextAlign           GetAlignment() const                            { return meAlign; }
50
115M
    rtl_TextEncoding    GetCharSet() const                              { return meCharSet; }
51
486M
    const Size&         GetFontSize() const                      { return maAverageFontSize; }
52
53
15.3M
    void                SetFamilyName( const OUString& sFamilyName )    { maFamilyName = sFamilyName; }
54
2.85k
    void                SetStyleName( const OUString& sStyleName )      { maStyleName = sStyleName; }
55
48.9M
    void                SetFamilyType( const FontFamily eFontFamily )   { meFamily = eFontFamily; }
56
57
28.2M
    void                SetPitch( const FontPitch ePitch )              { mePitch = ePitch; }
58
2.34M
    void                SetItalic( const FontItalic eItalic )           { meItalic = eItalic; }
59
24.3M
    void                SetWeight( const FontWeight eWeight )           { meWeight = eWeight; }
60
39.2M
    void                SetWidthType( const FontWidth eWidthType )      { meWidthType = eWidthType; }
61
56.9M
    void                SetAlignment( const TextAlign eAlignment )      { meAlign = eAlignment; }
62
44.6M
    void                SetCharSet( const rtl_TextEncoding eCharSet )   { meCharSet = eCharSet; }
63
    void                SetFontSize( const Size& rSize )
64
117M
    {
65
117M
        if(rSize.Height() != maAverageFontSize.Height())
66
92.2M
        {
67
            // reset evtl. buffered calculated AverageFontSize, it depends
68
            // on Font::Height
69
92.2M
            mnCalculatedAverageFontWidth = 0;
70
92.2M
        }
71
117M
        maAverageFontSize = rSize;
72
117M
    }
73
74
    // straight properties, no getting them from AskConfig()
75
116M
    FontFamily          GetFamilyTypeNoAsk() const                      { return meFamily; }
76
121M
    FontWeight          GetWeightNoAsk() const                          { return meWeight; }
77
127M
    FontItalic          GetItalicNoAsk() const                          { return meItalic; }
78
103M
    FontPitch           GetPitchNoAsk() const                           { return mePitch; }
79
39.2M
    FontWidth           GetWidthTypeNoAsk() const                       { return meWidthType; }
80
81
    // device dependent functions
82
0
    int                 GetQuality() const                              { return mnQuality; }
83
84
39.2M
    void                SetQuality( int nQuality )                      { mnQuality = nQuality; }
85
0
    void                IncreaseQualityBy( int nQualityAmount )         { mnQuality += nQualityAmount; }
86
0
    void                DecreaseQualityBy( int nQualityAmount )         { mnQuality -= nQualityAmount; }
87
88
5.09k
    tools::Long         GetCalculatedAverageFontWidth() const           { return mnCalculatedAverageFontWidth; }
89
2.43k
    void                SetCalculatedAverageFontWidth(tools::Long nNew) { mnCalculatedAverageFontWidth = nNew; }
90
91
    bool                operator==( const ImplFont& ) const;
92
    bool                EqualIgnoreColor( const ImplFont& ) const;
93
94
    size_t              GetHashValue() const;
95
    size_t              GetHashValueIgnoreColor() const;
96
97
private:
98
    friend class vcl::Font;
99
    friend SvStream&    ReadImplFont( SvStream& rIStm, ImplFont&, tools::Long& );
100
    friend SvStream&    WriteImplFont( SvStream& rOStm, const ImplFont&, tools::Long );
101
102
    void                AskConfig();
103
104
    // Device independent variables
105
    OUString            maFamilyName;
106
    OUString            maStyleName;
107
    FontWeight          meWeight;
108
    FontFamily          meFamily;
109
    FontPitch           mePitch;
110
    FontWidth           meWidthType;
111
    FontItalic          meItalic;
112
    TextAlign           meAlign;
113
    FontLineStyle       meUnderline;
114
    FontLineStyle       meOverline;
115
    FontStrikeout       meStrikeout;
116
    FontRelief          meRelief;
117
    FontEmphasisMark    meEmphasisMark;
118
    FontKerning         meKerning;
119
    short               mnSpacing;
120
    Size                maAverageFontSize;
121
    rtl_TextEncoding    meCharSet;
122
123
    LanguageTag         maLanguageTag;
124
    LanguageTag         maCJKLanguageTag;
125
126
    // Flags - device independent
127
    bool                mbOutline:1,
128
                        mbConfigLookup:1,   // config lookup should only be done once
129
                        mbShadow:1,
130
                        mbVertical:1,
131
                        mbTransparent:1;    // compatibility, now on output device
132
133
    // deprecated variables - device independent
134
    Color               maColor;            // compatibility, now on output device
135
    Color               maFillColor;        // compatibility, now on output device
136
137
    // Device dependent variables
138
    bool                mbWordLine:1;
139
140
    // TODO: metric data, should be migrated to ImplFontMetric
141
    Degree10            mnOrientation;
142
143
    int                 mnQuality;
144
145
    tools::Long         mnCalculatedAverageFontWidth;
146
};
147
148
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */