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 <drawinglayer/attribute/sdrshadowattribute.hxx>
21 #include <basegfx/vector/b2dvector.hxx>
22 #include <basegfx/color/bcolor.hxx>
23 #include <docmodel/theme/FormatScheme.hxx>
26 namespace drawinglayer::attribute
28 class ImpSdrShadowAttribute
32 basegfx::B2DVector maOffset
; // shadow offset 1/100th mm
33 basegfx::B2DVector maSize
; // [0.0 .. 2.0]
34 double mfTransparence
; // [0.0 .. 1.0], 0.0==no transp.
35 sal_Int32 mnBlur
; // [0 .. 180], radius of the blur
36 model::RectangleAlignment meAlignment
{model::RectangleAlignment::Unset
}; // alignment of the shadow
37 basegfx::BColor maColor
; // color of shadow
39 ImpSdrShadowAttribute(
40 const basegfx::B2DVector
& rOffset
,
41 const basegfx::B2DVector
& rSize
,
44 model::RectangleAlignment eAlignment
,
45 const basegfx::BColor
& rColor
)
48 mfTransparence(fTransparence
),
50 meAlignment(eAlignment
),
55 ImpSdrShadowAttribute()
56 : mfTransparence(0.0),
62 const basegfx::B2DVector
& getOffset() const { return maOffset
; }
63 const basegfx::B2DVector
& getSize() const { return maSize
; }
64 double getTransparence() const { return mfTransparence
; }
65 sal_Int32
getBlur() const { return mnBlur
; }
66 const basegfx::BColor
& getColor() const { return maColor
; }
68 bool operator==(const ImpSdrShadowAttribute
& rCandidate
) const
70 return (getOffset() == rCandidate
.getOffset()
71 && getSize() == rCandidate
.getSize()
72 && getTransparence() == rCandidate
.getTransparence()
73 && getBlur() == rCandidate
.getBlur()
74 && meAlignment
== rCandidate
.meAlignment
75 && getColor() == rCandidate
.getColor());
81 SdrShadowAttribute::ImplType
& theGlobalDefault()
83 static SdrShadowAttribute::ImplType SINGLETON
;
89 SdrShadowAttribute::SdrShadowAttribute(
90 const basegfx::B2DVector
& rOffset
,
91 const basegfx::B2DVector
& rSize
,
94 model::RectangleAlignment eAlignment
,
95 const basegfx::BColor
& rColor
)
96 : mpSdrShadowAttribute(ImpSdrShadowAttribute(
97 rOffset
, rSize
, fTransparence
, nBlur
, eAlignment
, rColor
))
101 SdrShadowAttribute::SdrShadowAttribute()
102 : mpSdrShadowAttribute(theGlobalDefault())
106 SdrShadowAttribute::SdrShadowAttribute(const SdrShadowAttribute
&) = default;
108 SdrShadowAttribute::SdrShadowAttribute(SdrShadowAttribute
&&) = default;
110 SdrShadowAttribute::~SdrShadowAttribute() = default;
112 bool SdrShadowAttribute::isDefault() const
114 return mpSdrShadowAttribute
.same_object(theGlobalDefault());
117 SdrShadowAttribute
& SdrShadowAttribute::operator=(const SdrShadowAttribute
&) = default;
119 SdrShadowAttribute
& SdrShadowAttribute::operator=(SdrShadowAttribute
&&) = default;
121 bool SdrShadowAttribute::operator==(const SdrShadowAttribute
& rCandidate
) const
123 // tdf#87509 default attr is always != non-default attr, even with same values
124 if(rCandidate
.isDefault() != isDefault())
127 return mpSdrShadowAttribute
== rCandidate
.mpSdrShadowAttribute
;
130 const basegfx::B2DVector
& SdrShadowAttribute::getOffset() const
132 return mpSdrShadowAttribute
->getOffset();
135 const basegfx::B2DVector
& SdrShadowAttribute::getSize() const
137 return mpSdrShadowAttribute
->getSize();
140 double SdrShadowAttribute::getTransparence() const
142 return mpSdrShadowAttribute
->getTransparence();
145 sal_Int32
SdrShadowAttribute::getBlur() const
147 return mpSdrShadowAttribute
->getBlur();
150 model::RectangleAlignment
SdrShadowAttribute::getAlignment() const
152 return mpSdrShadowAttribute
->meAlignment
;
155 const basegfx::BColor
& SdrShadowAttribute::getColor() const
157 return mpSdrShadowAttribute
->getColor();
160 } // end of namespace
162 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */