line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Win32::PowerPoint::Utils; |
2
|
|
|
|
|
|
|
|
3
|
1
|
|
|
1
|
|
847
|
use strict; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
28
|
|
4
|
1
|
|
|
1
|
|
3
|
use warnings; |
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
21
|
|
5
|
1
|
|
|
1
|
|
3
|
use Exporter 'import'; |
|
1
|
|
|
|
|
0
|
|
|
1
|
|
|
|
|
28
|
|
6
|
1
|
|
|
1
|
|
3
|
use Carp; |
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
678
|
|
7
|
|
|
|
|
|
|
|
8
|
|
|
|
|
|
|
our @EXPORT_OK = qw( |
9
|
|
|
|
|
|
|
RGB |
10
|
|
|
|
|
|
|
canonical_alignment |
11
|
|
|
|
|
|
|
canonical_pattern |
12
|
|
|
|
|
|
|
canonical_datetime |
13
|
|
|
|
|
|
|
convert_cygwin_path |
14
|
|
|
|
|
|
|
_defined_or |
15
|
|
|
|
|
|
|
); |
16
|
|
|
|
|
|
|
|
17
|
|
|
|
|
|
|
sub _defined_or { |
18
|
0
|
|
|
0
|
|
|
my ($target, $alternative) = @_; |
19
|
|
|
|
|
|
|
|
20
|
0
|
0
|
|
|
|
|
return defined $target ? $target : $alternative; |
21
|
|
|
|
|
|
|
} |
22
|
|
|
|
|
|
|
|
23
|
|
|
|
|
|
|
sub RGB { |
24
|
0
|
|
|
0
|
1
|
|
my @color; |
25
|
|
|
|
|
|
|
|
26
|
0
|
0
|
0
|
|
|
|
if ( @_ == 1 && !ref $_[0] ) { # combined string such as '255, 255, 255' |
|
|
0
|
0
|
|
|
|
|
|
|
0
|
|
|
|
|
|
27
|
0
|
|
|
|
|
|
my $str = shift; |
28
|
|
|
|
|
|
|
|
29
|
0
|
|
|
|
|
|
$str =~ s/^RGB//i; |
30
|
0
|
|
|
|
|
|
$str =~ tr/()//d; |
31
|
0
|
|
|
|
|
|
@color = _check_colors( split /[\s,]+/, $str ); |
32
|
|
|
|
|
|
|
} |
33
|
|
|
|
|
|
|
elsif ( @_ == 1 && ref $_[0] eq 'ARRAY' ) { |
34
|
0
|
|
|
|
|
|
@color = _check_colors( @{ $_[0] } ); |
|
0
|
|
|
|
|
|
|
35
|
|
|
|
|
|
|
} |
36
|
|
|
|
|
|
|
elsif ( @_ == 3 ) { |
37
|
0
|
|
|
|
|
|
@color = _check_colors( @_ ); |
38
|
|
|
|
|
|
|
} |
39
|
|
|
|
|
|
|
|
40
|
0
|
0
|
|
|
|
|
croak "wrong color specification" unless @color == 3; |
41
|
|
|
|
|
|
|
|
42
|
0
|
|
|
|
|
|
return $color[2] * 65536 + $color[1] * 256 + $color[0]; |
43
|
|
|
|
|
|
|
} |
44
|
|
|
|
|
|
|
|
45
|
|
|
|
|
|
|
sub _check_colors { |
46
|
0
|
|
|
0
|
|
|
my @colors = @_; |
47
|
|
|
|
|
|
|
|
48
|
0
|
0
|
|
|
|
|
return map { $_ = 0 if $_ < 0; $_ = 255 if $_ > 255; $_ } |
|
0
|
0
|
|
|
|
|
|
|
0
|
0
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
49
|
0
|
|
|
|
|
|
grep { defined $_ && /^\d+$/ } |
50
|
|
|
|
|
|
|
@colors; |
51
|
|
|
|
|
|
|
} |
52
|
|
|
|
|
|
|
|
53
|
|
|
|
|
|
|
sub canonical_alignment { |
54
|
0
|
|
|
0
|
1
|
|
my $align = shift; |
55
|
|
|
|
|
|
|
|
56
|
0
|
|
|
|
|
|
$align =~ s/^(?:pp)?align(?:ment)?//gi; |
57
|
0
|
|
|
|
|
|
$align = 'ppAlign' . (ucfirst lc $align); |
58
|
0
|
0
|
|
|
|
|
$align = 'ppAlignCenter' if $align eq 'ppAlignCentre'; |
59
|
0
|
0
|
|
|
|
|
$align = 'ppAlignmentMixed' if $align eq 'ppAlignMixed'; |
60
|
|
|
|
|
|
|
|
61
|
0
|
|
|
|
|
|
$align; |
62
|
|
|
|
|
|
|
} |
63
|
|
|
|
|
|
|
|
64
|
|
|
|
|
|
|
sub canonical_pattern { |
65
|
0
|
|
|
0
|
1
|
|
my $pattern = shift; |
66
|
|
|
|
|
|
|
|
67
|
0
|
|
|
|
|
|
$pattern =~ s/^(?:mso)?Pattern//gi; |
68
|
0
|
|
|
|
|
|
$pattern =~ s/_([a-z])/\U$1\E/g; |
69
|
0
|
|
|
|
|
|
$pattern =~ s/(^|[0-9])([a-z])/$1\U$2\E/g; |
70
|
0
|
|
|
|
|
|
$pattern = "msoPattern$pattern"; |
71
|
|
|
|
|
|
|
|
72
|
0
|
|
|
|
|
|
$pattern; |
73
|
|
|
|
|
|
|
} |
74
|
|
|
|
|
|
|
|
75
|
|
|
|
|
|
|
sub canonical_datetime { |
76
|
0
|
|
|
0
|
1
|
|
my $pattern = shift; |
77
|
|
|
|
|
|
|
|
78
|
0
|
|
|
|
|
|
$pattern =~ s/^(?:pp)?DateTime//gi; |
79
|
0
|
|
|
|
|
|
$pattern ="ppDateTime$pattern"; |
80
|
0
|
|
|
|
|
|
$pattern; |
81
|
|
|
|
|
|
|
} |
82
|
|
|
|
|
|
|
|
83
|
|
|
|
|
|
|
sub convert_cygwin_path { |
84
|
0
|
|
|
0
|
1
|
|
my $path = shift; |
85
|
0
|
0
|
|
|
|
|
return $path unless $^O eq 'cygwin'; |
86
|
0
|
0
|
|
|
|
|
return Cygwin::posix_to_win_path($path, 'absolute') if $] >= 5.010; |
87
|
0
|
|
|
|
|
|
require Filesys::CygwinPaths; |
88
|
0
|
|
|
|
|
|
return Filesys::CygwinPaths::fullwin32path($path); |
89
|
|
|
|
|
|
|
} |
90
|
|
|
|
|
|
|
|
91
|
|
|
|
|
|
|
1; |
92
|
|
|
|
|
|
|
|
93
|
|
|
|
|
|
|
__END__ |