Coverage Report

Created: 2026-04-09 11:41

next uncovered line (L), next uncovered region (R), next uncovered branch (B)
/src/libreoffice/drawinglayer/source/attribute/sdrlinestartendattribute.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/sdrlinestartendattribute.hxx>
21
#include <basegfx/polygon/b2dpolypolygon.hxx>
22
#include <utility>
23
24
25
namespace drawinglayer::attribute
26
{
27
        class ImpSdrLineStartEndAttribute
28
        {
29
        public:
30
            // line arrow definitions
31
            basegfx::B2DPolyPolygon                 maStartPolyPolygon;     // start Line PolyPolygon
32
            basegfx::B2DPolyPolygon                 maEndPolyPolygon;       // end Line PolyPolygon
33
            double                                  mfStartWidth;           // 1/100th mm
34
            double                                  mfEndWidth;             // 1/100th mm
35
36
            bool                                    mbStartActive : 1;     // start of Line is active
37
            bool                                    mbEndActive : 1;       // end of Line is active
38
            bool                                    mbStartCentered : 1;   // Line is centered on line start point
39
            bool                                    mbEndCentered : 1;     // Line is centered on line end point
40
41
            ImpSdrLineStartEndAttribute(
42
                basegfx::B2DPolyPolygon aStartPolyPolygon,
43
                basegfx::B2DPolyPolygon aEndPolyPolygon,
44
                double fStartWidth,
45
                double fEndWidth,
46
                bool bStartActive,
47
                bool bEndActive,
48
                bool bStartCentered,
49
                bool bEndCentered)
50
0
            :   maStartPolyPolygon(std::move(aStartPolyPolygon)),
51
0
                maEndPolyPolygon(std::move(aEndPolyPolygon)),
52
0
                mfStartWidth(fStartWidth),
53
0
                mfEndWidth(fEndWidth),
54
0
                mbStartActive(bStartActive),
55
0
                mbEndActive(bEndActive),
56
0
                mbStartCentered(bStartCentered),
57
0
                mbEndCentered(bEndCentered)
58
0
            {
59
0
            }
60
61
            ImpSdrLineStartEndAttribute()
62
4
            :   mfStartWidth(0.0),
63
4
                mfEndWidth(0.0),
64
4
                mbStartActive(false),
65
4
                mbEndActive(false),
66
4
                mbStartCentered(false),
67
4
                mbEndCentered(false)
68
4
            {
69
4
            }
70
71
            // data read access
72
0
            const basegfx::B2DPolyPolygon& getStartPolyPolygon() const { return maStartPolyPolygon; }
73
0
            const basegfx::B2DPolyPolygon& getEndPolyPolygon() const { return maEndPolyPolygon; }
74
0
            double getStartWidth() const { return mfStartWidth; }
75
0
            double getEndWidth() const { return mfEndWidth; }
76
0
            bool isStartActive() const { return mbStartActive; }
77
0
            bool isEndActive() const { return mbEndActive; }
78
0
            bool isStartCentered() const { return mbStartCentered; }
79
0
            bool isEndCentered() const { return mbEndCentered; }
80
81
            bool operator==(const ImpSdrLineStartEndAttribute& rCandidate) const
82
0
            {
83
0
                return (getStartPolyPolygon() == rCandidate.getStartPolyPolygon()
84
0
                    && getEndPolyPolygon() == rCandidate.getEndPolyPolygon()
85
0
                    && getStartWidth() == rCandidate.getStartWidth()
86
0
                    && getEndWidth() == rCandidate.getEndWidth()
87
0
                    && isStartActive() == rCandidate.isStartActive()
88
0
                    && isEndActive() == rCandidate.isEndActive()
89
0
                    && isStartCentered() == rCandidate.isStartCentered()
90
0
                    && isEndCentered() == rCandidate.isEndCentered());
91
0
            }
92
        };
93
94
        namespace
95
        {
96
            SdrLineStartEndAttribute::ImplType& theGlobalDefault()
97
1.69k
            {
98
1.69k
                static SdrLineStartEndAttribute::ImplType SINGLETON;
99
1.69k
                return SINGLETON;
100
1.69k
            }
101
        }
102
103
        SdrLineStartEndAttribute::SdrLineStartEndAttribute(
104
            const basegfx::B2DPolyPolygon& rStartPolyPolygon,
105
            const basegfx::B2DPolyPolygon& rEndPolyPolygon,
106
            double fStartWidth,
107
            double fEndWidth,
108
            bool bStartActive,
109
            bool bEndActive,
110
            bool bStartCentered,
111
            bool bEndCentered)
112
0
        :   mpSdrLineStartEndAttribute(ImpSdrLineStartEndAttribute(
113
0
                rStartPolyPolygon, rEndPolyPolygon, fStartWidth, fEndWidth, bStartActive, bEndActive, bStartCentered, bEndCentered))
114
0
        {
115
0
        }
116
117
        SdrLineStartEndAttribute::SdrLineStartEndAttribute()
118
1.04k
        :   mpSdrLineStartEndAttribute(theGlobalDefault())
119
1.04k
        {
120
1.04k
        }
121
122
1.15k
        SdrLineStartEndAttribute::SdrLineStartEndAttribute(const SdrLineStartEndAttribute&) = default;
123
124
579
        SdrLineStartEndAttribute::SdrLineStartEndAttribute(SdrLineStartEndAttribute&&) = default;
125
126
2.78k
        SdrLineStartEndAttribute::~SdrLineStartEndAttribute() = default;
127
128
        bool SdrLineStartEndAttribute::isDefault() const
129
651
        {
130
651
            return mpSdrLineStartEndAttribute.same_object(theGlobalDefault());
131
651
        }
132
133
0
        SdrLineStartEndAttribute& SdrLineStartEndAttribute::operator=(const SdrLineStartEndAttribute&) = default;
134
135
457
        SdrLineStartEndAttribute& SdrLineStartEndAttribute::operator=(SdrLineStartEndAttribute&&) = default;
136
137
        bool SdrLineStartEndAttribute::operator==(const SdrLineStartEndAttribute& rCandidate) const
138
134
        {
139
            // tdf#87509 default attr is always != non-default attr, even with same values
140
134
            if(rCandidate.isDefault() != isDefault())
141
0
                return false;
142
143
134
            return rCandidate.mpSdrLineStartEndAttribute == mpSdrLineStartEndAttribute;
144
134
        }
145
146
        const basegfx::B2DPolyPolygon& SdrLineStartEndAttribute::getStartPolyPolygon() const
147
0
        {
148
0
            return mpSdrLineStartEndAttribute->getStartPolyPolygon();
149
0
        }
150
151
        const basegfx::B2DPolyPolygon& SdrLineStartEndAttribute::getEndPolyPolygon() const
152
0
        {
153
0
            return mpSdrLineStartEndAttribute->getEndPolyPolygon();
154
0
        }
155
156
        double SdrLineStartEndAttribute::getStartWidth() const
157
0
        {
158
0
            return mpSdrLineStartEndAttribute->getStartWidth();
159
0
        }
160
161
        double SdrLineStartEndAttribute::getEndWidth() const
162
0
        {
163
0
            return mpSdrLineStartEndAttribute->getEndWidth();
164
0
        }
165
166
        bool SdrLineStartEndAttribute::isStartActive() const
167
0
        {
168
0
            return mpSdrLineStartEndAttribute->isStartActive();
169
0
        }
170
171
        bool SdrLineStartEndAttribute::isEndActive() const
172
0
        {
173
0
            return mpSdrLineStartEndAttribute->isEndActive();
174
0
        }
175
176
        bool SdrLineStartEndAttribute::isStartCentered() const
177
0
        {
178
0
            return mpSdrLineStartEndAttribute->isStartCentered();
179
0
        }
180
181
        bool SdrLineStartEndAttribute::isEndCentered() const
182
0
        {
183
0
            return mpSdrLineStartEndAttribute->isEndCentered();
184
0
        }
185
186
} // end of namespace
187
188
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */