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