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 	{
43 		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                         basegfx::B2DHomMatrix(),
62                         getSdrLSTAttribute().getLine(),
63                         getSdrLSTAttribute().getLineStartEnd()));
64 			}
65 
66 			// add text
67 			if(!getSdrLSTAttribute().getText().isDefault())
68 			{
69 				appendPrimitive2DReferenceToPrimitive2DSequence(aRetval,
70                     createTextPrimitive(
71                         basegfx::B2DPolyPolygon(getUnitPolygon()),
72                         basegfx::B2DHomMatrix(),
73                         getSdrLSTAttribute().getText(),
74                         getSdrLSTAttribute().getLine(),
75                         false,
76                         false,
77                         false));
78 			}
79 
80 			// add shadow
81 			if(!getSdrLSTAttribute().getShadow().isDefault())
82 			{
83                 aRetval = createEmbeddedShadowPrimitive(
84                     aRetval,
85                     getSdrLSTAttribute().getShadow());
86 			}
87 
88 			return aRetval;
89 		}
90 
91 		SdrConnectorPrimitive2D::SdrConnectorPrimitive2D(
92 			const attribute::SdrLineShadowTextAttribute& rSdrLSTAttribute,
93 			const ::basegfx::B2DPolygon& rUnitPolygon)
94 		:	BufferedDecompositionPrimitive2D(),
95 			maSdrLSTAttribute(rSdrLSTAttribute),
96 			maUnitPolygon(rUnitPolygon)
97 		{
98 		}
99 
100 		bool SdrConnectorPrimitive2D::operator==(const BasePrimitive2D& rPrimitive) const
101 		{
102 			if(BufferedDecompositionPrimitive2D::operator==(rPrimitive))
103 			{
104 				const SdrConnectorPrimitive2D& rCompare = (SdrConnectorPrimitive2D&)rPrimitive;
105 
106 				return (getUnitPolygon() == rCompare.getUnitPolygon()
107 					&& getSdrLSTAttribute() == rCompare.getSdrLSTAttribute());
108 			}
109 
110 			return false;
111 		}
112 
113 		// provide unique ID
114 		ImplPrimitrive2DIDBlock(SdrConnectorPrimitive2D, PRIMITIVE2D_ID_SDRCONNECTORPRIMITIVE2D)
115 
116 	} // end of namespace primitive2d
117 } // end of namespace drawinglayer
118 
119 //////////////////////////////////////////////////////////////////////////////
120 // eof
121