Version 5.2.6.1, tag libreoffice-5.2.6.1
[LibreOffice.git] / drawinglayer / source / attribute / lineattribute.cxx
blob89ce998924fe30c915452fe0d52c466e78795cd7
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
27 namespace attribute
29 class ImpLineAttribute
31 public:
32 // data definitions
33 basegfx::BColor maColor; // color
34 double mfWidth; // absolute line width
35 basegfx::B2DLineJoin meLineJoin; // type of LineJoin
36 css::drawing::LineCap meLineCap; // BUTT, ROUND, or SQUARE
37 double mfMiterMinimumAngle; // as needed for createAreaGeometry
39 ImpLineAttribute(
40 const basegfx::BColor& rColor,
41 double fWidth,
42 basegfx::B2DLineJoin aB2DLineJoin,
43 css::drawing::LineCap aLineCap,
44 double fMiterMinimumAngle)
45 : maColor(rColor),
46 mfWidth(fWidth),
47 meLineJoin(aB2DLineJoin),
48 meLineCap(aLineCap),
49 mfMiterMinimumAngle(fMiterMinimumAngle)
53 ImpLineAttribute()
54 : maColor(basegfx::BColor()),
55 mfWidth(0.0),
56 meLineJoin(basegfx::B2DLineJoin::Round),
57 meLineCap(css::drawing::LineCap_BUTT),
58 mfMiterMinimumAngle(15.0 * F_PI180)
62 // data read access
63 const basegfx::BColor& getColor() const { return maColor; }
64 double getWidth() const { return mfWidth; }
65 basegfx::B2DLineJoin getLineJoin() const { return meLineJoin; }
66 css::drawing::LineCap getLineCap() const { return meLineCap; }
67 double getMiterMinimumAngle() const { return mfMiterMinimumAngle; }
69 bool operator==(const ImpLineAttribute& rCandidate) const
71 return (getColor() == rCandidate.getColor()
72 && getWidth() == rCandidate.getWidth()
73 && getLineJoin() == rCandidate.getLineJoin()
74 && getLineCap() == rCandidate.getLineCap()
75 && getMiterMinimumAngle() == rCandidate.getMiterMinimumAngle());
79 namespace
81 struct theGlobalDefault :
82 public rtl::Static< LineAttribute::ImplType, theGlobalDefault > {};
85 LineAttribute::LineAttribute(
86 const basegfx::BColor& rColor,
87 double fWidth,
88 basegfx::B2DLineJoin aB2DLineJoin,
89 css::drawing::LineCap aLineCap,
90 double fMiterMinimumAngle)
91 : mpLineAttribute(
92 ImpLineAttribute(
93 rColor,
94 fWidth,
95 aB2DLineJoin,
96 aLineCap,
97 fMiterMinimumAngle))
101 LineAttribute::LineAttribute()
102 : mpLineAttribute(theGlobalDefault::get())
106 LineAttribute::LineAttribute(const LineAttribute& rCandidate)
107 : mpLineAttribute(rCandidate.mpLineAttribute)
111 LineAttribute::~LineAttribute()
115 bool LineAttribute::isDefault() const
117 return mpLineAttribute.same_object(theGlobalDefault::get());
120 LineAttribute& LineAttribute::operator=(const LineAttribute& rCandidate)
122 mpLineAttribute = rCandidate.mpLineAttribute;
123 return *this;
126 bool LineAttribute::operator==(const LineAttribute& rCandidate) const
128 // tdf#87509 default attr is always != non-default attr, even with same values
129 if(rCandidate.isDefault() != isDefault())
130 return false;
132 return rCandidate.mpLineAttribute == mpLineAttribute;
135 const basegfx::BColor& LineAttribute::getColor() const
137 return mpLineAttribute->getColor();
140 double LineAttribute::getWidth() const
142 return mpLineAttribute->getWidth();
145 basegfx::B2DLineJoin LineAttribute::getLineJoin() const
147 return mpLineAttribute->getLineJoin();
150 css::drawing::LineCap LineAttribute::getLineCap() const
152 return mpLineAttribute->getLineCap();
155 double LineAttribute::getMiterMinimumAngle() const
157 return mpLineAttribute->getMiterMinimumAngle();
160 } // end of namespace attribute
161 } // end of namespace drawinglayer
163 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */