Coverage Report

Created: 2025-12-08 09:28

next uncovered line (L), next uncovered region (R), next uncovered branch (B)
/src/libreoffice/tools/source/generic/point.cxx
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
#include <tools/gen.hxx>
21
22
void PointTemplateBase::RotateAround( PointTemplateBase& rPoint,
23
                          Degree10 nOrientation ) const
24
5.56M
{
25
5.56M
    tools::Long nX = rPoint.mnA;
26
5.56M
    tools::Long nY = rPoint.mnB;
27
5.56M
    RotateAround(nX, nY, nOrientation);
28
5.56M
    rPoint.mnA = nX;
29
5.56M
    rPoint.mnB = nY;
30
5.56M
}
31
32
void PointTemplateBase::RotateAround( tools::Long& rX, tools::Long& rY,
33
                          Degree10 nOrientation ) const
34
6.94M
{
35
6.94M
    const tools::Long nOriginX = mnA;
36
6.94M
    const tools::Long nOriginY = mnB;
37
38
6.94M
    if ( (nOrientation >= 0_deg10) && !(nOrientation % 900_deg10) )
39
367k
    {
40
367k
        if ( nOrientation >= 3600_deg10 )
41
229
            nOrientation %= 3600_deg10;
42
43
367k
        if ( nOrientation )
44
364k
        {
45
364k
            rX -= nOriginX;
46
364k
            rY -= nOriginY;
47
48
364k
            if ( nOrientation == 900_deg10 )
49
218k
            {
50
218k
                tools::Long nTemp = rX;
51
218k
                rX = rY;
52
218k
                rY = -nTemp;
53
218k
            }
54
146k
            else if ( nOrientation == 1800_deg10 )
55
2.18k
            {
56
2.18k
                rX = -rX;
57
2.18k
                rY = -rY;
58
2.18k
            }
59
143k
            else /* ( nOrientation == 2700 ) */
60
143k
            {
61
143k
                tools::Long nTemp = rX;
62
143k
                rX = -rY;
63
143k
                rY = nTemp;
64
143k
            }
65
66
364k
            rX += nOriginX;
67
364k
            rY += nOriginY;
68
364k
        }
69
367k
    }
70
6.57M
    else
71
6.57M
    {
72
6.57M
        double nRealOrientation = toRadians(nOrientation);
73
6.57M
        double nCos = cos( nRealOrientation );
74
6.57M
        double nSin = sin( nRealOrientation );
75
76
        // Translation...
77
6.57M
        tools::Long nX = rX-nOriginX;
78
6.57M
        tools::Long nY = rY-nOriginY;
79
80
        // Rotation...
81
6.57M
        rX = + static_cast<tools::Long>(nCos*nX + nSin*nY) + nOriginX;
82
6.57M
        rY = - static_cast<tools::Long>(nSin*nX - nCos*nY) + nOriginY;
83
6.57M
    }
84
6.94M
}
85
86
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */