1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
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 <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>
31 namespace sdr::overlay
33 OverlayPolyPolygon::OverlayPolyPolygon(
34 basegfx::B2DPolyPolygon aLinePolyPolygon
,
35 Color
const & rLineColor
,
37 Color
const & rFillColor
)
38 : OverlayObject(rLineColor
)
39 , maLinePolyPolygon(std::move(aLinePolyPolygon
))
40 , mfLineWidth(fLineWidth
)
41 , maFillColor(rFillColor
)
45 OverlayPolyPolygon::~OverlayPolyPolygon() = default;
47 drawinglayer::primitive2d::Primitive2DContainer
OverlayPolyPolygon::createOverlayObjectPrimitive2DSequence()
49 drawinglayer::primitive2d::Primitive2DContainer aReturnContainer
;
51 if (getOverlayManager())
53 const drawinglayer::attribute::LineAttribute
aLineAttribute(getBaseColor().getBColor(), mfLineWidth
);
55 aReturnContainer
= drawinglayer::primitive2d::Primitive2DContainer
{
56 new drawinglayer::primitive2d::PolyPolygonStrokePrimitive2D(maLinePolyPolygon
, aLineAttribute
) };
58 if (maFillColor
.GetAlpha() != 0)
60 aReturnContainer
.push_back(new drawinglayer::primitive2d::PolyPolygonColorPrimitive2D(maLinePolyPolygon
, maFillColor
.getBColor()));
63 sal_uInt8 nTransparency
= 255 - getBaseColor().GetAlpha();
64 if (nTransparency
> 0)
66 aReturnContainer
= drawinglayer::primitive2d::Primitive2DContainer
{
67 new drawinglayer::primitive2d::UnifiedTransparencePrimitive2D(std::move(aReturnContainer
), nTransparency
/ 255.0)
72 return aReturnContainer
;
75 drawinglayer::primitive2d::Primitive2DContainer
OverlayPolyPolygonStripedAndFilled::createOverlayObjectPrimitive2DSequence()
77 drawinglayer::primitive2d::Primitive2DContainer aRetval
;
79 if(getOverlayManager())
81 const basegfx::BColor
aRGBColorA(getOverlayManager()->getStripeColorA().getBColor());
82 const basegfx::BColor
aRGBColorB(getOverlayManager()->getStripeColorB().getBColor());
83 const double fStripeLengthPixel(getOverlayManager()->getStripeLengthPixel());
84 const drawinglayer::primitive2d::Primitive2DReference
aStriped(
85 new drawinglayer::primitive2d::PolyPolygonMarkerPrimitive2D(
91 aRetval
= drawinglayer::primitive2d::Primitive2DContainer
{ aStriped
};
93 const basegfx::BColor
aHilightColor(SvtOptionsDrawinglayer::getHilightColor().getBColor());
94 const double fTransparence(SvtOptionsDrawinglayer::GetTransparentSelectionPercent() * 0.01);
96 const drawinglayer::primitive2d::Primitive2DReference
aFilled(
97 new drawinglayer::primitive2d::PolyPolygonSelectionPrimitive2D(
104 aRetval
.push_back(aFilled
);
110 void OverlayPolyPolygonStripedAndFilled::stripeDefinitionHasChanged()
112 // react on OverlayManager's stripe definition change
116 OverlayPolyPolygonStripedAndFilled::OverlayPolyPolygonStripedAndFilled(
117 basegfx::B2DPolyPolygon aLinePolyPolygon
)
118 : OverlayObject(COL_BLACK
),
119 maLinePolyPolygon(std::move(aLinePolyPolygon
))
123 OverlayPolyPolygonStripedAndFilled::~OverlayPolyPolygonStripedAndFilled()
127 } // end of namespace
129 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */