1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
3 * This file is part of the LibreOffice project.
5 * This Source Code Form is subject to the terms of the Mozilla Public
6 * License, v. 2.0. If a copy of the MPL was not distributed with this
7 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
9 * This file incorporates work covered by the following license notice:
11 * Licensed to the Apache Software Foundation (ASF) under one or more
12 * contributor license agreements. See the NOTICE file distributed
13 * with this work for additional information regarding copyright
14 * ownership. The ASF licenses this file to you under the Apache
15 * License, Version 2.0 (the "License"); you may not use this file
16 * except in compliance with the License. You may obtain a copy of
17 * the License at http://www.apache.org/licenses/LICENSE-2.0 .
20 #include <drawinglayer/primitive2d/shadowprimitive2d.hxx>
21 #include <basegfx/color/bcolormodifier.hxx>
22 #include <drawinglayer/primitive2d/modifiedcolorprimitive2d.hxx>
23 #include <drawinglayer/primitive2d/transformprimitive2d.hxx>
24 #include <basegfx/tools/canvastools.hxx>
25 #include <drawinglayer/primitive2d/transparenceprimitive2d.hxx>
26 #include <drawinglayer/primitive2d/unifiedtransparenceprimitive2d.hxx>
27 #include <drawinglayer/primitive2d/drawinglayer_primitivetypes2d.hxx>
29 //////////////////////////////////////////////////////////////////////////////
31 using namespace com::sun::star
;
33 //////////////////////////////////////////////////////////////////////////////
35 namespace drawinglayer
39 ShadowPrimitive2D::ShadowPrimitive2D(
40 const basegfx::B2DHomMatrix
& rShadowTransform
,
41 const basegfx::BColor
& rShadowColor
,
42 const Primitive2DSequence
& rChildren
)
43 : GroupPrimitive2D(rChildren
),
44 maShadowTransform(rShadowTransform
),
45 maShadowColor(rShadowColor
)
49 bool ShadowPrimitive2D::operator==(const BasePrimitive2D
& rPrimitive
) const
51 if(BasePrimitive2D::operator==(rPrimitive
))
53 const ShadowPrimitive2D
& rCompare
= static_cast< const ShadowPrimitive2D
& >(rPrimitive
);
55 return (getShadowTransform() == rCompare
.getShadowTransform()
56 && getShadowColor() == rCompare
.getShadowColor());
62 basegfx::B2DRange
ShadowPrimitive2D::getB2DRange(const geometry::ViewInformation2D
& rViewInformation
) const
64 basegfx::B2DRange
aRetval(getB2DRangeFromPrimitive2DSequence(getChildren(), rViewInformation
));
65 aRetval
.transform(getShadowTransform());
69 Primitive2DSequence
ShadowPrimitive2D::get2DDecomposition(const geometry::ViewInformation2D
& /*rViewInformation*/) const
71 Primitive2DSequence aRetval
;
73 if(getChildren().hasElements())
75 // create a modifiedColorPrimitive containing the shadow color and the content
76 const basegfx::BColorModifier
aBColorModifier(getShadowColor());
77 const Primitive2DReference
xRefA(new ModifiedColorPrimitive2D(getChildren(), aBColorModifier
));
78 const Primitive2DSequence
aSequenceB(&xRefA
, 1L);
80 // build transformed primitiveVector with shadow offset and add to target
81 const Primitive2DReference
xRefB(new TransformPrimitive2D(getShadowTransform(), aSequenceB
));
82 aRetval
= Primitive2DSequence(&xRefB
, 1L);
89 ImplPrimitive2DIDBlock(ShadowPrimitive2D
, PRIMITIVE2D_ID_SHADOWPRIMITIVE2D
)
91 } // end of namespace primitive2d
92 } // end of namespace drawinglayer
94 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */