line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
# |
2
|
|
|
|
|
|
|
# PDF::Create::Outline - PDF outline support for PDF::Create |
3
|
|
|
|
|
|
|
# |
4
|
|
|
|
|
|
|
# Author: Fabien Tassin |
5
|
|
|
|
|
|
|
# |
6
|
|
|
|
|
|
|
# Copyright 1999-2001 Fabien Tassin |
7
|
|
|
|
|
|
|
# Copyright 2007 Markus Baertschi |
8
|
|
|
|
|
|
|
# Copyright 2010 Gary Lieberman |
9
|
|
|
|
|
|
|
# |
10
|
|
|
|
|
|
|
# Please see the CHANGES and Changes file for the detailed change log |
11
|
|
|
|
|
|
|
# |
12
|
|
|
|
|
|
|
# Please do not use any of the methods here directly. You will be |
13
|
|
|
|
|
|
|
# punished with your application no longer working after an upgrade ! |
14
|
|
|
|
|
|
|
# |
15
|
|
|
|
|
|
|
|
16
|
|
|
|
|
|
|
package PDF::Create::Outline; |
17
|
|
|
|
|
|
|
|
18
|
18
|
|
|
18
|
|
447
|
use 5.006; |
|
18
|
|
|
|
|
69
|
|
19
|
18
|
|
|
18
|
|
113
|
use strict; |
|
18
|
|
|
|
|
42
|
|
|
18
|
|
|
|
|
457
|
|
20
|
18
|
|
|
18
|
|
96
|
use warnings; |
|
18
|
|
|
|
|
36
|
|
|
18
|
|
|
|
|
581
|
|
21
|
|
|
|
|
|
|
|
22
|
18
|
|
|
18
|
|
98
|
use Carp; |
|
18
|
|
|
|
|
36
|
|
|
18
|
|
|
|
|
1301
|
|
23
|
18
|
|
|
18
|
|
109
|
use FileHandle; |
|
18
|
|
|
|
|
41
|
|
|
18
|
|
|
|
|
138
|
|
24
|
18
|
|
|
18
|
|
5738
|
use Data::Dumper; |
|
18
|
|
|
|
|
38
|
|
|
18
|
|
|
|
|
877
|
|
25
|
18
|
|
|
18
|
|
111
|
use Scalar::Util qw(weaken); |
|
18
|
|
|
|
|
36
|
|
|
18
|
|
|
|
|
9350
|
|
26
|
|
|
|
|
|
|
|
27
|
|
|
|
|
|
|
our $VERSION = '1.43'; |
28
|
|
|
|
|
|
|
our $DEBUG = 0; |
29
|
|
|
|
|
|
|
|
30
|
|
|
|
|
|
|
sub new |
31
|
|
|
|
|
|
|
{ |
32
|
43
|
|
|
43
|
0
|
9127
|
my $this = shift; |
33
|
43
|
|
33
|
|
|
9304
|
my $class = ref($this) || $this; |
34
|
43
|
|
|
|
|
9424
|
my $self = {}; |
35
|
43
|
|
|
|
|
9559
|
bless $self, $class; |
36
|
43
|
|
|
|
|
9473
|
$self->{'Kids'} = []; |
37
|
43
|
|
|
|
|
18334
|
$self; |
38
|
|
|
|
|
|
|
} |
39
|
|
|
|
|
|
|
|
40
|
|
|
|
|
|
|
sub add |
41
|
|
|
|
|
|
|
{ |
42
|
34
|
|
|
34
|
0
|
7137
|
my $self = shift; |
43
|
34
|
|
|
|
|
7162
|
my $outline = PDF::Create::Outline->new(); |
44
|
34
|
|
|
|
|
7516
|
$outline->{'id'} = shift; |
45
|
34
|
|
|
|
|
7458
|
$outline->{'name'} = shift; |
46
|
34
|
|
|
|
|
7317
|
$outline->{'Parent'} = $self; |
47
|
34
|
|
|
|
|
7357
|
weaken $outline->{Parent}; |
48
|
34
|
|
|
|
|
7251
|
$outline->{'pdf'} = $self->{'pdf'}; |
49
|
34
|
|
|
|
|
7305
|
weaken $outline->{pdf}; |
50
|
34
|
|
|
|
|
7243
|
my %params = @_; |
51
|
34
|
50
|
|
|
|
7330
|
$outline->{'Title'} = $params{'Title'} if defined $params{'Title'}; |
52
|
34
|
50
|
|
|
|
7688
|
$outline->{'Action'} = $params{'Action'} if defined $params{'Action'}; |
53
|
|
|
|
|
|
|
$outline->{'Status'} = defined $params{'Status'} |
54
|
34
|
100
|
66
|
|
|
7128
|
&& ( $params{'Status'} eq 'closed' || !$params{'Status'} ) ? 0 : 1; |
55
|
|
|
|
|
|
|
$outline->{'Dest'} = $params{'Destination'} |
56
|
34
|
50
|
|
|
|
7194
|
if defined $params{'Destination'}; |
57
|
34
|
|
|
|
|
6722
|
push @{ $self->{'Kids'} }, $outline; |
|
34
|
|
|
|
|
13341
|
|
58
|
34
|
|
|
|
|
13646
|
$outline; |
59
|
|
|
|
|
|
|
} |
60
|
|
|
|
|
|
|
|
61
|
|
|
|
|
|
|
sub count |
62
|
|
|
|
|
|
|
{ |
63
|
87
|
|
|
87
|
0
|
20799
|
my $self = shift; |
64
|
|
|
|
|
|
|
|
65
|
87
|
|
|
|
|
20866
|
my $c = scalar @{ $self->{'Kids'} }; |
|
87
|
|
|
|
|
41979
|
|
66
|
87
|
100
|
|
|
|
34514
|
return $c unless $c; |
67
|
27
|
|
|
|
|
7315
|
for my $outline ( @{ $self->{'Kids'} } ) { |
|
27
|
|
|
|
|
14545
|
|
68
|
52
|
|
|
|
|
12795
|
my $v = $outline->count; |
69
|
52
|
100
|
|
|
|
17923
|
$c += $v if $outline->{'Status'}; |
70
|
|
|
|
|
|
|
} |
71
|
27
|
100
|
|
|
|
6406
|
$c *= -1 unless $self->{'Status'}; |
72
|
27
|
|
|
|
|
12075
|
$c; |
73
|
|
|
|
|
|
|
} |
74
|
|
|
|
|
|
|
|
75
|
|
|
|
|
|
|
sub kids |
76
|
|
|
|
|
|
|
{ |
77
|
0
|
|
|
0
|
0
|
0
|
my $self = shift; |
78
|
|
|
|
|
|
|
|
79
|
0
|
|
|
|
|
0
|
my $t = []; |
80
|
0
|
|
|
|
|
0
|
map { push @$t, $_->{'id'} } @{ $self->{'Kids'} }; |
|
0
|
|
|
|
|
0
|
|
|
0
|
|
|
|
|
0
|
|
81
|
0
|
|
|
|
|
0
|
$t; |
82
|
|
|
|
|
|
|
} |
83
|
|
|
|
|
|
|
|
84
|
|
|
|
|
|
|
sub list |
85
|
|
|
|
|
|
|
{ |
86
|
35
|
|
|
35
|
0
|
6944
|
my $self = shift; |
87
|
35
|
|
|
|
|
7012
|
my @l; |
88
|
35
|
|
|
|
|
7096
|
for my $e ( @{ $self->{'Kids'} } ) { |
|
35
|
|
|
|
|
14279
|
|
89
|
30
|
|
|
|
|
6197
|
my @t = $e->list; |
90
|
30
|
|
|
|
|
6928
|
push @l, $e; |
91
|
30
|
100
|
|
|
|
10121
|
push @l, @t if scalar @t; |
92
|
|
|
|
|
|
|
} |
93
|
35
|
|
|
|
|
16183
|
@l; |
94
|
|
|
|
|
|
|
} |
95
|
|
|
|
|
|
|
|
96
|
|
|
|
|
|
|
sub new_outline |
97
|
|
|
|
|
|
|
{ |
98
|
16
|
|
|
16
|
0
|
8568
|
my $self = shift; |
99
|
|
|
|
|
|
|
|
100
|
16
|
|
|
|
|
4485
|
$self->{'pdf'}->new_outline( 'Parent' => $self, @_ ); |
101
|
|
|
|
|
|
|
} |
102
|
|
|
|
|
|
|
|
103
|
|
|
|
|
|
|
1; |