Line data Source code
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 :
20 : #include <drawinglayer/attribute/sdrlinestartendattribute.hxx>
21 : #include <basegfx/polygon/b2dpolypolygon.hxx>
22 : #include <rtl/instance.hxx>
23 :
24 :
25 :
26 : namespace drawinglayer
27 : {
28 : namespace attribute
29 : {
30 0 : class ImpSdrLineStartEndAttribute
31 : {
32 : public:
33 : // line arrow definitions
34 : basegfx::B2DPolyPolygon maStartPolyPolygon; // start Line PolyPolygon
35 : basegfx::B2DPolyPolygon maEndPolyPolygon; // end Line PolyPolygon
36 : double mfStartWidth; // 1/100th mm
37 : double mfEndWidth; // 1/100th mm
38 :
39 : // bitfield
40 : bool mbStartActive : 1; // start of Line is active
41 : bool mbEndActive : 1; // end of Line is active
42 : bool mbStartCentered : 1; // Line is centered on line start point
43 : bool mbEndCentered : 1; // Line is centered on line end point
44 :
45 0 : ImpSdrLineStartEndAttribute(
46 : const basegfx::B2DPolyPolygon& rStartPolyPolygon,
47 : const basegfx::B2DPolyPolygon& rEndPolyPolygon,
48 : double fStartWidth,
49 : double fEndWidth,
50 : bool bStartActive,
51 : bool bEndActive,
52 : bool bStartCentered,
53 : bool bEndCentered)
54 : : maStartPolyPolygon(rStartPolyPolygon),
55 : maEndPolyPolygon(rEndPolyPolygon),
56 : mfStartWidth(fStartWidth),
57 : mfEndWidth(fEndWidth),
58 : mbStartActive(bStartActive),
59 : mbEndActive(bEndActive),
60 : mbStartCentered(bStartCentered),
61 0 : mbEndCentered(bEndCentered)
62 : {
63 0 : }
64 :
65 0 : ImpSdrLineStartEndAttribute()
66 : : maStartPolyPolygon(basegfx::B2DPolyPolygon()),
67 : maEndPolyPolygon(basegfx::B2DPolyPolygon()),
68 : mfStartWidth(0.0),
69 : mfEndWidth(0.0),
70 : mbStartActive(false),
71 : mbEndActive(false),
72 : mbStartCentered(false),
73 0 : mbEndCentered(false)
74 : {
75 0 : }
76 :
77 : // data read access
78 0 : const basegfx::B2DPolyPolygon& getStartPolyPolygon() const { return maStartPolyPolygon; }
79 0 : const basegfx::B2DPolyPolygon& getEndPolyPolygon() const { return maEndPolyPolygon; }
80 0 : double getStartWidth() const { return mfStartWidth; }
81 0 : double getEndWidth() const { return mfEndWidth; }
82 0 : bool isStartActive() const { return mbStartActive; }
83 0 : bool isEndActive() const { return mbEndActive; }
84 0 : bool isStartCentered() const { return mbStartCentered; }
85 0 : bool isEndCentered() const { return mbEndCentered; }
86 :
87 0 : bool operator==(const ImpSdrLineStartEndAttribute& rCandidate) const
88 : {
89 0 : return (getStartPolyPolygon() == rCandidate.getStartPolyPolygon()
90 0 : && getEndPolyPolygon() == rCandidate.getEndPolyPolygon()
91 0 : && getStartWidth() == rCandidate.getStartWidth()
92 0 : && getEndWidth() == rCandidate.getEndWidth()
93 0 : && isStartActive() == rCandidate.isStartActive()
94 0 : && isEndActive() == rCandidate.isEndActive()
95 0 : && isStartCentered() == rCandidate.isStartCentered()
96 0 : && isEndCentered() == rCandidate.isEndCentered());
97 : }
98 : };
99 :
100 : namespace
101 : {
102 : struct theGlobalDefault :
103 : public rtl::Static< SdrLineStartEndAttribute::ImplType, theGlobalDefault > {};
104 : }
105 :
106 0 : SdrLineStartEndAttribute::SdrLineStartEndAttribute(
107 : const basegfx::B2DPolyPolygon& rStartPolyPolygon,
108 : const basegfx::B2DPolyPolygon& rEndPolyPolygon,
109 : double fStartWidth,
110 : double fEndWidth,
111 : bool bStartActive,
112 : bool bEndActive,
113 : bool bStartCentered,
114 : bool bEndCentered)
115 : : mpSdrLineStartEndAttribute(ImpSdrLineStartEndAttribute(
116 0 : rStartPolyPolygon, rEndPolyPolygon, fStartWidth, fEndWidth, bStartActive, bEndActive, bStartCentered, bEndCentered))
117 : {
118 0 : }
119 :
120 0 : SdrLineStartEndAttribute::SdrLineStartEndAttribute()
121 0 : : mpSdrLineStartEndAttribute(theGlobalDefault::get())
122 : {
123 0 : }
124 :
125 0 : SdrLineStartEndAttribute::SdrLineStartEndAttribute(const SdrLineStartEndAttribute& rCandidate)
126 0 : : mpSdrLineStartEndAttribute(rCandidate.mpSdrLineStartEndAttribute)
127 : {
128 0 : }
129 :
130 0 : SdrLineStartEndAttribute::~SdrLineStartEndAttribute()
131 : {
132 0 : }
133 :
134 0 : bool SdrLineStartEndAttribute::isDefault() const
135 : {
136 0 : return mpSdrLineStartEndAttribute.same_object(theGlobalDefault::get());
137 : }
138 :
139 0 : SdrLineStartEndAttribute& SdrLineStartEndAttribute::operator=(const SdrLineStartEndAttribute& rCandidate)
140 : {
141 0 : mpSdrLineStartEndAttribute = rCandidate.mpSdrLineStartEndAttribute;
142 0 : return *this;
143 : }
144 :
145 0 : bool SdrLineStartEndAttribute::operator==(const SdrLineStartEndAttribute& rCandidate) const
146 : {
147 0 : return rCandidate.mpSdrLineStartEndAttribute == mpSdrLineStartEndAttribute;
148 : }
149 :
150 0 : const basegfx::B2DPolyPolygon& SdrLineStartEndAttribute::getStartPolyPolygon() const
151 : {
152 0 : return mpSdrLineStartEndAttribute->getStartPolyPolygon();
153 : }
154 :
155 0 : const basegfx::B2DPolyPolygon& SdrLineStartEndAttribute::getEndPolyPolygon() const
156 : {
157 0 : return mpSdrLineStartEndAttribute->getEndPolyPolygon();
158 : }
159 :
160 0 : double SdrLineStartEndAttribute::getStartWidth() const
161 : {
162 0 : return mpSdrLineStartEndAttribute->getStartWidth();
163 : }
164 :
165 0 : double SdrLineStartEndAttribute::getEndWidth() const
166 : {
167 0 : return mpSdrLineStartEndAttribute->getEndWidth();
168 : }
169 :
170 0 : bool SdrLineStartEndAttribute::isStartActive() const
171 : {
172 0 : return mpSdrLineStartEndAttribute->isStartActive();
173 : }
174 :
175 0 : bool SdrLineStartEndAttribute::isEndActive() const
176 : {
177 0 : return mpSdrLineStartEndAttribute->isEndActive();
178 : }
179 :
180 0 : bool SdrLineStartEndAttribute::isStartCentered() const
181 : {
182 0 : return mpSdrLineStartEndAttribute->isStartCentered();
183 : }
184 :
185 0 : bool SdrLineStartEndAttribute::isEndCentered() const
186 : {
187 0 : return mpSdrLineStartEndAttribute->isEndCentered();
188 : }
189 : } // end of namespace attribute
190 : } // end of namespace drawinglayer
191 :
192 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|