LibreOffice Module svx (master) 1
sdrellipseprimitive2d.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
28#include <utility>
29
30
31using namespace com::sun::star;
32
33
35{
37 {
39
40 // create unit outline polygon
41 // Do use createPolygonFromUnitCircle, but let create from first quadrant to mimic old geometry creation.
42 // This is needed to have the same look when stroke is used since the polygon start point defines the
43 // stroke start, too.
45
46 // scale and move UnitEllipse to UnitObject (-1,-1 1,1) -> (0,0 1,1)
47 const basegfx::B2DHomMatrix aUnitCorrectionMatrix(
49
50 // apply to the geometry
51 aUnitOutline.transform(aUnitCorrectionMatrix);
52
53 // add fill
54 if(!getSdrLFSTAttribute().getFill().isDefault())
55 {
56 basegfx::B2DPolyPolygon aTransformed(aUnitOutline);
57
58 aTransformed.transform(getTransform());
59 aRetval.push_back(
61 aTransformed,
62 getSdrLFSTAttribute().getFill(),
63 getSdrLFSTAttribute().getFillFloatTransGradient()));
64 }
65
66 // add line
67 if(getSdrLFSTAttribute().getLine().isDefault())
68 {
69 // create invisible line for HitTest/BoundRect
70 aRetval.push_back(
72 false,
73 basegfx::B2DPolyPolygon(aUnitOutline),
74 getTransform()));
75 }
76 else
77 {
78 basegfx::B2DPolygon aTransformed(aUnitOutline);
79
80 aTransformed.transform(getTransform());
81 aRetval.push_back(
83 aTransformed,
84 getSdrLFSTAttribute().getLine(),
86 }
87
88 // add text
89 if(!getSdrLFSTAttribute().getText().isDefault())
90 {
91 aRetval.push_back(
93 basegfx::B2DPolyPolygon(aUnitOutline),
95 getSdrLFSTAttribute().getText(),
96 getSdrLFSTAttribute().getLine(),
97 false,
98 false));
99 }
100
101 // add shadow
102 if(!getSdrLFSTAttribute().getShadow().isDefault())
103 {
105 std::move(aRetval),
106 getSdrLFSTAttribute().getShadow());
107 }
108
109 rContainer.append(std::move(aRetval));
110 }
111
113 basegfx::B2DHomMatrix aTransform,
114 const attribute::SdrLineFillEffectsTextAttribute& rSdrLFSTAttribute)
115 : maTransform(std::move(aTransform)),
116 maSdrLFSTAttribute(rSdrLFSTAttribute)
117 {
118 }
119
121 {
122 if(BufferedDecompositionPrimitive2D::operator==(rPrimitive))
123 {
124 const SdrEllipsePrimitive2D& rCompare = static_cast<const SdrEllipsePrimitive2D&>(rPrimitive);
125
126 return (getTransform() == rCompare.getTransform()
127 && getSdrLFSTAttribute() == rCompare.getSdrLFSTAttribute());
128 }
129
130 return false;
131 }
132
133 // provide unique ID
135 {
137 }
138
139
140
142 {
143 Primitive2DContainer aRetval;
144
145 // create unit outline polygon
147
149 {
151 {
152 // for compatibility, insert the center point at polygon start to get the same
153 // line stroking pattern as the old painting mechanisms.
154 aUnitOutline.insert(0, basegfx::B2DPoint(0.0, 0.0));
155 }
156
157 aUnitOutline.setClosed(true);
158 }
159
160 // move and scale UnitEllipse to UnitObject (-1,-1 1,1) -> (0,0 1,1)
161 const basegfx::B2DHomMatrix aUnitCorrectionMatrix(
163
164 // apply to the geometry
165 aUnitOutline.transform(aUnitCorrectionMatrix);
166
167 // add fill
168 if(!getSdrLFSTAttribute().getFill().isDefault() && aUnitOutline.isClosed())
169 {
170 basegfx::B2DPolyPolygon aTransformed(aUnitOutline);
171
172 aTransformed.transform(getTransform());
173 aRetval.push_back(
175 aTransformed,
176 getSdrLFSTAttribute().getFill(),
177 getSdrLFSTAttribute().getFillFloatTransGradient()));
178 }
179
180 // add line
181 if(getSdrLFSTAttribute().getLine().isDefault())
182 {
183 // create invisible line for HitTest/BoundRect
184 aRetval.push_back(
186 false,
187 basegfx::B2DPolyPolygon(aUnitOutline),
188 getTransform()));
189 }
190 else
191 {
192 basegfx::B2DPolygon aTransformed(aUnitOutline);
193
194 aTransformed.transform(getTransform());
195 aRetval.push_back(
197 aTransformed,
198 getSdrLFSTAttribute().getLine(),
199 getSdrLFSTAttribute().getLineStartEnd()));
200 }
201
202 // add text
203 if(!getSdrLFSTAttribute().getText().isDefault())
204 {
205 aRetval.push_back(
207 basegfx::B2DPolyPolygon(aUnitOutline),
208 getTransform(),
209 getSdrLFSTAttribute().getText(),
210 getSdrLFSTAttribute().getLine(),
211 false,
212 false));
213 }
214
215 // add shadow
216 if(!getSdrLFSTAttribute().getShadow().isDefault())
217 {
219 std::move(aRetval),
220 getSdrLFSTAttribute().getShadow());
221 }
222
223 rContainer.append(std::move(aRetval));
224 }
225
227 const basegfx::B2DHomMatrix& rTransform,
228 const attribute::SdrLineFillEffectsTextAttribute& rSdrLFSTAttribute,
229 double fStartAngle,
230 double fEndAngle,
231 bool bCloseSegment,
232 bool bCloseUsingCenter)
233 : SdrEllipsePrimitive2D(rTransform, rSdrLFSTAttribute),
234 mfStartAngle(fStartAngle),
235 mfEndAngle(fEndAngle),
236 mbCloseSegment(bCloseSegment),
237 mbCloseUsingCenter(bCloseUsingCenter)
238 {
239 }
240
242 {
243 if(SdrEllipsePrimitive2D::operator==(rPrimitive))
244 {
245 const SdrEllipseSegmentPrimitive2D& rCompare = static_cast<const SdrEllipseSegmentPrimitive2D&>(rPrimitive);
246
247 if( mfStartAngle == rCompare.mfStartAngle
248 && mfEndAngle == rCompare.mfEndAngle
249 && mbCloseSegment == rCompare.mbCloseSegment
251 {
252 return true;
253 }
254 }
255
256 return false;
257 }
258
259 // provide unique ID
261 {
263 }
264
265} // end of namespace
266
267/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
void transform(const basegfx::B2DHomMatrix &rMatrix)
void insert(sal_uInt32 nIndex, const basegfx::B2DPoint &rPoint, sal_uInt32 nCount=1)
bool isClosed() const
void transform(const basegfx::B2DHomMatrix &rMatrix)
void setClosed(bool bNew)
void append(const Primitive2DReference &)
SdrEllipsePrimitive2D(::basegfx::B2DHomMatrix aTransform, const attribute::SdrLineFillEffectsTextAttribute &rSdrLFSTAttribute)
virtual void create2DDecomposition(Primitive2DContainer &rContainer, const geometry::ViewInformation2D &aViewInformation) const override
virtual bool operator==(const BasePrimitive2D &rPrimitive) const override
virtual sal_uInt32 getPrimitive2DID() const override
const ::basegfx::B2DHomMatrix & getTransform() const
const attribute::SdrLineFillEffectsTextAttribute & getSdrLFSTAttribute() const
virtual void create2DDecomposition(Primitive2DContainer &rContainer, const geometry::ViewInformation2D &aViewInformation) const override
SdrEllipseSegmentPrimitive2D(const ::basegfx::B2DHomMatrix &rTransform, const attribute::SdrLineFillEffectsTextAttribute &rSdrLFSTAttribute, double fStartAngle, double fEndAngle, bool bCloseSegment, bool bCloseUsingCenter)
virtual bool operator==(const BasePrimitive2D &rPrimitive) const override
B2DHomMatrix createScaleTranslateB2DHomMatrix(double fScaleX, double fScaleY, double fTranslateX, double fTranslateY)
B2DPolygon const & createPolygonFromUnitCircle(sal_uInt32 nStartQuadrant=0)
B2DPolygon createPolygonFromUnitEllipseSegment(double fStart, double fEnd)
Primitive2DReference createHiddenGeometryPrimitives2D(const basegfx::B2DHomMatrix &rMatrix)
Primitive2DContainer createEmbeddedShadowPrimitive(Primitive2DContainer &&rContent, const attribute::SdrShadowAttribute &rShadow, const basegfx::B2DHomMatrix &rObjectMatrix, const Primitive2DContainer *pContentForShadow)
Primitive2DReference createPolygonLinePrimitive(const basegfx::B2DPolygon &rPolygon, const attribute::SdrLineAttribute &rLine, const attribute::SdrLineStartEndAttribute &rStroke)
Primitive2DReference createTextPrimitive(const basegfx::B2DPolyPolygon &rUnitPolyPolygon, const basegfx::B2DHomMatrix &rObjectTransform, const attribute::SdrTextAttribute &rText, const attribute::SdrLineAttribute &rStroke, bool bCellText, bool bWordWrap)
Primitive2DReference createPolyPolygonFillPrimitive(const basegfx::B2DPolyPolygon &rPolyPolygon, const attribute::SdrFillAttribute &rFill, const attribute::FillGradientAttribute &rFillGradient)
#define PRIMITIVE2D_ID_SDRELLIPSESEGMENTPRIMITIVE2D
#define PRIMITIVE2D_ID_SDRELLIPSEPRIMITIVE2D
basegfx::B2DHomMatrix maTransform