Coverage Report

Created: 2026-02-14 09:37

next uncovered line (L), next uncovered region (R), next uncovered branch (B)
/src/libreoffice/include/tools/fldunit.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
#ifndef INCLUDED_TOOLS_FLDUNIT_HXX
20
#define INCLUDED_TOOLS_FLDUNIT_HXX
21
22
#include <sal/config.h>
23
24
#include <o3tl/unit_conversion.hxx>
25
#include <sal/types.h>
26
27
// Corresponds to offapi/com/sun/star/awt/FieldUnit.idl
28
enum class FieldUnit : sal_uInt16
29
{
30
    NONE,
31
    MM,
32
    CM,
33
    M,
34
    KM,
35
    TWIP,
36
    POINT,
37
    PICA,
38
    INCH,
39
    FOOT,
40
    MILE,
41
    CUSTOM,
42
    PERCENT,
43
    MM_100TH,
44
    CHAR,
45
    LINE,
46
    PIXEL,
47
    DEGREE,
48
    SECOND,
49
    MILLISECOND,
50
    FONT_EM,
51
    FONT_CJK_ADVANCE,
52
};
53
54
constexpr o3tl::Length FieldToO3tlLength(FieldUnit eU, o3tl::Length ePixelValue = o3tl::Length::px)
55
231k
{
56
231k
    switch (eU)
57
231k
    {
58
195k
        case FieldUnit::MM:
59
195k
            return o3tl::Length::mm;
60
36.3k
        case FieldUnit::CM:
61
36.3k
            return o3tl::Length::cm;
62
0
        case FieldUnit::M:
63
0
            return o3tl::Length::m;
64
0
        case FieldUnit::KM:
65
0
            return o3tl::Length::km;
66
0
        case FieldUnit::TWIP:
67
0
            return o3tl::Length::twip;
68
0
        case FieldUnit::POINT:
69
0
            return o3tl::Length::pt;
70
0
        case FieldUnit::PICA:
71
0
            return o3tl::Length::pc;
72
0
        case FieldUnit::INCH:
73
0
            return o3tl::Length::in;
74
0
        case FieldUnit::FOOT:
75
0
            return o3tl::Length::ft;
76
0
        case FieldUnit::MILE:
77
0
            return o3tl::Length::mi;
78
0
        case FieldUnit::CHAR:
79
0
            return o3tl::Length::ch;
80
0
        case FieldUnit::LINE:
81
0
            return o3tl::Length::line;
82
0
        case FieldUnit::MM_100TH:
83
0
            return o3tl::Length::mm100;
84
0
        case FieldUnit::PIXEL:
85
0
            return ePixelValue;
86
0
        default:
87
0
            return o3tl::Length::invalid;
88
231k
    }
89
231k
}
90
91
#endif
92
93
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */