line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Excel::Writer::XLSX::Format; |
2
|
|
|
|
|
|
|
|
3
|
|
|
|
|
|
|
############################################################################### |
4
|
|
|
|
|
|
|
# |
5
|
|
|
|
|
|
|
# Format - A class for defining Excel formatting. |
6
|
|
|
|
|
|
|
# |
7
|
|
|
|
|
|
|
# |
8
|
|
|
|
|
|
|
# Used in conjunction with Excel::Writer::XLSX |
9
|
|
|
|
|
|
|
# |
10
|
|
|
|
|
|
|
# Copyright 2000-2019, John McNamara, jmcnamara@cpan.org |
11
|
|
|
|
|
|
|
# |
12
|
|
|
|
|
|
|
# Documentation after __END__ |
13
|
|
|
|
|
|
|
# |
14
|
|
|
|
|
|
|
|
15
|
1041
|
|
|
1041
|
|
17539
|
use 5.008002; |
|
1041
|
|
|
|
|
15031
|
|
16
|
1041
|
|
|
1041
|
|
6062
|
use Exporter; |
|
1041
|
|
|
|
|
2033
|
|
|
1041
|
|
|
|
|
33827
|
|
17
|
1041
|
|
|
1041
|
|
5714
|
use strict; |
|
1041
|
|
|
|
|
2190
|
|
|
1041
|
|
|
|
|
23760
|
|
18
|
1041
|
|
|
1041
|
|
5590
|
use warnings; |
|
1041
|
|
|
|
|
2351
|
|
|
1041
|
|
|
|
|
29486
|
|
19
|
1041
|
|
|
1041
|
|
5976
|
use Carp; |
|
1041
|
|
|
|
|
2289
|
|
|
1041
|
|
|
|
|
2589723
|
|
20
|
|
|
|
|
|
|
|
21
|
|
|
|
|
|
|
|
22
|
|
|
|
|
|
|
our @ISA = qw(Exporter); |
23
|
|
|
|
|
|
|
our $VERSION = '1.03'; |
24
|
|
|
|
|
|
|
our $AUTOLOAD; |
25
|
|
|
|
|
|
|
|
26
|
|
|
|
|
|
|
|
27
|
|
|
|
|
|
|
############################################################################### |
28
|
|
|
|
|
|
|
# |
29
|
|
|
|
|
|
|
# new() |
30
|
|
|
|
|
|
|
# |
31
|
|
|
|
|
|
|
# Constructor |
32
|
|
|
|
|
|
|
# |
33
|
|
|
|
|
|
|
sub new { |
34
|
|
|
|
|
|
|
|
35
|
2002
|
|
|
2002
|
0
|
38062
|
my $class = shift; |
36
|
|
|
|
|
|
|
|
37
|
2002
|
|
|
|
|
52543
|
my $self = { |
38
|
|
|
|
|
|
|
_xf_format_indices => shift, |
39
|
|
|
|
|
|
|
_dxf_format_indices => shift, |
40
|
|
|
|
|
|
|
_xf_index => undef, |
41
|
|
|
|
|
|
|
_dxf_index => undef, |
42
|
|
|
|
|
|
|
|
43
|
|
|
|
|
|
|
_num_format => 'General', |
44
|
|
|
|
|
|
|
_num_format_index => 0, |
45
|
|
|
|
|
|
|
_font_index => 0, |
46
|
|
|
|
|
|
|
_has_font => 0, |
47
|
|
|
|
|
|
|
_has_dxf_font => 0, |
48
|
|
|
|
|
|
|
_font => 'Calibri', |
49
|
|
|
|
|
|
|
_size => 11, |
50
|
|
|
|
|
|
|
_bold => 0, |
51
|
|
|
|
|
|
|
_italic => 0, |
52
|
|
|
|
|
|
|
_color => 0x0, |
53
|
|
|
|
|
|
|
_underline => 0, |
54
|
|
|
|
|
|
|
_font_strikeout => 0, |
55
|
|
|
|
|
|
|
_font_outline => 0, |
56
|
|
|
|
|
|
|
_font_shadow => 0, |
57
|
|
|
|
|
|
|
_font_script => 0, |
58
|
|
|
|
|
|
|
_font_family => 2, |
59
|
|
|
|
|
|
|
_font_charset => 0, |
60
|
|
|
|
|
|
|
_font_scheme => 'minor', |
61
|
|
|
|
|
|
|
_font_condense => 0, |
62
|
|
|
|
|
|
|
_font_extend => 0, |
63
|
|
|
|
|
|
|
_theme => 0, |
64
|
|
|
|
|
|
|
_hyperlink => 0, |
65
|
|
|
|
|
|
|
_xf_id => 0, |
66
|
|
|
|
|
|
|
|
67
|
|
|
|
|
|
|
_hidden => 0, |
68
|
|
|
|
|
|
|
_locked => 1, |
69
|
|
|
|
|
|
|
|
70
|
|
|
|
|
|
|
_text_h_align => 0, |
71
|
|
|
|
|
|
|
_text_wrap => 0, |
72
|
|
|
|
|
|
|
_text_v_align => 0, |
73
|
|
|
|
|
|
|
_text_justlast => 0, |
74
|
|
|
|
|
|
|
_rotation => 0, |
75
|
|
|
|
|
|
|
|
76
|
|
|
|
|
|
|
_fg_color => 0x00, |
77
|
|
|
|
|
|
|
_bg_color => 0x00, |
78
|
|
|
|
|
|
|
_pattern => 0, |
79
|
|
|
|
|
|
|
_has_fill => 0, |
80
|
|
|
|
|
|
|
_has_dxf_fill => 0, |
81
|
|
|
|
|
|
|
_fill_index => 0, |
82
|
|
|
|
|
|
|
_fill_count => 0, |
83
|
|
|
|
|
|
|
|
84
|
|
|
|
|
|
|
_border_index => 0, |
85
|
|
|
|
|
|
|
_has_border => 0, |
86
|
|
|
|
|
|
|
_has_dxf_border => 0, |
87
|
|
|
|
|
|
|
_border_count => 0, |
88
|
|
|
|
|
|
|
|
89
|
|
|
|
|
|
|
_bottom => 0, |
90
|
|
|
|
|
|
|
_bottom_color => 0x0, |
91
|
|
|
|
|
|
|
_diag_border => 0, |
92
|
|
|
|
|
|
|
_diag_color => 0x0, |
93
|
|
|
|
|
|
|
_diag_type => 0, |
94
|
|
|
|
|
|
|
_left => 0, |
95
|
|
|
|
|
|
|
_left_color => 0x0, |
96
|
|
|
|
|
|
|
_right => 0, |
97
|
|
|
|
|
|
|
_right_color => 0x0, |
98
|
|
|
|
|
|
|
_top => 0, |
99
|
|
|
|
|
|
|
_top_color => 0x0, |
100
|
|
|
|
|
|
|
|
101
|
|
|
|
|
|
|
_indent => 0, |
102
|
|
|
|
|
|
|
_shrink => 0, |
103
|
|
|
|
|
|
|
_merge_range => 0, |
104
|
|
|
|
|
|
|
_reading_order => 0, |
105
|
|
|
|
|
|
|
_just_distrib => 0, |
106
|
|
|
|
|
|
|
_color_indexed => 0, |
107
|
|
|
|
|
|
|
_font_only => 0, |
108
|
|
|
|
|
|
|
|
109
|
|
|
|
|
|
|
}; |
110
|
|
|
|
|
|
|
|
111
|
2002
|
|
|
|
|
4872
|
bless $self, $class; |
112
|
|
|
|
|
|
|
|
113
|
|
|
|
|
|
|
# Set properties passed to Workbook::add_format() |
114
|
2002
|
100
|
|
|
|
9984
|
$self->set_format_properties(@_) if @_; |
115
|
|
|
|
|
|
|
|
116
|
2002
|
|
|
|
|
6704
|
return $self; |
117
|
|
|
|
|
|
|
} |
118
|
|
|
|
|
|
|
|
119
|
|
|
|
|
|
|
|
120
|
|
|
|
|
|
|
############################################################################### |
121
|
|
|
|
|
|
|
# |
122
|
|
|
|
|
|
|
# copy($format) |
123
|
|
|
|
|
|
|
# |
124
|
|
|
|
|
|
|
# Copy the attributes of another Excel::Writer::XLSX::Format object. |
125
|
|
|
|
|
|
|
# |
126
|
|
|
|
|
|
|
sub copy { |
127
|
2
|
|
|
2
|
0
|
9
|
my $self = shift; |
128
|
2
|
|
|
|
|
4
|
my $other = $_[0]; |
129
|
|
|
|
|
|
|
|
130
|
|
|
|
|
|
|
|
131
|
2
|
50
|
|
|
|
14
|
return unless defined $other; |
132
|
2
|
50
|
|
|
|
8
|
return unless ( ref( $self ) eq ref( $other ) ); |
133
|
|
|
|
|
|
|
|
134
|
|
|
|
|
|
|
# Store properties that we don't want over-ridden. |
135
|
2
|
|
|
|
|
5
|
my $xf_index = $self->{_xf_index}; |
136
|
2
|
|
|
|
|
4
|
my $dxf_index = $self->{_dxf_index}; |
137
|
2
|
|
|
|
|
3
|
my $xf_format_indices = $self->{_xf_format_indices}; |
138
|
2
|
|
|
|
|
10
|
my $dxf_format_indices = $self->{_dxf_format_indices}; |
139
|
2
|
|
|
|
|
5
|
my $palette = $self->{_palette}; |
140
|
|
|
|
|
|
|
|
141
|
|
|
|
|
|
|
# Copy properties. |
142
|
2
|
|
|
|
|
42
|
%$self = %$other; |
143
|
|
|
|
|
|
|
|
144
|
|
|
|
|
|
|
# Restore original properties. |
145
|
2
|
|
|
|
|
7
|
$self->{_xf_index} = $xf_index; |
146
|
2
|
|
|
|
|
4
|
$self->{_dxf_index} = $dxf_index; |
147
|
2
|
|
|
|
|
4
|
$self->{_xf_format_indices} = $xf_format_indices; |
148
|
2
|
|
|
|
|
3
|
$self->{_dxf_format_indices} = $dxf_format_indices; |
149
|
2
|
|
|
|
|
10
|
$self->{_palette} = $palette; |
150
|
|
|
|
|
|
|
} |
151
|
|
|
|
|
|
|
|
152
|
|
|
|
|
|
|
|
153
|
|
|
|
|
|
|
############################################################################### |
154
|
|
|
|
|
|
|
# |
155
|
|
|
|
|
|
|
# get_align_properties() |
156
|
|
|
|
|
|
|
# |
157
|
|
|
|
|
|
|
# Return properties for an Style xf sub-element. |
158
|
|
|
|
|
|
|
# |
159
|
|
|
|
|
|
|
sub get_align_properties { |
160
|
|
|
|
|
|
|
|
161
|
1113
|
|
|
1113
|
0
|
2773
|
my $self = shift; |
162
|
|
|
|
|
|
|
|
163
|
1113
|
|
|
|
|
2668
|
my @align; # Attributes to return |
164
|
|
|
|
|
|
|
|
165
|
|
|
|
|
|
|
# Check if any alignment options in the format have been changed. |
166
|
|
|
|
|
|
|
my $changed = |
167
|
|
|
|
|
|
|
( $self->{_text_h_align} != 0 |
168
|
|
|
|
|
|
|
|| $self->{_text_v_align} != 0 |
169
|
|
|
|
|
|
|
|| $self->{_indent} != 0 |
170
|
|
|
|
|
|
|
|| $self->{_rotation} != 0 |
171
|
|
|
|
|
|
|
|| $self->{_text_wrap} != 0 |
172
|
|
|
|
|
|
|
|| $self->{_shrink} != 0 |
173
|
1113
|
100
|
100
|
|
|
25332
|
|| $self->{_reading_order} != 0 ) ? 1 : 0; |
174
|
|
|
|
|
|
|
|
175
|
1113
|
100
|
|
|
|
6560
|
return unless $changed; |
176
|
|
|
|
|
|
|
|
177
|
|
|
|
|
|
|
|
178
|
|
|
|
|
|
|
|
179
|
|
|
|
|
|
|
# Indent is only allowed for horizontal left, right and distributed. If it |
180
|
|
|
|
|
|
|
# is defined for any other alignment or no alignment has been set then |
181
|
|
|
|
|
|
|
# default to left alignment. |
182
|
45
|
100
|
100
|
|
|
202
|
if ( $self->{_indent} |
|
|
|
100
|
|
|
|
|
|
|
|
100
|
|
|
|
|
183
|
|
|
|
|
|
|
&& $self->{_text_h_align} != 1 |
184
|
|
|
|
|
|
|
&& $self->{_text_h_align} != 3 |
185
|
|
|
|
|
|
|
&& $self->{_text_h_align} != 7 ) |
186
|
|
|
|
|
|
|
{ |
187
|
1
|
|
|
|
|
4
|
$self->{_text_h_align} = 1; |
188
|
|
|
|
|
|
|
} |
189
|
|
|
|
|
|
|
|
190
|
|
|
|
|
|
|
# Check for properties that are mutually exclusive. |
191
|
45
|
100
|
|
|
|
169
|
$self->{_shrink} = 0 if $self->{_text_wrap}; |
192
|
45
|
100
|
|
|
|
151
|
$self->{_shrink} = 0 if $self->{_text_h_align} == 4; # Fill |
193
|
45
|
100
|
|
|
|
152
|
$self->{_shrink} = 0 if $self->{_text_h_align} == 5; # Justify |
194
|
45
|
100
|
|
|
|
112
|
$self->{_shrink} = 0 if $self->{_text_h_align} == 7; # Distributed |
195
|
45
|
100
|
|
|
|
163
|
$self->{_just_distrib} = 0 if $self->{_text_h_align} != 7; # Distributed |
196
|
45
|
100
|
|
|
|
131
|
$self->{_just_distrib} = 0 if $self->{_indent}; |
197
|
|
|
|
|
|
|
|
198
|
45
|
|
|
|
|
89
|
my $continuous = 'centerContinuous'; |
199
|
|
|
|
|
|
|
|
200
|
45
|
100
|
|
|
|
120
|
push @align, 'horizontal', 'left' if $self->{_text_h_align} == 1; |
201
|
45
|
100
|
|
|
|
146
|
push @align, 'horizontal', 'center' if $self->{_text_h_align} == 2; |
202
|
45
|
100
|
|
|
|
116
|
push @align, 'horizontal', 'right' if $self->{_text_h_align} == 3; |
203
|
45
|
100
|
|
|
|
127
|
push @align, 'horizontal', 'fill' if $self->{_text_h_align} == 4; |
204
|
45
|
100
|
|
|
|
118
|
push @align, 'horizontal', 'justify' if $self->{_text_h_align} == 5; |
205
|
45
|
100
|
|
|
|
114
|
push @align, 'horizontal', $continuous if $self->{_text_h_align} == 6; |
206
|
45
|
100
|
|
|
|
121
|
push @align, 'horizontal', 'distributed' if $self->{_text_h_align} == 7; |
207
|
|
|
|
|
|
|
|
208
|
45
|
100
|
|
|
|
109
|
push @align, 'justifyLastLine', 1 if $self->{_just_distrib}; |
209
|
|
|
|
|
|
|
|
210
|
|
|
|
|
|
|
# Property 'vertical' => 'bottom' is a default. It sets applyAlignment |
211
|
|
|
|
|
|
|
# without an alignment sub-element. |
212
|
45
|
100
|
|
|
|
162
|
push @align, 'vertical', 'top' if $self->{_text_v_align} == 1; |
213
|
45
|
100
|
|
|
|
151
|
push @align, 'vertical', 'center' if $self->{_text_v_align} == 2; |
214
|
45
|
100
|
|
|
|
116
|
push @align, 'vertical', 'justify' if $self->{_text_v_align} == 4; |
215
|
45
|
100
|
|
|
|
128
|
push @align, 'vertical', 'distributed' if $self->{_text_v_align} == 5; |
216
|
|
|
|
|
|
|
|
217
|
45
|
100
|
|
|
|
125
|
push @align, 'indent', $self->{_indent} if $self->{_indent}; |
218
|
45
|
100
|
|
|
|
179
|
push @align, 'textRotation', $self->{_rotation} if $self->{_rotation}; |
219
|
|
|
|
|
|
|
|
220
|
45
|
100
|
|
|
|
112
|
push @align, 'wrapText', 1 if $self->{_text_wrap}; |
221
|
45
|
100
|
|
|
|
122
|
push @align, 'shrinkToFit', 1 if $self->{_shrink}; |
222
|
|
|
|
|
|
|
|
223
|
45
|
100
|
|
|
|
124
|
push @align, 'readingOrder', 1 if $self->{_reading_order} == 1; |
224
|
45
|
100
|
|
|
|
143
|
push @align, 'readingOrder', 2 if $self->{_reading_order} == 2; |
225
|
|
|
|
|
|
|
|
226
|
45
|
|
|
|
|
194
|
return $changed, @align; |
227
|
|
|
|
|
|
|
} |
228
|
|
|
|
|
|
|
|
229
|
|
|
|
|
|
|
|
230
|
|
|
|
|
|
|
############################################################################### |
231
|
|
|
|
|
|
|
# |
232
|
|
|
|
|
|
|
# get_protection_properties() |
233
|
|
|
|
|
|
|
# |
234
|
|
|
|
|
|
|
# Return properties for an Excel XML element. |
235
|
|
|
|
|
|
|
# |
236
|
|
|
|
|
|
|
sub get_protection_properties { |
237
|
|
|
|
|
|
|
|
238
|
1113
|
|
|
1113
|
0
|
2664
|
my $self = shift; |
239
|
|
|
|
|
|
|
|
240
|
1113
|
|
|
|
|
2463
|
my @attribs; |
241
|
|
|
|
|
|
|
|
242
|
1113
|
100
|
|
|
|
4174
|
push @attribs, 'locked', 0 if !$self->{_locked}; |
243
|
1113
|
100
|
|
|
|
4375
|
push @attribs, 'hidden', 1 if $self->{_hidden}; |
244
|
|
|
|
|
|
|
|
245
|
1113
|
|
|
|
|
3711
|
return @attribs; |
246
|
|
|
|
|
|
|
} |
247
|
|
|
|
|
|
|
|
248
|
|
|
|
|
|
|
|
249
|
|
|
|
|
|
|
############################################################################### |
250
|
|
|
|
|
|
|
# |
251
|
|
|
|
|
|
|
# get_format_key() |
252
|
|
|
|
|
|
|
# |
253
|
|
|
|
|
|
|
# Returns a unique hash key for the Format object. |
254
|
|
|
|
|
|
|
# |
255
|
|
|
|
|
|
|
sub get_format_key { |
256
|
|
|
|
|
|
|
|
257
|
283
|
|
|
283
|
0
|
609
|
my $self = shift; |
258
|
|
|
|
|
|
|
|
259
|
|
|
|
|
|
|
my $key = join ':', |
260
|
|
|
|
|
|
|
( |
261
|
|
|
|
|
|
|
$self->get_font_key(), $self->get_border_key, |
262
|
|
|
|
|
|
|
$self->get_fill_key(), $self->get_alignment_key(), |
263
|
|
|
|
|
|
|
$self->{_num_format}, $self->{_locked}, |
264
|
|
|
|
|
|
|
$self->{_hidden} |
265
|
283
|
|
|
|
|
998
|
); |
266
|
|
|
|
|
|
|
|
267
|
283
|
|
|
|
|
1184
|
return $key; |
268
|
|
|
|
|
|
|
} |
269
|
|
|
|
|
|
|
|
270
|
|
|
|
|
|
|
############################################################################### |
271
|
|
|
|
|
|
|
# |
272
|
|
|
|
|
|
|
# get_font_key() |
273
|
|
|
|
|
|
|
# |
274
|
|
|
|
|
|
|
# Returns a unique hash key for a font. Used by Workbook. |
275
|
|
|
|
|
|
|
# |
276
|
|
|
|
|
|
|
sub get_font_key { |
277
|
|
|
|
|
|
|
|
278
|
1394
|
|
|
1394
|
0
|
4688
|
my $self = shift; |
279
|
|
|
|
|
|
|
|
280
|
|
|
|
|
|
|
my $key = join ':', ( |
281
|
|
|
|
|
|
|
$self->{_bold}, |
282
|
|
|
|
|
|
|
$self->{_color}, |
283
|
|
|
|
|
|
|
$self->{_font_charset}, |
284
|
|
|
|
|
|
|
$self->{_font_family}, |
285
|
|
|
|
|
|
|
$self->{_font_outline}, |
286
|
|
|
|
|
|
|
$self->{_font_script}, |
287
|
|
|
|
|
|
|
$self->{_font_shadow}, |
288
|
|
|
|
|
|
|
$self->{_font_strikeout}, |
289
|
|
|
|
|
|
|
$self->{_font}, |
290
|
|
|
|
|
|
|
$self->{_italic}, |
291
|
|
|
|
|
|
|
$self->{_size}, |
292
|
|
|
|
|
|
|
$self->{_underline}, |
293
|
|
|
|
|
|
|
$self->{_theme}, |
294
|
|
|
|
|
|
|
|
295
|
1394
|
|
|
|
|
11743
|
); |
296
|
|
|
|
|
|
|
|
297
|
1394
|
|
|
|
|
5558
|
return $key; |
298
|
|
|
|
|
|
|
} |
299
|
|
|
|
|
|
|
|
300
|
|
|
|
|
|
|
|
301
|
|
|
|
|
|
|
############################################################################### |
302
|
|
|
|
|
|
|
# |
303
|
|
|
|
|
|
|
# get_border_key() |
304
|
|
|
|
|
|
|
# |
305
|
|
|
|
|
|
|
# Returns a unique hash key for a border style. Used by Workbook. |
306
|
|
|
|
|
|
|
# |
307
|
|
|
|
|
|
|
sub get_border_key { |
308
|
|
|
|
|
|
|
|
309
|
1427
|
|
|
1427
|
0
|
2899
|
my $self = shift; |
310
|
|
|
|
|
|
|
|
311
|
|
|
|
|
|
|
my $key = join ':', ( |
312
|
|
|
|
|
|
|
$self->{_bottom}, |
313
|
|
|
|
|
|
|
$self->{_bottom_color}, |
314
|
|
|
|
|
|
|
$self->{_diag_border}, |
315
|
|
|
|
|
|
|
$self->{_diag_color}, |
316
|
|
|
|
|
|
|
$self->{_diag_type}, |
317
|
|
|
|
|
|
|
$self->{_left}, |
318
|
|
|
|
|
|
|
$self->{_left_color}, |
319
|
|
|
|
|
|
|
$self->{_right}, |
320
|
|
|
|
|
|
|
$self->{_right_color}, |
321
|
|
|
|
|
|
|
$self->{_top}, |
322
|
|
|
|
|
|
|
$self->{_top_color}, |
323
|
|
|
|
|
|
|
|
324
|
1427
|
|
|
|
|
9036
|
); |
325
|
|
|
|
|
|
|
|
326
|
1427
|
|
|
|
|
4599
|
return $key; |
327
|
|
|
|
|
|
|
} |
328
|
|
|
|
|
|
|
|
329
|
|
|
|
|
|
|
|
330
|
|
|
|
|
|
|
############################################################################### |
331
|
|
|
|
|
|
|
# |
332
|
|
|
|
|
|
|
# get_fill_key() |
333
|
|
|
|
|
|
|
# |
334
|
|
|
|
|
|
|
# Returns a unique hash key for a fill style. Used by Workbook. |
335
|
|
|
|
|
|
|
# |
336
|
|
|
|
|
|
|
sub get_fill_key { |
337
|
|
|
|
|
|
|
|
338
|
1394
|
|
|
1394
|
0
|
2959
|
my $self = shift; |
339
|
|
|
|
|
|
|
|
340
|
|
|
|
|
|
|
my $key = join ':', ( |
341
|
|
|
|
|
|
|
$self->{_pattern}, |
342
|
|
|
|
|
|
|
$self->{_bg_color}, |
343
|
|
|
|
|
|
|
$self->{_fg_color}, |
344
|
|
|
|
|
|
|
|
345
|
1394
|
|
|
|
|
5212
|
); |
346
|
|
|
|
|
|
|
|
347
|
1394
|
|
|
|
|
4482
|
return $key; |
348
|
|
|
|
|
|
|
} |
349
|
|
|
|
|
|
|
|
350
|
|
|
|
|
|
|
|
351
|
|
|
|
|
|
|
############################################################################### |
352
|
|
|
|
|
|
|
# |
353
|
|
|
|
|
|
|
# get_alignment_key() |
354
|
|
|
|
|
|
|
# |
355
|
|
|
|
|
|
|
# Returns a unique hash key for alignment formats. |
356
|
|
|
|
|
|
|
# |
357
|
|
|
|
|
|
|
sub get_alignment_key { |
358
|
|
|
|
|
|
|
|
359
|
283
|
|
|
283
|
0
|
577
|
my $self = shift; |
360
|
|
|
|
|
|
|
|
361
|
|
|
|
|
|
|
my $key = join ':', ( |
362
|
|
|
|
|
|
|
$self->{_text_h_align}, |
363
|
|
|
|
|
|
|
$self->{_text_v_align}, |
364
|
|
|
|
|
|
|
$self->{_indent}, |
365
|
|
|
|
|
|
|
$self->{_rotation}, |
366
|
|
|
|
|
|
|
$self->{_text_wrap}, |
367
|
|
|
|
|
|
|
$self->{_shrink}, |
368
|
|
|
|
|
|
|
$self->{_reading_order}, |
369
|
|
|
|
|
|
|
|
370
|
283
|
|
|
|
|
1605
|
); |
371
|
|
|
|
|
|
|
|
372
|
283
|
|
|
|
|
1249
|
return $key; |
373
|
|
|
|
|
|
|
} |
374
|
|
|
|
|
|
|
|
375
|
|
|
|
|
|
|
|
376
|
|
|
|
|
|
|
############################################################################### |
377
|
|
|
|
|
|
|
# |
378
|
|
|
|
|
|
|
# get_xf_index() |
379
|
|
|
|
|
|
|
# |
380
|
|
|
|
|
|
|
# Returns the index used by Worksheet->_XF() |
381
|
|
|
|
|
|
|
# |
382
|
|
|
|
|
|
|
sub get_xf_index { |
383
|
550
|
|
|
550
|
0
|
1005
|
my $self = shift; |
384
|
|
|
|
|
|
|
|
385
|
550
|
100
|
|
|
|
1556
|
if ( defined $self->{_xf_index} ) { |
386
|
286
|
|
|
|
|
823
|
return $self->{_xf_index}; |
387
|
|
|
|
|
|
|
} |
388
|
|
|
|
|
|
|
else { |
389
|
264
|
|
|
|
|
971
|
my $key = $self->get_format_key(); |
390
|
264
|
|
|
|
|
575
|
my $indices_href = ${ $self->{_xf_format_indices} }; |
|
264
|
|
|
|
|
644
|
|
391
|
|
|
|
|
|
|
|
392
|
264
|
100
|
|
|
|
890
|
if ( exists $indices_href->{$key} ) { |
393
|
8
|
|
|
|
|
20
|
return $indices_href->{$key}; |
394
|
|
|
|
|
|
|
} |
395
|
|
|
|
|
|
|
else { |
396
|
256
|
|
|
|
|
1022
|
my $index = 1 + scalar keys %$indices_href; |
397
|
256
|
|
|
|
|
754
|
$indices_href->{$key} = $index; |
398
|
256
|
|
|
|
|
794
|
$self->{_xf_index} = $index; |
399
|
256
|
|
|
|
|
883
|
return $index; |
400
|
|
|
|
|
|
|
} |
401
|
|
|
|
|
|
|
} |
402
|
|
|
|
|
|
|
} |
403
|
|
|
|
|
|
|
|
404
|
|
|
|
|
|
|
|
405
|
|
|
|
|
|
|
############################################################################### |
406
|
|
|
|
|
|
|
# |
407
|
|
|
|
|
|
|
# get_dxf_index() |
408
|
|
|
|
|
|
|
# |
409
|
|
|
|
|
|
|
# Returns the index used by Worksheet->_XF() |
410
|
|
|
|
|
|
|
# |
411
|
|
|
|
|
|
|
sub get_dxf_index { |
412
|
37
|
|
|
37
|
0
|
115
|
my $self = shift; |
413
|
|
|
|
|
|
|
|
414
|
37
|
100
|
|
|
|
140
|
if ( defined $self->{_dxf_index} ) { |
415
|
18
|
|
|
|
|
59
|
return $self->{_dxf_index}; |
416
|
|
|
|
|
|
|
} |
417
|
|
|
|
|
|
|
else { |
418
|
19
|
|
|
|
|
86
|
my $key = $self->get_format_key(); |
419
|
19
|
|
|
|
|
44
|
my $indices_href = ${ $self->{_dxf_format_indices} }; |
|
19
|
|
|
|
|
52
|
|
420
|
|
|
|
|
|
|
|
421
|
19
|
50
|
|
|
|
79
|
if ( exists $indices_href->{$key} ) { |
422
|
0
|
|
|
|
|
0
|
return $indices_href->{$key}; |
423
|
|
|
|
|
|
|
} |
424
|
|
|
|
|
|
|
else { |
425
|
19
|
|
|
|
|
93
|
my $index = scalar keys %$indices_href; |
426
|
19
|
|
|
|
|
97
|
$indices_href->{$key} = $index; |
427
|
19
|
|
|
|
|
49
|
$self->{_dxf_index} = $index; |
428
|
19
|
|
|
|
|
83
|
return $index; |
429
|
|
|
|
|
|
|
} |
430
|
|
|
|
|
|
|
} |
431
|
|
|
|
|
|
|
} |
432
|
|
|
|
|
|
|
|
433
|
|
|
|
|
|
|
|
434
|
|
|
|
|
|
|
############################################################################### |
435
|
|
|
|
|
|
|
# |
436
|
|
|
|
|
|
|
# _get_color() |
437
|
|
|
|
|
|
|
# |
438
|
|
|
|
|
|
|
# Used in conjunction with the set_xxx_color methods to convert a color |
439
|
|
|
|
|
|
|
# string into a number. Color range is 0..63 but we will restrict it |
440
|
|
|
|
|
|
|
# to 8..63 to comply with Gnumeric. Colors 0..7 are repeated in 8..15. |
441
|
|
|
|
|
|
|
# |
442
|
|
|
|
|
|
|
sub _get_color { |
443
|
|
|
|
|
|
|
|
444
|
4275
|
|
|
4275
|
|
26958
|
my %colors = ( |
445
|
|
|
|
|
|
|
aqua => 0x0F, |
446
|
|
|
|
|
|
|
cyan => 0x0F, |
447
|
|
|
|
|
|
|
black => 0x08, |
448
|
|
|
|
|
|
|
blue => 0x0C, |
449
|
|
|
|
|
|
|
brown => 0x10, |
450
|
|
|
|
|
|
|
magenta => 0x0E, |
451
|
|
|
|
|
|
|
fuchsia => 0x0E, |
452
|
|
|
|
|
|
|
gray => 0x17, |
453
|
|
|
|
|
|
|
grey => 0x17, |
454
|
|
|
|
|
|
|
green => 0x11, |
455
|
|
|
|
|
|
|
lime => 0x0B, |
456
|
|
|
|
|
|
|
navy => 0x12, |
457
|
|
|
|
|
|
|
orange => 0x35, |
458
|
|
|
|
|
|
|
pink => 0x21, |
459
|
|
|
|
|
|
|
purple => 0x14, |
460
|
|
|
|
|
|
|
red => 0x0A, |
461
|
|
|
|
|
|
|
silver => 0x16, |
462
|
|
|
|
|
|
|
white => 0x09, |
463
|
|
|
|
|
|
|
yellow => 0x0D, |
464
|
|
|
|
|
|
|
); |
465
|
|
|
|
|
|
|
|
466
|
|
|
|
|
|
|
# Return the default color if undef, |
467
|
4275
|
50
|
|
|
|
8505
|
return 0x00 unless defined $_[0]; |
468
|
|
|
|
|
|
|
|
469
|
|
|
|
|
|
|
# Return RGB style colors for processing later. |
470
|
4275
|
100
|
|
|
|
8971
|
if ( $_[0] =~ m/^#[0-9A-F]{6}$/i ) { |
471
|
22
|
|
|
|
|
145
|
return $_[0]; |
472
|
|
|
|
|
|
|
} |
473
|
|
|
|
|
|
|
|
474
|
|
|
|
|
|
|
# or the color string converted to an integer, |
475
|
4253
|
100
|
|
|
|
9412
|
return $colors{ lc( $_[0] ) } if exists $colors{ lc( $_[0] ) }; |
476
|
|
|
|
|
|
|
|
477
|
|
|
|
|
|
|
# or the default color if string is unrecognised, |
478
|
4156
|
50
|
|
|
|
10520
|
return 0x00 if ( $_[0] =~ m/\D/ ); |
479
|
|
|
|
|
|
|
|
480
|
|
|
|
|
|
|
# or an index < 8 mapped into the correct range, |
481
|
4156
|
50
|
|
|
|
7721
|
return $_[0] + 8 if $_[0] < 8; |
482
|
|
|
|
|
|
|
|
483
|
|
|
|
|
|
|
# or the default color if arg is outside range, |
484
|
4156
|
100
|
|
|
|
17563
|
return 0x00 if $_[0] > 63; |
485
|
|
|
|
|
|
|
|
486
|
|
|
|
|
|
|
# or an integer in the valid range |
487
|
4
|
|
|
|
|
25
|
return $_[0]; |
488
|
|
|
|
|
|
|
} |
489
|
|
|
|
|
|
|
|
490
|
|
|
|
|
|
|
|
491
|
|
|
|
|
|
|
############################################################################### |
492
|
|
|
|
|
|
|
# |
493
|
|
|
|
|
|
|
# set_type() |
494
|
|
|
|
|
|
|
# |
495
|
|
|
|
|
|
|
# Set the XF object type as 0 = cell XF or 0xFFF5 = style XF. |
496
|
|
|
|
|
|
|
# |
497
|
|
|
|
|
|
|
sub set_type { |
498
|
|
|
|
|
|
|
|
499
|
0
|
|
|
0
|
0
|
0
|
my $self = shift; |
500
|
0
|
|
|
|
|
0
|
my $type = $_[0]; |
501
|
|
|
|
|
|
|
|
502
|
0
|
0
|
0
|
|
|
0
|
if (defined $_[0] and $_[0] eq 0) { |
503
|
0
|
|
|
|
|
0
|
$self->{_type} = 0x0000; |
504
|
|
|
|
|
|
|
} |
505
|
|
|
|
|
|
|
else { |
506
|
0
|
|
|
|
|
0
|
$self->{_type} = 0xFFF5; |
507
|
|
|
|
|
|
|
} |
508
|
|
|
|
|
|
|
} |
509
|
|
|
|
|
|
|
|
510
|
|
|
|
|
|
|
|
511
|
|
|
|
|
|
|
############################################################################### |
512
|
|
|
|
|
|
|
# |
513
|
|
|
|
|
|
|
# set_align() |
514
|
|
|
|
|
|
|
# |
515
|
|
|
|
|
|
|
# Set cell alignment. |
516
|
|
|
|
|
|
|
# |
517
|
|
|
|
|
|
|
sub set_align { |
518
|
|
|
|
|
|
|
|
519
|
34
|
|
|
34
|
0
|
75
|
my $self = shift; |
520
|
34
|
|
|
|
|
64
|
my $location = $_[0]; |
521
|
|
|
|
|
|
|
|
522
|
34
|
50
|
|
|
|
96
|
return if not defined $location; # No default |
523
|
34
|
50
|
|
|
|
132
|
return if $location =~ m/\d/; # Ignore numbers |
524
|
|
|
|
|
|
|
|
525
|
34
|
|
|
|
|
79
|
$location = lc( $location ); |
526
|
|
|
|
|
|
|
|
527
|
34
|
100
|
|
|
|
160
|
$self->set_text_h_align( 1 ) if $location eq 'left'; |
528
|
34
|
50
|
|
|
|
86
|
$self->set_text_h_align( 2 ) if $location eq 'centre'; |
529
|
34
|
100
|
|
|
|
155
|
$self->set_text_h_align( 2 ) if $location eq 'center'; |
530
|
34
|
100
|
|
|
|
95
|
$self->set_text_h_align( 3 ) if $location eq 'right'; |
531
|
34
|
100
|
|
|
|
97
|
$self->set_text_h_align( 4 ) if $location eq 'fill'; |
532
|
34
|
100
|
|
|
|
78
|
$self->set_text_h_align( 5 ) if $location eq 'justify'; |
533
|
34
|
100
|
|
|
|
97
|
$self->set_text_h_align( 6 ) if $location eq 'center_across'; |
534
|
34
|
50
|
|
|
|
92
|
$self->set_text_h_align( 6 ) if $location eq 'centre_across'; |
535
|
34
|
50
|
|
|
|
79
|
$self->set_text_h_align( 6 ) if $location eq 'merge'; # Legacy. |
536
|
34
|
100
|
|
|
|
85
|
$self->set_text_h_align( 7 ) if $location eq 'distributed'; |
537
|
34
|
50
|
|
|
|
78
|
$self->set_text_h_align( 7 ) if $location eq 'equal_space'; # S::PE. |
538
|
34
|
100
|
|
|
|
102
|
$self->set_text_h_align( 7 ) if $location eq 'justify_distributed'; |
539
|
|
|
|
|
|
|
|
540
|
34
|
100
|
|
|
|
100
|
$self->{_just_distrib} = 1 if $location eq 'justify_distributed'; |
541
|
|
|
|
|
|
|
|
542
|
34
|
100
|
|
|
|
103
|
$self->set_text_v_align( 1 ) if $location eq 'top'; |
543
|
34
|
50
|
|
|
|
82
|
$self->set_text_v_align( 2 ) if $location eq 'vcentre'; |
544
|
34
|
100
|
|
|
|
102
|
$self->set_text_v_align( 2 ) if $location eq 'vcenter'; |
545
|
34
|
100
|
|
|
|
105
|
$self->set_text_v_align( 3 ) if $location eq 'bottom'; |
546
|
34
|
100
|
|
|
|
97
|
$self->set_text_v_align( 4 ) if $location eq 'vjustify'; |
547
|
34
|
100
|
|
|
|
90
|
$self->set_text_v_align( 5 ) if $location eq 'vdistributed'; |
548
|
34
|
50
|
|
|
|
201
|
$self->set_text_v_align( 5 ) if $location eq 'vequal_space'; # S::PE. |
549
|
|
|
|
|
|
|
} |
550
|
|
|
|
|
|
|
|
551
|
|
|
|
|
|
|
|
552
|
|
|
|
|
|
|
############################################################################### |
553
|
|
|
|
|
|
|
# |
554
|
|
|
|
|
|
|
# set_valign() |
555
|
|
|
|
|
|
|
# |
556
|
|
|
|
|
|
|
# Set vertical cell alignment. This is required by the set_properties() method |
557
|
|
|
|
|
|
|
# to differentiate between the vertical and horizontal properties. |
558
|
|
|
|
|
|
|
# |
559
|
|
|
|
|
|
|
sub set_valign { |
560
|
|
|
|
|
|
|
|
561
|
3
|
|
|
3
|
0
|
7
|
my $self = shift; |
562
|
3
|
|
|
|
|
12
|
$self->set_align( @_ ); |
563
|
|
|
|
|
|
|
} |
564
|
|
|
|
|
|
|
|
565
|
|
|
|
|
|
|
|
566
|
|
|
|
|
|
|
############################################################################### |
567
|
|
|
|
|
|
|
# |
568
|
|
|
|
|
|
|
# set_center_across() |
569
|
|
|
|
|
|
|
# |
570
|
|
|
|
|
|
|
# Implements the Excel5 style "merge". |
571
|
|
|
|
|
|
|
# |
572
|
|
|
|
|
|
|
sub set_center_across { |
573
|
|
|
|
|
|
|
|
574
|
1
|
|
|
1
|
0
|
5
|
my $self = shift; |
575
|
|
|
|
|
|
|
|
576
|
1
|
|
|
|
|
7
|
$self->set_text_h_align( 6 ); |
577
|
|
|
|
|
|
|
} |
578
|
|
|
|
|
|
|
|
579
|
|
|
|
|
|
|
|
580
|
|
|
|
|
|
|
############################################################################### |
581
|
|
|
|
|
|
|
# |
582
|
|
|
|
|
|
|
# set_merge() |
583
|
|
|
|
|
|
|
# |
584
|
|
|
|
|
|
|
# This was the way to implement a merge in Excel5. However it should have been |
585
|
|
|
|
|
|
|
# called "center_across" and not "merge". |
586
|
|
|
|
|
|
|
# This is now deprecated. Use set_center_across() or better merge_range(). |
587
|
|
|
|
|
|
|
# |
588
|
|
|
|
|
|
|
# |
589
|
|
|
|
|
|
|
sub set_merge { |
590
|
|
|
|
|
|
|
|
591
|
1
|
|
|
1
|
0
|
6
|
my $self = shift; |
592
|
|
|
|
|
|
|
|
593
|
1
|
|
|
|
|
14
|
$self->set_text_h_align( 6 ); |
594
|
|
|
|
|
|
|
} |
595
|
|
|
|
|
|
|
|
596
|
|
|
|
|
|
|
|
597
|
|
|
|
|
|
|
############################################################################### |
598
|
|
|
|
|
|
|
# |
599
|
|
|
|
|
|
|
# set_bold() |
600
|
|
|
|
|
|
|
# |
601
|
|
|
|
|
|
|
# |
602
|
|
|
|
|
|
|
sub set_bold { |
603
|
|
|
|
|
|
|
|
604
|
78
|
|
|
78
|
0
|
191
|
my $self = shift; |
605
|
78
|
100
|
|
|
|
302
|
my $bold = defined $_[0] ? $_[0] : 1; |
606
|
|
|
|
|
|
|
|
607
|
78
|
50
|
|
|
|
616
|
$self->{_bold} = $bold ? 1 : 0; |
608
|
|
|
|
|
|
|
} |
609
|
|
|
|
|
|
|
|
610
|
|
|
|
|
|
|
|
611
|
|
|
|
|
|
|
############################################################################### |
612
|
|
|
|
|
|
|
# |
613
|
|
|
|
|
|
|
# set_border($style) |
614
|
|
|
|
|
|
|
# |
615
|
|
|
|
|
|
|
# Set cells borders to the same style |
616
|
|
|
|
|
|
|
# |
617
|
|
|
|
|
|
|
sub set_border { |
618
|
|
|
|
|
|
|
|
619
|
1
|
|
|
1
|
0
|
2
|
my $self = shift; |
620
|
1
|
|
|
|
|
3
|
my $style = $_[0]; |
621
|
|
|
|
|
|
|
|
622
|
1
|
|
|
|
|
10
|
$self->set_bottom( $style ); |
623
|
1
|
|
|
|
|
9
|
$self->set_top( $style ); |
624
|
1
|
|
|
|
|
10
|
$self->set_left( $style ); |
625
|
1
|
|
|
|
|
9
|
$self->set_right( $style ); |
626
|
|
|
|
|
|
|
} |
627
|
|
|
|
|
|
|
|
628
|
|
|
|
|
|
|
|
629
|
|
|
|
|
|
|
############################################################################### |
630
|
|
|
|
|
|
|
# |
631
|
|
|
|
|
|
|
# set_border_color($color) |
632
|
|
|
|
|
|
|
# |
633
|
|
|
|
|
|
|
# Set cells border to the same color |
634
|
|
|
|
|
|
|
# |
635
|
|
|
|
|
|
|
sub set_border_color { |
636
|
|
|
|
|
|
|
|
637
|
0
|
|
|
0
|
0
|
0
|
my $self = shift; |
638
|
0
|
|
|
|
|
0
|
my $color = $_[0]; |
639
|
|
|
|
|
|
|
|
640
|
0
|
|
|
|
|
0
|
$self->set_bottom_color( $color ); |
641
|
0
|
|
|
|
|
0
|
$self->set_top_color( $color ); |
642
|
0
|
|
|
|
|
0
|
$self->set_left_color( $color ); |
643
|
0
|
|
|
|
|
0
|
$self->set_right_color( $color ); |
644
|
|
|
|
|
|
|
} |
645
|
|
|
|
|
|
|
|
646
|
|
|
|
|
|
|
|
647
|
|
|
|
|
|
|
############################################################################### |
648
|
|
|
|
|
|
|
# |
649
|
|
|
|
|
|
|
# set_rotation($angle) |
650
|
|
|
|
|
|
|
# |
651
|
|
|
|
|
|
|
# Set the rotation angle of the text. An alignment property. |
652
|
|
|
|
|
|
|
# |
653
|
|
|
|
|
|
|
sub set_rotation { |
654
|
|
|
|
|
|
|
|
655
|
7
|
|
|
7
|
0
|
14
|
my $self = shift; |
656
|
7
|
|
|
|
|
13
|
my $rotation = $_[0]; |
657
|
|
|
|
|
|
|
|
658
|
|
|
|
|
|
|
# Argument should be a number |
659
|
7
|
50
|
|
|
|
52
|
return if $rotation !~ /^([+-]?)(?=\d|\.\d)\d*(\.\d*)?([Ee]([+-]?\d+))?$/; |
660
|
|
|
|
|
|
|
|
661
|
|
|
|
|
|
|
# The arg type can be a double but the Excel dialog only allows integers. |
662
|
7
|
|
|
|
|
18
|
$rotation = int $rotation; |
663
|
|
|
|
|
|
|
|
664
|
7
|
100
|
33
|
|
|
65
|
if ( $rotation == 270 ) { |
|
|
50
|
|
|
|
|
|
665
|
1
|
|
|
|
|
4
|
$rotation = 255; |
666
|
|
|
|
|
|
|
} |
667
|
|
|
|
|
|
|
elsif ( $rotation >= -90 and $rotation <= 90 ) { |
668
|
6
|
100
|
|
|
|
19
|
$rotation = -$rotation + 90 if $rotation < 0; |
669
|
|
|
|
|
|
|
} |
670
|
|
|
|
|
|
|
else { |
671
|
0
|
|
|
|
|
0
|
carp "Rotation $rotation outside range: -90 <= angle <= 90"; |
672
|
0
|
|
|
|
|
0
|
$rotation = 0; |
673
|
|
|
|
|
|
|
} |
674
|
|
|
|
|
|
|
|
675
|
7
|
|
|
|
|
36
|
$self->{_rotation} = $rotation; |
676
|
|
|
|
|
|
|
} |
677
|
|
|
|
|
|
|
|
678
|
|
|
|
|
|
|
|
679
|
|
|
|
|
|
|
############################################################################### |
680
|
|
|
|
|
|
|
# |
681
|
|
|
|
|
|
|
# set_hyperlink() |
682
|
|
|
|
|
|
|
# |
683
|
|
|
|
|
|
|
# Set the properties for the hyperlink style. This isn't a public method. To |
684
|
|
|
|
|
|
|
# be fixed when styles are supported. |
685
|
|
|
|
|
|
|
# |
686
|
|
|
|
|
|
|
sub set_hyperlink { |
687
|
|
|
|
|
|
|
|
688
|
813
|
|
|
813
|
0
|
2435
|
my $self = shift; |
689
|
813
|
|
|
|
|
2198
|
my $hyperlink = shift; |
690
|
|
|
|
|
|
|
|
691
|
813
|
|
|
|
|
2384
|
$self->{_xf_id} = 1; |
692
|
|
|
|
|
|
|
|
693
|
813
|
|
|
|
|
7627
|
$self->set_underline( 1 ); |
694
|
813
|
|
|
|
|
9261
|
$self->set_theme( 10 ); |
695
|
813
|
|
|
|
|
4650
|
$self->{_hyperlink} = $hyperlink; |
696
|
|
|
|
|
|
|
} |
697
|
|
|
|
|
|
|
|
698
|
|
|
|
|
|
|
|
699
|
|
|
|
|
|
|
############################################################################### |
700
|
|
|
|
|
|
|
# |
701
|
|
|
|
|
|
|
# set_format_properties() |
702
|
|
|
|
|
|
|
# |
703
|
|
|
|
|
|
|
# Convert hashes of properties to method calls. |
704
|
|
|
|
|
|
|
# |
705
|
|
|
|
|
|
|
sub set_format_properties { |
706
|
|
|
|
|
|
|
|
707
|
1965
|
|
|
1965
|
0
|
3840
|
my $self = shift; |
708
|
|
|
|
|
|
|
|
709
|
1965
|
|
|
|
|
6357
|
my %properties = @_; # Merge multiple hashes into one |
710
|
|
|
|
|
|
|
|
711
|
1965
|
|
|
|
|
9028
|
while ( my ( $key, $value ) = each( %properties ) ) { |
712
|
|
|
|
|
|
|
|
713
|
|
|
|
|
|
|
# Strip leading "-" from Tk style properties e.g. -color => 'red'. |
714
|
2265
|
|
|
|
|
5621
|
$key =~ s/^-//; |
715
|
|
|
|
|
|
|
|
716
|
|
|
|
|
|
|
# Create a sub to set the property. |
717
|
2265
|
|
|
|
|
3555
|
my $sub = \&{"set_$key"}; |
|
2265
|
|
|
|
|
11053
|
|
718
|
2265
|
|
|
|
|
10027
|
$sub->( $self, $value ); |
719
|
|
|
|
|
|
|
} |
720
|
|
|
|
|
|
|
} |
721
|
|
|
|
|
|
|
|
722
|
|
|
|
|
|
|
# Renamed rarely used set_properties() to set_format_properties() to avoid |
723
|
|
|
|
|
|
|
# confusion with Workbook method of the same name. The following acts as an |
724
|
|
|
|
|
|
|
# alias for any code that uses the old name. |
725
|
|
|
|
|
|
|
*set_properties = *set_format_properties; |
726
|
|
|
|
|
|
|
|
727
|
|
|
|
|
|
|
|
728
|
|
|
|
|
|
|
############################################################################### |
729
|
|
|
|
|
|
|
# |
730
|
|
|
|
|
|
|
# AUTOLOAD. Deus ex machina. |
731
|
|
|
|
|
|
|
# |
732
|
|
|
|
|
|
|
# Dynamically create set methods that aren't already defined. |
733
|
|
|
|
|
|
|
# |
734
|
|
|
|
|
|
|
sub AUTOLOAD { |
735
|
|
|
|
|
|
|
|
736
|
4723
|
|
|
4723
|
|
54200
|
my $self = shift; |
737
|
|
|
|
|
|
|
|
738
|
|
|
|
|
|
|
# Ignore calls to DESTROY |
739
|
4723
|
100
|
|
|
|
225849
|
return if $AUTOLOAD =~ /::DESTROY$/; |
740
|
|
|
|
|
|
|
|
741
|
|
|
|
|
|
|
# Check for a valid method names, i.e. "set_xxx_yyy". |
742
|
2721
|
50
|
|
|
|
16499
|
$AUTOLOAD =~ /.*::set(\w+)/ or die "Unknown method: $AUTOLOAD\n"; |
743
|
|
|
|
|
|
|
|
744
|
|
|
|
|
|
|
# Match the attribute, i.e. "_xxx_yyy". |
745
|
2721
|
|
|
|
|
8287
|
my $attribute = $1; |
746
|
|
|
|
|
|
|
|
747
|
|
|
|
|
|
|
# Check that the attribute exists |
748
|
2721
|
50
|
|
|
|
11000
|
exists $self->{$attribute} or die "Unknown method: $AUTOLOAD\n"; |
749
|
|
|
|
|
|
|
|
750
|
|
|
|
|
|
|
# The attribute value |
751
|
2721
|
|
|
|
|
4644
|
my $value; |
752
|
|
|
|
|
|
|
|
753
|
|
|
|
|
|
|
|
754
|
|
|
|
|
|
|
# There are two types of set methods: set_property() and |
755
|
|
|
|
|
|
|
# set_property_color(). When a method is AUTOLOADED we store a new anonymous |
756
|
|
|
|
|
|
|
# sub in the appropriate slot in the symbol table. The speeds up subsequent |
757
|
|
|
|
|
|
|
# calls to the same method. |
758
|
|
|
|
|
|
|
# |
759
|
1041
|
|
|
1041
|
|
9486
|
no strict 'refs'; # To allow symbol table hackery |
|
1041
|
|
|
|
|
2671
|
|
|
1041
|
|
|
|
|
235457
|
|
760
|
|
|
|
|
|
|
|
761
|
2721
|
100
|
|
|
|
8127
|
if ( $AUTOLOAD =~ /.*::set\w+color$/ ) { |
762
|
|
|
|
|
|
|
|
763
|
|
|
|
|
|
|
# For "set_property_color" methods |
764
|
40
|
|
|
|
|
218
|
$value = _get_color( $_[0] ); |
765
|
|
|
|
|
|
|
|
766
|
40
|
|
|
|
|
184
|
*{$AUTOLOAD} = sub { |
767
|
17
|
|
|
17
|
|
39
|
my $self = shift; |
768
|
|
|
|
|
|
|
|
769
|
17
|
|
|
|
|
71
|
$self->{$attribute} = _get_color( $_[0] ); |
770
|
40
|
|
|
|
|
260
|
}; |
771
|
|
|
|
|
|
|
} |
772
|
|
|
|
|
|
|
else { |
773
|
|
|
|
|
|
|
|
774
|
2681
|
|
|
|
|
4968
|
$value = $_[0]; |
775
|
2681
|
100
|
|
|
|
6722
|
$value = 1 if not defined $value; # The default value is always 1 |
776
|
|
|
|
|
|
|
|
777
|
2681
|
|
|
|
|
11659
|
*{$AUTOLOAD} = sub { |
778
|
265
|
|
|
265
|
|
476
|
my $self = shift; |
779
|
265
|
|
|
|
|
444
|
my $value = shift; |
780
|
|
|
|
|
|
|
|
781
|
265
|
50
|
|
|
|
632
|
$value = 1 if not defined $value; |
782
|
265
|
|
|
|
|
940
|
$self->{$attribute} = $value; |
783
|
2681
|
|
|
|
|
10787
|
}; |
784
|
|
|
|
|
|
|
} |
785
|
|
|
|
|
|
|
|
786
|
|
|
|
|
|
|
|
787
|
2721
|
|
|
|
|
16908
|
$self->{$attribute} = $value; |
788
|
|
|
|
|
|
|
} |
789
|
|
|
|
|
|
|
|
790
|
|
|
|
|
|
|
|
791
|
|
|
|
|
|
|
1; |
792
|
|
|
|
|
|
|
|
793
|
|
|
|
|
|
|
|
794
|
|
|
|
|
|
|
__END__ |