nss: upgrade to release 3.73
[LibreOffice.git] / drawinglayer / source / attribute / linestartendattribute.cxx
blobdcfa94f35c39a3105cd2f7ecd9a8f6bf765b25ec
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
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::attribute
28 class ImpLineStartEndAttribute
30 public:
31 // data definitions
32 double mfWidth; // absolute line StartEndGeometry base width
33 basegfx::B2DPolyPolygon maPolyPolygon; // the StartEndGeometry PolyPolygon
35 bool mbCentered : 1; // use centered to lineStart/End point?
37 ImpLineStartEndAttribute(
38 double fWidth,
39 const basegfx::B2DPolyPolygon& rPolyPolygon,
40 bool bCentered)
41 : mfWidth(fWidth),
42 maPolyPolygon(rPolyPolygon),
43 mbCentered(bCentered)
47 ImpLineStartEndAttribute()
48 : mfWidth(0.0),
49 maPolyPolygon(basegfx::B2DPolyPolygon()),
50 mbCentered(false)
54 // data read access
55 double getWidth() const { return mfWidth; }
56 const basegfx::B2DPolyPolygon& getB2DPolyPolygon() const { return maPolyPolygon; }
57 bool isCentered() const { return mbCentered; }
59 bool operator==(const ImpLineStartEndAttribute& rCandidate) const
61 return (basegfx::fTools::equal(getWidth(), rCandidate.getWidth())
62 && getB2DPolyPolygon() == rCandidate.getB2DPolyPolygon()
63 && isCentered() == rCandidate.isCentered());
67 namespace
69 struct theGlobalDefault :
70 public rtl::Static< LineStartEndAttribute::ImplType, theGlobalDefault > {};
73 LineStartEndAttribute::LineStartEndAttribute(
74 double fWidth,
75 const basegfx::B2DPolyPolygon& rPolyPolygon,
76 bool bCentered)
77 : mpLineStartEndAttribute(ImpLineStartEndAttribute(
78 fWidth, rPolyPolygon, bCentered))
82 LineStartEndAttribute::LineStartEndAttribute()
83 : mpLineStartEndAttribute(theGlobalDefault::get())
87 LineStartEndAttribute::LineStartEndAttribute(const LineStartEndAttribute&) = default;
89 LineStartEndAttribute::~LineStartEndAttribute() = default;
91 bool LineStartEndAttribute::isDefault() const
93 return mpLineStartEndAttribute.same_object(theGlobalDefault::get());
96 LineStartEndAttribute& LineStartEndAttribute::operator=(const LineStartEndAttribute&) = default;
98 bool LineStartEndAttribute::operator==(const LineStartEndAttribute& rCandidate) const
100 // tdf#87509 default attr is always != non-default attr, even with same values
101 if(rCandidate.isDefault() != isDefault())
102 return false;
104 return rCandidate.mpLineStartEndAttribute == mpLineStartEndAttribute;
107 double LineStartEndAttribute::getWidth() const
109 return mpLineStartEndAttribute->getWidth();
112 const basegfx::B2DPolyPolygon& LineStartEndAttribute::getB2DPolyPolygon() const
114 return mpLineStartEndAttribute->getB2DPolyPolygon();
117 bool LineStartEndAttribute::isCentered() const
119 return mpLineStartEndAttribute->isCentered();
122 bool LineStartEndAttribute::isActive() const
124 return (0.0 != getWidth()
125 && 0 != getB2DPolyPolygon().count()
126 && 0 != getB2DPolyPolygon().getB2DPolygon(0).count());
129 } // end of namespace
131 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */