cool#10610 Ensure the parent-child relations of comments.
[LibreOffice.git] / drawinglayer / source / primitive2d / PolyPolygonColorPrimitive2D.cxx
blob6c7cf4bb365a9aec86abed5b300f95d025ac7a9b
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/PolyPolygonColorPrimitive2D.hxx>
22 #include <basegfx/polygon/b2dpolypolygontools.hxx>
23 #include <basegfx/polygon/b2dpolygontools.hxx>
24 #include <drawinglayer/primitive2d/drawinglayer_primitivetypes2d.hxx>
25 #include <utility>
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))
34 , maBColor(rBColor)
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());
49 return false;
52 basegfx::B2DRange PolyPolygonColorPrimitive2D::getB2DRange(
53 const geometry::ViewInformation2D& /*rViewInformation*/) const
55 // return range
56 return basegfx::utils::getRange(getB2DPolyPolygon());
59 // provide unique ID
60 sal_uInt32 PolyPolygonColorPrimitive2D::getPrimitive2DID() const
62 return PRIMITIVE2D_ID_POLYPOLYGONCOLORPRIMITIVE2D;
65 FilledRectanglePrimitive2D::FilledRectanglePrimitive2D(const basegfx::B2DRange& rB2DRange,
66 const basegfx::BColor& rBColor)
67 : BasePrimitive2D()
68 , maB2DRange(rB2DRange)
69 , maBColor(rBColor)
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());
83 return false;
86 basegfx::B2DRange FilledRectanglePrimitive2D::getB2DRange(
87 const geometry::ViewInformation2D& /*rViewInformation*/) const
89 return getB2DRange();
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())
103 // no geometry, done
104 return;
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: */