calc: on editing invalidation of view with different zoom is wrong
[LibreOffice.git] / drawinglayer / source / primitive2d / PolyPolygonGradientPrimitive2D.cxx
blobc6e700f28fe395bedd4ce341ba2fb4e52acd1dfd
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/PolyPolygonGradientPrimitive2D.hxx>
22 #include <drawinglayer/primitive2d/drawinglayer_primitivetypes2d.hxx>
23 #include <drawinglayer/primitive2d/fillgradientprimitive2d.hxx>
24 #include <drawinglayer/primitive2d/maskprimitive2d.hxx>
25 #include <rtl/ref.hxx>
26 #include <utility>
28 using namespace com::sun::star;
30 namespace drawinglayer::primitive2d
32 void PolyPolygonGradientPrimitive2D::create2DDecomposition(
33 Primitive2DContainer& rContainer, const geometry::ViewInformation2D& /*rViewInformation*/) const
35 if (!getFillGradient().isDefault())
37 // create SubSequence with FillGradientPrimitive2D
38 const basegfx::B2DRange aPolyPolygonRange(getB2DPolyPolygon().getB2DRange());
39 rtl::Reference<FillGradientPrimitive2D> pNewGradient = new FillGradientPrimitive2D(
40 aPolyPolygonRange, getDefinitionRange(), getFillGradient());
41 Primitive2DContainer aSubSequence{ pNewGradient };
43 // create mask primitive
44 rContainer.push_back(new MaskPrimitive2D(getB2DPolyPolygon(), std::move(aSubSequence)));
48 PolyPolygonGradientPrimitive2D::PolyPolygonGradientPrimitive2D(
49 const basegfx::B2DPolyPolygon& rPolyPolygon, attribute::FillGradientAttribute aFillGradient)
50 : maPolyPolygon(rPolyPolygon)
51 , maDefinitionRange(rPolyPolygon.getB2DRange())
52 , maFillGradient(std::move(aFillGradient))
56 PolyPolygonGradientPrimitive2D::PolyPolygonGradientPrimitive2D(
57 basegfx::B2DPolyPolygon aPolyPolygon, const basegfx::B2DRange& rDefinitionRange,
58 attribute::FillGradientAttribute aFillGradient)
59 : maPolyPolygon(std::move(aPolyPolygon))
60 , maDefinitionRange(rDefinitionRange)
61 , maFillGradient(std::move(aFillGradient))
65 bool PolyPolygonGradientPrimitive2D::operator==(const BasePrimitive2D& rPrimitive) const
67 if (BufferedDecompositionPrimitive2D::operator==(rPrimitive))
69 const PolyPolygonGradientPrimitive2D& rCompare
70 = static_cast<const PolyPolygonGradientPrimitive2D&>(rPrimitive);
72 return (getB2DPolyPolygon() == rCompare.getB2DPolyPolygon()
73 && getDefinitionRange() == rCompare.getDefinitionRange()
74 && getFillGradient() == rCompare.getFillGradient());
77 return false;
80 // provide unique ID
81 sal_uInt32 PolyPolygonGradientPrimitive2D::getPrimitive2DID() const
83 return PRIMITIVE2D_ID_POLYPOLYGONGRADIENTPRIMITIVE2D;
86 } // end drawinglayer::primitive2d namespace
88 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */