xref: /AOO41X/main/drawinglayer/source/primitive2d/shadowprimitive2d.cxx (revision 8809db7a87f97847b57a57f4cd2b0104b2b83182)
1 /**************************************************************
2  *
3  * Licensed to the Apache Software Foundation (ASF) under one
4  * or more contributor license agreements.  See the NOTICE file
5  * distributed with this work for additional information
6  * regarding copyright ownership.  The ASF licenses this file
7  * to you under the Apache License, Version 2.0 (the
8  * "License"); you may not use this file except in compliance
9  * with the License.  You may obtain a copy of the License at
10  *
11  *   http://www.apache.org/licenses/LICENSE-2.0
12  *
13  * Unless required by applicable law or agreed to in writing,
14  * software distributed under the License is distributed on an
15  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16  * KIND, either express or implied.  See the License for the
17  * specific language governing permissions and limitations
18  * under the License.
19  *
20  *************************************************************/
21 
22 
23 
24 // MARKER(update_precomp.py): autogen include statement, do not remove
25 #include "precompiled_drawinglayer.hxx"
26 
27 #include <drawinglayer/primitive2d/shadowprimitive2d.hxx>
28 #include <basegfx/color/bcolormodifier.hxx>
29 #include <drawinglayer/primitive2d/modifiedcolorprimitive2d.hxx>
30 #include <drawinglayer/primitive2d/transformprimitive2d.hxx>
31 #include <basegfx/tools/canvastools.hxx>
32 #include <drawinglayer/primitive2d/transparenceprimitive2d.hxx>
33 #include <drawinglayer/primitive2d/unifiedtransparenceprimitive2d.hxx>
34 #include <drawinglayer/primitive2d/drawinglayer_primitivetypes2d.hxx>
35 
36 //////////////////////////////////////////////////////////////////////////////
37 
38 using namespace com::sun::star;
39 
40 //////////////////////////////////////////////////////////////////////////////
41 
42 namespace drawinglayer
43 {
44     namespace primitive2d
45     {
46         ShadowPrimitive2D::ShadowPrimitive2D(
47             const basegfx::B2DHomMatrix& rShadowTransform,
48             const basegfx::BColor& rShadowColor,
49             const Primitive2DSequence& rChildren)
50         :   GroupPrimitive2D(rChildren),
51             maShadowTransform(rShadowTransform),
52             maShadowColor(rShadowColor)
53         {
54         }
55 
56         bool ShadowPrimitive2D::operator==(const BasePrimitive2D& rPrimitive) const
57         {
58             if(BasePrimitive2D::operator==(rPrimitive))
59             {
60                 const ShadowPrimitive2D& rCompare = static_cast< const ShadowPrimitive2D& >(rPrimitive);
61 
62                 return (getShadowTransform() == rCompare.getShadowTransform()
63                     && getShadowColor() == rCompare.getShadowColor());
64             }
65 
66             return false;
67         }
68 
69         basegfx::B2DRange ShadowPrimitive2D::getB2DRange(const geometry::ViewInformation2D& rViewInformation) const
70         {
71             basegfx::B2DRange aRetval(getB2DRangeFromPrimitive2DSequence(getChildren(), rViewInformation));
72             aRetval.transform(getShadowTransform());
73             return aRetval;
74         }
75 
76         Primitive2DSequence ShadowPrimitive2D::get2DDecomposition(const geometry::ViewInformation2D& /*rViewInformation*/) const
77         {
78             Primitive2DSequence aRetval;
79 
80             if(getChildren().hasElements())
81             {
82                 // create a modifiedColorPrimitive containing the shadow color and the content
83                 const basegfx::BColorModifier aBColorModifier(getShadowColor());
84                 const Primitive2DReference xRefA(new ModifiedColorPrimitive2D(getChildren(), aBColorModifier));
85                 const Primitive2DSequence aSequenceB(&xRefA, 1L);
86 
87                 // build transformed primitiveVector with shadow offset and add to target
88                 const Primitive2DReference xRefB(new TransformPrimitive2D(getShadowTransform(), aSequenceB));
89                 aRetval = Primitive2DSequence(&xRefB, 1L);
90             }
91 
92             return aRetval;
93         }
94 
95         // provide unique ID
96         ImplPrimitrive2DIDBlock(ShadowPrimitive2D, PRIMITIVE2D_ID_SHADOWPRIMITIVE2D)
97 
98     } // end of namespace primitive2d
99 } // end of namespace drawinglayer
100 
101 //////////////////////////////////////////////////////////////////////////////
102 // eof
103