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/PolyPolygonRGBAPrimitive2D.hxx>
21 #include <basegfx/polygon/b2dpolypolygon.hxx>
22 #include <basegfx/polygon/b2dpolypolygontools.hxx>
23 #include <drawinglayer/primitive2d/PolyPolygonColorPrimitive2D.hxx>
24 #include <drawinglayer/primitive2d/unifiedtransparenceprimitive2d.hxx>
25 #include <drawinglayer/geometry/viewinformation2d.hxx>
26 #include <drawinglayer/primitive2d/drawinglayer_primitivetypes2d.hxx>
28 using namespace com::sun::star
;
30 namespace drawinglayer::primitive2d
32 Primitive2DReference
PolyPolygonRGBAPrimitive2D::create2DDecomposition(
33 const geometry::ViewInformation2D
& /*rViewInformation*/) const
35 if (basegfx::fTools::equal(getTransparency(), 1.0))
37 // completely transparent, done
41 if (0 == getB2DPolyPolygon().count())
47 if (basegfx::fTools::equalZero(getTransparency()))
49 // no transparency, use simple PolyPolygonColorPrimitive2D
50 return Primitive2DReference
{ new PolyPolygonColorPrimitive2D(getB2DPolyPolygon(),
54 // default: embed to UnifiedTransparencePrimitive2D
55 Primitive2DContainer aContent
{ new PolyPolygonColorPrimitive2D(getB2DPolyPolygon(),
57 return Primitive2DReference
{ new UnifiedTransparencePrimitive2D(std::move(aContent
),
61 PolyPolygonRGBAPrimitive2D::PolyPolygonRGBAPrimitive2D(const basegfx::B2DPolyPolygon
& rPolyPolygon
,
62 const basegfx::BColor
& rBColor
,
64 : maPolyPolygon(rPolyPolygon
)
66 , mfTransparency(std::max(0.0, std::min(1.0, fTransparency
)))
70 bool PolyPolygonRGBAPrimitive2D::operator==(const BasePrimitive2D
& rPrimitive
) const
72 if (BufferedDecompositionPrimitive2D::operator==(rPrimitive
))
74 const PolyPolygonRGBAPrimitive2D
& rCompare
75 = static_cast<const PolyPolygonRGBAPrimitive2D
&>(rPrimitive
);
77 return (getB2DPolyPolygon() == rCompare
.getB2DPolyPolygon()
78 && getBColor() == rCompare
.getBColor()
79 && basegfx::fTools::equal(getTransparency(), rCompare
.getTransparency()));
85 basegfx::B2DRange
PolyPolygonRGBAPrimitive2D::getB2DRange(
86 const geometry::ViewInformation2D
& /*rViewInformation*/) const
88 // return range - without decompose
89 return basegfx::utils::getRange(getB2DPolyPolygon());
93 sal_uInt32
PolyPolygonRGBAPrimitive2D::getPrimitive2DID() const
95 return PRIMITIVE2D_ID_POLYPOLYGONRGBAPRIMITIVE2D
;
99 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */