Coverage Report

Created: 2026-06-30 11:14

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 <string>
14
#include <type_traits>
15
16
inline sal_uInt32 AlignedWidth4Bytes(sal_uInt32 nWidthBits)
17
274k
{
18
274k
    if (nWidthBits > SAL_MAX_UINT32 - 31)
19
42
        nWidthBits = SAL_MAX_UINT32;
20
274k
    else
21
274k
        nWidthBits += 31;
22
274k
    return (nWidthBits >> 5) << 2;
23
274k
}
24
25
//valid range:  (-180,180]
26
template <typename T>
27
[[nodiscard]] inline typename std::enable_if<std::is_signed<T>::value, T>::type
28
NormAngle180(T angle)
29
0
{
30
0
    while (angle <= -180)
31
0
        angle += 360;
32
0
    while (angle > 180)
33
0
        angle -= 360;
34
0
    return angle;
35
0
}
36
37
//valid range:  [0,360)
38
template <typename T> [[nodiscard]] inline T NormAngle360(T angle)
39
5.09k
{
40
36.4k
    while (angle < 0)
41
31.3k
        angle += 360;
42
6.89k
    while (angle >= 360)
43
1.79k
        angle -= 360;
44
5.09k
    return angle;
45
5.09k
}
double NormAngle360<double>(double)
Line
Count
Source
39
5.09k
{
40
36.4k
    while (angle < 0)
41
31.3k
        angle += 360;
42
6.89k
    while (angle >= 360)
43
1.79k
        angle -= 360;
44
5.09k
    return angle;
45
5.09k
}
Unexecuted instantiation: int NormAngle360<int>(int)
46
47
// get hash from interface
48
// TODO: UNIT TEST
49
[[nodiscard]] inline
50
std::string GetInterfaceHash(const ::css::uno::Reference<::css::uno::XInterface>& xIf)
51
0
{
52
0
    if (xIf.is())
53
0
    {
54
0
        auto ptr = reinterpret_cast<sal_uIntPtr>(xIf.get());
55
0
        return std::to_string(ptr);
56
0
    }
57
0
    return {};
58
0
}
59
60
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */