/src/libreoffice/drawinglayer/source/attribute/fillhatchattribute.cxx
Line | Count | Source |
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 | | |
20 | | #include <drawinglayer/attribute/fillhatchattribute.hxx> |
21 | | #include <basegfx/color/bcolor.hxx> |
22 | | |
23 | | |
24 | | namespace drawinglayer::attribute |
25 | | { |
26 | | class ImpFillHatchAttribute |
27 | | { |
28 | | public: |
29 | | // data definitions |
30 | | HatchStyle meStyle; |
31 | | double mfDistance; |
32 | | double mfAngle; |
33 | | basegfx::BColor maColor; |
34 | | sal_uInt32 mnMinimalDiscreteDistance; |
35 | | |
36 | | bool mbFillBackground : 1; |
37 | | |
38 | | ImpFillHatchAttribute( |
39 | | HatchStyle eStyle, |
40 | | double fDistance, |
41 | | double fAngle, |
42 | | const basegfx::BColor& rColor, |
43 | | sal_uInt32 nMinimalDiscreteDistance, |
44 | | bool bFillBackground) |
45 | 0 | : meStyle(eStyle), |
46 | 0 | mfDistance(fDistance), |
47 | 0 | mfAngle(fAngle), |
48 | 0 | maColor(rColor), |
49 | 0 | mnMinimalDiscreteDistance(nMinimalDiscreteDistance), |
50 | 0 | mbFillBackground(bFillBackground) |
51 | 0 | { |
52 | 0 | } |
53 | | |
54 | | ImpFillHatchAttribute() |
55 | 8 | : meStyle(HatchStyle::Single), |
56 | 8 | mfDistance(0.0), |
57 | 8 | mfAngle(0.0), |
58 | 8 | mnMinimalDiscreteDistance(3), // same as VCL |
59 | 8 | mbFillBackground(false) |
60 | 8 | { |
61 | 8 | } |
62 | | |
63 | | // data read access |
64 | 0 | HatchStyle getStyle() const { return meStyle; } |
65 | 0 | double getDistance() const { return mfDistance; } |
66 | 0 | double getAngle() const { return mfAngle; } |
67 | 0 | const basegfx::BColor& getColor() const { return maColor; } |
68 | 0 | sal_uInt32 getMinimalDiscreteDistance() const { return mnMinimalDiscreteDistance; } |
69 | 0 | bool isFillBackground() const { return mbFillBackground; } |
70 | | |
71 | | bool operator==(const ImpFillHatchAttribute& rCandidate) const |
72 | 0 | { |
73 | 0 | return (getStyle() == rCandidate.getStyle() |
74 | 0 | && getDistance() == rCandidate.getDistance() |
75 | 0 | && getAngle() == rCandidate.getAngle() |
76 | 0 | && getColor() == rCandidate.getColor() |
77 | 0 | && getMinimalDiscreteDistance() == rCandidate.getMinimalDiscreteDistance() |
78 | 0 | && isFillBackground() == rCandidate.isFillBackground()); |
79 | 0 | } |
80 | | }; |
81 | | |
82 | | namespace |
83 | | { |
84 | | FillHatchAttribute::ImplType& theGlobalDefault() |
85 | 1.91k | { |
86 | 1.91k | static FillHatchAttribute::ImplType SINGLETON; |
87 | 1.91k | return SINGLETON; |
88 | 1.91k | } |
89 | | } |
90 | | |
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 | 0 | : mpFillHatchAttribute(ImpFillHatchAttribute( |
99 | 0 | eStyle, fDistance, fAngle, rColor, |
100 | 0 | nMinimalDiscreteDistance, bFillBackground)) |
101 | 0 | { |
102 | 0 | } |
103 | | |
104 | | FillHatchAttribute::FillHatchAttribute() |
105 | 838 | : mpFillHatchAttribute(theGlobalDefault()) |
106 | 838 | { |
107 | 838 | } |
108 | | |
109 | 828 | FillHatchAttribute::FillHatchAttribute(const FillHatchAttribute&) = default; |
110 | | |
111 | 1.65k | FillHatchAttribute::FillHatchAttribute(FillHatchAttribute&&) = default; |
112 | | |
113 | 3.32k | FillHatchAttribute::~FillHatchAttribute() = default; |
114 | | |
115 | | bool FillHatchAttribute::isDefault() const |
116 | 1.07k | { |
117 | 1.07k | return mpFillHatchAttribute.same_object(theGlobalDefault()); |
118 | 1.07k | } |
119 | | |
120 | 0 | FillHatchAttribute& FillHatchAttribute::operator=(const FillHatchAttribute&) = default; |
121 | | |
122 | 0 | FillHatchAttribute& FillHatchAttribute::operator=(FillHatchAttribute&&) = default; |
123 | | |
124 | | bool FillHatchAttribute::operator==(const FillHatchAttribute& rCandidate) const |
125 | 150 | { |
126 | | // tdf#87509 default attr is always != non-default attr, even with same values |
127 | 150 | if(rCandidate.isDefault() != isDefault()) |
128 | 0 | return false; |
129 | | |
130 | 150 | return rCandidate.mpFillHatchAttribute == mpFillHatchAttribute; |
131 | 150 | } |
132 | | |
133 | | // data read access |
134 | | HatchStyle FillHatchAttribute::getStyle() const |
135 | 0 | { |
136 | 0 | return mpFillHatchAttribute->getStyle(); |
137 | 0 | } |
138 | | |
139 | | double FillHatchAttribute::getDistance() const |
140 | 0 | { |
141 | 0 | return mpFillHatchAttribute->getDistance(); |
142 | 0 | } |
143 | | |
144 | | double FillHatchAttribute::getAngle() const |
145 | 0 | { |
146 | 0 | return mpFillHatchAttribute->getAngle(); |
147 | 0 | } |
148 | | |
149 | | const basegfx::BColor& FillHatchAttribute::getColor() const |
150 | 0 | { |
151 | 0 | return mpFillHatchAttribute->getColor(); |
152 | 0 | } |
153 | | |
154 | | sal_uInt32 FillHatchAttribute::getMinimalDiscreteDistance() const |
155 | 0 | { |
156 | 0 | return mpFillHatchAttribute->getMinimalDiscreteDistance(); |
157 | 0 | } |
158 | | |
159 | | bool FillHatchAttribute::isFillBackground() const |
160 | 0 | { |
161 | 0 | return mpFillHatchAttribute->isFillBackground(); |
162 | 0 | } |
163 | | |
164 | | } // end of namespace |
165 | | |
166 | | /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ |