Bump version to 24.04.3.4
[LibreOffice.git] / svx / source / sdr / primitive2d / sdrcustomshapeprimitive2d.cxx
blob19717e2eb12153f27ac674a787c4fce4d32e23fd
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/sdrcustomshapeprimitive2d.hxx>
21 #include <basegfx/polygon/b2dpolygon.hxx>
22 #include <basegfx/polygon/b2dpolygontools.hxx>
23 #include <basegfx/polygon/b2dpolypolygon.hxx>
24 #include <sdr/primitive2d/sdrdecompositiontools.hxx>
25 #include <svx/sdr/primitive2d/svx_primitivetypes2d.hxx>
26 #include <drawinglayer/attribute/sdrlineattribute.hxx>
27 #include <utility>
30 using namespace com::sun::star;
33 namespace drawinglayer::primitive2d
35 void SdrCustomShapePrimitive2D::create2DDecomposition(Primitive2DContainer& rContainer, const geometry::ViewInformation2D& /*aViewInformation*/) const
37 Primitive2DContainer aRetval(getSubPrimitives());
39 // Soft edges should be before text, since text is not affected by soft edges
40 if (!aRetval.empty() && getSdrSTAttribute().getSoftEdgeRadius())
42 aRetval = createEmbeddedSoftEdgePrimitive(std::move(aRetval),
43 getSdrSTAttribute().getSoftEdgeRadius());
46 // add text
47 if(!getSdrSTAttribute().getText().isDefault())
49 const basegfx::B2DPolygon& aUnitOutline(basegfx::utils::createUnitPolygon());
51 aRetval.push_back(
52 createTextPrimitive(
53 basegfx::B2DPolyPolygon(aUnitOutline),
54 getTextBox(),
55 getSdrSTAttribute().getText(),
56 attribute::SdrLineAttribute(),
57 false,
58 getWordWrap()));
61 // tdf#132199: put glow before shadow, to have shadow of the glow, not the opposite
62 if (!aRetval.empty() && !getSdrSTAttribute().getGlow().isDefault())
64 // glow
65 aRetval = createEmbeddedGlowPrimitive(std::move(aRetval), getSdrSTAttribute().getGlow());
68 // add shadow
69 if(!aRetval.empty() && !getSdrSTAttribute().getShadow().isDefault())
71 // #i105323# add generic shadow only for 2D shapes. For
72 // 3D shapes shadow will be set at the individual created
73 // visualisation objects and be visualized by the 3d renderer
74 // as a single shadow.
76 // The shadow for AutoShapes could be handled uniformly by not setting any
77 // shadow items at the helper model objects and only adding shadow here for
78 // 2D and 3D (and it works, too), but this would lead to two 3D scenes for
79 // the 3D object; one for the shadow and one for the content. The one for the
80 // shadow will be correct (using ColorModifierStack), but expensive.
81 if(!get3DShape())
83 aRetval = createEmbeddedShadowPrimitive(std::move(aRetval), getSdrSTAttribute().getShadow(),
84 maTransform);
88 rContainer.append(std::move(aRetval));
91 SdrCustomShapePrimitive2D::SdrCustomShapePrimitive2D(
92 const attribute::SdrEffectsTextAttribute& rSdrSTAttribute,
93 Primitive2DContainer&& rSubPrimitives,
94 basegfx::B2DHomMatrix aTextBox,
95 bool bWordWrap,
96 bool b3DShape,
97 basegfx::B2DHomMatrix aTransform)
98 : maSdrSTAttribute(rSdrSTAttribute),
99 maSubPrimitives(std::move(rSubPrimitives)),
100 maTextBox(std::move(aTextBox)),
101 mbWordWrap(bWordWrap),
102 mb3DShape(b3DShape),
103 maTransform(std::move(aTransform))
107 bool SdrCustomShapePrimitive2D::operator==(const BasePrimitive2D& rPrimitive) const
109 if(BufferedDecompositionPrimitive2D::operator==(rPrimitive))
111 const SdrCustomShapePrimitive2D& rCompare = static_cast<const SdrCustomShapePrimitive2D&>(rPrimitive);
113 return (getSdrSTAttribute() == rCompare.getSdrSTAttribute()
114 && getSubPrimitives() == rCompare.getSubPrimitives()
115 && getTextBox() == rCompare.getTextBox()
116 && getWordWrap() == rCompare.getWordWrap()
117 && get3DShape() == rCompare.get3DShape());
120 return false;
123 // provide unique ID
124 sal_uInt32 SdrCustomShapePrimitive2D::getPrimitive2DID() const
126 return PRIMITIVE2D_ID_SDRCUSTOMSHAPEPRIMITIVE2D;
129 } // end of namespace
131 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */