Version 6.4.0.3, tag libreoffice-6.4.0.3
[LibreOffice.git] / drawinglayer / source / primitive2d / sdrdecompositiontools2d.cxx
blobc1b95d8cf069c815127525cdcc068254125fce3d
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/sdrdecompositiontools2d.hxx>
21 #include <basegfx/polygon/b2dpolygon.hxx>
22 #include <basegfx/polygon/b2dpolygontools.hxx>
23 #include <basegfx/matrix/b2dhommatrix.hxx>
24 #include <drawinglayer/primitive2d/polypolygonprimitive2d.hxx>
25 #include <drawinglayer/primitive2d/hiddengeometryprimitive2d.hxx>
28 namespace drawinglayer
30 namespace primitive2d
32 Primitive2DReference createHiddenGeometryPrimitives2D(
33 const basegfx::B2DHomMatrix& rMatrix)
35 const basegfx::B2DPolygon& aUnitOutline(basegfx::utils::createUnitPolygon());
37 return createHiddenGeometryPrimitives2D(
38 false/*bFilled*/,
39 basegfx::B2DPolyPolygon(aUnitOutline),
40 rMatrix);
43 Primitive2DReference createHiddenGeometryPrimitives2D(
44 const basegfx::B2DPolyPolygon& rPolyPolygon)
46 return createHiddenGeometryPrimitives2D(
47 false/*bFilled*/,
48 rPolyPolygon,
49 basegfx::B2DHomMatrix());
52 Primitive2DReference createHiddenGeometryPrimitives2D(
53 bool bFilled,
54 const basegfx::B2DRange& rRange)
56 return createHiddenGeometryPrimitives2D(
57 bFilled,
58 rRange,
59 basegfx::B2DHomMatrix());
62 Primitive2DReference createHiddenGeometryPrimitives2D(
63 bool bFilled,
64 const basegfx::B2DRange& rRange,
65 const basegfx::B2DHomMatrix& rMatrix)
67 const basegfx::B2DPolyPolygon aOutline(basegfx::utils::createPolygonFromRect(rRange));
69 return createHiddenGeometryPrimitives2D(
70 bFilled,
71 aOutline,
72 rMatrix);
75 Primitive2DReference createHiddenGeometryPrimitives2D(
76 bool bFilled,
77 const basegfx::B2DPolyPolygon& rPolyPolygon,
78 const basegfx::B2DHomMatrix& rMatrix)
80 // create fill or line primitive
81 Primitive2DReference xReference;
82 basegfx::B2DPolyPolygon aScaledOutline(rPolyPolygon);
83 aScaledOutline.transform(rMatrix);
85 if(bFilled)
87 xReference = new PolyPolygonColorPrimitive2D(
88 aScaledOutline,
89 basegfx::BColor(0.0, 0.0, 0.0));
91 else
93 const basegfx::BColor aGrayTone(0xc0 / 255.0, 0xc0 / 255.0, 0xc0 / 255.0);
95 xReference = new PolyPolygonHairlinePrimitive2D(
96 aScaledOutline,
97 aGrayTone);
100 // create HiddenGeometryPrimitive2D
101 return Primitive2DReference(
102 new HiddenGeometryPrimitive2D(Primitive2DContainer { xReference }));
104 } // end of namespace primitive2d
105 } // end of namespace drawinglayer
107 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */