LibreOffice Module drawinglayer (master) 1
linestartendattribute.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
23#include <utility>
24
25
27{
29 {
30 public:
31 // data definitions
32 double mfWidth; // absolute line StartEndGeometry base width
33 basegfx::B2DPolyPolygon maPolyPolygon; // the StartEndGeometry PolyPolygon
34
35 bool mbCentered : 1; // use centered to lineStart/End point?
36
38 double fWidth,
39 basegfx::B2DPolyPolygon aPolyPolygon,
40 bool bCentered)
41 : mfWidth(fWidth),
42 maPolyPolygon(std::move(aPolyPolygon)),
43 mbCentered(bCentered)
44 {
45 }
46
48 : mfWidth(0.0),
49 mbCentered(false)
50 {
51 }
52
53 // data read access
54 double getWidth() const { return mfWidth; }
56 bool isCentered() const { return mbCentered; }
57
58 bool operator==(const ImpLineStartEndAttribute& rCandidate) const
59 {
60 return (basegfx::fTools::equal(getWidth(), rCandidate.getWidth())
61 && getB2DPolyPolygon() == rCandidate.getB2DPolyPolygon()
62 && isCentered() == rCandidate.isCentered());
63 }
64 };
65
66 namespace
67 {
68 LineStartEndAttribute::ImplType& theGlobalDefault()
69 {
70 static LineStartEndAttribute::ImplType SINGLETON;
71 return SINGLETON;
72 }
73 }
74
76 double fWidth,
77 const basegfx::B2DPolyPolygon& rPolyPolygon,
78 bool bCentered)
79 : mpLineStartEndAttribute(ImpLineStartEndAttribute(
80 fWidth, rPolyPolygon, bCentered))
81 {
82 }
83
85 : mpLineStartEndAttribute(theGlobalDefault())
86 {
87 }
88
90
92
94 {
95 return mpLineStartEndAttribute.same_object(theGlobalDefault());
96 }
97
99
101 {
102 // tdf#87509 default attr is always != non-default attr, even with same values
103 if(rCandidate.isDefault() != isDefault())
104 return false;
105
107 }
108
110 {
111 return mpLineStartEndAttribute->getWidth();
112 }
113
115 {
116 return mpLineStartEndAttribute->getB2DPolyPolygon();
117 }
118
120 {
121 return mpLineStartEndAttribute->isCentered();
122 }
123
125 {
126 return (0.0 != getWidth()
127 && 0 != getB2DPolyPolygon().count()
128 && 0 != getB2DPolyPolygon().getB2DPolygon(0).count());
129 }
130
131} // end of namespace
132
133/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
const basegfx::B2DPolyPolygon & getB2DPolyPolygon() const
ImpLineStartEndAttribute(double fWidth, basegfx::B2DPolyPolygon aPolyPolygon, bool bCentered)
bool operator==(const ImpLineStartEndAttribute &rCandidate) const
LineStartEndAttribute & operator=(const LineStartEndAttribute &)
bool operator==(const LineStartEndAttribute &rCandidate) const
o3tl::cow_wrapper< ImpLineStartEndAttribute > ImplType
const basegfx::B2DPolyPolygon & getB2DPolyPolygon() const
bool same_object(const cow_wrapper &rOther) const
bool equal(T const &rfValA, T const &rfValB)