1 /************************************************************************* 2 * 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 4 * 5 * Copyright 2000, 2010 Oracle and/or its affiliates. 6 * 7 * OpenOffice.org - a multi-platform office productivity suite 8 * 9 * This file is part of OpenOffice.org. 10 * 11 * OpenOffice.org is free software: you can redistribute it and/or modify 12 * it under the terms of the GNU Lesser General Public License version 3 13 * only, as published by the Free Software Foundation. 14 * 15 * OpenOffice.org is distributed in the hope that it will be useful, 16 * but WITHOUT ANY WARRANTY; without even the implied warranty of 17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 18 * GNU Lesser General Public License version 3 for more details 19 * (a copy is included in the LICENSE file that accompanied this code). 20 * 21 * You should have received a copy of the GNU Lesser General Public License 22 * version 3 along with OpenOffice.org. If not, see 23 * <http://www.openoffice.org/license.html> 24 * for a copy of the LGPLv3 License. 25 * 26 ************************************************************************/ 27 28 #include "precompiled_svx.hxx" 29 #include <svx/sdr/primitive2d/sdrpathprimitive2d.hxx> 30 #include <svx/sdr/primitive2d/sdrdecompositiontools.hxx> 31 #include <basegfx/polygon/b2dpolypolygontools.hxx> 32 #include <drawinglayer/primitive2d/groupprimitive2d.hxx> 33 #include <svx/sdr/primitive2d/svx_primitivetypes2d.hxx> 34 #include <drawinglayer/primitive2d/sdrdecompositiontools2d.hxx> 35 36 ////////////////////////////////////////////////////////////////////////////// 37 38 using namespace com::sun::star; 39 40 ////////////////////////////////////////////////////////////////////////////// 41 42 namespace drawinglayer 43 { 44 namespace primitive2d 45 { 46 Primitive2DSequence SdrPathPrimitive2D::create2DDecomposition(const geometry::ViewInformation2D& /*aViewInformation*/) const 47 { 48 Primitive2DSequence aRetval; 49 50 // add fill 51 if(!getSdrLFSTAttribute().getFill().isDefault() 52 && getUnitPolyPolygon().isClosed()) 53 { 54 // #i108255# no need to use correctOrientations here; target is 55 // straight visualisation 56 appendPrimitive2DReferenceToPrimitive2DSequence(aRetval, 57 createPolyPolygonFillPrimitive( 58 getUnitPolyPolygon(), 59 getTransform(), 60 getSdrLFSTAttribute().getFill(), 61 getSdrLFSTAttribute().getFillFloatTransGradient())); 62 } 63 64 // add line 65 if(getSdrLFSTAttribute().getLine().isDefault()) 66 { 67 // if initially no line is defined, create one for HitTest and BoundRect 68 appendPrimitive2DReferenceToPrimitive2DSequence(aRetval, 69 createHiddenGeometryPrimitives2D( 70 false, 71 getUnitPolyPolygon(), 72 getTransform())); 73 } 74 else 75 { 76 Primitive2DSequence aTemp(getUnitPolyPolygon().count()); 77 78 for(sal_uInt32 a(0); a < getUnitPolyPolygon().count(); a++) 79 { 80 aTemp[a] = createPolygonLinePrimitive( 81 getUnitPolyPolygon().getB2DPolygon(a), 82 getTransform(), 83 getSdrLFSTAttribute().getLine(), 84 getSdrLFSTAttribute().getLineStartEnd()); 85 } 86 87 appendPrimitive2DSequenceToPrimitive2DSequence(aRetval, aTemp); 88 } 89 90 // add text 91 if(!getSdrLFSTAttribute().getText().isDefault()) 92 { 93 appendPrimitive2DReferenceToPrimitive2DSequence(aRetval, 94 createTextPrimitive( 95 getUnitPolyPolygon(), 96 getTransform(), 97 getSdrLFSTAttribute().getText(), 98 getSdrLFSTAttribute().getLine(), 99 false, 100 false, 101 false)); 102 } 103 104 // add shadow 105 if(!getSdrLFSTAttribute().getShadow().isDefault()) 106 { 107 aRetval = createEmbeddedShadowPrimitive( 108 aRetval, 109 getSdrLFSTAttribute().getShadow()); 110 } 111 112 return aRetval; 113 } 114 115 SdrPathPrimitive2D::SdrPathPrimitive2D( 116 const basegfx::B2DHomMatrix& rTransform, 117 const attribute::SdrLineFillShadowTextAttribute& rSdrLFSTAttribute, 118 const basegfx::B2DPolyPolygon& rUnitPolyPolygon) 119 : BufferedDecompositionPrimitive2D(), 120 maTransform(rTransform), 121 maSdrLFSTAttribute(rSdrLFSTAttribute), 122 maUnitPolyPolygon(rUnitPolyPolygon) 123 { 124 } 125 126 bool SdrPathPrimitive2D::operator==(const BasePrimitive2D& rPrimitive) const 127 { 128 if(BufferedDecompositionPrimitive2D::operator==(rPrimitive)) 129 { 130 const SdrPathPrimitive2D& rCompare = (SdrPathPrimitive2D&)rPrimitive; 131 132 return (getUnitPolyPolygon() == rCompare.getUnitPolyPolygon() 133 && getTransform() == rCompare.getTransform() 134 && getSdrLFSTAttribute() == rCompare.getSdrLFSTAttribute()); 135 } 136 137 return false; 138 } 139 140 // provide unique ID 141 ImplPrimitrive2DIDBlock(SdrPathPrimitive2D, PRIMITIVE2D_ID_SDRPATHPRIMITIVE2D) 142 143 } // end of namespace primitive2d 144 } // end of namespace drawinglayer 145 146 ////////////////////////////////////////////////////////////////////////////// 147 // eof 148