1 /************************************************************** 2 * 3 * Licensed to the Apache Software Foundation (ASF) under one 4 * or more contributor license agreements. See the NOTICE file 5 * distributed with this work for additional information 6 * regarding copyright ownership. The ASF licenses this file 7 * to you under the Apache License, Version 2.0 (the 8 * "License"); you may not use this file except in compliance 9 * with the License. You may obtain a copy of the License at 10 * 11 * http://www.apache.org/licenses/LICENSE-2.0 12 * 13 * Unless required by applicable law or agreed to in writing, 14 * software distributed under the License is distributed on an 15 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 16 * KIND, either express or implied. See the License for the 17 * specific language governing permissions and limitations 18 * under the License. 19 * 20 *************************************************************/ 21 22 23 24 #include "precompiled_svx.hxx" 25 #include <svx/sdr/primitive2d/sdrcustomshapeprimitive2d.hxx> 26 #include <basegfx/polygon/b2dpolygon.hxx> 27 #include <basegfx/polygon/b2dpolygontools.hxx> 28 #include <svx/sdr/primitive2d/sdrdecompositiontools.hxx> 29 #include <drawinglayer/primitive2d/groupprimitive2d.hxx> 30 #include <svx/sdr/primitive2d/svx_primitivetypes2d.hxx> 31 #include <drawinglayer/attribute/sdrlineattribute.hxx> 32 33 ////////////////////////////////////////////////////////////////////////////// 34 35 using namespace com::sun::star; 36 37 ////////////////////////////////////////////////////////////////////////////// 38 39 namespace drawinglayer 40 { 41 namespace primitive2d 42 { create2DDecomposition(const geometry::ViewInformation2D &) const43 Primitive2DSequence SdrCustomShapePrimitive2D::create2DDecomposition(const geometry::ViewInformation2D& /*aViewInformation*/) const 44 { 45 Primitive2DSequence aRetval(getSubPrimitives()); 46 47 // add text 48 if(!getSdrSTAttribute().getText().isDefault()) 49 { 50 const basegfx::B2DPolygon aUnitOutline(basegfx::tools::createUnitPolygon()); 51 52 appendPrimitive2DReferenceToPrimitive2DSequence(aRetval, 53 createTextPrimitive( 54 basegfx::B2DPolyPolygon(aUnitOutline), 55 getTextBox(), 56 getSdrSTAttribute().getText(), 57 attribute::SdrLineAttribute(), 58 false, 59 getWordWrap(), 60 isForceTextClipToTextRange())); 61 } 62 63 // add shadow 64 if(aRetval.hasElements() && !getSdrSTAttribute().getShadow().isDefault()) 65 { 66 // #i105323# add generic shadow only for 2D shapes. For 67 // 3D shapes shadow will be set at the individual created 68 // visualisation objects and be visualized by the 3d renderer 69 // as a single shadow. 70 // 71 // The shadow for AutoShapes could be handled uniformely by not setting any 72 // shadow items at the helper model objects and only adding shadow here for 73 // 2D and 3D (and it works, too), but this would lead to two 3D scenes for 74 // the 3D object; one for the shadow aond one for the content. The one for the 75 // shadow will be correct (using ColorModifierStack), but expensive. 76 if(!get3DShape()) 77 { 78 aRetval = createEmbeddedShadowPrimitive(aRetval, getSdrSTAttribute().getShadow()); 79 } 80 } 81 82 return aRetval; 83 } 84 SdrCustomShapePrimitive2D(const attribute::SdrShadowTextAttribute & rSdrSTAttribute,const Primitive2DSequence & rSubPrimitives,const basegfx::B2DHomMatrix & rTextBox,bool bWordWrap,bool b3DShape,bool bForceTextClipToTextRange)85 SdrCustomShapePrimitive2D::SdrCustomShapePrimitive2D( 86 const attribute::SdrShadowTextAttribute& rSdrSTAttribute, 87 const Primitive2DSequence& rSubPrimitives, 88 const basegfx::B2DHomMatrix& rTextBox, 89 bool bWordWrap, 90 bool b3DShape, 91 bool bForceTextClipToTextRange) 92 : BufferedDecompositionPrimitive2D(), 93 maSdrSTAttribute(rSdrSTAttribute), 94 maSubPrimitives(rSubPrimitives), 95 maTextBox(rTextBox), 96 mbWordWrap(bWordWrap), 97 mb3DShape(b3DShape), 98 mbForceTextClipToTextRange(bForceTextClipToTextRange) 99 { 100 } 101 operator ==(const BasePrimitive2D & rPrimitive) const102 bool SdrCustomShapePrimitive2D::operator==(const BasePrimitive2D& rPrimitive) const 103 { 104 if(BufferedDecompositionPrimitive2D::operator==(rPrimitive)) 105 { 106 const SdrCustomShapePrimitive2D& rCompare = (SdrCustomShapePrimitive2D&)rPrimitive; 107 108 return (getSdrSTAttribute() == rCompare.getSdrSTAttribute() 109 && getSubPrimitives() == rCompare.getSubPrimitives() 110 && getTextBox() == rCompare.getTextBox() 111 && getWordWrap() == rCompare.getWordWrap() 112 && get3DShape() == rCompare.get3DShape() 113 && isForceTextClipToTextRange() == rCompare.isForceTextClipToTextRange()); 114 } 115 116 return false; 117 } 118 119 // provide unique ID 120 ImplPrimitrive2DIDBlock(SdrCustomShapePrimitive2D, PRIMITIVE2D_ID_SDRCUSTOMSHAPEPRIMITIVE2D) 121 122 } // end of namespace primitive2d 123 } // end of namespace drawinglayer 124 125 ////////////////////////////////////////////////////////////////////////////// 126 // eof 127