tdf#154285 Check upper bound of arguments in SbRtl_Minute function
[LibreOffice.git] / drawinglayer / source / attribute / linestartendattribute.cxx
blob33ac17c7059994f16efd1313df77caafd0006d0f
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 <utility>
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 basegfx::B2DPolyPolygon aPolyPolygon,
40 bool bCentered)
41 : mfWidth(fWidth),
42 maPolyPolygon(std::move(aPolyPolygon)),
43 mbCentered(bCentered)
47 ImpLineStartEndAttribute()
48 : mfWidth(0.0),
49 mbCentered(false)
53 // data read access
54 double getWidth() const { return mfWidth; }
55 const basegfx::B2DPolyPolygon& getB2DPolyPolygon() const { return maPolyPolygon; }
56 bool isCentered() const { return mbCentered; }
58 bool operator==(const ImpLineStartEndAttribute& rCandidate) const
60 return (basegfx::fTools::equal(getWidth(), rCandidate.getWidth())
61 && getB2DPolyPolygon() == rCandidate.getB2DPolyPolygon()
62 && isCentered() == rCandidate.isCentered());
66 namespace
68 LineStartEndAttribute::ImplType& theGlobalDefault()
70 static LineStartEndAttribute::ImplType SINGLETON;
71 return SINGLETON;
75 LineStartEndAttribute::LineStartEndAttribute(
76 double fWidth,
77 const basegfx::B2DPolyPolygon& rPolyPolygon,
78 bool bCentered)
79 : mpLineStartEndAttribute(ImpLineStartEndAttribute(
80 fWidth, rPolyPolygon, bCentered))
84 LineStartEndAttribute::LineStartEndAttribute()
85 : mpLineStartEndAttribute(theGlobalDefault())
89 LineStartEndAttribute::LineStartEndAttribute(const LineStartEndAttribute&) = default;
91 LineStartEndAttribute::~LineStartEndAttribute() = default;
93 bool LineStartEndAttribute::isDefault() const
95 return mpLineStartEndAttribute.same_object(theGlobalDefault());
98 LineStartEndAttribute& LineStartEndAttribute::operator=(const LineStartEndAttribute&) = default;
100 bool LineStartEndAttribute::operator==(const LineStartEndAttribute& rCandidate) const
102 // tdf#87509 default attr is always != non-default attr, even with same values
103 if(rCandidate.isDefault() != isDefault())
104 return false;
106 return rCandidate.mpLineStartEndAttribute == mpLineStartEndAttribute;
109 double LineStartEndAttribute::getWidth() const
111 return mpLineStartEndAttribute->getWidth();
114 const basegfx::B2DPolyPolygon& LineStartEndAttribute::getB2DPolyPolygon() const
116 return mpLineStartEndAttribute->getB2DPolyPolygon();
119 bool LineStartEndAttribute::isCentered() const
121 return mpLineStartEndAttribute->isCentered();
124 bool LineStartEndAttribute::isActive() const
126 return (0.0 != getWidth()
127 && 0 != getB2DPolyPolygon().count()
128 && 0 != getB2DPolyPolygon().getB2DPolygon(0).count());
131 } // end of namespace
133 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */