1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
|
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
/*
* This file is part of the LibreOffice project.
*
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
*
*/
#pragma once
#include <docmodel/dllapi.h>
#include <tools/color.hxx>
#include <docmodel/theme/ThemeColor.hxx>
namespace model
{
enum class ColorType
{
Unused,
RGB,
CRGB,
HSL,
Scheme,
Palette,
System,
Placeholder
};
enum class SystemColorType
{
Unused,
DarkShadow3D,
Light3D,
ActiveBorder,
ActiveCaption,
AppWorkspace,
Background,
ButtonFace,
ButtonHighlight,
ButtonShadow,
ButtonText,
CaptionText,
GradientActiveCaption,
GradientInactiveCaption,
GrayText,
Highlight,
HighlightText,
HotLight,
InactiveBorder,
InactiveCaption,
InactiveCaptionText,
InfoBack,
InfoText,
Menu,
MenuBar,
MenuHighlight,
MenuText,
ScrollBar,
Window,
WindowFrame,
WindowText
};
struct DOCMODEL_DLLPUBLIC ColorDefinition
{
ColorType meType = ColorType::Unused;
sal_Int32 mnComponent1 = 0; // Red, Hue
sal_Int32 mnComponent2 = 0; // Green, Saturation
sal_Int32 mnComponent3 = 0; // Blue, Luminance
sal_Int32 mnAlpha = 0; // Percentage
SystemColorType meSystemColorType = SystemColorType::Unused;
::Color maLastColor;
ThemeColorType meSchemeType = ThemeColorType::Unknown;
std::vector<Transformation> maTransformations;
void setCRGB(sal_Int32 nR, sal_Int32 nG, sal_Int32 nB)
{
mnComponent1 = nR;
mnComponent2 = nG;
mnComponent3 = nB;
meType = ColorType::CRGB;
}
void setRGB(sal_Int32 nRGB)
{
::Color aColor(ColorTransparency, nRGB);
mnComponent1 = aColor.GetRed();
mnComponent2 = aColor.GetGreen();
mnComponent3 = aColor.GetBlue();
meType = ColorType::RGB;
}
void setHSL(sal_Int32 nH, sal_Int32 nS, sal_Int32 nL)
{
mnComponent1 = nH;
mnComponent2 = nS;
mnComponent3 = nL;
meType = ColorType::HSL;
}
void setSystemColor(SystemColorType eSystemColorType, sal_Int32 nRGB)
{
maLastColor = ::Color(ColorTransparency, nRGB);
meSystemColorType = eSystemColorType;
meType = ColorType::System;
}
void setSchemePlaceholder() { meType = ColorType::Placeholder; }
void setSchemeColor(ThemeColorType eType)
{
meSchemeType = eType;
meType = ColorType::Scheme;
}
};
enum class FillType
{
None,
Solid,
Gradient,
Pattern,
Blip
};
class DOCMODEL_DLLPUBLIC Fill
{
public:
Fill(FillType eType)
: meType(eType)
{
}
FillType meType;
};
class DOCMODEL_DLLPUBLIC NoFill : public Fill
{
public:
NoFill()
: Fill(FillType::None)
{
}
};
class DOCMODEL_DLLPUBLIC SolidFill : public Fill
{
public:
ColorDefinition maColorDefinition;
SolidFill()
: Fill(FillType::Solid)
{
}
};
class DOCMODEL_DLLPUBLIC GradientStop
{
public:
double mfPosition = 0.0; // 0.0 - 1.0
ColorDefinition maColor;
};
enum class GradientType
{
Undefined,
Linear,
Circle,
Rectangle,
Shape,
};
struct DOCMODEL_DLLPUBLIC LinearGradientProperties
{
sal_Int32 mnAngle = 0;
bool mbScaled = false;
};
struct DOCMODEL_DLLPUBLIC RelativeRectangle
{
sal_Int32 mnLeft = 0;
sal_Int32 mnTop = 0;
sal_Int32 mnRight = 0;
sal_Int32 mnBottom = 0;
};
class DOCMODEL_DLLPUBLIC GradientFill : public Fill
{
public:
bool mbRotateWithShape = false;
GradientType meGradientType = GradientType::Undefined;
std::vector<GradientStop> maGradientStops;
LinearGradientProperties maLinearGradient;
RelativeRectangle maFillToRectangle;
RelativeRectangle maTileRectangle;
GradientFill()
: Fill(FillType::Gradient)
{
}
};
// Format Scheme
class DOCMODEL_DLLPUBLIC FillStyle
{
public:
std::shared_ptr<Fill> mpFill;
};
class DOCMODEL_DLLPUBLIC FormatScheme
{
private:
OUString maName;
std::vector<FillStyle> maFillStyleList;
std::vector<FillStyle> maBackgroundFillStyleList;
public:
FormatScheme() = default;
FormatScheme(OUString const& rName)
: maName(rName)
{
}
const OUString& getName() const { return maName; }
std::vector<FillStyle> const& getFillStyleList() const { return maFillStyleList; }
FillStyle* addFillStyle()
{
if (maFillStyleList.size() > 3)
return nullptr;
auto& rFillStyle = maFillStyleList.emplace_back();
return &rFillStyle;
}
std::vector<FillStyle> const& getBackgroundFillStyleList() const
{
return maBackgroundFillStyleList;
}
FillStyle* addBackgroundFillStyle()
{
if (maBackgroundFillStyleList.size() > 3)
return nullptr;
auto& rBackgroundFillStyle = maBackgroundFillStyleList.emplace_back();
return &rBackgroundFillStyle;
}
};
} // end of namespace svx
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|