merge the formfield patch from ooo-build
[ooovba.git] / drawinglayer / source / primitive3d / polygonprimitive3d.cxx
blobbde0ae85eaa879ae0960e6e71ed8c77005428a18
1 /*************************************************************************
3 * OpenOffice.org - a multi-platform office productivity suite
5 * $RCSfile: polygonprimitive3d.cxx,v $
7 * $Revision: 1.10 $
9 * last change: $Author: aw $ $Date: 2008-06-10 09:29:33 $
11 * The Contents of this file are made available subject to
12 * the terms of GNU Lesser General Public License Version 2.1.
15 * GNU Lesser General Public License Version 2.1
16 * =============================================
17 * Copyright 2005 by Sun Microsystems, Inc.
18 * 901 San Antonio Road, Palo Alto, CA 94303, USA
20 * This library is free software; you can redistribute it and/or
21 * modify it under the terms of the GNU Lesser General Public
22 * License version 2.1, as published by the Free Software Foundation.
24 * This library is distributed in the hope that it will be useful,
25 * but WITHOUT ANY WARRANTY; without even the implied warranty of
26 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
27 * Lesser General Public License for more details.
29 * You should have received a copy of the GNU Lesser General Public
30 * License along with this library; if not, write to the Free Software
31 * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
32 * MA 02111-1307 USA
34 ************************************************************************/
36 // MARKER(update_precomp.py): autogen include statement, do not remove
37 #include "precompiled_drawinglayer.hxx"
39 #include <drawinglayer/primitive3d/polygonprimitive3d.hxx>
40 #include <basegfx/polygon/b3dpolygontools.hxx>
41 #include <basegfx/tools/canvastools.hxx>
42 #include <basegfx/polygon/b3dpolypolygontools.hxx>
43 #include <drawinglayer/primitive3d/polygontubeprimitive3d.hxx>
44 #include <drawinglayer/primitive3d/drawinglayer_primitivetypes3d.hxx>
46 //////////////////////////////////////////////////////////////////////////////
48 using namespace com::sun::star;
50 //////////////////////////////////////////////////////////////////////////////
52 namespace drawinglayer
54 namespace primitive3d
56 PolygonHairlinePrimitive3D::PolygonHairlinePrimitive3D(
57 const basegfx::B3DPolygon& rPolygon,
58 const basegfx::BColor& rBColor)
59 : BasePrimitive3D(),
60 maPolygon(rPolygon),
61 maBColor(rBColor)
65 bool PolygonHairlinePrimitive3D::operator==(const BasePrimitive3D& rPrimitive) const
67 if(BasePrimitive3D::operator==(rPrimitive))
69 const PolygonHairlinePrimitive3D& rCompare = (PolygonHairlinePrimitive3D&)rPrimitive;
71 return (getB3DPolygon() == rCompare.getB3DPolygon()
72 && getBColor() == rCompare.getBColor());
75 return false;
78 basegfx::B3DRange PolygonHairlinePrimitive3D::getB3DRange(const geometry::ViewInformation3D& /*rViewInformation*/) const
80 return basegfx::tools::getRange(getB3DPolygon());
83 // provide unique ID
84 ImplPrimitrive3DIDBlock(PolygonHairlinePrimitive3D, PRIMITIVE3D_ID_POLYGONHAIRLINEPRIMITIVE3D)
86 } // end of namespace primitive3d
87 } // end of namespace drawinglayer
89 //////////////////////////////////////////////////////////////////////////////
91 namespace drawinglayer
93 namespace primitive3d
95 Primitive3DSequence PolygonStrokePrimitive3D::createLocalDecomposition(const geometry::ViewInformation3D& /*rViewInformation*/) const
97 Primitive3DSequence aRetval;
99 if(getB3DPolygon().count())
101 basegfx::B3DPolyPolygon aHairLinePolyPolygon;
103 if(0.0 == getStrokeAttribute().getFullDotDashLen())
105 aHairLinePolyPolygon = basegfx::B3DPolyPolygon(getB3DPolygon());
107 else
109 // apply LineStyle
110 basegfx::tools::applyLineDashing(getB3DPolygon(), getStrokeAttribute().getDotDashArray(), &aHairLinePolyPolygon, 0, getStrokeAttribute().getFullDotDashLen());
113 // prepare result
114 aRetval.realloc(aHairLinePolyPolygon.count());
116 if(getLineAttribute().getWidth())
118 // create fat line data
119 const double fRadius(getLineAttribute().getWidth() / 2.0);
120 const basegfx::B2DLineJoin aLineJoin(getLineAttribute().getLineJoin());
122 for(sal_uInt32 a(0L); a < aHairLinePolyPolygon.count(); a++)
124 // create tube primitives
125 const Primitive3DReference xRef(new PolygonTubePrimitive3D(aHairLinePolyPolygon.getB3DPolygon(a), getLineAttribute().getColor(), fRadius, aLineJoin));
126 aRetval[a] = xRef;
129 else
131 // create hair line data for all sub polygons
132 for(sal_uInt32 a(0L); a < aHairLinePolyPolygon.count(); a++)
134 const basegfx::B3DPolygon aCandidate = aHairLinePolyPolygon.getB3DPolygon(a);
135 const Primitive3DReference xRef(new PolygonHairlinePrimitive3D(aCandidate, getLineAttribute().getColor()));
136 aRetval[a] = xRef;
141 return aRetval;
144 PolygonStrokePrimitive3D::PolygonStrokePrimitive3D(
145 const basegfx::B3DPolygon& rPolygon,
146 const attribute::LineAttribute& rLineAttribute,
147 const attribute::StrokeAttribute& rStrokeAttribute)
148 : BasePrimitive3D(),
149 maPolygon(rPolygon),
150 maLineAttribute(rLineAttribute),
151 maStrokeAttribute(rStrokeAttribute)
155 PolygonStrokePrimitive3D::PolygonStrokePrimitive3D(
156 const basegfx::B3DPolygon& rPolygon,
157 const attribute::LineAttribute& rLineAttribute)
158 : BasePrimitive3D(),
159 maPolygon(rPolygon),
160 maLineAttribute(rLineAttribute),
161 maStrokeAttribute()
165 bool PolygonStrokePrimitive3D::operator==(const BasePrimitive3D& rPrimitive) const
167 if(BasePrimitive3D::operator==(rPrimitive))
169 const PolygonStrokePrimitive3D& rCompare = (PolygonStrokePrimitive3D&)rPrimitive;
171 return (getB3DPolygon() == rCompare.getB3DPolygon()
172 && getLineAttribute() == rCompare.getLineAttribute()
173 && getStrokeAttribute() == rCompare.getStrokeAttribute());
176 return false;
179 // provide unique ID
180 ImplPrimitrive3DIDBlock(PolygonStrokePrimitive3D, PRIMITIVE3D_ID_POLYGONSTROKEPRIMITIVE3D)
182 } // end of namespace primitive3d
183 } // end of namespace drawinglayer
185 //////////////////////////////////////////////////////////////////////////////
186 // eof