xref: /trunk/main/svx/source/sdr/primitive2d/sdrconnectorprimitive2d.cxx (revision cdf0e10c4e3984b49a9502b011690b615761d4a3)
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/sdrconnectorprimitive2d.hxx>
30 #include <svx/sdr/primitive2d/sdrdecompositiontools.hxx>
31 #include <basegfx/matrix/b2dhommatrix.hxx>
32 #include <drawinglayer/primitive2d/groupprimitive2d.hxx>
33 #include <svx/sdr/primitive2d/svx_primitivetypes2d.hxx>
34 #include <drawinglayer/primitive2d/sdrdecompositiontools2d.hxx>
35 #include <basegfx/polygon/b2dpolypolygon.hxx>
36 
37 //////////////////////////////////////////////////////////////////////////////
38 
39 using namespace com::sun::star;
40 
41 //////////////////////////////////////////////////////////////////////////////
42 
43 namespace drawinglayer
44 {
45     namespace primitive2d
46     {
47         Primitive2DSequence SdrConnectorPrimitive2D::create2DDecomposition(const geometry::ViewInformation2D& /*aViewInformation*/) const
48         {
49             Primitive2DSequence aRetval;
50 
51             // add line
52             if(getSdrLSTAttribute().getLine().isDefault())
53             {
54                 // create invisible line for HitTest/BoundRect
55                 appendPrimitive2DReferenceToPrimitive2DSequence(aRetval,
56                     createHiddenGeometryPrimitives2D(
57                         false,
58                         basegfx::B2DPolyPolygon(getUnitPolygon())));
59             }
60             else
61             {
62                 appendPrimitive2DReferenceToPrimitive2DSequence(aRetval,
63                     createPolygonLinePrimitive(
64                         getUnitPolygon(),
65                         basegfx::B2DHomMatrix(),
66                         getSdrLSTAttribute().getLine(),
67                         getSdrLSTAttribute().getLineStartEnd()));
68             }
69 
70             // add text
71             if(!getSdrLSTAttribute().getText().isDefault())
72             {
73                 appendPrimitive2DReferenceToPrimitive2DSequence(aRetval,
74                     createTextPrimitive(
75                         basegfx::B2DPolyPolygon(getUnitPolygon()),
76                         basegfx::B2DHomMatrix(),
77                         getSdrLSTAttribute().getText(),
78                         getSdrLSTAttribute().getLine(),
79                         false,
80                         false,
81                         false));
82             }
83 
84             // add shadow
85             if(!getSdrLSTAttribute().getShadow().isDefault())
86             {
87                 aRetval = createEmbeddedShadowPrimitive(
88                     aRetval,
89                     getSdrLSTAttribute().getShadow());
90             }
91 
92             return aRetval;
93         }
94 
95         SdrConnectorPrimitive2D::SdrConnectorPrimitive2D(
96             const attribute::SdrLineShadowTextAttribute& rSdrLSTAttribute,
97             const ::basegfx::B2DPolygon& rUnitPolygon)
98         :   BufferedDecompositionPrimitive2D(),
99             maSdrLSTAttribute(rSdrLSTAttribute),
100             maUnitPolygon(rUnitPolygon)
101         {
102         }
103 
104         bool SdrConnectorPrimitive2D::operator==(const BasePrimitive2D& rPrimitive) const
105         {
106             if(BufferedDecompositionPrimitive2D::operator==(rPrimitive))
107             {
108                 const SdrConnectorPrimitive2D& rCompare = (SdrConnectorPrimitive2D&)rPrimitive;
109 
110                 return (getUnitPolygon() == rCompare.getUnitPolygon()
111                     && getSdrLSTAttribute() == rCompare.getSdrLSTAttribute());
112             }
113 
114             return false;
115         }
116 
117         // provide unique ID
118         ImplPrimitrive2DIDBlock(SdrConnectorPrimitive2D, PRIMITIVE2D_ID_SDRCONNECTORPRIMITIVE2D)
119 
120     } // end of namespace primitive2d
121 } // end of namespace drawinglayer
122 
123 //////////////////////////////////////////////////////////////////////////////
124 // eof
125