nss: upgrade to release 3.73
[LibreOffice.git] / drawinglayer / source / attribute / lineattribute.cxx
blob48d1f73380ebec03292aa35b2fa119e9e1a14304
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
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
29 public:
30 // data definitions
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
37 ImpLineAttribute(
38 const basegfx::BColor& rColor,
39 double fWidth,
40 basegfx::B2DLineJoin aB2DLineJoin,
41 css::drawing::LineCap aLineCap,
42 double fMiterMinimumAngle)
43 : maColor(rColor),
44 mfWidth(fWidth),
45 meLineJoin(aB2DLineJoin),
46 meLineCap(aLineCap),
47 mfMiterMinimumAngle(fMiterMinimumAngle)
51 ImpLineAttribute()
52 : maColor(basegfx::BColor()),
53 mfWidth(0.0),
54 meLineJoin(basegfx::B2DLineJoin::Round),
55 meLineCap(css::drawing::LineCap_BUTT),
56 mfMiterMinimumAngle(basegfx::deg2rad(15.0))
60 // data read access
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());
77 namespace
79 struct theGlobalDefault :
80 public rtl::Static< LineAttribute::ImplType, theGlobalDefault > {};
83 LineAttribute::LineAttribute(
84 const basegfx::BColor& rColor,
85 double fWidth,
86 basegfx::B2DLineJoin aB2DLineJoin,
87 css::drawing::LineCap aLineCap,
88 double fMiterMinimumAngle)
89 : mpLineAttribute(
90 ImpLineAttribute(
91 rColor,
92 fWidth,
93 aB2DLineJoin,
94 aLineCap,
95 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())
119 return false;
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: */