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/linestartendattribute.hxx>
21 #include <basegfx/polygon/b2dpolygon.hxx>
22 #include <basegfx/polygon/b2dpolypolygon.hxx>
23 #include <rtl/instance.hxx>
26 namespace drawinglayer
30 class ImpLineStartEndAttribute
34 double mfWidth
; // absolute line StartEndGeometry base width
35 basegfx::B2DPolyPolygon maPolyPolygon
; // the StartEndGeometry PolyPolygon
38 bool mbCentered
: 1; // use centered to ineStart/End point?
40 ImpLineStartEndAttribute(
42 const basegfx::B2DPolyPolygon
& rPolyPolygon
,
45 maPolyPolygon(rPolyPolygon
),
50 ImpLineStartEndAttribute()
52 maPolyPolygon(basegfx::B2DPolyPolygon()),
58 double getWidth() const { return mfWidth
; }
59 const basegfx::B2DPolyPolygon
& getB2DPolyPolygon() const { return maPolyPolygon
; }
60 bool isCentered() const { return mbCentered
; }
62 bool operator==(const ImpLineStartEndAttribute
& rCandidate
) const
64 return (basegfx::fTools::equal(getWidth(), rCandidate
.getWidth())
65 && getB2DPolyPolygon() == rCandidate
.getB2DPolyPolygon()
66 && isCentered() == rCandidate
.isCentered());
72 struct theGlobalDefault
:
73 public rtl::Static
< LineStartEndAttribute::ImplType
, theGlobalDefault
> {};
76 LineStartEndAttribute::LineStartEndAttribute(
78 const basegfx::B2DPolyPolygon
& rPolyPolygon
,
80 : mpLineStartEndAttribute(ImpLineStartEndAttribute(
81 fWidth
, rPolyPolygon
, bCentered
))
85 LineStartEndAttribute::LineStartEndAttribute()
86 : mpLineStartEndAttribute(theGlobalDefault::get())
90 LineStartEndAttribute::LineStartEndAttribute(const LineStartEndAttribute
& rCandidate
)
91 : mpLineStartEndAttribute(rCandidate
.mpLineStartEndAttribute
)
95 LineStartEndAttribute::~LineStartEndAttribute()
99 bool LineStartEndAttribute::isDefault() const
101 return mpLineStartEndAttribute
.same_object(theGlobalDefault::get());
104 LineStartEndAttribute
& LineStartEndAttribute::operator=(const LineStartEndAttribute
& rCandidate
)
106 mpLineStartEndAttribute
= rCandidate
.mpLineStartEndAttribute
;
110 bool LineStartEndAttribute::operator==(const LineStartEndAttribute
& rCandidate
) const
112 // tdf#87509 default attr is always != non-default attr, even with same values
113 if(rCandidate
.isDefault() != isDefault())
116 return rCandidate
.mpLineStartEndAttribute
== mpLineStartEndAttribute
;
119 double LineStartEndAttribute::getWidth() const
121 return mpLineStartEndAttribute
->getWidth();
124 const basegfx::B2DPolyPolygon
& LineStartEndAttribute::getB2DPolyPolygon() const
126 return mpLineStartEndAttribute
->getB2DPolyPolygon();
129 bool LineStartEndAttribute::isCentered() const
131 return mpLineStartEndAttribute
->isCentered();
134 bool LineStartEndAttribute::isActive() const
136 return (0.0 != getWidth()
137 && 0 != getB2DPolyPolygon().count()
138 && 0 != getB2DPolyPolygon().getB2DPolygon(0).count());
140 } // end of namespace attribute
141 } // end of namespace drawinglayer
143 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */