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/sdrfillattribute.hxx>
21 #include <basegfx/color/bcolor.hxx>
22 #include <drawinglayer/attribute/sdrfillgraphicattribute.hxx>
23 #include <drawinglayer/attribute/fillhatchattribute.hxx>
24 #include <drawinglayer/attribute/fillgradientattribute.hxx>
25 #include <rtl/instance.hxx>
28 namespace drawinglayer::attribute
30 class ImpSdrFillAttribute
34 double mfTransparence
; // [0.0 .. 1.0], 0.0==no transp.
35 basegfx::BColor maColor
; // fill color
36 FillGradientAttribute maGradient
; // fill gradient (if used)
37 FillHatchAttribute maHatch
; // fill hatch (if used)
38 SdrFillGraphicAttribute maFillGraphic
; // fill graphic (if used)
43 const basegfx::BColor
& rColor
,
44 const FillGradientAttribute
& rGradient
,
45 const FillHatchAttribute
& rHatch
,
46 const SdrFillGraphicAttribute
& rFillGraphic
)
47 : mfTransparence(fTransparence
),
49 maGradient(rGradient
),
51 maFillGraphic(rFillGraphic
)
56 : mfTransparence(0.0),
57 maColor(basegfx::BColor()),
58 maGradient(FillGradientAttribute()),
59 maHatch(FillHatchAttribute()),
60 maFillGraphic(SdrFillGraphicAttribute())
65 double getTransparence() const { return mfTransparence
; }
66 const basegfx::BColor
& getColor() const { return maColor
; }
67 const FillGradientAttribute
& getGradient() const { return maGradient
; }
68 const FillHatchAttribute
& getHatch() const { return maHatch
; }
69 const SdrFillGraphicAttribute
& getFillGraphic() const { return maFillGraphic
; }
72 bool operator==(const ImpSdrFillAttribute
& rCandidate
) const
74 return(getTransparence() == rCandidate
.getTransparence()
75 && getColor() == rCandidate
.getColor()
76 && getGradient() == rCandidate
.getGradient()
77 && getHatch() == rCandidate
.getHatch()
78 && getFillGraphic() == rCandidate
.getFillGraphic());
84 struct theGlobalDefault
:
85 public rtl::Static
< SdrFillAttribute::ImplType
, theGlobalDefault
> {};
88 SdrFillAttribute::SdrFillAttribute(
90 const basegfx::BColor
& rColor
,
91 const FillGradientAttribute
& rGradient
,
92 const FillHatchAttribute
& rHatch
,
93 const SdrFillGraphicAttribute
& rFillGraphic
)
94 : mpSdrFillAttribute(ImpSdrFillAttribute(
95 fTransparence
, rColor
, rGradient
, rHatch
, rFillGraphic
))
99 SdrFillAttribute::SdrFillAttribute()
100 : mpSdrFillAttribute(theGlobalDefault::get())
104 SdrFillAttribute::SdrFillAttribute(const SdrFillAttribute
&) = default;
106 SdrFillAttribute::SdrFillAttribute(SdrFillAttribute
&&) = default;
108 SdrFillAttribute::~SdrFillAttribute() = default;
110 bool SdrFillAttribute::isDefault() const
112 return mpSdrFillAttribute
.same_object(theGlobalDefault::get());
115 SdrFillAttribute
& SdrFillAttribute::operator=(const SdrFillAttribute
&) = default;
117 SdrFillAttribute
& SdrFillAttribute::operator=(SdrFillAttribute
&&) = default;
119 bool SdrFillAttribute::operator==(const SdrFillAttribute
& rCandidate
) const
121 // tdf#87509 default attr is always != non-default attr, even with same values
122 if(rCandidate
.isDefault() != isDefault())
125 return rCandidate
.mpSdrFillAttribute
== mpSdrFillAttribute
;
128 double SdrFillAttribute::getTransparence() const
130 return mpSdrFillAttribute
->getTransparence();
133 const basegfx::BColor
& SdrFillAttribute::getColor() const
135 return mpSdrFillAttribute
->getColor();
138 const FillGradientAttribute
& SdrFillAttribute::getGradient() const
140 return mpSdrFillAttribute
->getGradient();
143 const FillHatchAttribute
& SdrFillAttribute::getHatch() const
145 return mpSdrFillAttribute
->getHatch();
148 const SdrFillGraphicAttribute
& SdrFillAttribute::getFillGraphic() const
150 return mpSdrFillAttribute
->getFillGraphic();
153 } // end of namespace
155 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */