1 /*************************************************************************
3 * OpenOffice.org - a multi-platform office productivity suite
5 * $RCSfile: shadowprimitive2d.cxx,v $
9 * last change: $Author: aw $ $Date: 2008-05-27 14:11:20 $
11 * The Contents of this file are made available subject to
12 * the terms of GNU Lesser General Public License Version 2.1.
15 * GNU Lesser General Public License Version 2.1
16 * =============================================
17 * Copyright 2005 by Sun Microsystems, Inc.
18 * 901 San Antonio Road, Palo Alto, CA 94303, USA
20 * This library is free software; you can redistribute it and/or
21 * modify it under the terms of the GNU Lesser General Public
22 * License version 2.1, as published by the Free Software Foundation.
24 * This library is distributed in the hope that it will be useful,
25 * but WITHOUT ANY WARRANTY; without even the implied warranty of
26 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
27 * Lesser General Public License for more details.
29 * You should have received a copy of the GNU Lesser General Public
30 * License along with this library; if not, write to the Free Software
31 * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
34 ************************************************************************/
36 // MARKER(update_precomp.py): autogen include statement, do not remove
37 #include "precompiled_drawinglayer.hxx"
39 #include <drawinglayer/primitive2d/shadowprimitive2d.hxx>
40 #include <basegfx/color/bcolormodifier.hxx>
41 #include <drawinglayer/primitive2d/modifiedcolorprimitive2d.hxx>
42 #include <drawinglayer/primitive2d/transformprimitive2d.hxx>
43 #include <basegfx/tools/canvastools.hxx>
44 #include <drawinglayer/primitive2d/alphaprimitive2d.hxx>
45 #include <drawinglayer/primitive2d/unifiedalphaprimitive2d.hxx>
46 #include <drawinglayer/primitive2d/drawinglayer_primitivetypes2d.hxx>
48 //////////////////////////////////////////////////////////////////////////////
50 using namespace com::sun::star
;
52 //////////////////////////////////////////////////////////////////////////////
54 namespace drawinglayer
58 Primitive2DSequence
ShadowPrimitive2D::createLocalDecomposition(const geometry::ViewInformation2D
& /*rViewInformation*/) const
60 Primitive2DSequence aRetval
;
62 if(getChildren().hasElements())
64 // create a modifiedColorPrimitive containing the shadow color and the content
65 const basegfx::BColorModifier
aBColorModifier(getShadowColor());
66 const Primitive2DReference
xRefA(new ModifiedColorPrimitive2D(getChildren(), aBColorModifier
));
67 const Primitive2DSequence
aSequenceB(&xRefA
, 1L);
69 // build transformed primitiveVector with shadow offset and add to target
70 const Primitive2DReference
xRefB(new TransformPrimitive2D(getShadowTransform(), aSequenceB
));
71 aRetval
= Primitive2DSequence(&xRefB
, 1L);
77 ShadowPrimitive2D::ShadowPrimitive2D(
78 const basegfx::B2DHomMatrix
& rShadowTransform
,
79 const basegfx::BColor
& rShadowColor
,
80 const Primitive2DSequence
& rChildren
)
81 : GroupPrimitive2D(rChildren
),
82 maShadowTransform(rShadowTransform
),
83 maShadowColor(rShadowColor
)
87 bool ShadowPrimitive2D::operator==(const BasePrimitive2D
& rPrimitive
) const
89 if(GroupPrimitive2D::operator==(rPrimitive
))
91 const ShadowPrimitive2D
& rCompare
= static_cast< const ShadowPrimitive2D
& >(rPrimitive
);
93 return (getShadowTransform() == rCompare
.getShadowTransform()
94 && getShadowColor() == rCompare
.getShadowColor());
100 basegfx::B2DRange
ShadowPrimitive2D::getB2DRange(const geometry::ViewInformation2D
& rViewInformation
) const
102 basegfx::B2DRange
aRetval(getB2DRangeFromPrimitive2DSequence(getChildren(), rViewInformation
));
103 aRetval
.transform(getShadowTransform());
108 ImplPrimitrive2DIDBlock(ShadowPrimitive2D
, PRIMITIVE2D_ID_SHADOWPRIMITIVE2D
)
110 } // end of namespace primitive2d
111 } // end of namespace drawinglayer
113 //////////////////////////////////////////////////////////////////////////////