Coverage Report

Created: 2026-10-14 09:33

next uncovered line (L), next uncovered region (R), next uncovered branch (B)
/src/libreoffice/include/tools/mapunit.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
#pragma once
20
21
#include <sal/config.h>
22
23
#include <o3tl/unit_conversion.hxx>
24
#include <sal/types.h>
25
26
enum class MapUnit : sal_uInt8
27
{
28
    Map100thMM, Map10thMM, MapMM, MapCM,
29
    Map1000thInch, Map100thInch, Map10thInch, MapInch,
30
    MapPoint, MapTwip,
31
    MapPixel,
32
    MapSysFont, MapAppFont,
33
    MapRelative,
34
    LAST = MapRelative,
35
    LASTENUMDUMMY // used as an error return
36
};
37
38
constexpr o3tl::Length MapToO3tlLength(MapUnit eU, o3tl::Length ePixelValue = o3tl::Length::px)
39
2.40M
{
40
2.40M
    switch (eU)
41
2.40M
    {
42
1.13M
        case MapUnit::Map100thMM:
43
1.13M
            return o3tl::Length::mm100;
44
143k
        case MapUnit::Map10thMM:
45
143k
            return o3tl::Length::mm10;
46
0
        case MapUnit::MapMM:
47
0
            return o3tl::Length::mm;
48
0
        case MapUnit::MapCM:
49
0
            return o3tl::Length::cm;
50
0
        case MapUnit::Map1000thInch:
51
0
            return o3tl::Length::in1000;
52
0
        case MapUnit::Map100thInch:
53
0
            return o3tl::Length::in100;
54
0
        case MapUnit::Map10thInch:
55
0
            return o3tl::Length::in10;
56
30.2k
        case MapUnit::MapInch:
57
30.2k
            return o3tl::Length::in;
58
203k
        case MapUnit::MapPoint:
59
203k
            return o3tl::Length::pt;
60
816k
        case MapUnit::MapTwip:
61
816k
            return o3tl::Length::twip;
62
75.5k
        case MapUnit::MapPixel:
63
75.5k
            return ePixelValue;
64
0
        default:
65
0
            return o3tl::Length::invalid;
66
2.40M
    }
67
2.40M
}
68
69
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */