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>
26 using namespace com::sun::star
;
29 namespace drawinglayer::primitive2d
31 void SdrPathPrimitive2D::create2DDecomposition(Primitive2DContainer
& rContainer
, const geometry::ViewInformation2D
& /*aViewInformation*/) const
33 Primitive2DContainer aRetval
;
36 if(!getSdrLFSTAttribute().getFill().isDefault()
37 && getUnitPolyPolygon().isClosed())
39 // #i108255# no need to use correctOrientations here; target is
40 // straight visualisation
41 basegfx::B2DPolyPolygon
aTransformed(getUnitPolyPolygon());
42 aTransformed
.transform(getTransform());
44 // OperationSmiley: Check if a UnitDefinitionPolyPolygon is set
45 if(getUnitDefinitionPolyPolygon().count()
46 && getUnitDefinitionPolyPolygon() != getUnitPolyPolygon())
48 // if yes, use the B2DRange of it's transformed form
49 basegfx::B2DPolyPolygon
aTransformedDefinition(getUnitDefinitionPolyPolygon());
50 aTransformedDefinition
.transform(getTransform());
53 createPolyPolygonFillPrimitive(
55 aTransformedDefinition
.getB2DRange(),
56 getSdrLFSTAttribute().getFill(),
57 getSdrLFSTAttribute().getFillFloatTransGradient()));
62 createPolyPolygonFillPrimitive(
64 getSdrLFSTAttribute().getFill(),
65 getSdrLFSTAttribute().getFillFloatTransGradient()));
70 if(getSdrLFSTAttribute().getLine().isDefault())
72 // if initially no line is defined, create one for HitTest and BoundRect
74 createHiddenGeometryPrimitives2D(
81 Primitive2DContainer
aTemp(getUnitPolyPolygon().count());
83 for(sal_uInt32
a(0); a
< getUnitPolyPolygon().count(); a
++)
85 basegfx::B2DPolygon
aTransformed(getUnitPolyPolygon().getB2DPolygon(a
));
87 aTransformed
.transform(getTransform());
88 aTemp
[a
] = createPolygonLinePrimitive(
90 getSdrLFSTAttribute().getLine(),
91 getSdrLFSTAttribute().getLineStartEnd());
94 aRetval
.append(aTemp
);
98 if(!getSdrLFSTAttribute().getText().isDefault())
102 getUnitPolyPolygon(),
104 getSdrLFSTAttribute().getText(),
105 getSdrLFSTAttribute().getLine(),
111 if(!getSdrLFSTAttribute().getShadow().isDefault())
113 aRetval
= createEmbeddedShadowPrimitive(
115 getSdrLFSTAttribute().getShadow());
118 rContainer
.insert(rContainer
.end(), aRetval
.begin(), aRetval
.end());
121 SdrPathPrimitive2D::SdrPathPrimitive2D(
122 const basegfx::B2DHomMatrix
& rTransform
,
123 const attribute::SdrLineFillEffectsTextAttribute
& rSdrLFSTAttribute
,
124 const basegfx::B2DPolyPolygon
& rUnitPolyPolygon
,
125 const basegfx::B2DPolyPolygon
& rUnitDefinitionPolyPolygon
)
126 : BufferedDecompositionPrimitive2D(),
127 maTransform(rTransform
),
128 maSdrLFSTAttribute(rSdrLFSTAttribute
),
129 maUnitPolyPolygon(rUnitPolyPolygon
),
130 maUnitDefinitionPolyPolygon(rUnitDefinitionPolyPolygon
)
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 ImplPrimitive2DIDBlock(SdrPathPrimitive2D
, PRIMITIVE2D_ID_SDRPATHPRIMITIVE2D
)
152 } // end of namespace
154 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */