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/sdrpathprimitive2d.hxx>
26 #include <svx/sdr/primitive2d/sdrdecompositiontools.hxx>
27 #include <basegfx/polygon/b2dpolypolygontools.hxx>
28 #include <drawinglayer/primitive2d/groupprimitive2d.hxx>
29 #include <svx/sdr/primitive2d/svx_primitivetypes2d.hxx>
30 #include <drawinglayer/primitive2d/sdrdecompositiontools2d.hxx>
31 
32 //////////////////////////////////////////////////////////////////////////////
33 
34 using namespace com::sun::star;
35 
36 //////////////////////////////////////////////////////////////////////////////
37 
38 namespace drawinglayer
39 {
40 	namespace primitive2d
41 	{
create2DDecomposition(const geometry::ViewInformation2D &) const42 		Primitive2DSequence SdrPathPrimitive2D::create2DDecomposition(const geometry::ViewInformation2D& /*aViewInformation*/) const
43 		{
44 			Primitive2DSequence aRetval;
45 
46 			// add fill
47 			if(!getSdrLFSTAttribute().getFill().isDefault()
48 				&& getUnitPolyPolygon().isClosed())
49 			{
50                 // #i108255# no need to use correctOrientations here; target is
51                 // straight visualisation
52 				appendPrimitive2DReferenceToPrimitive2DSequence(aRetval,
53                     createPolyPolygonFillPrimitive(
54                         getUnitPolyPolygon(),
55                         getTransform(),
56                         getSdrLFSTAttribute().getFill(),
57                         getSdrLFSTAttribute().getFillFloatTransGradient()));
58 			}
59 
60 			// add line
61 			if(getSdrLFSTAttribute().getLine().isDefault())
62 			{
63                 // if initially no line is defined, create one for HitTest and BoundRect
64                 appendPrimitive2DReferenceToPrimitive2DSequence(aRetval,
65                     createHiddenGeometryPrimitives2D(
66                         false,
67                         getUnitPolyPolygon(),
68                         getTransform()));
69 			}
70 			else
71 			{
72 				Primitive2DSequence aTemp(getUnitPolyPolygon().count());
73 
74 				for(sal_uInt32 a(0); a < getUnitPolyPolygon().count(); a++)
75 				{
76 					aTemp[a] = createPolygonLinePrimitive(
77                         getUnitPolyPolygon().getB2DPolygon(a),
78                         getTransform(),
79                         getSdrLFSTAttribute().getLine(),
80                         getSdrLFSTAttribute().getLineStartEnd());
81 				}
82 
83 				appendPrimitive2DSequenceToPrimitive2DSequence(aRetval, aTemp);
84 			}
85 
86 			// add text
87 			if(!getSdrLFSTAttribute().getText().isDefault())
88 			{
89 				appendPrimitive2DReferenceToPrimitive2DSequence(aRetval,
90                     createTextPrimitive(
91                         getUnitPolyPolygon(),
92                         getTransform(),
93                         getSdrLFSTAttribute().getText(),
94                         getSdrLFSTAttribute().getLine(),
95                         false,
96                         false,
97                         false));
98 			}
99 
100 			// add shadow
101 			if(!getSdrLFSTAttribute().getShadow().isDefault())
102 			{
103                 aRetval = createEmbeddedShadowPrimitive(
104                     aRetval,
105                     getSdrLFSTAttribute().getShadow());
106 			}
107 
108 			return aRetval;
109 		}
110 
SdrPathPrimitive2D(const basegfx::B2DHomMatrix & rTransform,const attribute::SdrLineFillShadowTextAttribute & rSdrLFSTAttribute,const basegfx::B2DPolyPolygon & rUnitPolyPolygon)111 		SdrPathPrimitive2D::SdrPathPrimitive2D(
112 			const basegfx::B2DHomMatrix& rTransform,
113 			const attribute::SdrLineFillShadowTextAttribute& rSdrLFSTAttribute,
114 			const basegfx::B2DPolyPolygon& rUnitPolyPolygon)
115 		:	BufferedDecompositionPrimitive2D(),
116 			maTransform(rTransform),
117 			maSdrLFSTAttribute(rSdrLFSTAttribute),
118 			maUnitPolyPolygon(rUnitPolyPolygon)
119 		{
120 		}
121 
operator ==(const BasePrimitive2D & rPrimitive) const122 		bool SdrPathPrimitive2D::operator==(const BasePrimitive2D& rPrimitive) const
123 		{
124 			if(BufferedDecompositionPrimitive2D::operator==(rPrimitive))
125 			{
126 				const SdrPathPrimitive2D& rCompare = (SdrPathPrimitive2D&)rPrimitive;
127 
128 				return (getUnitPolyPolygon() == rCompare.getUnitPolyPolygon()
129 					&& getTransform() == rCompare.getTransform()
130 					&& getSdrLFSTAttribute() == rCompare.getSdrLFSTAttribute());
131 			}
132 
133 			return false;
134 		}
135 
136 		// provide unique ID
137 		ImplPrimitrive2DIDBlock(SdrPathPrimitive2D, PRIMITIVE2D_ID_SDRPATHPRIMITIVE2D)
138 
139 	} // end of namespace primitive2d
140 } // end of namespace drawinglayer
141 
142 //////////////////////////////////////////////////////////////////////////////
143 // eof
144