1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
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/sdrlinestartendattribute.hxx>
21 #include <basegfx/polygon/b2dpolypolygon.hxx>
25 namespace drawinglayer::attribute
27 class ImpSdrLineStartEndAttribute
30 // line arrow definitions
31 basegfx::B2DPolyPolygon maStartPolyPolygon
; // start Line PolyPolygon
32 basegfx::B2DPolyPolygon maEndPolyPolygon
; // end Line PolyPolygon
33 double mfStartWidth
; // 1/100th mm
34 double mfEndWidth
; // 1/100th mm
36 bool mbStartActive
: 1; // start of Line is active
37 bool mbEndActive
: 1; // end of Line is active
38 bool mbStartCentered
: 1; // Line is centered on line start point
39 bool mbEndCentered
: 1; // Line is centered on line end point
41 ImpSdrLineStartEndAttribute(
42 basegfx::B2DPolyPolygon aStartPolyPolygon
,
43 basegfx::B2DPolyPolygon aEndPolyPolygon
,
50 : maStartPolyPolygon(std::move(aStartPolyPolygon
)),
51 maEndPolyPolygon(std::move(aEndPolyPolygon
)),
52 mfStartWidth(fStartWidth
),
53 mfEndWidth(fEndWidth
),
54 mbStartActive(bStartActive
),
55 mbEndActive(bEndActive
),
56 mbStartCentered(bStartCentered
),
57 mbEndCentered(bEndCentered
)
61 ImpSdrLineStartEndAttribute()
66 mbStartCentered(false),
72 const basegfx::B2DPolyPolygon
& getStartPolyPolygon() const { return maStartPolyPolygon
; }
73 const basegfx::B2DPolyPolygon
& getEndPolyPolygon() const { return maEndPolyPolygon
; }
74 double getStartWidth() const { return mfStartWidth
; }
75 double getEndWidth() const { return mfEndWidth
; }
76 bool isStartActive() const { return mbStartActive
; }
77 bool isEndActive() const { return mbEndActive
; }
78 bool isStartCentered() const { return mbStartCentered
; }
79 bool isEndCentered() const { return mbEndCentered
; }
81 bool operator==(const ImpSdrLineStartEndAttribute
& rCandidate
) const
83 return (getStartPolyPolygon() == rCandidate
.getStartPolyPolygon()
84 && getEndPolyPolygon() == rCandidate
.getEndPolyPolygon()
85 && getStartWidth() == rCandidate
.getStartWidth()
86 && getEndWidth() == rCandidate
.getEndWidth()
87 && isStartActive() == rCandidate
.isStartActive()
88 && isEndActive() == rCandidate
.isEndActive()
89 && isStartCentered() == rCandidate
.isStartCentered()
90 && isEndCentered() == rCandidate
.isEndCentered());
96 SdrLineStartEndAttribute::ImplType
& theGlobalDefault()
98 static SdrLineStartEndAttribute::ImplType SINGLETON
;
103 SdrLineStartEndAttribute::SdrLineStartEndAttribute(
104 const basegfx::B2DPolyPolygon
& rStartPolyPolygon
,
105 const basegfx::B2DPolyPolygon
& rEndPolyPolygon
,
112 : mpSdrLineStartEndAttribute(ImpSdrLineStartEndAttribute(
113 rStartPolyPolygon
, rEndPolyPolygon
, fStartWidth
, fEndWidth
, bStartActive
, bEndActive
, bStartCentered
, bEndCentered
))
117 SdrLineStartEndAttribute::SdrLineStartEndAttribute()
118 : mpSdrLineStartEndAttribute(theGlobalDefault())
122 SdrLineStartEndAttribute::SdrLineStartEndAttribute(const SdrLineStartEndAttribute
&) = default;
124 SdrLineStartEndAttribute::SdrLineStartEndAttribute(SdrLineStartEndAttribute
&&) = default;
126 SdrLineStartEndAttribute::~SdrLineStartEndAttribute() = default;
128 bool SdrLineStartEndAttribute::isDefault() const
130 return mpSdrLineStartEndAttribute
.same_object(theGlobalDefault());
133 SdrLineStartEndAttribute
& SdrLineStartEndAttribute::operator=(const SdrLineStartEndAttribute
&) = default;
135 SdrLineStartEndAttribute
& SdrLineStartEndAttribute::operator=(SdrLineStartEndAttribute
&&) = default;
137 bool SdrLineStartEndAttribute::operator==(const SdrLineStartEndAttribute
& rCandidate
) const
139 // tdf#87509 default attr is always != non-default attr, even with same values
140 if(rCandidate
.isDefault() != isDefault())
143 return rCandidate
.mpSdrLineStartEndAttribute
== mpSdrLineStartEndAttribute
;
146 const basegfx::B2DPolyPolygon
& SdrLineStartEndAttribute::getStartPolyPolygon() const
148 return mpSdrLineStartEndAttribute
->getStartPolyPolygon();
151 const basegfx::B2DPolyPolygon
& SdrLineStartEndAttribute::getEndPolyPolygon() const
153 return mpSdrLineStartEndAttribute
->getEndPolyPolygon();
156 double SdrLineStartEndAttribute::getStartWidth() const
158 return mpSdrLineStartEndAttribute
->getStartWidth();
161 double SdrLineStartEndAttribute::getEndWidth() const
163 return mpSdrLineStartEndAttribute
->getEndWidth();
166 bool SdrLineStartEndAttribute::isStartActive() const
168 return mpSdrLineStartEndAttribute
->isStartActive();
171 bool SdrLineStartEndAttribute::isEndActive() const
173 return mpSdrLineStartEndAttribute
->isEndActive();
176 bool SdrLineStartEndAttribute::isStartCentered() const
178 return mpSdrLineStartEndAttribute
->isStartCentered();
181 bool SdrLineStartEndAttribute::isEndCentered() const
183 return mpSdrLineStartEndAttribute
->isEndCentered();
186 } // end of namespace
188 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */