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 
28 
29 using namespace com::sun::star;
30 
31 
33 {
34  void SdrCustomShapePrimitive2D::create2DDecomposition(Primitive2DContainer& rContainer, const geometry::ViewInformation2D& /*aViewInformation*/) const
35  {
36  Primitive2DContainer aRetval(getSubPrimitives());
37 
38  // Soft edges should be before text, since text is not affected by soft edges
39  if (!aRetval.empty() && getSdrSTAttribute().getSoftEdgeRadius())
40  {
41  aRetval = createEmbeddedSoftEdgePrimitive(aRetval,
42  getSdrSTAttribute().getSoftEdgeRadius());
43  }
44 
45  // add text
46  if(!getSdrSTAttribute().getText().isDefault())
47  {
49 
50  aRetval.push_back(
52  basegfx::B2DPolyPolygon(aUnitOutline),
53  getTextBox(),
54  getSdrSTAttribute().getText(),
56  false,
57  getWordWrap()));
58  }
59 
60  // tdf#132199: put glow before shadow, to have shadow of the glow, not the opposite
61  if (!aRetval.empty() && !getSdrSTAttribute().getGlow().isDefault())
62  {
63  // glow
64  aRetval = createEmbeddedGlowPrimitive(aRetval, getSdrSTAttribute().getGlow());
65  }
66 
67  // add shadow
68  if(!aRetval.empty() && !getSdrSTAttribute().getShadow().isDefault())
69  {
70  // #i105323# add generic shadow only for 2D shapes. For
71  // 3D shapes shadow will be set at the individual created
72  // visualisation objects and be visualized by the 3d renderer
73  // as a single shadow.
74 
75  // The shadow for AutoShapes could be handled uniformly by not setting any
76  // shadow items at the helper model objects and only adding shadow here for
77  // 2D and 3D (and it works, too), but this would lead to two 3D scenes for
78  // the 3D object; one for the shadow and one for the content. The one for the
79  // shadow will be correct (using ColorModifierStack), but expensive.
80  if(!get3DShape())
81  {
82  aRetval = createEmbeddedShadowPrimitive(aRetval, getSdrSTAttribute().getShadow(),
83  maTransform);
84  }
85  }
86 
87  rContainer.insert(rContainer.end(), aRetval.begin(), aRetval.end());
88  }
89 
90  SdrCustomShapePrimitive2D::SdrCustomShapePrimitive2D(
91  const attribute::SdrEffectsTextAttribute& rSdrSTAttribute,
92  const Primitive2DContainer& rSubPrimitives,
93  const basegfx::B2DHomMatrix& rTextBox,
94  bool bWordWrap,
95  bool b3DShape,
96  const basegfx::B2DHomMatrix& rTransform)
98  maSdrSTAttribute(rSdrSTAttribute),
99  maSubPrimitives(rSubPrimitives),
100  maTextBox(rTextBox),
101  mbWordWrap(bWordWrap),
102  mb3DShape(b3DShape),
103  maTransform(rTransform)
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 
126 } // end of namespace
127 
128 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
Primitive2DContainer createEmbeddedGlowPrimitive(const Primitive2DContainer &rContent, const attribute::SdrGlowAttribute &rGlow)
const attribute::SdrEffectsTextAttribute & getSdrSTAttribute() const
B2DPolygon const & createUnitPolygon()
virtual bool operator==(const BasePrimitive2D &rPrimitive) const override
Primitive2DContainer createEmbeddedShadowPrimitive(const Primitive2DContainer &rContent, const attribute::SdrShadowAttribute &rShadow, const basegfx::B2DHomMatrix &rObjectMatrix, const Primitive2DContainer *pContentForShadow)
basegfx::B2DHomMatrix maTransform
#define PRIMITIVE2D_ID_SDRCUSTOMSHAPEPRIMITIVE2D
ImplPrimitive2DIDBlock(BorderLinePrimitive2D, PRIMITIVE2D_ID_BORDERLINEPRIMITIVE2D) Primitive2DReference tryMergeBorderLinePrimitive2D(const BorderLinePrimitive2D *pCandidateA
Primitive2DReference createTextPrimitive(const basegfx::B2DPolyPolygon &rUnitPolyPolygon, const basegfx::B2DHomMatrix &rObjectTransform, const attribute::SdrTextAttribute &rText, const attribute::SdrLineAttribute &rStroke, bool bCellText, bool bWordWrap)
Primitive2DContainer createEmbeddedSoftEdgePrimitive(const Primitive2DContainer &rContent, sal_Int32 nRadius)