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/fillhatchattribute.hxx>
21 #include <basegfx/color/bcolor.hxx>
24 namespace drawinglayer::attribute
26 class ImpFillHatchAttribute
33 basegfx::BColor maColor
;
34 sal_uInt32 mnMinimalDiscreteDistance
;
36 bool mbFillBackground
: 1;
38 ImpFillHatchAttribute(
42 const basegfx::BColor
& rColor
,
43 sal_uInt32 nMinimalDiscreteDistance
,
46 mfDistance(fDistance
),
49 mnMinimalDiscreteDistance(nMinimalDiscreteDistance
),
50 mbFillBackground(bFillBackground
)
54 ImpFillHatchAttribute()
55 : meStyle(HatchStyle::Single
),
58 mnMinimalDiscreteDistance(3), // same as VCL
59 mbFillBackground(false)
64 HatchStyle
getStyle() const { return meStyle
; }
65 double getDistance() const { return mfDistance
; }
66 double getAngle() const { return mfAngle
; }
67 const basegfx::BColor
& getColor() const { return maColor
; }
68 sal_uInt32
getMinimalDiscreteDistance() const { return mnMinimalDiscreteDistance
; }
69 bool isFillBackground() const { return mbFillBackground
; }
71 bool operator==(const ImpFillHatchAttribute
& rCandidate
) const
73 return (getStyle() == rCandidate
.getStyle()
74 && getDistance() == rCandidate
.getDistance()
75 && getAngle() == rCandidate
.getAngle()
76 && getColor() == rCandidate
.getColor()
77 && getMinimalDiscreteDistance() == rCandidate
.getMinimalDiscreteDistance()
78 && isFillBackground() == rCandidate
.isFillBackground());
84 FillHatchAttribute::ImplType
& theGlobalDefault()
86 static FillHatchAttribute::ImplType SINGLETON
;
91 FillHatchAttribute::FillHatchAttribute(
95 const basegfx::BColor
& rColor
,
96 sal_uInt32 nMinimalDiscreteDistance
,
98 : mpFillHatchAttribute(ImpFillHatchAttribute(
99 eStyle
, fDistance
, fAngle
, rColor
,
100 nMinimalDiscreteDistance
, bFillBackground
))
104 FillHatchAttribute::FillHatchAttribute()
105 : mpFillHatchAttribute(theGlobalDefault())
109 FillHatchAttribute::FillHatchAttribute(const FillHatchAttribute
&) = default;
111 FillHatchAttribute::FillHatchAttribute(FillHatchAttribute
&&) = default;
113 FillHatchAttribute::~FillHatchAttribute() = default;
115 bool FillHatchAttribute::isDefault() const
117 return mpFillHatchAttribute
.same_object(theGlobalDefault());
120 FillHatchAttribute
& FillHatchAttribute::operator=(const FillHatchAttribute
&) = default;
122 FillHatchAttribute
& FillHatchAttribute::operator=(FillHatchAttribute
&&) = default;
124 bool FillHatchAttribute::operator==(const FillHatchAttribute
& rCandidate
) const
126 // tdf#87509 default attr is always != non-default attr, even with same values
127 if(rCandidate
.isDefault() != isDefault())
130 return rCandidate
.mpFillHatchAttribute
== mpFillHatchAttribute
;
134 HatchStyle
FillHatchAttribute::getStyle() const
136 return mpFillHatchAttribute
->getStyle();
139 double FillHatchAttribute::getDistance() const
141 return mpFillHatchAttribute
->getDistance();
144 double FillHatchAttribute::getAngle() const
146 return mpFillHatchAttribute
->getAngle();
149 const basegfx::BColor
& FillHatchAttribute::getColor() const
151 return mpFillHatchAttribute
->getColor();
154 sal_uInt32
FillHatchAttribute::getMinimalDiscreteDistance() const
156 return mpFillHatchAttribute
->getMinimalDiscreteDistance();
159 bool FillHatchAttribute::isFillBackground() const
161 return mpFillHatchAttribute
->isFillBackground();
164 } // end of namespace
166 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */