Coverage Report

Created: 2026-11-06 11:29

next uncovered line (L), next uncovered region (R), next uncovered branch (B)
/src/libreoffice/drawinglayer/source/attribute/linestartendattribute.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 <drawinglayer/attribute/linestartendattribute.hxx>
21
#include <basegfx/polygon/b2dpolygon.hxx>
22
#include <basegfx/polygon/b2dpolypolygon.hxx>
23
#include <utility>
24
25
26
namespace drawinglayer::attribute
27
{
28
        class ImpLineStartEndAttribute
29
        {
30
        public:
31
            // data definitions
32
            double                                  mfWidth;                // absolute line StartEndGeometry base width
33
            basegfx::B2DPolyPolygon                 maPolyPolygon;          // the StartEndGeometry PolyPolygon
34
35
            bool                                    mbCentered : 1;         // use centered to lineStart/End point?
36
37
            ImpLineStartEndAttribute(
38
                double fWidth,
39
                basegfx::B2DPolyPolygon aPolyPolygon,
40
                bool bCentered)
41
1.22k
            :   mfWidth(fWidth),
42
1.22k
                maPolyPolygon(std::move(aPolyPolygon)),
43
1.22k
                mbCentered(bCentered)
44
1.22k
            {
45
1.22k
            }
46
47
            ImpLineStartEndAttribute()
48
1
            :   mfWidth(0.0),
49
1
                mbCentered(false)
50
1
            {
51
1
            }
52
53
            // data read access
54
4.54k
            double getWidth() const { return mfWidth; }
55
5.34k
            const basegfx::B2DPolyPolygon& getB2DPolyPolygon() const { return maPolyPolygon; }
56
1.04k
            bool isCentered() const { return mbCentered; }
57
58
            bool operator==(const ImpLineStartEndAttribute& rCandidate) const
59
0
            {
60
0
                return (basegfx::fTools::equal(getWidth(), rCandidate.getWidth())
61
0
                    && getB2DPolyPolygon() == rCandidate.getB2DPolyPolygon()
62
0
                    && isCentered() == rCandidate.isCentered());
63
0
            }
64
        };
65
66
        namespace
67
        {
68
            LineStartEndAttribute::ImplType& theGlobalDefault()
69
4.21k
            {
70
4.21k
                static LineStartEndAttribute::ImplType SINGLETON;
71
4.21k
                return SINGLETON;
72
4.21k
            }
73
        }
74
75
        LineStartEndAttribute::LineStartEndAttribute(
76
            double fWidth,
77
            const basegfx::B2DPolyPolygon& rPolyPolygon,
78
            bool bCentered)
79
1.22k
        :   mpLineStartEndAttribute(ImpLineStartEndAttribute(
80
1.22k
                fWidth, rPolyPolygon, bCentered))
81
1.22k
        {
82
1.22k
        }
83
84
        LineStartEndAttribute::LineStartEndAttribute()
85
1.89k
        :   mpLineStartEndAttribute(theGlobalDefault())
86
1.89k
        {
87
1.89k
        }
88
89
2.30k
        LineStartEndAttribute::LineStartEndAttribute(const LineStartEndAttribute&) = default;
90
91
5.41k
        LineStartEndAttribute::~LineStartEndAttribute() = default;
92
93
        bool LineStartEndAttribute::isDefault() const
94
2.32k
        {
95
2.32k
            return mpLineStartEndAttribute.same_object(theGlobalDefault());
96
2.32k
        }
97
98
1.44k
        LineStartEndAttribute& LineStartEndAttribute::operator=(const LineStartEndAttribute&) = default;
99
100
        bool LineStartEndAttribute::operator==(const LineStartEndAttribute& rCandidate) const
101
0
        {
102
            // tdf#87509 default attr is always != non-default attr, even with same values
103
0
            if(rCandidate.isDefault() != isDefault())
104
0
                return false;
105
106
0
            return rCandidate.mpLineStartEndAttribute == mpLineStartEndAttribute;
107
0
        }
108
109
        double LineStartEndAttribute::getWidth() const
110
4.54k
        {
111
4.54k
            return mpLineStartEndAttribute->getWidth();
112
4.54k
        }
113
114
        const basegfx::B2DPolyPolygon& LineStartEndAttribute::getB2DPolyPolygon() const
115
5.34k
        {
116
5.34k
            return mpLineStartEndAttribute->getB2DPolyPolygon();
117
5.34k
        }
118
119
        bool LineStartEndAttribute::isCentered() const
120
1.04k
        {
121
1.04k
            return mpLineStartEndAttribute->isCentered();
122
1.04k
        }
123
124
        bool LineStartEndAttribute::isActive() const
125
2.45k
        {
126
2.45k
            return (0.0 != getWidth()
127
2.15k
                && 0 != getB2DPolyPolygon().count()
128
2.15k
                && 0 != getB2DPolyPolygon().getB2DPolygon(0).count());
129
2.45k
        }
130
131
} // end of namespace
132
133
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */