nss: upgrade to release 3.73
[LibreOffice.git] / drawinglayer / source / attribute / sdrshadowattribute.cxx
blob9e379acaae280807fd71af3c4ca7c25702c6b58b
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/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
30 public:
31 // shadow definitions
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,
41 double fTransparence,
42 sal_Int32 nBlur,
43 const basegfx::BColor& rColor)
44 : maOffset(rOffset),
45 maSize(rSize),
46 mfTransparence(fTransparence),
47 mnBlur(nBlur),
48 maColor(rColor)
52 ImpSdrShadowAttribute()
53 : maOffset(basegfx::B2DVector()),
54 maSize(basegfx::B2DVector()),
55 mfTransparence(0.0),
56 mnBlur(0),
57 maColor(basegfx::BColor())
61 // data read access
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());
78 namespace
80 struct theGlobalDefault :
81 public rtl::Static< SdrShadowAttribute::ImplType, theGlobalDefault > {};
85 SdrShadowAttribute::SdrShadowAttribute(
86 const basegfx::B2DVector& rOffset,
87 const basegfx::B2DVector& rSize,
88 double fTransparence,
89 sal_Int32 nBlur,
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())
120 return false;
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: */