cool#10610 Ensure the parent-child relations of comments.
[LibreOffice.git] / drawinglayer / source / primitive2d / PolyPolygonRGBAPrimitive2D.cxx
blobfb230af8712e637c81fd33a335b534df2b03cc2f
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/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
38 return nullptr;
41 if (0 == getB2DPolyPolygon().count())
43 // no geometry, done
44 return nullptr;
47 if (basegfx::fTools::equalZero(getTransparency()))
49 // no transparency, use simple PolyPolygonColorPrimitive2D
50 return Primitive2DReference{ new PolyPolygonColorPrimitive2D(getB2DPolyPolygon(),
51 getBColor()) };
54 // default: embed to UnifiedTransparencePrimitive2D
55 Primitive2DContainer aContent{ new PolyPolygonColorPrimitive2D(getB2DPolyPolygon(),
56 getBColor()) };
57 return Primitive2DReference{ new UnifiedTransparencePrimitive2D(std::move(aContent),
58 getTransparency()) };
61 PolyPolygonRGBAPrimitive2D::PolyPolygonRGBAPrimitive2D(const basegfx::B2DPolyPolygon& rPolyPolygon,
62 const basegfx::BColor& rBColor,
63 double fTransparency)
64 : maPolyPolygon(rPolyPolygon)
65 , maBColor(rBColor)
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()));
82 return false;
85 basegfx::B2DRange PolyPolygonRGBAPrimitive2D::getB2DRange(
86 const geometry::ViewInformation2D& /*rViewInformation*/) const
88 // return range - without decompose
89 return basegfx::utils::getRange(getB2DPolyPolygon());
92 // provide unique ID
93 sal_uInt32 PolyPolygonRGBAPrimitive2D::getPrimitive2DID() const
95 return PRIMITIVE2D_ID_POLYPOLYGONRGBAPRIMITIVE2D;
97 } // end of namespace
99 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */