Coverage Report

Created: 2025-11-16 09:57

next uncovered line (L), next uncovered region (R), next uncovered branch (B)
/src/libreoffice/include/tools/helpers.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
#pragma once
10
#include <com/sun/star/uno/Reference.h>
11
#include <sal/config.h>
12
#include <sal/types.h>
13
#include <tools/long.hxx>
14
#include <limits>
15
#include <string>
16
#include <type_traits>
17
18
inline sal_uInt32 AlignedWidth4Bytes(sal_uInt32 nWidthBits)
19
1.06M
{
20
1.06M
    if (nWidthBits > SAL_MAX_UINT32 - 31)
21
34
        nWidthBits = SAL_MAX_UINT32;
22
1.06M
    else
23
1.06M
        nWidthBits += 31;
24
1.06M
    return (nWidthBits >> 5) << 2;
25
1.06M
}
26
27
//valid range:  (-180,180]
28
template <typename T>
29
[[nodiscard]] inline typename std::enable_if<std::is_signed<T>::value, T>::type
30
NormAngle180(T angle)
31
0
{
32
0
    while (angle <= -180)
33
0
        angle += 360;
34
0
    while (angle > 180)
35
0
        angle -= 360;
36
0
    return angle;
37
0
}
38
39
//valid range:  [0,360)
40
template <typename T> [[nodiscard]] inline T NormAngle360(T angle)
41
5.80k
{
42
37.5k
    while (angle < 0)
43
31.7k
        angle += 360;
44
7.78k
    while (angle >= 360)
45
1.98k
        angle -= 360;
46
5.80k
    return angle;
47
5.80k
}
double NormAngle360<double>(double)
Line
Count
Source
41
5.80k
{
42
37.5k
    while (angle < 0)
43
31.7k
        angle += 360;
44
7.78k
    while (angle >= 360)
45
1.98k
        angle -= 360;
46
5.80k
    return angle;
47
5.80k
}
Unexecuted instantiation: int NormAngle360<int>(int)
48
49
// get hash from interface
50
// TODO: UNIT TEST
51
[[nodiscard]] inline
52
std::string GetInterfaceHash(const ::css::uno::Reference<::css::uno::XInterface>& xIf)
53
0
{
54
0
    if (xIf.is())
55
0
    {
56
0
        auto ptr = reinterpret_cast<sal_uIntPtr>(xIf.get());
57
0
        return std::to_string(ptr);
58
0
    }
59
0
    return {};
60
0
}
61
62
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */