Coverage Report

Created: 2026-07-10 11:04

next uncovered line (L), next uncovered region (R), next uncovered branch (B)
/src/libreoffice/drawinglayer/source/attribute/sdrlineattribute.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/sdrlineattribute.hxx>
21
#include <basegfx/color/bcolor.hxx>
22
#include <basegfx/vector/b2enums.hxx>
23
#include <com/sun/star/drawing/LineCap.hpp>
24
25
26
namespace drawinglayer::attribute
27
{
28
        class ImpSdrLineAttribute
29
        {
30
        public:
31
            // line definitions
32
            double                                  mfWidth;            // 1/100th mm, 0.0==hair
33
            double                                  mfTransparence;     // [0.0 .. 1.0], 0.0==no transp.
34
            double                                  mfFullDotDashLen;   // sum of maDotDashArray (for convenience)
35
            basegfx::BColor                         maColor;            // color of line
36
            std::vector< double >                   maDotDashArray;     // array of double which defines the dot-dash pattern
37
            basegfx::B2DLineJoin                    meJoin;             // B2DLINEJOIN_* defines
38
            css::drawing::LineCap                   meCap;              // BUTT, ROUND, or SQUARE
39
40
            ImpSdrLineAttribute(
41
                basegfx::B2DLineJoin eJoin,
42
                double fWidth,
43
                double fTransparence,
44
                const basegfx::BColor& rColor,
45
                css::drawing::LineCap eCap,
46
                std::vector< double >&& rDotDashArray,
47
                double fFullDotDashLen)
48
1.57k
            :   mfWidth(fWidth),
49
1.57k
                mfTransparence(fTransparence),
50
1.57k
                mfFullDotDashLen(fFullDotDashLen),
51
1.57k
                maColor(rColor),
52
1.57k
                maDotDashArray(std::move(rDotDashArray)),
53
1.57k
                meJoin(eJoin),
54
1.57k
                meCap(eCap)
55
1.57k
            {
56
1.57k
            }
57
58
            ImpSdrLineAttribute()
59
5
            :   mfWidth(0.0),
60
5
                mfTransparence(0.0),
61
5
                mfFullDotDashLen(0.0),
62
5
                meJoin(basegfx::B2DLineJoin::Round),
63
5
                meCap(css::drawing::LineCap_BUTT)
64
5
            {
65
5
            }
66
67
            // data read access
68
510
            basegfx::B2DLineJoin getJoin() const { return meJoin; }
69
2.23k
            double getWidth() const { return mfWidth; }
70
510
            double getTransparence() const { return mfTransparence; }
71
510
            const basegfx::BColor& getColor() const { return maColor; }
72
510
            css::drawing::LineCap getCap() const { return meCap; }
73
510
            const std::vector< double >& getDotDashArray() const { return maDotDashArray; }
74
514
            double getFullDotDashLen() const { return mfFullDotDashLen; }
75
76
            bool operator==(const ImpSdrLineAttribute& rCandidate) const
77
77
            {
78
77
                return (getJoin() == rCandidate.getJoin()
79
77
                    && getWidth() == rCandidate.getWidth()
80
77
                    && getTransparence() == rCandidate.getTransparence()
81
77
                    && getColor() == rCandidate.getColor()
82
77
                    && getCap() == rCandidate.getCap()
83
77
                    && getDotDashArray() == rCandidate.getDotDashArray());
84
77
            }
85
        };
86
87
        namespace
88
        {
89
            SdrLineAttribute::ImplType& theGlobalDefault()
90
3.24k
            {
91
3.24k
                static SdrLineAttribute::ImplType SINGLETON;
92
3.24k
                return SINGLETON;
93
3.24k
            }
94
        }
95
96
        SdrLineAttribute::SdrLineAttribute(
97
            basegfx::B2DLineJoin eJoin,
98
            double fWidth,
99
            double fTransparence,
100
            const basegfx::BColor& rColor,
101
            css::drawing::LineCap eCap,
102
            std::vector< double >&& rDotDashArray,
103
            double fFullDotDashLen)
104
1.57k
        :   mpSdrLineAttribute(
105
1.57k
                ImpSdrLineAttribute(
106
1.57k
                    eJoin,
107
1.57k
                    fWidth,
108
1.57k
                    fTransparence,
109
1.57k
                    rColor,
110
1.57k
                    eCap,
111
1.57k
                    std::move(rDotDashArray),
112
1.57k
                    fFullDotDashLen))
113
114
1.57k
        {
115
1.57k
        }
116
117
        SdrLineAttribute::SdrLineAttribute()
118
1.23k
        :   mpSdrLineAttribute(theGlobalDefault())
119
1.23k
        {
120
1.23k
        }
121
122
1.08k
        SdrLineAttribute::SdrLineAttribute(const SdrLineAttribute&) = default;
123
124
540
        SdrLineAttribute::SdrLineAttribute(SdrLineAttribute&&) = default;
125
126
4.42k
        SdrLineAttribute::~SdrLineAttribute() = default;
127
128
        bool SdrLineAttribute::isDefault() const
129
2.00k
        {
130
2.00k
            return mpSdrLineAttribute.same_object(theGlobalDefault());
131
2.00k
        }
132
133
0
        SdrLineAttribute& SdrLineAttribute::operator=(const SdrLineAttribute&) = default;
134
135
540
        SdrLineAttribute& SdrLineAttribute::operator=(SdrLineAttribute&&) = default;
136
137
        bool SdrLineAttribute::operator==(const SdrLineAttribute& rCandidate) const
138
154
        {
139
            // tdf#87509 default attr is always != non-default attr, even with same values
140
154
            if(rCandidate.isDefault() != isDefault())
141
0
                return false;
142
143
154
            return rCandidate.mpSdrLineAttribute == mpSdrLineAttribute;
144
154
        }
145
146
        basegfx::B2DLineJoin SdrLineAttribute::getJoin() const
147
356
        {
148
356
            return mpSdrLineAttribute->getJoin();
149
356
        }
150
151
        double SdrLineAttribute::getWidth() const
152
2.08k
        {
153
2.08k
            return mpSdrLineAttribute->getWidth();
154
2.08k
        }
155
156
        double SdrLineAttribute::getTransparence() const
157
356
        {
158
356
            return mpSdrLineAttribute->getTransparence();
159
356
        }
160
161
        const basegfx::BColor& SdrLineAttribute::getColor() const
162
356
        {
163
356
            return mpSdrLineAttribute->getColor();
164
356
        }
165
166
        const std::vector< double >& SdrLineAttribute::getDotDashArray() const
167
356
        {
168
356
            return mpSdrLineAttribute->getDotDashArray();
169
356
        }
170
171
        double SdrLineAttribute::getFullDotDashLen() const
172
514
        {
173
514
            return mpSdrLineAttribute->getFullDotDashLen();
174
514
        }
175
176
        css::drawing::LineCap SdrLineAttribute::getCap() const
177
356
        {
178
356
            return mpSdrLineAttribute->getCap();
179
356
        }
180
181
} // end of namespace
182
183
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */