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 <rtl/instance.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 basegfx::BColor maColor
; // color of shadow
38 ImpSdrShadowAttribute(
39 const basegfx::B2DVector
& rOffset
,
40 const basegfx::B2DVector
& rSize
,
43 const basegfx::BColor
& rColor
)
46 mfTransparence(fTransparence
),
52 ImpSdrShadowAttribute()
53 : maOffset(basegfx::B2DVector()),
54 maSize(basegfx::B2DVector()),
57 maColor(basegfx::BColor())
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 && getColor() == rCandidate
.getColor());
80 struct theGlobalDefault
:
81 public rtl::Static
< SdrShadowAttribute::ImplType
, theGlobalDefault
> {};
85 SdrShadowAttribute::SdrShadowAttribute(
86 const basegfx::B2DVector
& rOffset
,
87 const basegfx::B2DVector
& rSize
,
90 const basegfx::BColor
& rColor
)
91 : mpSdrShadowAttribute(ImpSdrShadowAttribute(
92 rOffset
, rSize
, fTransparence
,nBlur
, rColor
))
96 SdrShadowAttribute::SdrShadowAttribute()
97 : mpSdrShadowAttribute(theGlobalDefault::get())
101 SdrShadowAttribute::SdrShadowAttribute(const SdrShadowAttribute
&) = default;
103 SdrShadowAttribute::SdrShadowAttribute(SdrShadowAttribute
&&) = default;
105 SdrShadowAttribute::~SdrShadowAttribute() = default;
107 bool SdrShadowAttribute::isDefault() const
109 return mpSdrShadowAttribute
.same_object(theGlobalDefault::get());
112 SdrShadowAttribute
& SdrShadowAttribute::operator=(const SdrShadowAttribute
&) = default;
114 SdrShadowAttribute
& SdrShadowAttribute::operator=(SdrShadowAttribute
&&) = default;
116 bool SdrShadowAttribute::operator==(const SdrShadowAttribute
& rCandidate
) const
118 // tdf#87509 default attr is always != non-default attr, even with same values
119 if(rCandidate
.isDefault() != isDefault())
122 return mpSdrShadowAttribute
== rCandidate
.mpSdrShadowAttribute
;
125 const basegfx::B2DVector
& SdrShadowAttribute::getOffset() const
127 return mpSdrShadowAttribute
->getOffset();
130 const basegfx::B2DVector
& SdrShadowAttribute::getSize() const
132 return mpSdrShadowAttribute
->getSize();
135 double SdrShadowAttribute::getTransparence() const
137 return mpSdrShadowAttribute
->getTransparence();
140 sal_Int32
SdrShadowAttribute::getBlur() const
142 return mpSdrShadowAttribute
->getBlur();
145 const basegfx::BColor
& SdrShadowAttribute::getColor() const
147 return mpSdrShadowAttribute
->getColor();
150 } // end of namespace
152 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */