tdf#130857 qt weld: Support mail merge "Server Auth" dialog
[LibreOffice.git] / drawinglayer / source / attribute / lineattribute.cxx
blobd4f2418c13548115cdb4c3c0e900b65233774861
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>
24 namespace drawinglayer::attribute
26 class ImpLineAttribute
28 public:
29 // data definitions
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
36 ImpLineAttribute(
37 const basegfx::BColor& rColor,
38 double fWidth,
39 basegfx::B2DLineJoin aB2DLineJoin,
40 css::drawing::LineCap aLineCap,
41 double fMiterMinimumAngle)
42 : maColor(rColor),
43 mfWidth(fWidth),
44 meLineJoin(aB2DLineJoin),
45 meLineCap(aLineCap),
46 mfMiterMinimumAngle(fMiterMinimumAngle)
50 ImpLineAttribute()
51 : mfWidth(0.0),
52 meLineJoin(basegfx::B2DLineJoin::Round),
53 meLineCap(css::drawing::LineCap_BUTT),
54 mfMiterMinimumAngle(basegfx::deg2rad(15.0))
58 // data read access
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());
75 namespace
77 LineAttribute::ImplType& theGlobalDefault()
79 static LineAttribute::ImplType SINGLETON;
80 return SINGLETON;
84 LineAttribute::LineAttribute(
85 const basegfx::BColor& rColor,
86 double fWidth,
87 basegfx::B2DLineJoin aB2DLineJoin,
88 css::drawing::LineCap aLineCap,
89 double fMiterMinimumAngle)
90 : mpLineAttribute(
91 ImpLineAttribute(
92 rColor,
93 fWidth,
94 aB2DLineJoin,
95 aLineCap,
96 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())
120 return false;
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: */