/src/libreoffice/svx/source/sdr/overlay/overlaypolypolygon.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 <svx/sdr/overlay/overlaypolypolygon.hxx> |
21 | | #include <svx/sdr/overlay/overlaymanager.hxx> |
22 | | #include <drawinglayer/primitive2d/PolyPolygonMarkerPrimitive2D.hxx> |
23 | | #include <drawinglayer/primitive2d/PolyPolygonSelectionPrimitive2D.hxx> |
24 | | #include <drawinglayer/primitive2d/PolyPolygonStrokePrimitive2D.hxx> |
25 | | #include <drawinglayer/primitive2d/PolyPolygonColorPrimitive2D.hxx> |
26 | | #include <drawinglayer/primitive2d/unifiedtransparenceprimitive2d.hxx> |
27 | | #include <svtools/optionsdrawinglayer.hxx> |
28 | | #include <utility> |
29 | | |
30 | | |
31 | | namespace sdr::overlay |
32 | | { |
33 | | OverlayPolyPolygon::OverlayPolyPolygon( |
34 | | basegfx::B2DPolyPolygon aLinePolyPolygon, |
35 | | Color const & rLineColor, |
36 | | double fLineWidth, |
37 | | Color const & rFillColor) |
38 | 0 | : OverlayObject(rLineColor) |
39 | 0 | , maLinePolyPolygon(std::move(aLinePolyPolygon)) |
40 | 0 | , mfLineWidth(fLineWidth) |
41 | 0 | , maFillColor(rFillColor) |
42 | 0 | { |
43 | 0 | } |
44 | | |
45 | 0 | OverlayPolyPolygon::~OverlayPolyPolygon() = default; |
46 | | |
47 | | drawinglayer::primitive2d::Primitive2DContainer OverlayPolyPolygon::createOverlayObjectPrimitive2DSequence() |
48 | 0 | { |
49 | 0 | drawinglayer::primitive2d::Primitive2DContainer aReturnContainer; |
50 | |
|
51 | 0 | if (getOverlayManager()) |
52 | 0 | { |
53 | 0 | const drawinglayer::attribute::LineAttribute aLineAttribute(getBaseColor().getBColor(), mfLineWidth); |
54 | |
|
55 | 0 | aReturnContainer = drawinglayer::primitive2d::Primitive2DContainer { |
56 | 0 | new drawinglayer::primitive2d::PolyPolygonStrokePrimitive2D(maLinePolyPolygon, aLineAttribute) }; |
57 | |
|
58 | 0 | if (maFillColor.GetAlpha() != 0) |
59 | 0 | { |
60 | 0 | aReturnContainer.push_back(new drawinglayer::primitive2d::PolyPolygonColorPrimitive2D(maLinePolyPolygon, maFillColor.getBColor())); |
61 | 0 | } |
62 | |
|
63 | 0 | sal_uInt8 nTransparency = 255 - getBaseColor().GetAlpha(); |
64 | 0 | if (nTransparency > 0) |
65 | 0 | { |
66 | 0 | aReturnContainer = drawinglayer::primitive2d::Primitive2DContainer{ |
67 | 0 | new drawinglayer::primitive2d::UnifiedTransparencePrimitive2D(std::move(aReturnContainer), nTransparency / 255.0) |
68 | 0 | }; |
69 | 0 | } |
70 | 0 | } |
71 | |
|
72 | 0 | return aReturnContainer; |
73 | 0 | } |
74 | | |
75 | | drawinglayer::primitive2d::Primitive2DContainer OverlayPolyPolygonStripedAndFilled::createOverlayObjectPrimitive2DSequence() |
76 | 0 | { |
77 | 0 | drawinglayer::primitive2d::Primitive2DContainer aRetval; |
78 | |
|
79 | 0 | if(getOverlayManager()) |
80 | 0 | { |
81 | 0 | const basegfx::BColor aRGBColorA(getOverlayManager()->getStripeColorA().getBColor()); |
82 | 0 | const basegfx::BColor aRGBColorB(getOverlayManager()->getStripeColorB().getBColor()); |
83 | 0 | const double fStripeLengthPixel(getOverlayManager()->getStripeLengthPixel()); |
84 | 0 | const drawinglayer::primitive2d::Primitive2DReference aStriped( |
85 | 0 | new drawinglayer::primitive2d::PolyPolygonMarkerPrimitive2D( |
86 | 0 | getLinePolyPolygon(), |
87 | 0 | aRGBColorA, |
88 | 0 | aRGBColorB, |
89 | 0 | fStripeLengthPixel)); |
90 | |
|
91 | 0 | aRetval = drawinglayer::primitive2d::Primitive2DContainer { aStriped }; |
92 | |
|
93 | 0 | const basegfx::BColor aHilightColor(SvtOptionsDrawinglayer::getHilightColor().getBColor()); |
94 | 0 | const double fTransparence(SvtOptionsDrawinglayer::GetTransparentSelectionPercent() * 0.01); |
95 | |
|
96 | 0 | const drawinglayer::primitive2d::Primitive2DReference aFilled( |
97 | 0 | new drawinglayer::primitive2d::PolyPolygonSelectionPrimitive2D( |
98 | 0 | getLinePolyPolygon(), |
99 | 0 | aHilightColor, |
100 | 0 | fTransparence, |
101 | 0 | 3.0, |
102 | 0 | false)); |
103 | |
|
104 | 0 | aRetval.push_back(aFilled); |
105 | 0 | } |
106 | |
|
107 | 0 | return aRetval; |
108 | 0 | } |
109 | | |
110 | | void OverlayPolyPolygonStripedAndFilled::stripeDefinitionHasChanged() |
111 | 0 | { |
112 | | // react on OverlayManager's stripe definition change |
113 | 0 | objectChange(); |
114 | 0 | } |
115 | | |
116 | | OverlayPolyPolygonStripedAndFilled::OverlayPolyPolygonStripedAndFilled( |
117 | | basegfx::B2DPolyPolygon aLinePolyPolygon) |
118 | 0 | : OverlayObject(COL_BLACK), |
119 | 0 | maLinePolyPolygon(std::move(aLinePolyPolygon)) |
120 | 0 | { |
121 | 0 | } |
122 | | |
123 | | OverlayPolyPolygonStripedAndFilled::~OverlayPolyPolygonStripedAndFilled() |
124 | 0 | { |
125 | 0 | } |
126 | | |
127 | | } // end of namespace |
128 | | |
129 | | /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ |