/src/libreoffice/drawinglayer/source/attribute/lineattribute.cxx
Line | Count | Source (jump to first uncovered line) |
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 | | |
20 | | #include <drawinglayer/attribute/lineattribute.hxx> |
21 | | #include <basegfx/color/bcolor.hxx> |
22 | | |
23 | | |
24 | | namespace drawinglayer::attribute |
25 | | { |
26 | | class ImpLineAttribute |
27 | | { |
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 |
35 | | |
36 | | ImpLineAttribute( |
37 | | const basegfx::BColor& rColor, |
38 | | double fWidth, |
39 | | basegfx::B2DLineJoin aB2DLineJoin, |
40 | | css::drawing::LineCap aLineCap, |
41 | | double fMiterMinimumAngle) |
42 | 2.82k | : maColor(rColor), |
43 | 2.82k | mfWidth(fWidth), |
44 | 2.82k | meLineJoin(aB2DLineJoin), |
45 | 2.82k | meLineCap(aLineCap), |
46 | 2.82k | mfMiterMinimumAngle(fMiterMinimumAngle) |
47 | 2.82k | { |
48 | 2.82k | } |
49 | | |
50 | | ImpLineAttribute() |
51 | 5 | : mfWidth(0.0), |
52 | 5 | meLineJoin(basegfx::B2DLineJoin::Round), |
53 | 5 | meLineCap(css::drawing::LineCap_BUTT), |
54 | 5 | mfMiterMinimumAngle(basegfx::deg2rad(15.0)) |
55 | 5 | { |
56 | 5 | } |
57 | | |
58 | | // data read access |
59 | 5.62k | const basegfx::BColor& getColor() const { return maColor; } |
60 | 13.9k | double getWidth() const { return mfWidth; } |
61 | 5.39k | basegfx::B2DLineJoin getLineJoin() const { return meLineJoin; } |
62 | 5.39k | css::drawing::LineCap getLineCap() const { return meLineCap; } |
63 | 112 | double getMiterMinimumAngle() const { return mfMiterMinimumAngle; } |
64 | | |
65 | | bool operator==(const ImpLineAttribute& rCandidate) const |
66 | 56 | { |
67 | 56 | return (getColor() == rCandidate.getColor() |
68 | 56 | && getWidth() == rCandidate.getWidth() |
69 | 56 | && getLineJoin() == rCandidate.getLineJoin() |
70 | 56 | && getLineCap() == rCandidate.getLineCap() |
71 | 56 | && getMiterMinimumAngle() == rCandidate.getMiterMinimumAngle()); |
72 | 56 | } |
73 | | }; |
74 | | |
75 | | namespace |
76 | | { |
77 | | LineAttribute::ImplType& theGlobalDefault() |
78 | 390 | { |
79 | 390 | static LineAttribute::ImplType SINGLETON; |
80 | 390 | return SINGLETON; |
81 | 390 | } |
82 | | } |
83 | | |
84 | | LineAttribute::LineAttribute( |
85 | | const basegfx::BColor& rColor, |
86 | | double fWidth, |
87 | | basegfx::B2DLineJoin aB2DLineJoin, |
88 | | css::drawing::LineCap aLineCap, |
89 | | double fMiterMinimumAngle) |
90 | 2.82k | : mpLineAttribute( |
91 | 2.82k | ImpLineAttribute( |
92 | 2.82k | rColor, |
93 | 2.82k | fWidth, |
94 | 2.82k | aB2DLineJoin, |
95 | 2.82k | aLineCap, |
96 | 2.82k | fMiterMinimumAngle)) |
97 | 2.82k | { |
98 | 2.82k | } |
99 | | |
100 | | LineAttribute::LineAttribute() |
101 | 5 | : mpLineAttribute(theGlobalDefault()) |
102 | 5 | { |
103 | 5 | } |
104 | | |
105 | 7.88k | LineAttribute::LineAttribute(const LineAttribute&) = default; |
106 | | |
107 | 10.7k | LineAttribute::~LineAttribute() = default; |
108 | | |
109 | | bool LineAttribute::isDefault() const |
110 | 385 | { |
111 | 385 | return mpLineAttribute.same_object(theGlobalDefault()); |
112 | 385 | } |
113 | | |
114 | 0 | LineAttribute& LineAttribute::operator=(const LineAttribute&) = default; |
115 | | |
116 | | bool LineAttribute::operator==(const LineAttribute& rCandidate) const |
117 | 56 | { |
118 | | // tdf#87509 default attr is always != non-default attr, even with same values |
119 | 56 | if(rCandidate.isDefault() != isDefault()) |
120 | 0 | return false; |
121 | | |
122 | 56 | return rCandidate.mpLineAttribute == mpLineAttribute; |
123 | 56 | } |
124 | | |
125 | | const basegfx::BColor& LineAttribute::getColor() const |
126 | 5.51k | { |
127 | 5.51k | return mpLineAttribute->getColor(); |
128 | 5.51k | } |
129 | | |
130 | | double LineAttribute::getWidth() const |
131 | 13.7k | { |
132 | 13.7k | return mpLineAttribute->getWidth(); |
133 | 13.7k | } |
134 | | |
135 | | basegfx::B2DLineJoin LineAttribute::getLineJoin() const |
136 | 5.28k | { |
137 | 5.28k | return mpLineAttribute->getLineJoin(); |
138 | 5.28k | } |
139 | | |
140 | | css::drawing::LineCap LineAttribute::getLineCap() const |
141 | 5.28k | { |
142 | 5.28k | return mpLineAttribute->getLineCap(); |
143 | 5.28k | } |
144 | | |
145 | | double LineAttribute::getMiterMinimumAngle() const |
146 | 0 | { |
147 | 0 | return mpLineAttribute->getMiterMinimumAngle(); |
148 | 0 | } |
149 | | |
150 | | } // end of namespace |
151 | | |
152 | | /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ |