Coverage Report

Created: 2026-03-31 11:00

next uncovered line (L), next uncovered region (R), next uncovered branch (B)
/src/libreoffice/starmath/inc/utility.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
#include "smdllapi.hxx"
24
25
#include <o3tl/unit_conversion.hxx>
26
#include <sal/log.hxx>
27
#include <vcl/font.hxx>
28
#include <vcl/weld/ComboBox.hxx>
29
#include <vcl/weld/weld.hxx>
30
#include <tools/fract.hxx>
31
#include <tools/mapunit.hxx>
32
#include <deque>
33
34
35
class SmViewShell;
36
SmViewShell * SmGetActiveView();
37
38
39
// SmFace
40
41
42
bool    IsItalic( const vcl::Font &rFont );
43
bool    IsBold( const vcl::Font &rFont );
44
45
class SM_DLLPUBLIC SmFace final : public vcl::Font
46
{
47
    tools::Long    nBorderWidth;
48
49
    void    Impl_Init();
50
51
public:
52
    SmFace() :
53
11.7M
        Font(), nBorderWidth(-1) { Impl_Init(); }
54
    explicit SmFace(const Font& rFont) :
55
7
        Font(rFont), nBorderWidth(-1) { Impl_Init(); }
56
    SmFace(const OUString& rName, const Size& rSize) :
57
88.5k
        Font(rName, rSize), nBorderWidth(-1) { Impl_Init(); }
58
59
    SmFace(const SmFace &rFace) :
60
0
        Font(rFace), nBorderWidth(-1) { Impl_Init(); }
61
62
    // overloaded version in order to supply a min value
63
    // for font size (height). (Also used in ctor's to do so.)
64
    void    SetSize(const Size& rSize);
65
66
0
    void    SetBorderWidth(tools::Long nWidth)     { nBorderWidth = nWidth; }
67
    tools::Long    GetBorderWidth() const;
68
2.75M
    tools::Long    GetDefaultBorderWidth() const   { return GetFontSize().Height() / 20 ; }
69
18.6k
    void    FreezeBorderWidth()     { nBorderWidth = GetDefaultBorderWidth(); }
70
71
    SmFace & operator = (const SmFace &rFace);
72
};
73
74
SmFace & operator *= (SmFace &rFace, double fFrac);
75
76
77
// SmFontPickList
78
79
80
class SmFontDialog;
81
82
class SmFontPickList
83
{
84
protected:
85
    sal_uInt16 nMaxItems;
86
    std::deque<vcl::Font> aFontVec;
87
88
public:
89
8
    explicit SmFontPickList(sal_uInt16 nMax = 5) : nMaxItems(nMax) {}
90
0
    virtual ~SmFontPickList() { Clear(); }
91
92
    virtual void    Insert(const vcl::Font &rFont);
93
94
    void            Clear();
95
    vcl::Font       Get(sal_uInt16 nPos = 0) const;
96
97
    SmFontPickList& operator = (const SmFontPickList& rList);
98
99
    void            ReadFrom(const SmFontDialog& rDialog);
100
    void            WriteTo(SmFontDialog& rDialog) const;
101
};
102
103
104
//  SmFontPickListBox
105
106
107
class SmFontPickListBox final : public SmFontPickList
108
{
109
private:
110
    std::unique_ptr<weld::ComboBox> m_xWidget;
111
112
    DECL_LINK(SelectHdl, weld::ComboBox&, void);
113
114
public:
115
    SmFontPickListBox(std::unique_ptr<weld::ComboBox> pWidget);
116
    SmFontPickListBox& operator = (const SmFontPickList& rList);
117
    virtual void    Insert(const vcl::Font &rFont) override;
118
};
119
120
// Math used to use 100ths of MM by default, but now uses twips
121
// which seems to improve (subpixel) positioning.
122
inline MapUnit SmMapUnit()
123
3.45M
{
124
3.45M
    return MapUnit::MapTwip;
125
3.45M
}
126
inline o3tl::Length SmO3tlLengthUnit()
127
94.1M
{
128
94.1M
    return o3tl::Length::twip;
129
94.1M
}
130
131
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */