1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
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 <sdr/primitive2d/sdrpathprimitive2d.hxx>
21 #include <sdr/primitive2d/sdrdecompositiontools.hxx>
22 #include <svx/sdr/primitive2d/svx_primitivetypes2d.hxx>
23 #include <drawinglayer/primitive2d/sdrdecompositiontools2d.hxx>
27 using namespace com::sun::star
;
30 namespace drawinglayer::primitive2d
32 void SdrPathPrimitive2D::create2DDecomposition(Primitive2DContainer
& rContainer
, const geometry::ViewInformation2D
& /*aViewInformation*/) const
34 Primitive2DContainer aRetval
;
37 if(!getSdrLFSTAttribute().getFill().isDefault()
38 && getUnitPolyPolygon().isClosed())
40 // #i108255# no need to use correctOrientations here; target is
41 // straight visualisation
42 basegfx::B2DPolyPolygon
aTransformed(getUnitPolyPolygon());
43 aTransformed
.transform(getTransform());
45 // OperationSmiley: Check if a UnitDefinitionPolyPolygon is set
46 if(getUnitDefinitionPolyPolygon().count()
47 && getUnitDefinitionPolyPolygon() != getUnitPolyPolygon())
49 // if yes, use the B2DRange of it's transformed form
50 basegfx::B2DPolyPolygon
aTransformedDefinition(getUnitDefinitionPolyPolygon());
51 aTransformedDefinition
.transform(getTransform());
54 createPolyPolygonFillPrimitive(
56 aTransformedDefinition
.getB2DRange(),
57 getSdrLFSTAttribute().getFill(),
58 getSdrLFSTAttribute().getFillFloatTransGradient()));
63 createPolyPolygonFillPrimitive(
65 getSdrLFSTAttribute().getFill(),
66 getSdrLFSTAttribute().getFillFloatTransGradient()));
71 if(getSdrLFSTAttribute().getLine().isDefault())
73 // if initially no line is defined, create one for HitTest and BoundRect
75 createHiddenGeometryPrimitives2D(
82 Primitive2DContainer
aTemp(getUnitPolyPolygon().count());
84 for(sal_uInt32
a(0); a
< getUnitPolyPolygon().count(); a
++)
86 basegfx::B2DPolygon
aTransformed(getUnitPolyPolygon().getB2DPolygon(a
));
88 aTransformed
.transform(getTransform());
89 aTemp
[a
] = createPolygonLinePrimitive(
91 getSdrLFSTAttribute().getLine(),
92 getSdrLFSTAttribute().getLineStartEnd());
95 aRetval
.append(aTemp
);
99 if(!getSdrLFSTAttribute().getText().isDefault())
103 getUnitPolyPolygon(),
105 getSdrLFSTAttribute().getText(),
106 getSdrLFSTAttribute().getLine(),
112 if(!getSdrLFSTAttribute().getShadow().isDefault())
114 aRetval
= createEmbeddedShadowPrimitive(
116 getSdrLFSTAttribute().getShadow());
119 rContainer
.append(std::move(aRetval
));
122 SdrPathPrimitive2D::SdrPathPrimitive2D(
123 basegfx::B2DHomMatrix aTransform
,
124 const attribute::SdrLineFillEffectsTextAttribute
& rSdrLFSTAttribute
,
125 basegfx::B2DPolyPolygon aUnitPolyPolygon
,
126 basegfx::B2DPolyPolygon aUnitDefinitionPolyPolygon
)
127 : maTransform(std::move(aTransform
)),
128 maSdrLFSTAttribute(rSdrLFSTAttribute
),
129 maUnitPolyPolygon(std::move(aUnitPolyPolygon
)),
130 maUnitDefinitionPolyPolygon(std::move(aUnitDefinitionPolyPolygon
))
134 bool SdrPathPrimitive2D::operator==(const BasePrimitive2D
& rPrimitive
) const
136 if(BufferedDecompositionPrimitive2D::operator==(rPrimitive
))
138 const SdrPathPrimitive2D
& rCompare
= static_cast<const SdrPathPrimitive2D
&>(rPrimitive
);
140 return (getUnitPolyPolygon() == rCompare
.getUnitPolyPolygon()
141 && getUnitDefinitionPolyPolygon() == rCompare
.getUnitDefinitionPolyPolygon()
142 && getTransform() == rCompare
.getTransform()
143 && getSdrLFSTAttribute() == rCompare
.getSdrLFSTAttribute());
150 sal_uInt32
SdrPathPrimitive2D::getPrimitive2DID() const
152 return PRIMITIVE2D_ID_SDRPATHPRIMITIVE2D
;
155 } // end of namespace
157 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */