-
Notifications
You must be signed in to change notification settings - Fork 9
/
Copy pathfpscell.pas
272 lines (229 loc) · 7.57 KB
/
fpscell.pas
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
260
261
262
263
264
265
266
267
268
269
270
271
unit fpsCell;
{$mode objfpc}{$H+}
{$modeswitch advancedrecords}
interface
uses
Classes, SysUtils, fpstypes, fpspreadsheet;
type
TCellHelper = record helper for TCell
private
function GetBackgroundColor: TsColor;
function GetBorder: TsCellBorders;
function GetBorderStyle(const ABorder: TsCellBorder): TsCellBorderStyle;
function GetBorderStyles: TsCellBorderStyles;
function GetCellFormat: TsCellFormat;
function GetComment: String;
function GetFont: TsFont;
function GetFontIndex: integer;
function GetHorAlignment: TsHorAlignment;
function GetHyperlink: TsHyperlink;
function GetNumberFormat: TsNumberFormat;
function GetNumberFormatStr: String;
function GetTextRotation: TsTextRotation;
function GetUsedFormattingFields: TsUsedFormattingFields;
function GetVertAlignment: TsVertAlignment;
function GetWordwrap: Boolean;
procedure SetBackgroundColor(const AValue: TsColor);
procedure SetBorder(const AValue: TsCellBorders);
procedure SetBorderStyle(const ABorder: TsCellBorder; const AValue: TsCellBorderStyle);
procedure SetBorderStyles(const AValue: TsCellBorderStyles);
procedure SetCellFormat(const AValue: TsCellFormat);
procedure SetComment(const AValue: String);
procedure SetFontIndex(const AValue: Integer);
procedure SetHorAlignment(const AValue: TsHorAlignment);
procedure SetHyperlink(const AValue: TsHyperlink);
procedure SetNumberFormat(const AValue: TsNumberFormat);
procedure SetNumberFormatStr(const AValue: String);
procedure SetTextRotation(const AValue: TsTextRotation);
procedure SetUsedFormattingFields(const AValue: TsUsedFormattingFields);
procedure SetVertAlignment(const AValue: TsVertAlignment);
procedure SetWordwrap(const AValue: Boolean);
protected
function GetWorkbook: TsWorkbook; inline;
function GetWorksheet: TsWorksheet; inline;
public
property BackgroundColor: TsColor
read GetBackgroundColor write SetBackgroundColor;
property Border: TsCellBorders
read GetBorder write SetBorder;
property BorderStyle[ABorder: TsCellBorder]: TsCellBorderStyle
read GetBorderStyle write SetBorderStyle;
property BorderStyles: TsCellBorderStyles
read GetBorderStyles write SetBorderStyles;
property CellFormat: TsCellFormat
read GetCellFormat write SetCellFormat;
property Comment: String
read GetComment write SetComment;
property Font: TsFont read GetFont;
property FontIndex: Integer
read GetFontIndex write SetFontIndex;
property HorAlignment: TsHorAlignment
read GetHorAlignment write SetHorAlignment;
property Hyperlink: TsHyperlink
read GetHyperlink write SetHyperlink;
property NumberFormat: TsNumberFormat
read GetNumberFormat write SetNumberFormat;
property NumberFormatStr: String
read GetNumberFormatStr write SetNumberFormatStr;
property TextRotation: TsTextRotation
read GetTextRotation write SetTextRotation;
property UsedFormattingFields: TsUsedFormattingFields
read GetUsedFormattingFields write SetUsedFormattingFields;
property VertAlignment: TsVertAlignment
read GetVertAlignment write SetVertAlignment;
property Wordwrap: Boolean
read GetWordwrap write SetWordwrap;
property Workbook: TsWorkbook read GetWorkbook;
end;
implementation
function TCellHelper.GetBackgroundColor: TsColor;
begin
Result := GetWorksheet.ReadBackgroundColor(@self);
end;
function TCellHelper.GetBorder: TsCellBorders;
begin
Result := GetWorksheet.ReadCellBorders(@self);
end;
function TCellHelper.GetBorderStyle(const ABorder: TsCellBorder): TsCellBorderStyle;
begin
Result := GetWorksheet.ReadCellBorderStyle(@self, ABorder);
end;
function TCellHelper.GetBorderStyles: TsCellBorderStyles;
begin
Result := GetWorksheet.ReadCellBorderStyles(@self);
end;
function TCellHelper.GetCellFormat: TsCellFormat;
begin
Result := GetWorkbook.GetCellFormat(FormatIndex);
end;
function TCellHelper.GetComment: String;
begin
Result := GetWorksheet.ReadComment(@self);
end;
function TCellHelper.GetFont: TsFont;
begin
Result := GetWorksheet.ReadCellFont(@self);
end;
function TCellHelper.GetFontIndex: Integer;
var
fmt: PsCellFormat;
begin
fmt := Workbook.GetPointerToCellFormat(FormatIndex);
Result := fmt^.FontIndex;
end;
function TCellHelper.GetHorAlignment: TsHorAlignment;
begin
Result := GetWorksheet.ReadHorAlignment(@Self);
end;
function TCellHelper.GetHyperlink: TsHyperlink;
begin
Result := GetWorksheet.ReadHyperlink(@self);
end;
function TCellHelper.GetNumberFormat: TsNumberFormat;
var
fmt: PsCellFormat;
begin
fmt := Workbook.GetPointerToCellFormat(FormatIndex);
Result := fmt^.NumberFormat;
end;
function TCellHelper.GetNumberFormatStr: String;
var
fmt: PsCellFormat;
begin
fmt := Workbook.GetPointerToCellFormat(FormatIndex);
Result := fmt^.NumberFormatStr;
end;
function TCellHelper.GetTextRotation: TsTextRotation;
begin
Result := GetWorksheet.ReadTextRotation(@Self);
end;
function TCellHelper.GetUsedFormattingFields: TsUsedFormattingFields;
begin
Result := GetWorksheet.ReadUsedFormatting(@Self);
end;
function TCellHelper.GetVertAlignment: TsVertAlignment;
begin
Result := GetWorksheet.ReadVertAlignment(@self);
end;
function TCellHelper.GetWordwrap: Boolean;
begin
Result := GetWorksheet.ReadWordwrap(@self);
end;
function TCellHelper.GetWorkbook: TsWorkbook;
begin
Result := GetWorksheet.Workbook;
end;
function TCellHelper.GetWorksheet: TsWorksheet;
begin
Result := TsWorksheet(Worksheet);
end;
procedure TCellHelper.SetBackgroundColor(const AValue: TsColor);
begin
GetWorksheet.WriteBackgroundColor(@self, AValue);
end;
procedure TCellHelper.SetBorder(const AValue: TsCellBorders);
begin
GetWorksheet.WriteBorders(@self, AValue);
end;
procedure TCellHelper.SetBorderStyle(const ABorder: TsCellBorder;
const AValue: TsCellBorderStyle);
begin
GetWorksheet.WriteBorderStyle(@self, ABorder, AValue);
end;
procedure TCellHelper.SetBorderStyles(const AValue: TsCellBorderStyles);
begin
GetWorksheet.WriteBorderStyles(@self, AValue);
end;
procedure TCellHelper.SetCellFormat(const AValue: TsCellFormat);
begin
GetWorksheet.WriteCellFormat(@self, AValue);
end;
procedure TCellHelper.SetComment(const AValue: String);
begin
GetWorksheet.WriteComment(@self, AValue);
end;
procedure TCellHelper.SetFontIndex(const AValue: Integer);
begin
GetWorksheet.WriteFont(@self, AValue);
end;
procedure TCellHelper.SetHorAlignment(const AValue: TsHorAlignment);
begin
GetWorksheet.WriteHorAlignment(@self, AValue);
end;
procedure TCellHelper.SetHyperlink(const AValue: TsHyperlink);
begin
GetWorksheet.WriteHyperlink(@self, AValue.Target, AValue.Tooltip);
end;
procedure TCellHelper.SetNumberFormat(const AValue: TsNumberFormat);
var
fmt: TsCellFormat;
begin
fmt := Workbook.GetCellFormat(FormatIndex);
fmt.NumberFormat := AValue;
GetWorksheet.WriteCellFormat(@self, fmt);
end;
procedure TCellHelper.SetNumberFormatStr(const AValue: String);
var
fmt: TsCellFormat;
begin
fmt := Workbook.GetCellFormat(FormatIndex);
fmt.NumberFormatStr := AValue;
GetWorksheet.WriteCellFormat(@self, fmt);
end;
procedure TCellHelper.SetTextRotation(const AValue: TsTextRotation);
begin
GetWorksheet.WriteTextRotation(@self, AValue);
end;
procedure TCellHelper.SetUsedFormattingFields(const AValue: TsUsedFormattingFields);
begin
GetWorksheet.WriteUsedFormatting(@self, AValue);
end;
procedure TCellHelper.SetVertAlignment(const AValue: TsVertAlignment);
begin
GetWorksheet.WriteVertAlignment(@self, AValue);
end;
procedure TCellHelper.SetWordwrap(const AValue: Boolean);
begin
GetWorksheet.WriteWordwrap(@self, AValue);
end;
end.