1464702f4SAndrew Rist /**************************************************************
2cdf0e10cSrcweir  *
3464702f4SAndrew Rist  * Licensed to the Apache Software Foundation (ASF) under one
4464702f4SAndrew Rist  * or more contributor license agreements.  See the NOTICE file
5464702f4SAndrew Rist  * distributed with this work for additional information
6464702f4SAndrew Rist  * regarding copyright ownership.  The ASF licenses this file
7464702f4SAndrew Rist  * to you under the Apache License, Version 2.0 (the
8464702f4SAndrew Rist  * "License"); you may not use this file except in compliance
9464702f4SAndrew Rist  * with the License.  You may obtain a copy of the License at
10464702f4SAndrew Rist  *
11464702f4SAndrew Rist  *   http://www.apache.org/licenses/LICENSE-2.0
12464702f4SAndrew Rist  *
13464702f4SAndrew Rist  * Unless required by applicable law or agreed to in writing,
14464702f4SAndrew Rist  * software distributed under the License is distributed on an
15464702f4SAndrew Rist  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16464702f4SAndrew Rist  * KIND, either express or implied.  See the License for the
17464702f4SAndrew Rist  * specific language governing permissions and limitations
18464702f4SAndrew Rist  * under the License.
19464702f4SAndrew Rist  *
20464702f4SAndrew Rist  *************************************************************/
21464702f4SAndrew Rist 
22464702f4SAndrew Rist 
23cdf0e10cSrcweir 
24cdf0e10cSrcweir // MARKER(update_precomp.py): autogen include statement, do not remove
25cdf0e10cSrcweir #include "precompiled_drawinglayer.hxx"
26cdf0e10cSrcweir 
27cdf0e10cSrcweir #include <drawinglayer/primitive2d/shadowprimitive2d.hxx>
28cdf0e10cSrcweir #include <basegfx/color/bcolormodifier.hxx>
29cdf0e10cSrcweir #include <drawinglayer/primitive2d/modifiedcolorprimitive2d.hxx>
30cdf0e10cSrcweir #include <drawinglayer/primitive2d/transformprimitive2d.hxx>
31cdf0e10cSrcweir #include <basegfx/tools/canvastools.hxx>
32cdf0e10cSrcweir #include <drawinglayer/primitive2d/transparenceprimitive2d.hxx>
33cdf0e10cSrcweir #include <drawinglayer/primitive2d/unifiedtransparenceprimitive2d.hxx>
34cdf0e10cSrcweir #include <drawinglayer/primitive2d/drawinglayer_primitivetypes2d.hxx>
35cdf0e10cSrcweir 
36cdf0e10cSrcweir //////////////////////////////////////////////////////////////////////////////
37cdf0e10cSrcweir 
38cdf0e10cSrcweir using namespace com::sun::star;
39cdf0e10cSrcweir 
40cdf0e10cSrcweir //////////////////////////////////////////////////////////////////////////////
41cdf0e10cSrcweir 
42cdf0e10cSrcweir namespace drawinglayer
43cdf0e10cSrcweir {
44cdf0e10cSrcweir 	namespace primitive2d
45cdf0e10cSrcweir 	{
ShadowPrimitive2D(const basegfx::B2DHomMatrix & rShadowTransform,const basegfx::BColor & rShadowColor,const Primitive2DSequence & rChildren)46cdf0e10cSrcweir 		ShadowPrimitive2D::ShadowPrimitive2D(
47cdf0e10cSrcweir 			const basegfx::B2DHomMatrix& rShadowTransform,
48cdf0e10cSrcweir 			const basegfx::BColor& rShadowColor,
49cdf0e10cSrcweir 			const Primitive2DSequence& rChildren)
50cdf0e10cSrcweir 		:	GroupPrimitive2D(rChildren),
51cdf0e10cSrcweir 			maShadowTransform(rShadowTransform),
52cdf0e10cSrcweir 			maShadowColor(rShadowColor)
53cdf0e10cSrcweir 		{
54cdf0e10cSrcweir 		}
55cdf0e10cSrcweir 
operator ==(const BasePrimitive2D & rPrimitive) const56cdf0e10cSrcweir 		bool ShadowPrimitive2D::operator==(const BasePrimitive2D& rPrimitive) const
57cdf0e10cSrcweir 		{
58cdf0e10cSrcweir 			if(BasePrimitive2D::operator==(rPrimitive))
59cdf0e10cSrcweir 			{
60cdf0e10cSrcweir 				const ShadowPrimitive2D& rCompare = static_cast< const ShadowPrimitive2D& >(rPrimitive);
61cdf0e10cSrcweir 
62cdf0e10cSrcweir 				return (getShadowTransform() == rCompare.getShadowTransform()
63cdf0e10cSrcweir 					&& getShadowColor() == rCompare.getShadowColor());
64cdf0e10cSrcweir 			}
65cdf0e10cSrcweir 
66cdf0e10cSrcweir 			return false;
67cdf0e10cSrcweir 		}
68cdf0e10cSrcweir 
getB2DRange(const geometry::ViewInformation2D & rViewInformation) const69cdf0e10cSrcweir 		basegfx::B2DRange ShadowPrimitive2D::getB2DRange(const geometry::ViewInformation2D& rViewInformation) const
70cdf0e10cSrcweir 		{
71cdf0e10cSrcweir 			basegfx::B2DRange aRetval(getB2DRangeFromPrimitive2DSequence(getChildren(), rViewInformation));
72cdf0e10cSrcweir 			aRetval.transform(getShadowTransform());
73cdf0e10cSrcweir 			return aRetval;
74cdf0e10cSrcweir 		}
75cdf0e10cSrcweir 
get2DDecomposition(const geometry::ViewInformation2D &) const76cdf0e10cSrcweir 		Primitive2DSequence ShadowPrimitive2D::get2DDecomposition(const geometry::ViewInformation2D& /*rViewInformation*/) const
77cdf0e10cSrcweir 		{
78cdf0e10cSrcweir 			Primitive2DSequence aRetval;
79cdf0e10cSrcweir 
80*49c58f9bSArmin Le Grand             if(getChildren().hasElements())
81*49c58f9bSArmin Le Grand             {
82*49c58f9bSArmin Le Grand                 // create a modifiedColorPrimitive containing the shadow color and the content
83*49c58f9bSArmin Le Grand                 const basegfx::BColorModifierSharedPtr aBColorModifier(
84*49c58f9bSArmin Le Grand                     new basegfx::BColorModifier_replace(
85*49c58f9bSArmin Le Grand                         getShadowColor()));
86*49c58f9bSArmin Le Grand                 const Primitive2DReference xRefA(
87*49c58f9bSArmin Le Grand                     new ModifiedColorPrimitive2D(
88*49c58f9bSArmin Le Grand                         getChildren(),
89*49c58f9bSArmin Le Grand                         aBColorModifier));
90*49c58f9bSArmin Le Grand                 const Primitive2DSequence aSequenceB(&xRefA, 1L);
91*49c58f9bSArmin Le Grand 
92*49c58f9bSArmin Le Grand                 // build transformed primitiveVector with shadow offset and add to target
93*49c58f9bSArmin Le Grand                 const Primitive2DReference xRefB(new TransformPrimitive2D(getShadowTransform(), aSequenceB));
94*49c58f9bSArmin Le Grand                 aRetval = Primitive2DSequence(&xRefB, 1L);
95*49c58f9bSArmin Le Grand             }
96cdf0e10cSrcweir 
97cdf0e10cSrcweir 			return aRetval;
98cdf0e10cSrcweir 		}
99cdf0e10cSrcweir 
100cdf0e10cSrcweir 		// provide unique ID
101cdf0e10cSrcweir 		ImplPrimitrive2DIDBlock(ShadowPrimitive2D, PRIMITIVE2D_ID_SHADOWPRIMITIVE2D)
102cdf0e10cSrcweir 
103cdf0e10cSrcweir 	} // end of namespace primitive2d
104cdf0e10cSrcweir } // end of namespace drawinglayer
105cdf0e10cSrcweir 
106cdf0e10cSrcweir //////////////////////////////////////////////////////////////////////////////
107cdf0e10cSrcweir // eof
108