1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: sdrconnectorprimitive2d.cxx,v $
11 * $Revision: 1.2.18.1 $
13 * This file is part of OpenOffice.org.
15 * OpenOffice.org is free software: you can redistribute it and/or modify
16 * it under the terms of the GNU Lesser General Public License version 3
17 * only, as published by the Free Software Foundation.
19 * OpenOffice.org is distributed in the hope that it will be useful,
20 * but WITHOUT ANY WARRANTY; without even the implied warranty of
21 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
22 * GNU Lesser General Public License version 3 for more details
23 * (a copy is included in the LICENSE file that accompanied this code).
25 * You should have received a copy of the GNU Lesser General Public License
26 * version 3 along with OpenOffice.org. If not, see
27 * <http://www.openoffice.org/license.html>
28 * for a copy of the LGPLv3 License.
30 ************************************************************************/
32 #include "precompiled_svx.hxx"
33 #include <svx/sdr/primitive2d/sdrconnectorprimitive2d.hxx>
34 #include <svx/sdr/primitive2d/sdrdecompositiontools.hxx>
35 #include <basegfx/matrix/b2dhommatrix.hxx>
36 #include <drawinglayer/primitive2d/groupprimitive2d.hxx>
37 #include <svx/sdr/primitive2d/svx_primitivetypes2d.hxx>
38 #include <drawinglayer/primitive2d/hittestprimitive2d.hxx>
40 //////////////////////////////////////////////////////////////////////////////
42 using namespace com::sun::star
;
44 //////////////////////////////////////////////////////////////////////////////
46 namespace drawinglayer
50 Primitive2DSequence
SdrConnectorPrimitive2D::createLocalDecomposition(const geometry::ViewInformation2D
& /*aViewInformation*/) const
52 Primitive2DSequence aRetval
;
54 // prepare unit transform
55 ::basegfx::B2DHomMatrix aEmptyMatrix
;
58 if(getSdrLSTAttribute().getLine())
60 appendPrimitive2DReferenceToPrimitive2DSequence(aRetval
, createPolygonLinePrimitive(getUnitPolygon(), aEmptyMatrix
, *getSdrLSTAttribute().getLine(), getSdrLSTAttribute().getLineStartEnd()));
64 // if initially no line is defined, create one for HitTest and BoundRect
65 const attribute::SdrLineAttribute
aBlackHairline(basegfx::BColor(0.0, 0.0, 0.0));
66 const Primitive2DReference
xHiddenLineReference(createPolygonLinePrimitive(getUnitPolygon(), aEmptyMatrix
, aBlackHairline
));
67 const Primitive2DSequence
xHiddenLineSequence(&xHiddenLineReference
, 1);
69 appendPrimitive2DReferenceToPrimitive2DSequence(aRetval
, Primitive2DReference(new HitTestPrimitive2D(xHiddenLineSequence
)));
73 if(getSdrLSTAttribute().getText())
75 appendPrimitive2DReferenceToPrimitive2DSequence(aRetval
, createTextPrimitive(::basegfx::B2DPolyPolygon(getUnitPolygon()), aEmptyMatrix
, *getSdrLSTAttribute().getText(), getSdrLSTAttribute().getLine(), false, false));
79 if(getSdrLSTAttribute().getShadow())
81 aRetval
= createEmbeddedShadowPrimitive(aRetval
, *getSdrLSTAttribute().getShadow());
87 SdrConnectorPrimitive2D::SdrConnectorPrimitive2D(
88 const attribute::SdrLineShadowTextAttribute
& rSdrLSTAttribute
,
89 const ::basegfx::B2DPolygon
& rUnitPolygon
)
91 maSdrLSTAttribute(rSdrLSTAttribute
),
92 maUnitPolygon(rUnitPolygon
)
96 bool SdrConnectorPrimitive2D::operator==(const BasePrimitive2D
& rPrimitive
) const
98 if(BasePrimitive2D::operator==(rPrimitive
))
100 const SdrConnectorPrimitive2D
& rCompare
= (SdrConnectorPrimitive2D
&)rPrimitive
;
102 return (getUnitPolygon() == rCompare
.getUnitPolygon()
103 && getSdrLSTAttribute() == rCompare
.getSdrLSTAttribute());
110 ImplPrimitrive2DIDBlock(SdrConnectorPrimitive2D
, PRIMITIVE2D_ID_SDRCONNECTORPRIMITIVE2D
)
112 } // end of namespace primitive2d
113 } // end of namespace drawinglayer
115 //////////////////////////////////////////////////////////////////////////////