bump product version to 4.1.6.2
[LibreOffice.git] / svx / source / sdr / primitive2d / sdrcustomshapeprimitive2d.cxx
blobb48dc9fe81bc852c0ea4c1d0b6b49942572b5013
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 <svx/sdr/primitive2d/sdrcustomshapeprimitive2d.hxx>
21 #include <basegfx/polygon/b2dpolygon.hxx>
22 #include <basegfx/polygon/b2dpolygontools.hxx>
23 #include <svx/sdr/primitive2d/sdrdecompositiontools.hxx>
24 #include <drawinglayer/primitive2d/groupprimitive2d.hxx>
25 #include <svx/sdr/primitive2d/svx_primitivetypes2d.hxx>
26 #include <drawinglayer/attribute/sdrlineattribute.hxx>
28 //////////////////////////////////////////////////////////////////////////////
30 using namespace com::sun::star;
32 //////////////////////////////////////////////////////////////////////////////
34 namespace drawinglayer
36 namespace primitive2d
38 Primitive2DSequence SdrCustomShapePrimitive2D::create2DDecomposition(const geometry::ViewInformation2D& /*aViewInformation*/) const
40 Primitive2DSequence aRetval(getSubPrimitives());
42 // add text
43 if(!getSdrSTAttribute().getText().isDefault())
45 const basegfx::B2DPolygon aUnitOutline(basegfx::tools::createUnitPolygon());
47 appendPrimitive2DReferenceToPrimitive2DSequence(aRetval,
48 createTextPrimitive(
49 basegfx::B2DPolyPolygon(aUnitOutline),
50 getTextBox(),
51 getSdrSTAttribute().getText(),
52 attribute::SdrLineAttribute(),
53 false,
54 getWordWrap(),
55 isForceTextClipToTextRange()));
58 // add shadow
59 if(aRetval.hasElements() && !getSdrSTAttribute().getShadow().isDefault())
61 // #i105323# add generic shadow only for 2D shapes. For
62 // 3D shapes shadow will be set at the individual created
63 // visualisation objects and be visualized by the 3d renderer
64 // as a single shadow.
66 // The shadow for AutoShapes could be handled uniformely by not setting any
67 // shadow items at the helper model objects and only adding shadow here for
68 // 2D and 3D (and it works, too), but this would lead to two 3D scenes for
69 // the 3D object; one for the shadow aond one for the content. The one for the
70 // shadow will be correct (using ColorModifierStack), but expensive.
71 if(!get3DShape())
73 aRetval = createEmbeddedShadowPrimitive(aRetval, getSdrSTAttribute().getShadow());
77 return aRetval;
80 SdrCustomShapePrimitive2D::SdrCustomShapePrimitive2D(
81 const attribute::SdrShadowTextAttribute& rSdrSTAttribute,
82 const Primitive2DSequence& rSubPrimitives,
83 const basegfx::B2DHomMatrix& rTextBox,
84 bool bWordWrap,
85 bool b3DShape,
86 bool bForceTextClipToTextRange)
87 : BufferedDecompositionPrimitive2D(),
88 maSdrSTAttribute(rSdrSTAttribute),
89 maSubPrimitives(rSubPrimitives),
90 maTextBox(rTextBox),
91 mbWordWrap(bWordWrap),
92 mb3DShape(b3DShape),
93 mbForceTextClipToTextRange(bForceTextClipToTextRange)
97 bool SdrCustomShapePrimitive2D::operator==(const BasePrimitive2D& rPrimitive) const
99 if(BufferedDecompositionPrimitive2D::operator==(rPrimitive))
101 const SdrCustomShapePrimitive2D& rCompare = (SdrCustomShapePrimitive2D&)rPrimitive;
103 return (getSdrSTAttribute() == rCompare.getSdrSTAttribute()
104 && getSubPrimitives() == rCompare.getSubPrimitives()
105 && getTextBox() == rCompare.getTextBox()
106 && getWordWrap() == rCompare.getWordWrap()
107 && get3DShape() == rCompare.get3DShape()
108 && isForceTextClipToTextRange() == rCompare.isForceTextClipToTextRange());
111 return false;
114 // provide unique ID
115 ImplPrimitive2DIDBlock(SdrCustomShapePrimitive2D, PRIMITIVE2D_ID_SDRCUSTOMSHAPEPRIMITIVE2D)
117 } // end of namespace primitive2d
118 } // end of namespace drawinglayer
120 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */