| 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
| |||||||||||||||
| 51 | 6 | $file->open_page($num->(1)); | |||||||||||||
| 52 | 6 | ▶ | $y = $file->page->header ? $file->page->header->h : 0; | ||||||||||||
|
Branch: 1 branch
| |||||||||||||||
| 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; | |||||||||||||