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/sdrconnectorprimitive2d.hxx> 26 #include <svx/sdr/primitive2d/sdrdecompositiontools.hxx> 27 #include <basegfx/matrix/b2dhommatrix.hxx> 28 #include <drawinglayer/primitive2d/groupprimitive2d.hxx> 29 #include <svx/sdr/primitive2d/svx_primitivetypes2d.hxx> 30 #include <drawinglayer/primitive2d/sdrdecompositiontools2d.hxx> 31 #include <basegfx/polygon/b2dpolypolygon.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 SdrConnectorPrimitive2D::create2DDecomposition(const geometry::ViewInformation2D& /*aViewInformation*/) const 44 { 45 Primitive2DSequence aRetval; 46 47 // add line 48 if(getSdrLSTAttribute().getLine().isDefault()) 49 { 50 // create invisible line for HitTest/BoundRect 51 appendPrimitive2DReferenceToPrimitive2DSequence(aRetval, 52 createHiddenGeometryPrimitives2D( 53 false, 54 basegfx::B2DPolyPolygon(getUnitPolygon()))); 55 } 56 else 57 { 58 appendPrimitive2DReferenceToPrimitive2DSequence(aRetval, 59 createPolygonLinePrimitive( 60 getUnitPolygon(), 61 getSdrLSTAttribute().getLine(), 62 getSdrLSTAttribute().getLineStartEnd())); 63 } 64 65 // add text 66 if(!getSdrLSTAttribute().getText().isDefault()) 67 { 68 appendPrimitive2DReferenceToPrimitive2DSequence(aRetval, 69 createTextPrimitive( 70 basegfx::B2DPolyPolygon(getUnitPolygon()), 71 basegfx::B2DHomMatrix(), 72 getSdrLSTAttribute().getText(), 73 getSdrLSTAttribute().getLine(), 74 false, 75 false, 76 false)); 77 } 78 79 // add shadow 80 if(!getSdrLSTAttribute().getShadow().isDefault()) 81 { 82 aRetval = createEmbeddedShadowPrimitive( 83 aRetval, 84 getSdrLSTAttribute().getShadow()); 85 } 86 87 return aRetval; 88 } 89 SdrConnectorPrimitive2D(const attribute::SdrLineShadowTextAttribute & rSdrLSTAttribute,const::basegfx::B2DPolygon & rUnitPolygon)90 SdrConnectorPrimitive2D::SdrConnectorPrimitive2D( 91 const attribute::SdrLineShadowTextAttribute& rSdrLSTAttribute, 92 const ::basegfx::B2DPolygon& rUnitPolygon) 93 : BufferedDecompositionPrimitive2D(), 94 maSdrLSTAttribute(rSdrLSTAttribute), 95 maUnitPolygon(rUnitPolygon) 96 { 97 } 98 operator ==(const BasePrimitive2D & rPrimitive) const99 bool SdrConnectorPrimitive2D::operator==(const BasePrimitive2D& rPrimitive) const 100 { 101 if(BufferedDecompositionPrimitive2D::operator==(rPrimitive)) 102 { 103 const SdrConnectorPrimitive2D& rCompare = (SdrConnectorPrimitive2D&)rPrimitive; 104 105 return (getUnitPolygon() == rCompare.getUnitPolygon() 106 && getSdrLSTAttribute() == rCompare.getSdrLSTAttribute()); 107 } 108 109 return false; 110 } 111 112 // provide unique ID 113 ImplPrimitrive2DIDBlock(SdrConnectorPrimitive2D, PRIMITIVE2D_ID_SDRCONNECTORPRIMITIVE2D) 114 115 } // end of namespace primitive2d 116 } // end of namespace drawinglayer 117 118 ////////////////////////////////////////////////////////////////////////////// 119 // eof 120