Version 6.4.0.3, tag libreoffice-6.4.0.3
[LibreOffice.git] / drawinglayer / source / primitive2d / shadowprimitive2d.cxx
blob78b15dbb2c6fd09d7910937dbc95476b86aa0999
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
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/utils/canvastools.hxx>
25 #include <drawinglayer/primitive2d/transparenceprimitive2d.hxx>
26 #include <drawinglayer/primitive2d/unifiedtransparenceprimitive2d.hxx>
27 #include <drawinglayer/primitive2d/drawinglayer_primitivetypes2d.hxx>
30 using namespace com::sun::star;
33 namespace drawinglayer
35 namespace primitive2d
37 ShadowPrimitive2D::ShadowPrimitive2D(
38 const basegfx::B2DHomMatrix& rShadowTransform,
39 const basegfx::BColor& rShadowColor,
40 const Primitive2DContainer& rChildren)
41 : GroupPrimitive2D(rChildren),
42 maShadowTransform(rShadowTransform),
43 maShadowColor(rShadowColor)
47 bool ShadowPrimitive2D::operator==(const BasePrimitive2D& rPrimitive) const
49 if(BasePrimitive2D::operator==(rPrimitive))
51 const ShadowPrimitive2D& rCompare = static_cast< const ShadowPrimitive2D& >(rPrimitive);
53 return (getShadowTransform() == rCompare.getShadowTransform()
54 && getShadowColor() == rCompare.getShadowColor());
57 return false;
60 basegfx::B2DRange ShadowPrimitive2D::getB2DRange(const geometry::ViewInformation2D& rViewInformation) const
62 basegfx::B2DRange aRetval(getChildren().getB2DRange(rViewInformation));
63 aRetval.transform(getShadowTransform());
64 return aRetval;
67 void ShadowPrimitive2D::get2DDecomposition(Primitive2DDecompositionVisitor& rVisitor, const geometry::ViewInformation2D& /*rViewInformation*/) const
69 if(!getChildren().empty())
71 // create a modifiedColorPrimitive containing the shadow color and the content
72 const basegfx::BColorModifierSharedPtr aBColorModifier(
73 new basegfx::BColorModifier_replace(
74 getShadowColor()));
75 const Primitive2DReference xRefA(
76 new ModifiedColorPrimitive2D(
77 getChildren(),
78 aBColorModifier));
79 const Primitive2DContainer aSequenceB { xRefA };
81 // build transformed primitiveVector with shadow offset and add to target
82 rVisitor.append(new TransformPrimitive2D(getShadowTransform(), aSequenceB));
86 // provide unique ID
87 ImplPrimitive2DIDBlock(ShadowPrimitive2D, PRIMITIVE2D_ID_SHADOWPRIMITIVE2D)
89 } // end of namespace primitive2d
90 } // end of namespace drawinglayer
92 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */