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>
22 #include <rtl/instance.hxx>
25 namespace drawinglayer::attribute
27 class ImpLineAttribute
31 basegfx::BColor maColor
; // color
32 double mfWidth
; // absolute line width
33 basegfx::B2DLineJoin meLineJoin
; // type of LineJoin
34 css::drawing::LineCap meLineCap
; // BUTT, ROUND, or SQUARE
35 double mfMiterMinimumAngle
; // as needed for createAreaGeometry
38 const basegfx::BColor
& rColor
,
40 basegfx::B2DLineJoin aB2DLineJoin
,
41 css::drawing::LineCap aLineCap
,
42 double fMiterMinimumAngle
)
45 meLineJoin(aB2DLineJoin
),
47 mfMiterMinimumAngle(fMiterMinimumAngle
)
52 : maColor(basegfx::BColor()),
54 meLineJoin(basegfx::B2DLineJoin::Round
),
55 meLineCap(css::drawing::LineCap_BUTT
),
56 mfMiterMinimumAngle(basegfx::deg2rad(15.0))
61 const basegfx::BColor
& getColor() const { return maColor
; }
62 double getWidth() const { return mfWidth
; }
63 basegfx::B2DLineJoin
getLineJoin() const { return meLineJoin
; }
64 css::drawing::LineCap
getLineCap() const { return meLineCap
; }
65 double getMiterMinimumAngle() const { return mfMiterMinimumAngle
; }
67 bool operator==(const ImpLineAttribute
& rCandidate
) const
69 return (getColor() == rCandidate
.getColor()
70 && getWidth() == rCandidate
.getWidth()
71 && getLineJoin() == rCandidate
.getLineJoin()
72 && getLineCap() == rCandidate
.getLineCap()
73 && getMiterMinimumAngle() == rCandidate
.getMiterMinimumAngle());
79 struct theGlobalDefault
:
80 public rtl::Static
< LineAttribute::ImplType
, theGlobalDefault
> {};
83 LineAttribute::LineAttribute(
84 const basegfx::BColor
& rColor
,
86 basegfx::B2DLineJoin aB2DLineJoin
,
87 css::drawing::LineCap aLineCap
,
88 double fMiterMinimumAngle
)
99 LineAttribute::LineAttribute()
100 : mpLineAttribute(theGlobalDefault::get())
104 LineAttribute::LineAttribute(const LineAttribute
&) = default;
106 LineAttribute::~LineAttribute() = default;
108 bool LineAttribute::isDefault() const
110 return mpLineAttribute
.same_object(theGlobalDefault::get());
113 LineAttribute
& LineAttribute::operator=(const LineAttribute
&) = default;
115 bool LineAttribute::operator==(const LineAttribute
& rCandidate
) const
117 // tdf#87509 default attr is always != non-default attr, even with same values
118 if(rCandidate
.isDefault() != isDefault())
121 return rCandidate
.mpLineAttribute
== mpLineAttribute
;
124 const basegfx::BColor
& LineAttribute::getColor() const
126 return mpLineAttribute
->getColor();
129 double LineAttribute::getWidth() const
131 return mpLineAttribute
->getWidth();
134 basegfx::B2DLineJoin
LineAttribute::getLineJoin() const
136 return mpLineAttribute
->getLineJoin();
139 css::drawing::LineCap
LineAttribute::getLineCap() const
141 return mpLineAttribute
->getLineCap();
144 double LineAttribute::getMiterMinimumAngle() const
146 return mpLineAttribute
->getMiterMinimumAngle();
149 } // end of namespace
151 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */