LibreOffice Module svx (master) 1
sdrcustomshapeprimitive2d.cxx
Go to the documentation of this file.
1/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2/*
3 * This file is part of the LibreOffice project.
4 *
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/.
8 *
9 * This file incorporates work covered by the following license notice:
10 *
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 .
18 */
19
27#include <utility>
28
29
30using namespace com::sun::star;
31
32
34{
36 {
38
39 // Soft edges should be before text, since text is not affected by soft edges
40 if (!aRetval.empty() && getSdrSTAttribute().getSoftEdgeRadius())
41 {
42 aRetval = createEmbeddedSoftEdgePrimitive(std::move(aRetval),
43 getSdrSTAttribute().getSoftEdgeRadius());
44 }
45
46 // add text
47 if(!getSdrSTAttribute().getText().isDefault())
48 {
50
51 aRetval.push_back(
53 basegfx::B2DPolyPolygon(aUnitOutline),
54 getTextBox(),
55 getSdrSTAttribute().getText(),
57 false,
58 getWordWrap()));
59 }
60
61 // tdf#132199: put glow before shadow, to have shadow of the glow, not the opposite
62 if (!aRetval.empty() && !getSdrSTAttribute().getGlow().isDefault())
63 {
64 // glow
65 aRetval = createEmbeddedGlowPrimitive(std::move(aRetval), getSdrSTAttribute().getGlow());
66 }
67
68 // add shadow
69 if(!aRetval.empty() && !getSdrSTAttribute().getShadow().isDefault())
70 {
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.
75
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())
82 {
83 aRetval = createEmbeddedShadowPrimitive(std::move(aRetval), getSdrSTAttribute().getShadow(),
85 }
86 }
87
88 rContainer.append(std::move(aRetval));
89 }
90
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))
104 {
105 }
106
108 {
109 if(BufferedDecompositionPrimitive2D::operator==(rPrimitive))
110 {
111 const SdrCustomShapePrimitive2D& rCompare = static_cast<const SdrCustomShapePrimitive2D&>(rPrimitive);
112
113 return (getSdrSTAttribute() == rCompare.getSdrSTAttribute()
114 && getSubPrimitives() == rCompare.getSubPrimitives()
115 && getTextBox() == rCompare.getTextBox()
116 && getWordWrap() == rCompare.getWordWrap()
117 && get3DShape() == rCompare.get3DShape());
118 }
119
120 return false;
121 }
122
123 // provide unique ID
125 {
127 }
128
129} // end of namespace
130
131/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
void append(const Primitive2DReference &)
const attribute::SdrEffectsTextAttribute & getSdrSTAttribute() const
virtual void create2DDecomposition(Primitive2DContainer &rContainer, const geometry::ViewInformation2D &aViewInformation) const override
SdrCustomShapePrimitive2D(const attribute::SdrEffectsTextAttribute &rSdrSTAttribute, Primitive2DContainer &&rSubPrimitives, basegfx::B2DHomMatrix aTextBox, bool bWordWrap, bool b3DShape, basegfx::B2DHomMatrix aObjectMatrix)
virtual bool operator==(const BasePrimitive2D &rPrimitive) const override
B2DPolygon const & createUnitPolygon()
Primitive2DContainer createEmbeddedSoftEdgePrimitive(Primitive2DContainer &&aContent, sal_Int32 nRadius)
Primitive2DContainer createEmbeddedShadowPrimitive(Primitive2DContainer &&rContent, const attribute::SdrShadowAttribute &rShadow, const basegfx::B2DHomMatrix &rObjectMatrix, const Primitive2DContainer *pContentForShadow)
Primitive2DReference createTextPrimitive(const basegfx::B2DPolyPolygon &rUnitPolyPolygon, const basegfx::B2DHomMatrix &rObjectTransform, const attribute::SdrTextAttribute &rText, const attribute::SdrLineAttribute &rStroke, bool bCellText, bool bWordWrap)
Primitive2DContainer createEmbeddedGlowPrimitive(Primitive2DContainer &&rContent, const attribute::SdrGlowAttribute &rGlow)
#define PRIMITIVE2D_ID_SDRCUSTOMSHAPEPRIMITIVE2D
basegfx::B2DHomMatrix maTransform