LibreOffice Module drawinglayer (master) 1
sdrlineattribute.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 // line definitions
30 double mfWidth; // 1/100th mm, 0.0==hair
31 double mfTransparence; // [0.0 .. 1.0], 0.0==no transp.
32 double mfFullDotDashLen; // sum of maDotDashArray (for convenience)
33 basegfx::BColor maColor; // color of line
34 std::vector< double > maDotDashArray; // array of double which defines the dot-dash pattern
35 basegfx::B2DLineJoin meJoin; // B2DLINEJOIN_* defines
36 css::drawing::LineCap meCap; // BUTT, ROUND, or SQUARE
37
40 double fWidth,
41 double fTransparence,
42 const basegfx::BColor& rColor,
43 css::drawing::LineCap eCap,
44 std::vector< double >&& rDotDashArray,
45 double fFullDotDashLen)
46 : mfWidth(fWidth),
47 mfTransparence(fTransparence),
48 mfFullDotDashLen(fFullDotDashLen),
49 maColor(rColor),
50 maDotDashArray(std::move(rDotDashArray)),
51 meJoin(eJoin),
52 meCap(eCap)
53 {
54 }
55
57 : mfWidth(0.0),
58 mfTransparence(0.0),
61 meCap(css::drawing::LineCap_BUTT)
62 {
63 }
64
65 // data read access
67 double getWidth() const { return mfWidth; }
68 double getTransparence() const { return mfTransparence; }
69 const basegfx::BColor& getColor() const { return maColor; }
70 css::drawing::LineCap getCap() const { return meCap; }
71 const std::vector< double >& getDotDashArray() const { return maDotDashArray; }
72 double getFullDotDashLen() const { return mfFullDotDashLen; }
73
74 bool operator==(const ImpSdrLineAttribute& rCandidate) const
75 {
76 return (getJoin() == rCandidate.getJoin()
77 && getWidth() == rCandidate.getWidth()
78 && getTransparence() == rCandidate.getTransparence()
79 && getColor() == rCandidate.getColor()
80 && getCap() == rCandidate.getCap()
81 && getDotDashArray() == rCandidate.getDotDashArray());
82 }
83 };
84
85 namespace
86 {
87 SdrLineAttribute::ImplType& theGlobalDefault()
88 {
89 static SdrLineAttribute::ImplType SINGLETON;
90 return SINGLETON;
91 }
92 }
93
96 double fWidth,
97 double fTransparence,
98 const basegfx::BColor& rColor,
99 css::drawing::LineCap eCap,
100 std::vector< double >&& rDotDashArray,
101 double fFullDotDashLen)
102 : mpSdrLineAttribute(
104 eJoin,
105 fWidth,
106 fTransparence,
107 rColor,
108 eCap,
109 std::move(rDotDashArray),
110 fFullDotDashLen))
111
112 {
113 }
114
116 : mpSdrLineAttribute(theGlobalDefault())
117 {
118 }
119
121
123
125
127 {
128 return mpSdrLineAttribute.same_object(theGlobalDefault());
129 }
130
132
134
135 bool SdrLineAttribute::operator==(const SdrLineAttribute& rCandidate) const
136 {
137 // tdf#87509 default attr is always != non-default attr, even with same values
138 if(rCandidate.isDefault() != isDefault())
139 return false;
140
141 return rCandidate.mpSdrLineAttribute == mpSdrLineAttribute;
142 }
143
145 {
146 return mpSdrLineAttribute->getJoin();
147 }
148
150 {
151 return mpSdrLineAttribute->getWidth();
152 }
153
155 {
156 return mpSdrLineAttribute->getTransparence();
157 }
158
160 {
161 return mpSdrLineAttribute->getColor();
162 }
163
164 const std::vector< double >& SdrLineAttribute::getDotDashArray() const
165 {
166 return mpSdrLineAttribute->getDotDashArray();
167 }
168
170 {
171 return mpSdrLineAttribute->getFullDotDashLen();
172 }
173
174 css::drawing::LineCap SdrLineAttribute::getCap() const
175 {
176 return mpSdrLineAttribute->getCap();
177 }
178
179} // end of namespace
180
181/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
const basegfx::BColor & getColor() const
const std::vector< double > & getDotDashArray() const
bool operator==(const ImpSdrLineAttribute &rCandidate) const
ImpSdrLineAttribute(basegfx::B2DLineJoin eJoin, double fWidth, double fTransparence, const basegfx::BColor &rColor, css::drawing::LineCap eCap, std::vector< double > &&rDotDashArray, double fFullDotDashLen)
o3tl::cow_wrapper< ImpSdrLineAttribute > ImplType
SdrLineAttribute & operator=(const SdrLineAttribute &)
bool operator==(const SdrLineAttribute &rCandidate) const
const ::std::vector< double > & getDotDashArray() const
const basegfx::BColor & getColor() const
bool same_object(const cow_wrapper &rOther) const
const char Round[]