1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
3 * This file is part of the LibreOffice project.
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/.
9 * This file incorporates work covered by the following license notice:
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 .
20 #include <drawinglayer/attribute/sdrlineattribute.hxx>
21 #include <basegfx/color/bcolor.hxx>
24 namespace drawinglayer::attribute
26 class ImpSdrLineAttribute
30 double mfWidth
; // 1/100th mm, 0.0==hair
31 double mfTransparence
; // [0.0 .. 1.0], 0.0==no transp.
32 double mfFullDotDashLen
; // sum of maDotDashArray (for convenience)
33 basegfx::BColor maColor
; // color of line
34 std::vector
< double > maDotDashArray
; // array of double which defines the dot-dash pattern
35 basegfx::B2DLineJoin meJoin
; // B2DLINEJOIN_* defines
36 css::drawing::LineCap meCap
; // BUTT, ROUND, or SQUARE
39 basegfx::B2DLineJoin eJoin
,
42 const basegfx::BColor
& rColor
,
43 css::drawing::LineCap eCap
,
44 std::vector
< double >&& rDotDashArray
,
45 double fFullDotDashLen
)
47 mfTransparence(fTransparence
),
48 mfFullDotDashLen(fFullDotDashLen
),
50 maDotDashArray(std::move(rDotDashArray
)),
59 mfFullDotDashLen(0.0),
60 meJoin(basegfx::B2DLineJoin::Round
),
61 meCap(css::drawing::LineCap_BUTT
)
66 basegfx::B2DLineJoin
getJoin() const { return meJoin
; }
67 double getWidth() const { return mfWidth
; }
68 double getTransparence() const { return mfTransparence
; }
69 const basegfx::BColor
& getColor() const { return maColor
; }
70 css::drawing::LineCap
getCap() const { return meCap
; }
71 const std::vector
< double >& getDotDashArray() const { return maDotDashArray
; }
72 double getFullDotDashLen() const { return mfFullDotDashLen
; }
74 bool operator==(const ImpSdrLineAttribute
& rCandidate
) const
76 return (getJoin() == rCandidate
.getJoin()
77 && getWidth() == rCandidate
.getWidth()
78 && getTransparence() == rCandidate
.getTransparence()
79 && getColor() == rCandidate
.getColor()
80 && getCap() == rCandidate
.getCap()
81 && getDotDashArray() == rCandidate
.getDotDashArray());
87 SdrLineAttribute::ImplType
& theGlobalDefault()
89 static SdrLineAttribute::ImplType SINGLETON
;
94 SdrLineAttribute::SdrLineAttribute(
95 basegfx::B2DLineJoin eJoin
,
98 const basegfx::BColor
& rColor
,
99 css::drawing::LineCap eCap
,
100 std::vector
< double >&& rDotDashArray
,
101 double fFullDotDashLen
)
102 : mpSdrLineAttribute(
109 std::move(rDotDashArray
),
115 SdrLineAttribute::SdrLineAttribute()
116 : mpSdrLineAttribute(theGlobalDefault())
120 SdrLineAttribute::SdrLineAttribute(const SdrLineAttribute
&) = default;
122 SdrLineAttribute::SdrLineAttribute(SdrLineAttribute
&&) = default;
124 SdrLineAttribute::~SdrLineAttribute() = default;
126 bool SdrLineAttribute::isDefault() const
128 return mpSdrLineAttribute
.same_object(theGlobalDefault());
131 SdrLineAttribute
& SdrLineAttribute::operator=(const SdrLineAttribute
&) = default;
133 SdrLineAttribute
& SdrLineAttribute::operator=(SdrLineAttribute
&&) = default;
135 bool SdrLineAttribute::operator==(const SdrLineAttribute
& rCandidate
) const
137 // tdf#87509 default attr is always != non-default attr, even with same values
138 if(rCandidate
.isDefault() != isDefault())
141 return rCandidate
.mpSdrLineAttribute
== mpSdrLineAttribute
;
144 basegfx::B2DLineJoin
SdrLineAttribute::getJoin() const
146 return mpSdrLineAttribute
->getJoin();
149 double SdrLineAttribute::getWidth() const
151 return mpSdrLineAttribute
->getWidth();
154 double SdrLineAttribute::getTransparence() const
156 return mpSdrLineAttribute
->getTransparence();
159 const basegfx::BColor
& SdrLineAttribute::getColor() const
161 return mpSdrLineAttribute
->getColor();
164 const std::vector
< double >& SdrLineAttribute::getDotDashArray() const
166 return mpSdrLineAttribute
->getDotDashArray();
169 double SdrLineAttribute::getFullDotDashLen() const
171 return mpSdrLineAttribute
->getFullDotDashLen();
174 css::drawing::LineCap
SdrLineAttribute::getCap() const
176 return mpSdrLineAttribute
->getCap();
179 } // end of namespace
181 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */