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: sdrpathprimitive2d.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/sdrpathprimitive2d.hxx>
34 #include <svx/sdr/primitive2d/sdrdecompositiontools.hxx>
35 #include <basegfx/polygon/b2dpolypolygontools.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
SdrPathPrimitive2D::createLocalDecomposition(const geometry::ViewInformation2D
& /*aViewInformation*/) const
52 Primitive2DSequence aRetval
;
55 if(getSdrLFSTAttribute().getFill() && getUnitPolyPolygon().isClosed())
57 // take care for orientations
58 basegfx::B2DPolyPolygon
aOrientedUnitPolyPolygon(basegfx::tools::correctOrientations(getUnitPolyPolygon()));
60 appendPrimitive2DReferenceToPrimitive2DSequence(aRetval
, createPolyPolygonFillPrimitive(aOrientedUnitPolyPolygon
, getTransform(), *getSdrLFSTAttribute().getFill(), getSdrLFSTAttribute().getFillFloatTransGradient()));
64 if(getSdrLFSTAttribute().getLine())
66 Primitive2DSequence
aTemp(getUnitPolyPolygon().count());
68 for(sal_uInt32
a(0L); a
< getUnitPolyPolygon().count(); a
++)
70 aTemp
[a
] = createPolygonLinePrimitive(getUnitPolyPolygon().getB2DPolygon(a
), getTransform(), *getSdrLFSTAttribute().getLine(), getSdrLFSTAttribute().getLineStartEnd());
73 appendPrimitive2DSequenceToPrimitive2DSequence(aRetval
, aTemp
);
77 // if initially no line is defined, create one for HitTest and BoundRect
78 const attribute::SdrLineAttribute
aBlackHairline(basegfx::BColor(0.0, 0.0, 0.0));
79 Primitive2DSequence
xHiddenLineSequence(getUnitPolyPolygon().count());
81 for(sal_uInt32
a(0); a
< getUnitPolyPolygon().count(); a
++)
83 xHiddenLineSequence
[a
] = createPolygonLinePrimitive(getUnitPolyPolygon().getB2DPolygon(a
), getTransform(), aBlackHairline
);
86 appendPrimitive2DReferenceToPrimitive2DSequence(aRetval
, Primitive2DReference(new HitTestPrimitive2D(xHiddenLineSequence
)));
90 if(getSdrLFSTAttribute().getText())
92 appendPrimitive2DReferenceToPrimitive2DSequence(aRetval
, createTextPrimitive(getUnitPolyPolygon(), getTransform(), *getSdrLFSTAttribute().getText(), getSdrLFSTAttribute().getLine(), false, false));
96 if(getSdrLFSTAttribute().getShadow())
98 aRetval
= createEmbeddedShadowPrimitive(aRetval
, *getSdrLFSTAttribute().getShadow());
104 SdrPathPrimitive2D::SdrPathPrimitive2D(
105 const basegfx::B2DHomMatrix
& rTransform
,
106 const attribute::SdrLineFillShadowTextAttribute
& rSdrLFSTAttribute
,
107 const basegfx::B2DPolyPolygon
& rUnitPolyPolygon
)
109 maTransform(rTransform
),
110 maSdrLFSTAttribute(rSdrLFSTAttribute
),
111 maUnitPolyPolygon(rUnitPolyPolygon
)
115 bool SdrPathPrimitive2D::operator==(const BasePrimitive2D
& rPrimitive
) const
117 if(BasePrimitive2D::operator==(rPrimitive
))
119 const SdrPathPrimitive2D
& rCompare
= (SdrPathPrimitive2D
&)rPrimitive
;
121 return (getUnitPolyPolygon() == rCompare
.getUnitPolyPolygon()
122 && getTransform() == rCompare
.getTransform()
123 && getSdrLFSTAttribute() == rCompare
.getSdrLFSTAttribute());
130 ImplPrimitrive2DIDBlock(SdrPathPrimitive2D
, PRIMITIVE2D_ID_SDRPATHPRIMITIVE2D
)
132 } // end of namespace primitive2d
133 } // end of namespace drawinglayer
135 //////////////////////////////////////////////////////////////////////////////