| 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 <markus@markus.org> | ||||||||||||||||||||||||||||||||||||||||||
| 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 | ▶ | use 5.006; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 19 | 18 | ▶ | use strict; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 20 | 18 | ▶ | use warnings; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 21 | |||||||||||||||||||||||||||||||||||||||||||
| 22 | 18 | ▶ | use Carp; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 23 | 18 | ▶ | use FileHandle; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 24 | 18 | ▶ | use Data::Dumper; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 25 | 18 | ▶ | use Scalar::Util qw(weaken); | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 26 | |||||||||||||||||||||||||||||||||||||||||||
| 27 | 18 | our $VERSION = '1.28'; | |||||||||||||||||||||||||||||||||||||||||
| 28 | 18 | our $DEBUG = 0; | |||||||||||||||||||||||||||||||||||||||||
| 29 | |||||||||||||||||||||||||||||||||||||||||||
| 30 | sub new | ||||||||||||||||||||||||||||||||||||||||||
| 31 | { | ||||||||||||||||||||||||||||||||||||||||||
| 32 | 25 | ▶ | my $this = shift; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
new: called CC=2 SCAR=7.1
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 33 | 25 | ▶ | my $class = ref($this) || $this; | ||||||||||||||||||||||||||||||||||||||||
|
Condition33%1/3
ref $this || $this
MC/DC0%0/2
ref $this || $this
ref $this
$this
Truth table33%1/3
A || B
A= ref $thisB= $this
| |||||||||||||||||||||||||||||||||||||||||||
| 34 | 25 | my $self = {}; | |||||||||||||||||||||||||||||||||||||||||
| 35 | 25 | bless $self, $class; | |||||||||||||||||||||||||||||||||||||||||
| 36 | 25 | $self->{'Kids'} = []; | |||||||||||||||||||||||||||||||||||||||||
| 37 | 25 | $self; | |||||||||||||||||||||||||||||||||||||||||
| 38 | } | ||||||||||||||||||||||||||||||||||||||||||
| 39 | |||||||||||||||||||||||||||||||||||||||||||
| 40 | sub add | ||||||||||||||||||||||||||||||||||||||||||
| 41 | { | ||||||||||||||||||||||||||||||||||||||||||
| 42 | 20 | ▶ | my $self = shift; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
add: called CC=7 SCAR=20.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 43 | 20 | my $outline = PDF::Create::Outline->new(); | |||||||||||||||||||||||||||||||||||||||||
| 44 | 20 | $outline->{'id'} = shift; | |||||||||||||||||||||||||||||||||||||||||
| 45 | 20 | $outline->{'name'} = shift; | |||||||||||||||||||||||||||||||||||||||||
| 46 | 20 | $outline->{'Parent'} = $self; | |||||||||||||||||||||||||||||||||||||||||
| 47 | 20 | weaken $outline->{Parent}; | |||||||||||||||||||||||||||||||||||||||||
| 48 | 20 | $outline->{'pdf'} = $self->{'pdf'}; | |||||||||||||||||||||||||||||||||||||||||
| 49 | 20 | weaken $outline->{pdf}; | |||||||||||||||||||||||||||||||||||||||||
| 50 | 20 | my %params = @_; | |||||||||||||||||||||||||||||||||||||||||
| 51 | 20 | ▶ | $outline->{'Title'} = $params{'Title'} if defined $params{'Title'}; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 52 | 20 | ▶ | $outline->{'Action'} = $params{'Action'} if defined $params{'Action'}; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 53 | $outline->{'Status'} = defined $params{'Status'} | ||||||||||||||||||||||||||||||||||||||||||
| 54 | 20 | ▶ | && ( $params{'Status'} eq 'closed' || !$params{'Status'} ) ? 0 : 1; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition50%3/6
defined $params{"Status"} and $params{"Status"} eq "closed" || !$params{"Status"}
$params{"Status"} eq "closed" or not $params{"Status"}
MC/DC33%1/3
defined $params{"Status"} and $params{"Status"} eq "closed" || !$params{"Status"}
defined $params{"Status"}
$params{"Status"} eq "closed"
not $params{"Status"}
Truth table50%2/4
A and B or not(C)
A= defined $params{"Status"}B= $params{"Status"} eq "closed"C= not $params{"Status"}
| |||||||||||||||||||||||||||||||||||||||||||
| 55 | $outline->{'Dest'} = $params{'Destination'} | ||||||||||||||||||||||||||||||||||||||||||
| 56 | 20 | ▶ | if defined $params{'Destination'}; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 57 | 20 | push @{ $self->{'Kids'} }, $outline; | |||||||||||||||||||||||||||||||||||||||||
| 58 | 20 | $outline; | |||||||||||||||||||||||||||||||||||||||||
| 59 | } | ||||||||||||||||||||||||||||||||||||||||||
| 60 | |||||||||||||||||||||||||||||||||||||||||||
| 61 | sub count | ||||||||||||||||||||||||||||||||||||||||||
| 62 | { | ||||||||||||||||||||||||||||||||||||||||||
| 63 | 51 | ▶ | my $self = shift; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
count: called CC=5 SCAR=16.1
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 64 | |||||||||||||||||||||||||||||||||||||||||||
| 65 | 51 | my $c = scalar @{ $self->{'Kids'} }; | |||||||||||||||||||||||||||||||||||||||||
| 66 | 51 | ▶ | return $c unless $c; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 67 | 15 | for my $outline ( @{ $self->{'Kids'} } ) { | |||||||||||||||||||||||||||||||||||||||||
| 68 | 30 | my $v = $outline->count; | |||||||||||||||||||||||||||||||||||||||||
| 69 | 30 | ▶ | $c += $v if $outline->{'Status'}; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 70 | } | ||||||||||||||||||||||||||||||||||||||||||
| 71 | 15 | ▶ | $c *= -1 unless $self->{'Status'}; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 72 | 15 | $c; | |||||||||||||||||||||||||||||||||||||||||
| 73 | } | ||||||||||||||||||||||||||||||||||||||||||
| 74 | |||||||||||||||||||||||||||||||||||||||||||
| 75 | sub kids | ||||||||||||||||||||||||||||||||||||||||||
| 76 | { | ||||||||||||||||||||||||||||||||||||||||||
| 77 | 0 | ▶ | my $self = shift; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
kids: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 78 | |||||||||||||||||||||||||||||||||||||||||||
| 79 | 0 | my $t = []; | |||||||||||||||||||||||||||||||||||||||||
| 80 | 0 | map { push @$t, $_->{'id'} } @{ $self->{'Kids'} }; | |||||||||||||||||||||||||||||||||||||||||
| 81 | 0 | $t; | |||||||||||||||||||||||||||||||||||||||||
| 82 | } | ||||||||||||||||||||||||||||||||||||||||||
| 83 | |||||||||||||||||||||||||||||||||||||||||||
| 84 | sub list | ||||||||||||||||||||||||||||||||||||||||||
| 85 | { | ||||||||||||||||||||||||||||||||||||||||||
| 86 | 21 | ▶ | my $self = shift; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
list: called CC=3 SCAR=11.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 87 | 21 | my @l; | |||||||||||||||||||||||||||||||||||||||||
| 88 | 21 | for my $e ( @{ $self->{'Kids'} } ) { | |||||||||||||||||||||||||||||||||||||||||
| 89 | 18 | my @t = $e->list; | |||||||||||||||||||||||||||||||||||||||||
| 90 | 18 | push @l, $e; | |||||||||||||||||||||||||||||||||||||||||
| 91 | 18 | ▶ | push @l, @t if scalar @t; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 92 | } | ||||||||||||||||||||||||||||||||||||||||||
| 93 | 21 | @l; | |||||||||||||||||||||||||||||||||||||||||
| 94 | } | ||||||||||||||||||||||||||||||||||||||||||
| 95 | |||||||||||||||||||||||||||||||||||||||||||
| 96 | sub new_outline | ||||||||||||||||||||||||||||||||||||||||||
| 97 | { | ||||||||||||||||||||||||||||||||||||||||||
| 98 | 8 | ▶ | my $self = shift; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
new_outline: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 99 | |||||||||||||||||||||||||||||||||||||||||||
| 100 | 8 | $self->{'pdf'}->new_outline( 'Parent' => $self, @_ ); | |||||||||||||||||||||||||||||||||||||||||
| 101 | } | ||||||||||||||||||||||||||||||||||||||||||
| 102 | |||||||||||||||||||||||||||||||||||||||||||
| 103 | 18 | 1; | |||||||||||||||||||||||||||||||||||||||||