calc: on editing invalidation of view with different zoom is wrong
[LibreOffice.git] / drawinglayer / source / attribute / sdrfillattribute.cxx
blob8cee8f98d1e913c1d3801bda67bb4b92b506ca86
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/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 <utility>
28 namespace drawinglayer::attribute
30 class ImpSdrFillAttribute
32 public:
33 // fill definitions
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)
40 public:
41 ImpSdrFillAttribute(
42 double fTransparence,
43 const basegfx::BColor& rColor,
44 FillGradientAttribute aGradient,
45 FillHatchAttribute aHatch,
46 SdrFillGraphicAttribute aFillGraphic)
47 : mfTransparence(fTransparence),
48 maColor(rColor),
49 maGradient(std::move(aGradient)),
50 maHatch(std::move(aHatch)),
51 maFillGraphic(std::move(aFillGraphic))
55 ImpSdrFillAttribute()
56 : mfTransparence(0.0)
60 // data read access
61 double getTransparence() const { return mfTransparence; }
62 const basegfx::BColor& getColor() const { return maColor; }
63 const FillGradientAttribute& getGradient() const { return maGradient; }
64 const FillHatchAttribute& getHatch() const { return maHatch; }
65 const SdrFillGraphicAttribute& getFillGraphic() const { return maFillGraphic; }
67 // compare operator
68 bool operator==(const ImpSdrFillAttribute& rCandidate) const
70 return(getTransparence() == rCandidate.getTransparence()
71 && getColor() == rCandidate.getColor()
72 && getGradient() == rCandidate.getGradient()
73 && getHatch() == rCandidate.getHatch()
74 && getFillGraphic() == rCandidate.getFillGraphic());
78 namespace
80 SdrFillAttribute::ImplType& theGlobalDefault()
82 static SdrFillAttribute::ImplType SINGLETON;
83 return SINGLETON;
85 SdrFillAttribute::ImplType& slideBackgroundFillGlobalDefault()
87 static SdrFillAttribute::ImplType SINGLETON2;
88 return SINGLETON2;
92 SdrFillAttribute::SdrFillAttribute(
93 double fTransparence,
94 const basegfx::BColor& rColor,
95 const FillGradientAttribute& rGradient,
96 const FillHatchAttribute& rHatch,
97 const SdrFillGraphicAttribute& rFillGraphic)
98 : mpSdrFillAttribute(ImpSdrFillAttribute(
99 fTransparence, rColor, rGradient, rHatch, rFillGraphic))
103 SdrFillAttribute::SdrFillAttribute(bool bSlideBackgroundFill)
104 : mpSdrFillAttribute(bSlideBackgroundFill
105 ? slideBackgroundFillGlobalDefault()
106 : theGlobalDefault())
110 SdrFillAttribute::SdrFillAttribute(const SdrFillAttribute&) = default;
112 SdrFillAttribute::SdrFillAttribute(SdrFillAttribute&&) = default;
114 SdrFillAttribute::~SdrFillAttribute() = default;
116 bool SdrFillAttribute::isDefault() const
118 return mpSdrFillAttribute.same_object(theGlobalDefault());
121 bool SdrFillAttribute::isSlideBackgroundFill() const
123 return mpSdrFillAttribute.same_object(slideBackgroundFillGlobalDefault());
126 SdrFillAttribute& SdrFillAttribute::operator=(const SdrFillAttribute&) = default;
128 SdrFillAttribute& SdrFillAttribute::operator=(SdrFillAttribute&&) = default;
130 bool SdrFillAttribute::operator==(const SdrFillAttribute& rCandidate) const
132 // tdf#87509 default attr is always != non-default attr, even with same values
133 if(rCandidate.isDefault() != isDefault())
134 return false;
136 return rCandidate.mpSdrFillAttribute == mpSdrFillAttribute;
139 double SdrFillAttribute::getTransparence() const
141 return mpSdrFillAttribute->getTransparence();
144 const basegfx::BColor& SdrFillAttribute::getColor() const
146 return mpSdrFillAttribute->getColor();
149 const FillGradientAttribute& SdrFillAttribute::getGradient() const
151 return mpSdrFillAttribute->getGradient();
154 const FillHatchAttribute& SdrFillAttribute::getHatch() const
156 return mpSdrFillAttribute->getHatch();
159 const SdrFillGraphicAttribute& SdrFillAttribute::getFillGraphic() const
161 return mpSdrFillAttribute->getFillGraphic();
164 } // end of namespace
166 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */