Version 7.6.3.2-android, tag libreoffice-7.6.3.2-android
[LibreOffice.git] / svx / source / sdr / primitive2d / sdrpathprimitive2d.cxx
blob46fcec09115beb6f543a1544ac58d2027986949c
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>
24 #include <utility>
27 using namespace com::sun::star;
30 namespace drawinglayer::primitive2d
32 void SdrPathPrimitive2D::create2DDecomposition(Primitive2DContainer& rContainer, const geometry::ViewInformation2D& /*aViewInformation*/) const
34 Primitive2DContainer aRetval;
36 // add fill
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());
53 aRetval.push_back(
54 createPolyPolygonFillPrimitive(
55 aTransformed,
56 aTransformedDefinition.getB2DRange(),
57 getSdrLFSTAttribute().getFill(),
58 getSdrLFSTAttribute().getFillFloatTransGradient()));
60 else
62 aRetval.push_back(
63 createPolyPolygonFillPrimitive(
64 aTransformed,
65 getSdrLFSTAttribute().getFill(),
66 getSdrLFSTAttribute().getFillFloatTransGradient()));
70 // add line
71 if(getSdrLFSTAttribute().getLine().isDefault())
73 // if initially no line is defined, create one for HitTest and BoundRect
74 aRetval.push_back(
75 createHiddenGeometryPrimitives2D(
76 false,
77 getUnitPolyPolygon(),
78 getTransform()));
80 else
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(
90 aTransformed,
91 getSdrLFSTAttribute().getLine(),
92 getSdrLFSTAttribute().getLineStartEnd());
95 aRetval.append(aTemp);
98 // add text
99 if(!getSdrLFSTAttribute().getText().isDefault())
101 aRetval.push_back(
102 createTextPrimitive(
103 getUnitPolyPolygon(),
104 getTransform(),
105 getSdrLFSTAttribute().getText(),
106 getSdrLFSTAttribute().getLine(),
107 false,
108 false));
111 // add shadow
112 if(!getSdrLFSTAttribute().getShadow().isDefault())
114 aRetval = createEmbeddedShadowPrimitive(
115 std::move(aRetval),
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());
146 return false;
149 // provide unique ID
150 sal_uInt32 SdrPathPrimitive2D::getPrimitive2DID() const
152 return PRIMITIVE2D_ID_SDRPATHPRIMITIVE2D;
155 } // end of namespace
157 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */