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/lineattribute.hxx>
21 #include <basegfx/color/bcolor.hxx>
24 namespace drawinglayer::attribute
26 class ImpLineAttribute
30 basegfx::BColor maColor
; // color
31 double mfWidth
; // absolute line width
32 basegfx::B2DLineJoin meLineJoin
; // type of LineJoin
33 css::drawing::LineCap meLineCap
; // BUTT, ROUND, or SQUARE
34 double mfMiterMinimumAngle
; // as needed for createAreaGeometry
37 const basegfx::BColor
& rColor
,
39 basegfx::B2DLineJoin aB2DLineJoin
,
40 css::drawing::LineCap aLineCap
,
41 double fMiterMinimumAngle
)
44 meLineJoin(aB2DLineJoin
),
46 mfMiterMinimumAngle(fMiterMinimumAngle
)
52 meLineJoin(basegfx::B2DLineJoin::Round
),
53 meLineCap(css::drawing::LineCap_BUTT
),
54 mfMiterMinimumAngle(basegfx::deg2rad(15.0))
59 const basegfx::BColor
& getColor() const { return maColor
; }
60 double getWidth() const { return mfWidth
; }
61 basegfx::B2DLineJoin
getLineJoin() const { return meLineJoin
; }
62 css::drawing::LineCap
getLineCap() const { return meLineCap
; }
63 double getMiterMinimumAngle() const { return mfMiterMinimumAngle
; }
65 bool operator==(const ImpLineAttribute
& rCandidate
) const
67 return (getColor() == rCandidate
.getColor()
68 && getWidth() == rCandidate
.getWidth()
69 && getLineJoin() == rCandidate
.getLineJoin()
70 && getLineCap() == rCandidate
.getLineCap()
71 && getMiterMinimumAngle() == rCandidate
.getMiterMinimumAngle());
77 LineAttribute::ImplType
& theGlobalDefault()
79 static LineAttribute::ImplType SINGLETON
;
84 LineAttribute::LineAttribute(
85 const basegfx::BColor
& rColor
,
87 basegfx::B2DLineJoin aB2DLineJoin
,
88 css::drawing::LineCap aLineCap
,
89 double fMiterMinimumAngle
)
100 LineAttribute::LineAttribute()
101 : mpLineAttribute(theGlobalDefault())
105 LineAttribute::LineAttribute(const LineAttribute
&) = default;
107 LineAttribute::~LineAttribute() = default;
109 bool LineAttribute::isDefault() const
111 return mpLineAttribute
.same_object(theGlobalDefault());
114 LineAttribute
& LineAttribute::operator=(const LineAttribute
&) = default;
116 bool LineAttribute::operator==(const LineAttribute
& rCandidate
) const
118 // tdf#87509 default attr is always != non-default attr, even with same values
119 if(rCandidate
.isDefault() != isDefault())
122 return rCandidate
.mpLineAttribute
== mpLineAttribute
;
125 const basegfx::BColor
& LineAttribute::getColor() const
127 return mpLineAttribute
->getColor();
130 double LineAttribute::getWidth() const
132 return mpLineAttribute
->getWidth();
135 basegfx::B2DLineJoin
LineAttribute::getLineJoin() const
137 return mpLineAttribute
->getLineJoin();
140 css::drawing::LineCap
LineAttribute::getLineCap() const
142 return mpLineAttribute
->getLineCap();
145 double LineAttribute::getMiterMinimumAngle() const
147 return mpLineAttribute
->getMiterMinimumAngle();
150 } // end of namespace
152 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */