line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package PDF::Table::Settings; |
2
|
|
|
|
|
|
|
|
3
|
4
|
|
|
4
|
|
19
|
use strict; |
|
4
|
|
|
|
|
6
|
|
|
4
|
|
|
|
|
92
|
|
4
|
4
|
|
|
4
|
|
14
|
use warnings; |
|
4
|
|
|
|
|
8
|
|
|
4
|
|
|
|
|
77
|
|
5
|
|
|
|
|
|
|
|
6
|
4
|
|
|
4
|
|
14
|
use Carp; |
|
4
|
|
|
|
|
6
|
|
|
4
|
|
|
|
|
1961
|
|
7
|
|
|
|
|
|
|
|
8
|
|
|
|
|
|
|
our $VERSION = '1.003'; # VERSION |
9
|
|
|
|
|
|
|
our $LAST_UPDATE = '1.003'; # manually update whenever code is changed |
10
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
########################################################### |
12
|
|
|
|
|
|
|
# move deprecated settings names to current names, and delete old |
13
|
|
|
|
|
|
|
# assume any leading '-' already removed |
14
|
|
|
|
|
|
|
# warning if both deprecated and new name given (use new) |
15
|
|
|
|
|
|
|
# release at T-6 months, consider issuing warning to remind update needed |
16
|
|
|
|
|
|
|
# release at T-0 months, give warning on use of deprecated items |
17
|
|
|
|
|
|
|
# release at T+12 months, remove deprecated names |
18
|
|
|
|
|
|
|
############################################################ |
19
|
|
|
|
|
|
|
|
20
|
|
|
|
|
|
|
sub deprecated_settings { |
21
|
10
|
|
|
10
|
0
|
22
|
my ($data, $row_props, $col_props, $cell_props, $header_props, $argref) = @_; |
22
|
|
|
|
|
|
|
# 1 $row_props, 2 $col_props, 3 $cell_props, 4 $header_props |
23
|
|
|
|
|
|
|
# need to use $_[n] form so that its call be reference, not value |
24
|
|
|
|
|
|
|
#my $data = $_[0]; |
25
|
|
|
|
|
|
|
#my $argref = $_[5]; |
26
|
|
|
|
|
|
|
#my %arg = %{$argref}; |
27
|
|
|
|
|
|
|
|
28
|
10
|
|
|
|
|
76
|
my %cur_names = ( |
29
|
|
|
|
|
|
|
# old deprecated name new current name |
30
|
|
|
|
|
|
|
# (old_key) |
31
|
|
|
|
|
|
|
'start_y' => 'y', |
32
|
|
|
|
|
|
|
'start_h' => 'h', |
33
|
|
|
|
|
|
|
'row_height' => 'min_rh', |
34
|
|
|
|
|
|
|
'background_color' => 'bg_color', |
35
|
|
|
|
|
|
|
'background_color_odd' => 'bg_color_odd', |
36
|
|
|
|
|
|
|
'background_color_even' => 'bg_color_even', |
37
|
|
|
|
|
|
|
'font_color' => 'fg_color', |
38
|
|
|
|
|
|
|
'font_color_odd' => 'fg_color_odd', |
39
|
|
|
|
|
|
|
'font_color_even' => 'fg_color_even', |
40
|
|
|
|
|
|
|
'font_underline' => 'underline', |
41
|
|
|
|
|
|
|
#'justify' => 'align', # different set of values allowed |
42
|
|
|
|
|
|
|
'lead' => 'leading', |
43
|
|
|
|
|
|
|
'border' => 'border_w', |
44
|
|
|
|
|
|
|
'horizontal_borders' => 'h_border_w', |
45
|
|
|
|
|
|
|
'vertical_borders' => 'v_border_w', |
46
|
|
|
|
|
|
|
'border_color' => 'border_c', |
47
|
|
|
|
|
|
|
# currently same color for H and V borders |
48
|
|
|
|
|
|
|
); |
49
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
# global arg |
51
|
10
|
|
|
|
|
55
|
foreach my $old_key (keys %cur_names) { |
52
|
150
|
100
|
|
|
|
216
|
if (defined $argref->{$old_key}) { |
53
|
|
|
|
|
|
|
# set deprecated name setting (need to transfer to new name). |
54
|
|
|
|
|
|
|
# did we also set new name setting? |
55
|
14
|
50
|
|
|
|
26
|
if (defined $argref->{$cur_names{$old_key}}) { |
56
|
0
|
|
|
|
|
0
|
carp "!! Warning !! both deprecated global name '$old_key' and current name '$cur_names{$old_key}' given, current name's value used."; |
57
|
|
|
|
|
|
|
} else { |
58
|
14
|
|
|
|
|
21
|
$argref->{$cur_names{$old_key}} = $argref->{$old_key}; |
59
|
14
|
|
|
|
|
33
|
delete $argref->{$old_key}; |
60
|
|
|
|
|
|
|
# eventually given warning to stop using $old_key |
61
|
|
|
|
|
|
|
} |
62
|
|
|
|
|
|
|
} |
63
|
|
|
|
|
|
|
} |
64
|
|
|
|
|
|
|
|
65
|
|
|
|
|
|
|
# row properties |
66
|
10
|
|
|
|
|
31
|
foreach my $old_key (keys %cur_names) { |
67
|
150
|
|
|
|
|
193
|
for (my $row = 0; $row < scalar(@$data); $row++) { |
68
|
285
|
50
|
|
|
|
448
|
if (defined $row_props->[$row]->{$old_key}) { |
69
|
|
|
|
|
|
|
# set deprecated name setting (need to transfer to new name). |
70
|
0
|
0
|
|
|
|
0
|
if (defined $row_props->[$row]->{$cur_names{$old_key}}) { |
71
|
|
|
|
|
|
|
# did we also set new name setting? |
72
|
0
|
|
|
|
|
0
|
carp "!! Warning !! both deprecated name '$old_key' and current name '$cur_names{$old_key}' given in row_props[$row], current name's value used."; |
73
|
|
|
|
|
|
|
} else { |
74
|
|
|
|
|
|
|
# transfer deprecated setting to new |
75
|
0
|
|
|
|
|
0
|
$row_props->[$row]->{$cur_names{$old_key}} = $row_props->[$row]->{$old_key}; |
76
|
0
|
|
|
|
|
0
|
delete $row_props->[$row]->{$old_key}; |
77
|
|
|
|
|
|
|
# eventually given warning to stop using $old_key |
78
|
|
|
|
|
|
|
} |
79
|
|
|
|
|
|
|
} |
80
|
|
|
|
|
|
|
} |
81
|
|
|
|
|
|
|
} |
82
|
|
|
|
|
|
|
|
83
|
|
|
|
|
|
|
# column properties |
84
|
10
|
|
|
|
|
28
|
foreach my $old_key (keys %cur_names) { |
85
|
150
|
|
|
|
|
139
|
for (my $col = 0; $col < scalar(@{$col_props}); $col++) { |
|
345
|
|
|
|
|
420
|
|
86
|
195
|
100
|
|
|
|
243
|
if (defined $col_props->[$col]->{$old_key}) { |
87
|
|
|
|
|
|
|
# set deprecated name setting (need to transfer to new name). |
88
|
8
|
50
|
|
|
|
13
|
if (defined $col_props->[$col]->{$cur_names{$old_key}}) { |
89
|
|
|
|
|
|
|
# did we also set new name setting? |
90
|
0
|
|
|
|
|
0
|
carp "!! Warning !! both deprecated name '$old_key' and current name '$cur_names{$old_key}' given in column_props[$col], current name's value used."; |
91
|
|
|
|
|
|
|
} else { |
92
|
|
|
|
|
|
|
# transfer deprecated setting to new |
93
|
8
|
|
|
|
|
30
|
$col_props->[$col]->{$cur_names{$old_key}} = $col_props->[$col]->{$old_key}; |
94
|
8
|
|
|
|
|
12
|
delete $col_props->[$col]->{$old_key}; |
95
|
|
|
|
|
|
|
# eventually given warning to stop using $old_key |
96
|
|
|
|
|
|
|
} |
97
|
|
|
|
|
|
|
} |
98
|
|
|
|
|
|
|
} |
99
|
|
|
|
|
|
|
} |
100
|
|
|
|
|
|
|
|
101
|
|
|
|
|
|
|
# cell properties |
102
|
10
|
|
|
|
|
29
|
foreach my $old_key (keys %cur_names) { |
103
|
150
|
|
|
|
|
197
|
for (my $row = 0; $row < scalar(@$data); $row++) { |
104
|
285
|
|
|
|
|
257
|
for ( my $col = 0; |
105
|
1035
|
|
|
|
|
1373
|
$col < scalar(@{$data->[$row]}); |
106
|
|
|
|
|
|
|
$col++ ) { |
107
|
750
|
100
|
|
|
|
931
|
if (defined $cell_props->[$row][$col]->{$old_key}) { |
108
|
|
|
|
|
|
|
# set deprecated name setting (need to transfer to new name). |
109
|
2
|
50
|
|
|
|
5
|
if (defined $cell_props->[$row][$col]->{$cur_names{$old_key}}) { |
110
|
|
|
|
|
|
|
# did we also set new name setting? |
111
|
0
|
|
|
|
|
0
|
carp "!! Warning !! both deprecated name '$old_key' and current name '$cur_names{$old_key}' given in cell_props[$row][$col], current name's value used."; |
112
|
|
|
|
|
|
|
} else { |
113
|
|
|
|
|
|
|
# transfer deprecated setting to new |
114
|
2
|
|
|
|
|
3
|
$cell_props->[$row][$col]->{$cur_names{$old_key}} = $cell_props->[$row][$col]->{$old_key}; |
115
|
2
|
|
|
|
|
8
|
delete $cell_props->[$row][$col]->{$old_key}; |
116
|
|
|
|
|
|
|
# eventually given warning to stop using $old_key |
117
|
|
|
|
|
|
|
} |
118
|
|
|
|
|
|
|
} |
119
|
|
|
|
|
|
|
} |
120
|
|
|
|
|
|
|
} |
121
|
|
|
|
|
|
|
} |
122
|
|
|
|
|
|
|
|
123
|
|
|
|
|
|
|
# header properties |
124
|
10
|
100
|
|
|
|
24
|
if ($header_props) { |
125
|
1
|
|
|
|
|
3
|
foreach my $old_key (keys %cur_names) { |
126
|
15
|
50
|
|
|
|
19
|
if (defined $header_props->{$old_key}) { |
127
|
|
|
|
|
|
|
# set deprecated name setting (need to transfer to new name). |
128
|
|
|
|
|
|
|
# did we also set new name setting? |
129
|
0
|
0
|
|
|
|
0
|
if (defined $header_props->{$cur_names{$old_key}}) { |
130
|
0
|
|
|
|
|
0
|
carp "!! Warning !! both deprecated header name '$old_key' and current name '$cur_names{$old_key}' given, current name's value used."; |
131
|
|
|
|
|
|
|
} else { |
132
|
0
|
|
|
|
|
0
|
$header_props->{$cur_names{$old_key}} = $header_props->{$old_key}; |
133
|
0
|
|
|
|
|
0
|
delete $header_props->{$old_key}; |
134
|
|
|
|
|
|
|
# eventually given warning to stop using $old_key |
135
|
|
|
|
|
|
|
} |
136
|
|
|
|
|
|
|
} |
137
|
|
|
|
|
|
|
} |
138
|
|
|
|
|
|
|
} |
139
|
|
|
|
|
|
|
|
140
|
10
|
|
|
|
|
31
|
return; |
141
|
|
|
|
|
|
|
} # end of deprecated_settings() |
142
|
|
|
|
|
|
|
|
143
|
|
|
|
|
|
|
############################################################ |
144
|
|
|
|
|
|
|
# validate/fix up settings and parameters as much as possible TBD per #12 |
145
|
|
|
|
|
|
|
############################################################ |
146
|
|
|
|
|
|
|
|
147
|
|
|
|
|
|
|
sub check_settings { |
148
|
10
|
|
|
10
|
0
|
41
|
my (%arg) = @_; |
149
|
|
|
|
|
|
|
|
150
|
|
|
|
|
|
|
# TBD $arg{} values, some col, row, cell, header? |
151
|
|
|
|
|
|
|
# x, y >= 0; w, h >= 0; x+w < page width; y+h < page height |
152
|
|
|
|
|
|
|
# next_h (if def) > 0, next_y (if def) >= 0; next_y+next_h < page height |
153
|
|
|
|
|
|
|
# line widths >= 0, min_rh > 0 |
154
|
|
|
|
|
|
|
# TBD in general, validate integer values and possibly some |
155
|
|
|
|
|
|
|
# other values, per #12 |
156
|
10
|
|
|
|
|
20
|
return; |
157
|
|
|
|
|
|
|
} # end of check_settings() |
158
|
|
|
|
|
|
|
|
159
|
|
|
|
|
|
|
1; |