LibreOffice Module drawinglayer (master) 1
lineattribute.cxx
Go to the documentation of this file.
1/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2/*
3 * This file is part of the LibreOffice project.
4 *
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/.
8 *
9 * This file incorporates work covered by the following license notice:
10 *
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 .
18 */
19
22
23
25{
27 {
28 public:
29 // data definitions
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
35
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)
47 {
48 }
49
51 : mfWidth(0.0),
53 meLineCap(css::drawing::LineCap_BUTT),
55 {
56 }
57
58 // data read access
59 const basegfx::BColor& getColor() const { return maColor; }
60 double getWidth() const { return mfWidth; }
62 css::drawing::LineCap getLineCap() const { return meLineCap; }
63 double getMiterMinimumAngle() const { return mfMiterMinimumAngle; }
64
65 bool operator==(const ImpLineAttribute& rCandidate) const
66 {
67 return (getColor() == rCandidate.getColor()
68 && getWidth() == rCandidate.getWidth()
69 && getLineJoin() == rCandidate.getLineJoin()
70 && getLineCap() == rCandidate.getLineCap()
71 && getMiterMinimumAngle() == rCandidate.getMiterMinimumAngle());
72 }
73 };
74
75 namespace
76 {
77 LineAttribute::ImplType& theGlobalDefault()
78 {
79 static LineAttribute::ImplType SINGLETON;
80 return SINGLETON;
81 }
82 }
83
85 const basegfx::BColor& rColor,
86 double fWidth,
87 basegfx::B2DLineJoin aB2DLineJoin,
88 css::drawing::LineCap aLineCap,
89 double fMiterMinimumAngle)
90 : mpLineAttribute(
92 rColor,
93 fWidth,
94 aB2DLineJoin,
95 aLineCap,
96 fMiterMinimumAngle))
97 {
98 }
99
101 : mpLineAttribute(theGlobalDefault())
102 {
103 }
104
106
108
110 {
111 return mpLineAttribute.same_object(theGlobalDefault());
112 }
113
115
116 bool LineAttribute::operator==(const LineAttribute& rCandidate) const
117 {
118 // tdf#87509 default attr is always != non-default attr, even with same values
119 if(rCandidate.isDefault() != isDefault())
120 return false;
121
122 return rCandidate.mpLineAttribute == mpLineAttribute;
123 }
124
126 {
127 return mpLineAttribute->getColor();
128 }
129
131 {
132 return mpLineAttribute->getWidth();
133 }
134
136 {
137 return mpLineAttribute->getLineJoin();
138 }
139
140 css::drawing::LineCap LineAttribute::getLineCap() const
141 {
142 return mpLineAttribute->getLineCap();
143 }
144
146 {
147 return mpLineAttribute->getMiterMinimumAngle();
148 }
149
150} // end of namespace
151
152/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
ImpLineAttribute(const basegfx::BColor &rColor, double fWidth, basegfx::B2DLineJoin aB2DLineJoin, css::drawing::LineCap aLineCap, double fMiterMinimumAngle)
bool operator==(const ImpLineAttribute &rCandidate) const
basegfx::B2DLineJoin getLineJoin() const
css::drawing::LineCap getLineCap() const
const basegfx::BColor & getColor() const
LineAttribute & operator=(const LineAttribute &)
basegfx::B2DLineJoin getLineJoin() const
o3tl::cow_wrapper< ImpLineAttribute > ImplType
css::drawing::LineCap getLineCap() const
const basegfx::BColor & getColor() const
bool operator==(const LineAttribute &rCandidate) const
bool same_object(const cow_wrapper &rOther) const
constexpr double deg2rad(double v)
const char Round[]