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/PolyPolygonColorPrimitive2D.hxx>
22 #include <basegfx/polygon/b2dpolypolygontools.hxx>
23 #include <basegfx/polygon/b2dpolygontools.hxx>
24 #include <drawinglayer/primitive2d/drawinglayer_primitivetypes2d.hxx>
27 using namespace com::sun::star
;
29 namespace drawinglayer::primitive2d
31 PolyPolygonColorPrimitive2D::PolyPolygonColorPrimitive2D(basegfx::B2DPolyPolygon aPolyPolygon
,
32 const basegfx::BColor
& rBColor
)
33 : maPolyPolygon(std::move(aPolyPolygon
))
38 bool PolyPolygonColorPrimitive2D::operator==(const BasePrimitive2D
& rPrimitive
) const
40 if (BasePrimitive2D::operator==(rPrimitive
))
42 const PolyPolygonColorPrimitive2D
& rCompare
43 = static_cast<const PolyPolygonColorPrimitive2D
&>(rPrimitive
);
45 return (getB2DPolyPolygon() == rCompare
.getB2DPolyPolygon()
46 && getBColor() == rCompare
.getBColor());
52 basegfx::B2DRange
PolyPolygonColorPrimitive2D::getB2DRange(
53 const geometry::ViewInformation2D
& /*rViewInformation*/) const
56 return basegfx::utils::getRange(getB2DPolyPolygon());
60 sal_uInt32
PolyPolygonColorPrimitive2D::getPrimitive2DID() const
62 return PRIMITIVE2D_ID_POLYPOLYGONCOLORPRIMITIVE2D
;
65 FilledRectanglePrimitive2D::FilledRectanglePrimitive2D(const basegfx::B2DRange
& rB2DRange
,
66 const basegfx::BColor
& rBColor
)
68 , maB2DRange(rB2DRange
)
73 bool FilledRectanglePrimitive2D::operator==(const BasePrimitive2D
& rPrimitive
) const
75 if (BasePrimitive2D::operator==(rPrimitive
))
77 const FilledRectanglePrimitive2D
& rCompare(
78 static_cast<const FilledRectanglePrimitive2D
&>(rPrimitive
));
80 return (getB2DRange() == rCompare
.getB2DRange() && getBColor() == rCompare
.getBColor());
86 basegfx::B2DRange
FilledRectanglePrimitive2D::getB2DRange(
87 const geometry::ViewInformation2D
& /*rViewInformation*/) const
92 sal_uInt32
FilledRectanglePrimitive2D::getPrimitive2DID() const
94 return PRIMITIVE2D_ID_FILLEDRECTANGLEPRIMITIVE2D
;
97 void FilledRectanglePrimitive2D::get2DDecomposition(
98 Primitive2DDecompositionVisitor
& rVisitor
,
99 const geometry::ViewInformation2D
& /*rViewInformation*/) const
101 if (getB2DRange().isEmpty())
107 const basegfx::B2DPolygon
aPolygon(basegfx::utils::createPolygonFromRect(getB2DRange()));
108 Primitive2DContainer aSequence
109 = { new PolyPolygonColorPrimitive2D(basegfx::B2DPolyPolygon(aPolygon
), getBColor()) };
110 rVisitor
.visit(aSequence
);
113 } // end drawinglayer::primitive2d namespace
115 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */