LibreOffice Module drawinglayer (master) 1
sdrfillattribute.cxx
Go to the documentation of this file.
1/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2/*
3 * This file is part of the LibreOffice project.
4 *
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/.
8 *
9 * This file incorporates work covered by the following license notice:
10 *
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 .
18 */
19
25#include <utility>
26
27
29{
31 {
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)
39
40 public:
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))
52 {
53 }
54
56 : mfTransparence(0.0)
57 {
58 }
59
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; }
66
67 // compare operator
68 bool operator==(const ImpSdrFillAttribute& rCandidate) const
69 {
70 return(getTransparence() == rCandidate.getTransparence()
71 && getColor() == rCandidate.getColor()
72 && getGradient() == rCandidate.getGradient()
73 && getHatch() == rCandidate.getHatch()
74 && getFillGraphic() == rCandidate.getFillGraphic());
75 }
76 };
77
78 namespace
79 {
80 SdrFillAttribute::ImplType& theGlobalDefault()
81 {
82 static SdrFillAttribute::ImplType SINGLETON;
83 return SINGLETON;
84 }
85 SdrFillAttribute::ImplType& slideBackgroundFillGlobalDefault()
86 {
87 static SdrFillAttribute::ImplType SINGLETON2;
88 return SINGLETON2;
89 }
90 }
91
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))
100 {
101 }
102
103 SdrFillAttribute::SdrFillAttribute(bool bSlideBackgroundFill)
104 : mpSdrFillAttribute(bSlideBackgroundFill
105 ? slideBackgroundFillGlobalDefault()
106 : theGlobalDefault())
107 {
108 }
109
111
113
115
117 {
118 return mpSdrFillAttribute.same_object(theGlobalDefault());
119 }
120
122 {
123 return mpSdrFillAttribute.same_object(slideBackgroundFillGlobalDefault());
124 }
125
127
129
130 bool SdrFillAttribute::operator==(const SdrFillAttribute& rCandidate) const
131 {
132 // tdf#87509 default attr is always != non-default attr, even with same values
133 if(rCandidate.isDefault() != isDefault())
134 return false;
135
136 return rCandidate.mpSdrFillAttribute == mpSdrFillAttribute;
137 }
138
140 {
141 return mpSdrFillAttribute->getTransparence();
142 }
143
145 {
146 return mpSdrFillAttribute->getColor();
147 }
148
150 {
151 return mpSdrFillAttribute->getGradient();
152 }
153
155 {
156 return mpSdrFillAttribute->getHatch();
157 }
158
160 {
161 return mpSdrFillAttribute->getFillGraphic();
162 }
163
164} // end of namespace
165
166/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
bool operator==(const ImpSdrFillAttribute &rCandidate) const
ImpSdrFillAttribute(double fTransparence, const basegfx::BColor &rColor, FillGradientAttribute aGradient, FillHatchAttribute aHatch, SdrFillGraphicAttribute aFillGraphic)
const SdrFillGraphicAttribute & getFillGraphic() const
const FillHatchAttribute & getHatch() const
const basegfx::BColor & getColor() const
const FillGradientAttribute & getGradient() const
const basegfx::BColor & getColor() const
SdrFillAttribute & operator=(const SdrFillAttribute &)
bool operator==(const SdrFillAttribute &rCandidate) const
const FillHatchAttribute & getHatch() const
const FillGradientAttribute & getGradient() const
SdrFillAttribute(double fTransparence, const basegfx::BColor &rColor, const FillGradientAttribute &rGradient, const FillHatchAttribute &rHatch, const SdrFillGraphicAttribute &rFillGraphic)
constructors/assignmentoperator/destructor
const SdrFillGraphicAttribute & getFillGraphic() const
o3tl::cow_wrapper< ImpSdrFillAttribute > ImplType
bool same_object(const cow_wrapper &rOther) const