line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Excel::CloneXLSX::Format; |
2
|
|
|
|
|
|
|
|
3
|
2
|
|
|
2
|
|
15487
|
use 5.008001; |
|
2
|
|
|
|
|
6
|
|
|
2
|
|
|
|
|
62
|
|
4
|
2
|
|
|
2
|
|
8
|
use strict; |
|
2
|
|
|
|
|
3
|
|
|
2
|
|
|
|
|
53
|
|
5
|
2
|
|
|
2
|
|
14
|
use warnings; |
|
2
|
|
|
|
|
3
|
|
|
2
|
|
|
|
|
87
|
|
6
|
|
|
|
|
|
|
|
7
|
|
|
|
|
|
|
our $VERSION = "0.03"; |
8
|
|
|
|
|
|
|
|
9
|
2
|
|
|
2
|
|
11
|
use Exporter 'import'; |
|
2
|
|
|
|
|
2
|
|
|
2
|
|
|
|
|
542
|
|
10
|
|
|
|
|
|
|
our @EXPORT_OK = qw(translate_xlsx_format); |
11
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
sub translate_xlsx_format { |
13
|
1
|
|
|
1
|
1
|
38
|
my ($old_fmt) = @_; |
14
|
1
|
50
|
|
|
|
5
|
return {} unless (defined $old_fmt); |
15
|
|
|
|
|
|
|
|
16
|
|
|
|
|
|
|
# font |
17
|
1
|
|
|
|
|
2
|
my $old_font = $old_fmt->{Font}; |
18
|
1
|
|
|
|
|
9
|
my %new_fmt = ( |
19
|
|
|
|
|
|
|
font => $old_font->{Name}, |
20
|
|
|
|
|
|
|
size => $old_font->{Height}, |
21
|
|
|
|
|
|
|
color => $old_font->{Color}, |
22
|
|
|
|
|
|
|
bold => $old_font->{Bold}, |
23
|
|
|
|
|
|
|
italic => $old_font->{Italic}, |
24
|
|
|
|
|
|
|
underline => $old_font->{UnderlineStyle}, |
25
|
|
|
|
|
|
|
font_strikeout => $old_font->{Strikeout}, |
26
|
|
|
|
|
|
|
font_script => $old_font->{Super}, |
27
|
|
|
|
|
|
|
); |
28
|
|
|
|
|
|
|
|
29
|
|
|
|
|
|
|
# shading |
30
|
1
|
|
|
|
|
2
|
my $old_shading = $old_fmt->{Fill}; |
31
|
1
|
|
|
|
|
3
|
my @shading_fields = qw(pattern fg_color bg_color); |
32
|
1
|
|
|
|
|
5
|
for my $idx (0..$#shading_fields) { |
33
|
3
|
100
|
|
|
|
10
|
$new_fmt{ $shading_fields[$idx] } = $old_shading->[$idx] |
34
|
|
|
|
|
|
|
if (defined $old_shading->[$idx]); |
35
|
|
|
|
|
|
|
} |
36
|
|
|
|
|
|
|
|
37
|
|
|
|
|
|
|
# if pattern is 'solid', Excel swaps fgColor and bgColor. This unswaps. |
38
|
1
|
50
|
|
|
|
7
|
if ($new_fmt{pattern} == 1) { |
39
|
0
|
|
|
|
|
0
|
@new_fmt{qw(bg_color fg_color)} = @new_fmt{qw(fg_color bg_color)}; |
40
|
|
|
|
|
|
|
} |
41
|
|
|
|
|
|
|
|
42
|
|
|
|
|
|
|
# alignment |
43
|
|
|
|
|
|
|
# halign numbers match up, valign numbers are off by one |
44
|
1
|
|
|
|
|
3
|
my ($old_halign, $old_valign) = @{$old_fmt}{qw(AlignH AlignV)}; |
|
1
|
|
|
|
|
3
|
|
45
|
1
|
|
|
|
|
3
|
$new_fmt{text_h_align} = $old_halign; |
46
|
1
|
50
|
|
|
|
3
|
$new_fmt{text_v_align} = defined($old_valign) ? $old_valign+1 : 0; |
47
|
|
|
|
|
|
|
|
48
|
|
|
|
|
|
|
# borders |
49
|
1
|
|
|
|
|
2
|
my $old_border_style = $old_fmt->{BdrStyle}; |
50
|
1
|
|
|
|
|
2
|
my $old_border_color = $old_fmt->{BdrColor}; |
51
|
1
|
|
|
|
|
3
|
my @sides = qw(left right top bottom); |
52
|
1
|
|
|
|
|
3
|
for my $idx (0..$#sides) { |
53
|
4
|
|
|
|
|
6
|
my $side = $sides[$idx]; |
54
|
4
|
100
|
|
|
|
6
|
$new_fmt{$side} = $old_border_style->[$idx] if ($old_border_style->[$idx]); |
55
|
4
|
100
|
|
|
|
10
|
$new_fmt{"${side}_color"} = $old_border_color->[$idx] if ($old_border_color->[$idx]); |
56
|
|
|
|
|
|
|
} |
57
|
|
|
|
|
|
|
|
58
|
1
|
|
|
|
|
4
|
return \%new_fmt; |
59
|
|
|
|
|
|
|
} |
60
|
|
|
|
|
|
|
|
61
|
|
|
|
|
|
|
|
62
|
|
|
|
|
|
|
|
63
|
|
|
|
|
|
|
1; |
64
|
|
|
|
|
|
|
__END__ |