calc: on editing invalidation of view with different zoom is wrong
[LibreOffice.git] / drawinglayer / source / attribute / fillhatchattribute.cxx
blobbc892a0248420cc6932e44480c6572e006cb9976
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/fillhatchattribute.hxx>
21 #include <basegfx/color/bcolor.hxx>
24 namespace drawinglayer::attribute
26 class ImpFillHatchAttribute
28 public:
29 // data definitions
30 HatchStyle meStyle;
31 double mfDistance;
32 double mfAngle;
33 basegfx::BColor maColor;
34 sal_uInt32 mnMinimalDiscreteDistance;
36 bool mbFillBackground : 1;
38 ImpFillHatchAttribute(
39 HatchStyle eStyle,
40 double fDistance,
41 double fAngle,
42 const basegfx::BColor& rColor,
43 sal_uInt32 nMinimalDiscreteDistance,
44 bool bFillBackground)
45 : meStyle(eStyle),
46 mfDistance(fDistance),
47 mfAngle(fAngle),
48 maColor(rColor),
49 mnMinimalDiscreteDistance(nMinimalDiscreteDistance),
50 mbFillBackground(bFillBackground)
54 ImpFillHatchAttribute()
55 : meStyle(HatchStyle::Single),
56 mfDistance(0.0),
57 mfAngle(0.0),
58 mnMinimalDiscreteDistance(3), // same as VCL
59 mbFillBackground(false)
63 // data read access
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());
82 namespace
84 FillHatchAttribute::ImplType& theGlobalDefault()
86 static FillHatchAttribute::ImplType SINGLETON;
87 return SINGLETON;
91 FillHatchAttribute::FillHatchAttribute(
92 HatchStyle eStyle,
93 double fDistance,
94 double fAngle,
95 const basegfx::BColor& rColor,
96 sal_uInt32 nMinimalDiscreteDistance,
97 bool bFillBackground)
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())
128 return false;
130 return rCandidate.mpFillHatchAttribute == mpFillHatchAttribute;
133 // data read access
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: */