line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Khonsu::Page; |
2
|
|
|
|
|
|
|
|
3
|
5
|
|
|
5
|
|
35
|
use parent 'Khonsu::Ra'; |
|
5
|
|
|
|
|
11
|
|
|
5
|
|
|
|
|
38
|
|
4
|
|
|
|
|
|
|
|
5
|
|
|
|
|
|
|
sub attributes { |
6
|
90
|
|
|
90
|
0
|
209
|
my $a = shift; |
7
|
|
|
|
|
|
|
return ( |
8
|
|
|
|
|
|
|
page_size => {$a->RW, $a->REQ, $a->STR}, |
9
|
|
|
|
|
|
|
background => {$a->RW, $a->STR}, |
10
|
|
|
|
|
|
|
num => {$a->RW, $a->REQ, $a->NUM}, |
11
|
|
|
|
|
|
|
current => {$a->RW, $a->OBJ}, |
12
|
0
|
|
|
0
|
|
0
|
columns => {$a->RW, $a->NUM, default => sub { 1 }}, |
13
|
90
|
|
|
90
|
|
234
|
column => {$a->RW, $a->NUM, default => sub { 1 }}, |
14
|
90
|
|
|
90
|
|
271
|
column_y => {$a->RW, $a->NUM, default => sub {1 }}, |
15
|
90
|
|
|
|
|
4753
|
is_rotated => {$a->RW, $a->NUM}, |
16
|
|
|
|
|
|
|
header => {$a->RW, $a->OBJ}, |
17
|
|
|
|
|
|
|
footer => {$a->RW, $a->OBJ}, |
18
|
|
|
|
|
|
|
toc => {$a->RW, $a->BOOL}, |
19
|
|
|
|
|
|
|
padding => {$a->RW, $a->NUM}, |
20
|
|
|
|
|
|
|
$a->POINTS, |
21
|
|
|
|
|
|
|
$a->BOX, |
22
|
|
|
|
|
|
|
); |
23
|
|
|
|
|
|
|
} |
24
|
|
|
|
|
|
|
|
25
|
|
|
|
|
|
|
sub add { |
26
|
90
|
|
|
90
|
0
|
226
|
my ($self, $file, %args) = @_; |
27
|
|
|
|
|
|
|
|
28
|
90
|
50
|
0
|
|
|
469
|
my $page = $args{open} ? $file->pdf->openpage($args{num} || $self->num) : $file->pdf->page($args{num} || $self->num || 0); |
|
|
|
50
|
|
|
|
|
29
|
90
|
|
|
|
|
77782
|
$page->mediabox($self->page_size); |
30
|
90
|
|
|
|
|
14934
|
$self->set_points($page->get_mediabox); |
31
|
|
|
|
|
|
|
|
32
|
90
|
|
|
|
|
483
|
$self->current($page); |
33
|
90
|
50
|
|
|
|
294
|
$self->rotate if $args{rotate}; |
34
|
90
|
50
|
|
|
|
376
|
if ($self->background) { |
35
|
90
|
|
|
|
|
422
|
$self->box->add( |
36
|
|
|
|
|
|
|
$file, |
37
|
|
|
|
|
|
|
fill_colour => $self->background, |
38
|
|
|
|
|
|
|
$self->get_points |
39
|
|
|
|
|
|
|
); |
40
|
|
|
|
|
|
|
} |
41
|
|
|
|
|
|
|
|
42
|
90
|
100
|
|
|
|
609
|
if ($self->header) { |
43
|
85
|
|
|
|
|
391
|
$self->column_y($self->y($self->header->h)); |
44
|
|
|
|
|
|
|
} |
45
|
|
|
|
|
|
|
|
46
|
90
|
100
|
|
|
|
437
|
if ($self->padding) { |
47
|
14
|
|
|
|
|
86
|
$self->x($self->padding); |
48
|
|
|
|
|
|
|
} |
49
|
90
|
|
|
|
|
374
|
return $self; |
50
|
|
|
|
|
|
|
} |
51
|
|
|
|
|
|
|
|
52
|
|
|
|
|
|
|
sub rotate { |
53
|
0
|
|
|
0
|
0
|
0
|
my ($self) = shift; |
54
|
0
|
|
|
|
|
0
|
my ($blx, $bly, $trx, $try) = $self->current->get_mediabox; |
55
|
0
|
|
|
|
|
0
|
$self->current->mediabox( |
56
|
|
|
|
|
|
|
$self->x(0), |
57
|
|
|
|
|
|
|
$self->y(0), |
58
|
|
|
|
|
|
|
$self->w($try), |
59
|
|
|
|
|
|
|
$self->h($trx), |
60
|
|
|
|
|
|
|
); |
61
|
0
|
|
|
|
|
0
|
$self->is_rotated(!$self->is_rotated); |
62
|
0
|
|
|
|
|
0
|
return $self; |
63
|
|
|
|
|
|
|
} |
64
|
|
|
|
|
|
|
|
65
|
|
|
|
|
|
|
sub render { |
66
|
90
|
|
|
90
|
0
|
255
|
my ($self, $file) = @_; |
67
|
90
|
100
|
|
|
|
386
|
$self->header->render($file) if $self->header; |
68
|
90
|
100
|
|
|
|
577
|
$self->footer->render($file) if $self->footer; |
69
|
|
|
|
|
|
|
|
70
|
|
|
|
|
|
|
} |
71
|
|
|
|
|
|
|
|
72
|
|
|
|
|
|
|
sub remaining_height { |
73
|
36
|
|
|
36
|
0
|
117
|
my ($self) = @_; |
74
|
36
|
50
|
|
|
|
170
|
return $self->h - ($self->y + ($self->footer ? $self->footer->h : 0)) |
75
|
|
|
|
|
|
|
} |
76
|
|
|
|
|
|
|
|
77
|
|
|
|
|
|
|
sub width { |
78
|
41
|
|
|
41
|
0
|
145
|
my ($self) = @_; |
79
|
41
|
|
|
|
|
176
|
return ($self->w - ($self->padding * (2 + ($self->columns - 1)))) / $self->columns; |
80
|
|
|
|
|
|
|
} |
81
|
|
|
|
|
|
|
|
82
|
|
|
|
|
|
|
sub next { |
83
|
17
|
|
|
17
|
0
|
60
|
my ($self, $file) = @_; |
84
|
17
|
100
|
|
|
|
105
|
if ($self->column < $self->columns) { |
85
|
5
|
|
|
|
|
31
|
$self->column($self->column + 1); |
86
|
5
|
|
|
|
|
46
|
$self->x($self->x + $self->width + $self->padding); |
87
|
5
|
|
|
|
|
38
|
$self->y($self->column_y); |
88
|
|
|
|
|
|
|
} else { |
89
|
12
|
|
|
|
|
82
|
$self->column(1); |
90
|
12
|
|
|
|
|
137
|
$file->add_page(); |
91
|
|
|
|
|
|
|
} |
92
|
|
|
|
|
|
|
} |
93
|
|
|
|
|
|
|
|
94
|
|
|
|
|
|
|
1; |