bump product version to 7.2.5.1
[LibreOffice.git] / svx / source / sdr / primitive2d / sdrpathprimitive2d.cxx
blob721eff0ce364cf98afe1b2e101644ee55d3b052b
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
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;
35 // add fill
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());
52 aRetval.push_back(
53 createPolyPolygonFillPrimitive(
54 aTransformed,
55 aTransformedDefinition.getB2DRange(),
56 getSdrLFSTAttribute().getFill(),
57 getSdrLFSTAttribute().getFillFloatTransGradient()));
59 else
61 aRetval.push_back(
62 createPolyPolygonFillPrimitive(
63 aTransformed,
64 getSdrLFSTAttribute().getFill(),
65 getSdrLFSTAttribute().getFillFloatTransGradient()));
69 // add line
70 if(getSdrLFSTAttribute().getLine().isDefault())
72 // if initially no line is defined, create one for HitTest and BoundRect
73 aRetval.push_back(
74 createHiddenGeometryPrimitives2D(
75 false,
76 getUnitPolyPolygon(),
77 getTransform()));
79 else
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(
89 aTransformed,
90 getSdrLFSTAttribute().getLine(),
91 getSdrLFSTAttribute().getLineStartEnd());
94 aRetval.append(aTemp);
97 // add text
98 if(!getSdrLFSTAttribute().getText().isDefault())
100 aRetval.push_back(
101 createTextPrimitive(
102 getUnitPolyPolygon(),
103 getTransform(),
104 getSdrLFSTAttribute().getText(),
105 getSdrLFSTAttribute().getLine(),
106 false,
107 false));
110 // add shadow
111 if(!getSdrLFSTAttribute().getShadow().isDefault())
113 aRetval = createEmbeddedShadowPrimitive(
114 aRetval,
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());
146 return false;
149 // provide unique ID
150 ImplPrimitive2DIDBlock(SdrPathPrimitive2D, PRIMITIVE2D_ID_SDRPATHPRIMITIVE2D)
152 } // end of namespace
154 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */