/src/libreoffice/drawinglayer/source/primitive2d/sdrdecompositiontools2d.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/sdrdecompositiontools2d.hxx> |
21 | | #include <basegfx/polygon/b2dpolygon.hxx> |
22 | | #include <basegfx/polygon/b2dpolygontools.hxx> |
23 | | #include <basegfx/matrix/b2dhommatrix.hxx> |
24 | | #include <drawinglayer/primitive2d/PolyPolygonColorPrimitive2D.hxx> |
25 | | #include <drawinglayer/primitive2d/PolyPolygonHairlinePrimitive2D.hxx> |
26 | | #include <drawinglayer/primitive2d/hiddengeometryprimitive2d.hxx> |
27 | | |
28 | | |
29 | | namespace drawinglayer::primitive2d |
30 | | { |
31 | | Primitive2DReference createHiddenGeometryPrimitives2D( |
32 | | const basegfx::B2DHomMatrix& rMatrix) |
33 | 132 | { |
34 | 132 | const basegfx::B2DPolygon& aUnitOutline(basegfx::utils::createUnitPolygon()); |
35 | | |
36 | 132 | return createHiddenGeometryPrimitives2D( |
37 | 132 | false/*bFilled*/, |
38 | 132 | basegfx::B2DPolyPolygon(aUnitOutline), |
39 | 132 | rMatrix); |
40 | 132 | } |
41 | | |
42 | | Primitive2DReference createHiddenGeometryPrimitives2D( |
43 | | const basegfx::B2DPolyPolygon& rPolyPolygon) |
44 | 0 | { |
45 | 0 | return createHiddenGeometryPrimitives2D( |
46 | 0 | false/*bFilled*/, |
47 | 0 | rPolyPolygon, |
48 | 0 | basegfx::B2DHomMatrix()); |
49 | 0 | } |
50 | | |
51 | | Primitive2DReference createHiddenGeometryPrimitives2D( |
52 | | bool bFilled, |
53 | | const basegfx::B2DRange& rRange) |
54 | 852 | { |
55 | 852 | return createHiddenGeometryPrimitives2D( |
56 | 852 | bFilled, |
57 | 852 | rRange, |
58 | 852 | basegfx::B2DHomMatrix()); |
59 | 852 | } |
60 | | |
61 | | Primitive2DReference createHiddenGeometryPrimitives2D( |
62 | | bool bFilled, |
63 | | const basegfx::B2DRange& rRange, |
64 | | const basegfx::B2DHomMatrix& rMatrix) |
65 | 852 | { |
66 | 852 | const basegfx::B2DPolyPolygon aOutline(basegfx::utils::createPolygonFromRect(rRange)); |
67 | | |
68 | 852 | return createHiddenGeometryPrimitives2D( |
69 | 852 | bFilled, |
70 | 852 | aOutline, |
71 | 852 | rMatrix); |
72 | 852 | } |
73 | | |
74 | | Primitive2DReference createHiddenGeometryPrimitives2D( |
75 | | bool bFilled, |
76 | | const basegfx::B2DPolyPolygon& rPolyPolygon, |
77 | | const basegfx::B2DHomMatrix& rMatrix) |
78 | 984 | { |
79 | | // create fill or line primitive |
80 | 984 | Primitive2DReference xReference; |
81 | 984 | basegfx::B2DPolyPolygon aScaledOutline(rPolyPolygon); |
82 | 984 | aScaledOutline.transform(rMatrix); |
83 | | |
84 | 984 | if(bFilled) |
85 | 536 | { |
86 | 536 | xReference = new PolyPolygonColorPrimitive2D( |
87 | 536 | std::move(aScaledOutline), |
88 | 536 | basegfx::BColor(0.0, 0.0, 0.0)); |
89 | 536 | } |
90 | 448 | else |
91 | 448 | { |
92 | 448 | const basegfx::BColor aGrayTone(0xc0 / 255.0, 0xc0 / 255.0, 0xc0 / 255.0); |
93 | | |
94 | 448 | xReference = new PolyPolygonHairlinePrimitive2D( |
95 | 448 | std::move(aScaledOutline), |
96 | 448 | aGrayTone); |
97 | 448 | } |
98 | | |
99 | | // create HiddenGeometryPrimitive2D |
100 | 984 | return new HiddenGeometryPrimitive2D(Primitive2DContainer { xReference }); |
101 | 984 | } |
102 | | |
103 | | } // end of namespace |
104 | | |
105 | | /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ |