/src/libreoffice/drawinglayer/source/primitive2d/PolyPolygonHatchPrimitive2D.cxx
Line | Count | Source |
1 | | /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ |
2 | | /* |
3 | | * This file is part of the LibreOffice project. |
4 | | * |
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/. |
8 | | * |
9 | | * This file incorporates work covered by the following license notice: |
10 | | * |
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 . |
18 | | */ |
19 | | |
20 | | #include <drawinglayer/primitive2d/PolyPolygonHatchPrimitive2D.hxx> |
21 | | |
22 | | #include <drawinglayer/primitive2d/drawinglayer_primitivetypes2d.hxx> |
23 | | #include <drawinglayer/primitive2d/maskprimitive2d.hxx> |
24 | | #include <drawinglayer/primitive2d/fillhatchprimitive2d.hxx> |
25 | | #include <rtl/ref.hxx> |
26 | | #include <utility> |
27 | | |
28 | | using namespace com::sun::star; |
29 | | |
30 | | namespace drawinglayer::primitive2d |
31 | | { |
32 | | Primitive2DReference PolyPolygonHatchPrimitive2D::create2DDecomposition( |
33 | | const geometry::ViewInformation2D& /*rViewInformation*/) const |
34 | 0 | { |
35 | 0 | if (!getFillHatch().isDefault()) |
36 | 0 | { |
37 | | // create SubSequence with FillHatchPrimitive2D |
38 | 0 | const basegfx::B2DRange aPolyPolygonRange(getB2DPolyPolygon().getB2DRange()); |
39 | 0 | rtl::Reference<FillHatchPrimitive2D> pNewHatch = new FillHatchPrimitive2D( |
40 | 0 | aPolyPolygonRange, getDefinitionRange(), getBackgroundColor(), getFillHatch()); |
41 | 0 | Primitive2DContainer aSubSequence{ pNewHatch }; |
42 | | |
43 | | // create mask primitive |
44 | 0 | return new MaskPrimitive2D(getB2DPolyPolygon(), std::move(aSubSequence)); |
45 | 0 | } |
46 | 0 | return nullptr; |
47 | 0 | } |
48 | | |
49 | | PolyPolygonHatchPrimitive2D::PolyPolygonHatchPrimitive2D( |
50 | | const basegfx::B2DPolyPolygon& rPolyPolygon, const basegfx::BColor& rBackgroundColor, |
51 | | attribute::FillHatchAttribute rFillHatch) |
52 | 0 | : maPolyPolygon(rPolyPolygon) |
53 | 0 | , maDefinitionRange(rPolyPolygon.getB2DRange()) |
54 | 0 | , maBackgroundColor(rBackgroundColor) |
55 | 0 | , maFillHatch(std::move(rFillHatch)) |
56 | 0 | { |
57 | 0 | } |
58 | | |
59 | | PolyPolygonHatchPrimitive2D::PolyPolygonHatchPrimitive2D(basegfx::B2DPolyPolygon aPolyPolygon, |
60 | | const basegfx::B2DRange& rDefinitionRange, |
61 | | const basegfx::BColor& rBackgroundColor, |
62 | | attribute::FillHatchAttribute rFillHatch) |
63 | 0 | : maPolyPolygon(std::move(aPolyPolygon)) |
64 | 0 | , maDefinitionRange(rDefinitionRange) |
65 | 0 | , maBackgroundColor(rBackgroundColor) |
66 | 0 | , maFillHatch(std::move(rFillHatch)) |
67 | 0 | { |
68 | 0 | } |
69 | | |
70 | | bool PolyPolygonHatchPrimitive2D::operator==(const BasePrimitive2D& rPrimitive) const |
71 | 0 | { |
72 | 0 | if (BufferedDecompositionPrimitive2D::operator==(rPrimitive)) |
73 | 0 | { |
74 | 0 | const PolyPolygonHatchPrimitive2D& rCompare |
75 | 0 | = static_cast<const PolyPolygonHatchPrimitive2D&>(rPrimitive); |
76 | |
|
77 | 0 | return (getB2DPolyPolygon() == rCompare.getB2DPolyPolygon() |
78 | 0 | && getDefinitionRange() == rCompare.getDefinitionRange() |
79 | 0 | && getBackgroundColor() == rCompare.getBackgroundColor() |
80 | 0 | && getFillHatch() == rCompare.getFillHatch()); |
81 | 0 | } |
82 | | |
83 | 0 | return false; |
84 | 0 | } |
85 | | |
86 | | // provide unique ID |
87 | | sal_uInt32 PolyPolygonHatchPrimitive2D::getPrimitive2DID() const |
88 | 0 | { |
89 | 0 | return PRIMITIVE2D_ID_POLYPOLYGONHATCHPRIMITIVE2D; |
90 | 0 | } |
91 | | |
92 | | } // end drawinglayer::primitive2d namespace |
93 | | |
94 | | /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ |