Khonsu/TOC/Outline.pm

filter: Statementstmt 100% 33 / 33 Branchbran 66.6% 4 / 6 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 100% 4 / 4 Podpod 0.0% 0 / 3 totaltotal 89.1% 41 / 46 CC 5 SCAR 12.6
CC
5
Cov
95%
render
5.0
BEGIN
1.0
attributes
1.0
CRAP 3.5
« Khonsu/Page/Header.pm ↑ Summary Khonsu/File.pm »
1 package Khonsu::TOC::Outline;
2  
3 3 ▶use parent 'Khonsu::Text';
Subroutine BEGIN: called CC=1 SCAR=0.0
4  
5 sub attributes {
6 612 ▶ my $a = shift;
Subroutine attributes: called CC=1 SCAR=0.0
Pod undocumented
7 return (
8 612 $a->SUPER::attributes(),
9 page => {$a->RW, $a->OBJ},
10 outline => {$a->RW, $a->OBJ},
11 outline_position => {$a->RW, $a->DHR},
12 end_y => {$a->RW, $a->NUM},
13 level => {$a->RW, $a->NUM},
14 children => {$a->RW, $a->DAR},
15 );
16 }
17  
18 sub add {
19 612 ▶ my ($self, $file, $outline, %attributes) = @_;
Subroutine add: called CC=1 SCAR=0.0
Pod undocumented
20 612 $self->set_attributes(%attributes);
21 612 my %position = $self->get_points();
22 612 $position{y} = $file->page->h - $position{y};
23 612 $self->outline_position(\%position);
24 $outline = $outline->outline()->open()
25 ->title($self->text)
26 612 ->dest($self->page->current, '-xyz' => [$position{x}, $position{y}, 0]);
27 612 $self->outline($outline);
28 612 return $file;
29 }
30  
31 sub render {
32 612 ▶ my ($self, $file, %attributes) = @_;
Subroutine render: called CC=5 SCAR=16.1
Pod undocumented
33 $self->set_attributes(
34 pad => '.',
35 pad_end => $self->page->num + $attributes{page_offset},
36 612 %attributes
37 );
38 612 $self->SUPER::add($file);
39 612 my %position = $self->get_points();
40 612 my $outline_position = $self->outline_position;
41 612 $attributes{y} = $position{y} + $self->font->size;
42 612 $position{y} = $file->page->h - $position{y};
43 my $annotation = $file->page->current->annotation()->rect(
44 $position{x}, $position{y}, $position{w}, $position{y} - $self->font->size
45 612 )->link($self->page->current, '-xyz' => [$outline_position->{x}, $outline_position->{y}, 0]);
46 612 my $y = $attributes{y};
47 612 my $num = $attributes{num};
48 612 for (@{$self->children}) {
49 510 $y += $attributes{padding};
50 510 ▶ if ($y > $file->page->h - ($file->page->footer ? $file->page->footer->h : 0)) {
Branch: 2 branches
BranchTrueFalseTotal
if ($y > $file->page->h - ($file->page->footer ? $file->page->footer->h : 0)) 6 504 510
$file->page->footer ? : 510 0 510
51 6 $file->open_page($num->(1));
52 6 ▶ $y = $file->page->header ? $file->page->header->h : 0;
Branch: 1 branch
BranchTrueFalseTotal
$file->page->header ? : 6 0 6
53 }
54 510 $_->render($file, %attributes, y => $y);
55 510 $y = $_->end_y;
56 }
57 612 $self->end_y($y);
58 }
59  
60 3 1;
« Khonsu/Page/Header.pm ↑ Summary Khonsu/File.pm »