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 // MARKER(update_precomp.py): autogen include statement, do not remove
29 #include "precompiled_drawinglayer.hxx"
30 
31 #include <drawinglayer/primitive2d/shadowprimitive2d.hxx>
32 #include <basegfx/color/bcolormodifier.hxx>
33 #include <drawinglayer/primitive2d/modifiedcolorprimitive2d.hxx>
34 #include <drawinglayer/primitive2d/transformprimitive2d.hxx>
35 #include <basegfx/tools/canvastools.hxx>
36 #include <drawinglayer/primitive2d/transparenceprimitive2d.hxx>
37 #include <drawinglayer/primitive2d/unifiedtransparenceprimitive2d.hxx>
38 #include <drawinglayer/primitive2d/drawinglayer_primitivetypes2d.hxx>
39 
40 //////////////////////////////////////////////////////////////////////////////
41 
42 using namespace com::sun::star;
43 
44 //////////////////////////////////////////////////////////////////////////////
45 
46 namespace drawinglayer
47 {
48 	namespace primitive2d
49 	{
50 		ShadowPrimitive2D::ShadowPrimitive2D(
51 			const basegfx::B2DHomMatrix& rShadowTransform,
52 			const basegfx::BColor& rShadowColor,
53 			const Primitive2DSequence& rChildren)
54 		:	GroupPrimitive2D(rChildren),
55 			maShadowTransform(rShadowTransform),
56 			maShadowColor(rShadowColor)
57 		{
58 		}
59 
60 		bool ShadowPrimitive2D::operator==(const BasePrimitive2D& rPrimitive) const
61 		{
62 			if(BasePrimitive2D::operator==(rPrimitive))
63 			{
64 				const ShadowPrimitive2D& rCompare = static_cast< const ShadowPrimitive2D& >(rPrimitive);
65 
66 				return (getShadowTransform() == rCompare.getShadowTransform()
67 					&& getShadowColor() == rCompare.getShadowColor());
68 			}
69 
70 			return false;
71 		}
72 
73 		basegfx::B2DRange ShadowPrimitive2D::getB2DRange(const geometry::ViewInformation2D& rViewInformation) const
74 		{
75 			basegfx::B2DRange aRetval(getB2DRangeFromPrimitive2DSequence(getChildren(), rViewInformation));
76 			aRetval.transform(getShadowTransform());
77 			return aRetval;
78 		}
79 
80 		Primitive2DSequence ShadowPrimitive2D::get2DDecomposition(const geometry::ViewInformation2D& /*rViewInformation*/) const
81 		{
82 			Primitive2DSequence aRetval;
83 
84 			if(getChildren().hasElements())
85 			{
86 				// create a modifiedColorPrimitive containing the shadow color and the content
87 				const basegfx::BColorModifier aBColorModifier(getShadowColor());
88 				const Primitive2DReference xRefA(new ModifiedColorPrimitive2D(getChildren(), aBColorModifier));
89 				const Primitive2DSequence aSequenceB(&xRefA, 1L);
90 
91 				// build transformed primitiveVector with shadow offset and add to target
92 				const Primitive2DReference xRefB(new TransformPrimitive2D(getShadowTransform(), aSequenceB));
93 				aRetval = Primitive2DSequence(&xRefB, 1L);
94 			}
95 
96 			return aRetval;
97 		}
98 
99 		// provide unique ID
100 		ImplPrimitrive2DIDBlock(ShadowPrimitive2D, PRIMITIVE2D_ID_SHADOWPRIMITIVE2D)
101 
102 	} // end of namespace primitive2d
103 } // end of namespace drawinglayer
104 
105 //////////////////////////////////////////////////////////////////////////////
106 // eof
107