line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Khonsu::TOC::Outline; |
2
|
|
|
|
|
|
|
|
3
|
5
|
|
|
5
|
|
46
|
use parent 'Khonsu::Text'; |
|
5
|
|
|
|
|
56
|
|
|
5
|
|
|
|
|
28
|
|
4
|
|
|
|
|
|
|
|
5
|
|
|
|
|
|
|
sub attributes { |
6
|
346
|
|
|
346
|
0
|
603
|
my $a = shift; |
7
|
|
|
|
|
|
|
return ( |
8
|
346
|
|
|
|
|
891
|
$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
|
346
|
|
|
346
|
0
|
781
|
my ($self, $file, $outline, %attributes) = @_; |
20
|
346
|
|
|
|
|
1148
|
$self->set_attributes(%attributes); |
21
|
346
|
|
|
|
|
793
|
my %position = $self->get_points(); |
22
|
346
|
|
|
|
|
1561
|
$position{y} = $file->page->h - $position{y}; |
23
|
346
|
|
|
|
|
1924
|
$self->outline_position(\%position); |
24
|
|
|
|
|
|
|
$outline = $outline->outline()->open() |
25
|
|
|
|
|
|
|
->title($self->text) |
26
|
346
|
|
|
|
|
1319
|
->dest($self->page->current, '-xyz' => [$position{x}, $position{y}, 0]); |
27
|
346
|
|
|
|
|
43044
|
$self->outline($outline); |
28
|
346
|
|
|
|
|
1126
|
return $file; |
29
|
|
|
|
|
|
|
} |
30
|
|
|
|
|
|
|
|
31
|
|
|
|
|
|
|
sub render { |
32
|
346
|
|
|
346
|
0
|
1998
|
my ($self, $file, %attributes) = @_; |
33
|
|
|
|
|
|
|
$self->set_attributes( |
34
|
|
|
|
|
|
|
pad => '.', |
35
|
|
|
|
|
|
|
pad_end => $self->page->num + $attributes{page_offset}, |
36
|
346
|
|
|
|
|
1809
|
%attributes |
37
|
|
|
|
|
|
|
); |
38
|
346
|
|
|
|
|
1711
|
$self->SUPER::add($file, align => 'none'); |
39
|
346
|
|
|
|
|
1262
|
my %position = $self->get_points(); |
40
|
346
|
|
|
|
|
1667
|
my $outline_position = $self->outline_position; |
41
|
346
|
|
|
|
|
1482
|
$attributes{y} = $position{y} + $self->font->size; |
42
|
346
|
|
|
|
|
1726
|
$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
|
346
|
|
|
|
|
1692
|
)->link($self->page->current, '-xyz' => [$outline_position->{x}, $outline_position->{y}, 0]); |
46
|
346
|
|
|
|
|
65486
|
my $y = $attributes{y}; |
47
|
346
|
|
|
|
|
879
|
my $num = $attributes{num}; |
48
|
346
|
|
|
|
|
574
|
for (@{$self->children}) { |
|
346
|
|
|
|
|
1980
|
|
49
|
287
|
|
|
|
|
736
|
$y += $attributes{padding}; |
50
|
287
|
50
|
|
|
|
1554
|
if ($y > $file->page->h - ($file->page->footer ? $file->page->footer->h : 0)) { |
|
|
100
|
|
|
|
|
|
51
|
3
|
|
|
|
|
19
|
$file->open_page($num->(1)); |
52
|
3
|
50
|
|
|
|
15
|
$y = $file->page->header ? $file->page->header->h : 0; |
53
|
|
|
|
|
|
|
} |
54
|
287
|
|
|
|
|
2483
|
$_->render($file, %attributes, y => $y); |
55
|
287
|
|
|
|
|
1557
|
$y = $_->end_y; |
56
|
|
|
|
|
|
|
} |
57
|
346
|
|
|
|
|
1587
|
$self->end_y($y); |
58
|
|
|
|
|
|
|
} |
59
|
|
|
|
|
|
|
|
60
|
|
|
|
|
|
|
1; |