line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Khonsu::File; |
2
|
|
|
|
|
|
|
|
3
|
5
|
|
|
5
|
|
46
|
use parent 'Khonsu::Ra'; |
|
5
|
|
|
|
|
15
|
|
|
5
|
|
|
|
|
41
|
|
4
|
|
|
|
|
|
|
|
5
|
5
|
|
|
5
|
|
2702
|
use Khonsu::Page; |
|
5
|
|
|
|
|
22
|
|
|
5
|
|
|
|
|
157
|
|
6
|
5
|
|
|
5
|
|
1998
|
use Khonsu::Page::Header; |
|
5
|
|
|
|
|
14
|
|
|
5
|
|
|
|
|
162
|
|
7
|
5
|
|
|
5
|
|
1917
|
use Khonsu::Page::Footer; |
|
5
|
|
|
|
|
24
|
|
|
5
|
|
|
|
|
190
|
|
8
|
|
|
|
|
|
|
|
9
|
5
|
|
|
5
|
|
2535
|
use Module::Runtime qw/use_module/; |
|
5
|
|
|
|
|
9027
|
|
|
5
|
|
|
|
|
28
|
|
10
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
our @PLUGINS = (); |
12
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
sub load_plugin { |
14
|
0
|
|
|
0
|
0
|
0
|
my ($self, @plugins) = @_; |
15
|
0
|
|
|
|
|
0
|
for my $plugin (@plugins) { |
16
|
0
|
|
|
|
|
0
|
$plugin =~ s/^\+/Khonsu::/; |
17
|
0
|
|
|
|
|
0
|
use_module($plugin); |
18
|
0
|
|
|
|
|
0
|
push @PLUGINS, $plugin; |
19
|
|
|
|
|
|
|
} |
20
|
|
|
|
|
|
|
} |
21
|
|
|
|
|
|
|
|
22
|
|
|
|
|
|
|
sub new { |
23
|
4
|
|
|
4
|
0
|
15739
|
my ($self, %params) = @_; |
24
|
|
|
|
|
|
|
|
25
|
4
|
|
|
|
|
48
|
$self = $self->SUPER::new(%params, PLUGINS => \@PLUGINS); |
26
|
|
|
|
|
|
|
|
27
|
4
|
|
|
|
|
29
|
$self->add_page(); |
28
|
4
|
100
|
|
|
|
23
|
if ($params{configure}) { |
29
|
3
|
|
|
|
|
96
|
$self->add_page_header(%{delete $params{configure}->{page_header}}) |
30
|
3
|
50
|
|
|
|
15
|
if ($params{configure}->{page_header}); |
31
|
3
|
|
|
|
|
35
|
$self->add_page_footer(%{delete $params{configure}->{page_footer}}) |
32
|
3
|
50
|
|
|
|
23
|
if ($params{configure}->{page_footer}); |
33
|
3
|
|
|
|
|
13
|
for my $key ( keys %{ $params{configure} }) { |
|
3
|
|
|
|
|
25
|
|
34
|
8
|
50
|
|
|
|
32
|
if ($self->{$key}) { |
35
|
8
|
100
|
|
|
|
29
|
if ($params{configure}->{$key}->{font}) { |
36
|
3
|
|
|
|
|
30
|
$self->$key->font->load($self, %{ delete $params{configure}->{$key}->{font} }); |
|
3
|
|
|
|
|
28
|
|
37
|
|
|
|
|
|
|
} |
38
|
8
|
|
|
|
|
58
|
$self->$key->set_attributes(%{$params{configure}->{$key}}); |
|
8
|
|
|
|
|
100
|
|
39
|
|
|
|
|
|
|
} |
40
|
|
|
|
|
|
|
} |
41
|
|
|
|
|
|
|
} |
42
|
4
|
|
|
|
|
53
|
return $self; |
43
|
|
|
|
|
|
|
} |
44
|
|
|
|
|
|
|
|
45
|
|
|
|
|
|
|
|
46
|
|
|
|
|
|
|
sub attributes { |
47
|
4
|
|
|
4
|
0
|
11
|
my $a = shift; |
48
|
|
|
|
|
|
|
return ( |
49
|
|
|
|
|
|
|
file_name => {$a->RW, $a->REQ, $a->STR}, |
50
|
|
|
|
|
|
|
pdf => {$a->RW, $a->REQ, $a->OBJ}, |
51
|
|
|
|
|
|
|
pages => {$a->RW, $a->REQ, $a->DAR}, |
52
|
|
|
|
|
|
|
page => {$a->RW, $a->OBJ}, |
53
|
|
|
|
|
|
|
page_args => {$a->RW, $a->DHR}, |
54
|
4
|
|
|
4
|
|
16
|
page_offset => {$a->RW, $a->NUM, default => sub { 0 }}, |
55
|
4
|
|
|
|
|
584
|
onsave_cbs => {$a->RW, $a->DAR}, |
56
|
|
|
|
|
|
|
$a->LINE, |
57
|
|
|
|
|
|
|
$a->BOX, |
58
|
|
|
|
|
|
|
$a->CIRCLE, |
59
|
|
|
|
|
|
|
$a->PIE, |
60
|
|
|
|
|
|
|
$a->ELLIPSE, |
61
|
|
|
|
|
|
|
$a->FONT, |
62
|
|
|
|
|
|
|
$a->TEXT, |
63
|
|
|
|
|
|
|
$a->H1, |
64
|
|
|
|
|
|
|
$a->H2, |
65
|
|
|
|
|
|
|
$a->H3, |
66
|
|
|
|
|
|
|
$a->H4, |
67
|
|
|
|
|
|
|
$a->H5, |
68
|
|
|
|
|
|
|
$a->H6, |
69
|
|
|
|
|
|
|
$a->IMAGE, |
70
|
|
|
|
|
|
|
$a->TOC, |
71
|
|
|
|
|
|
|
$a->FORM, |
72
|
|
|
|
|
|
|
$a->INPUT, |
73
|
|
|
|
|
|
|
$a->SELECT, |
74
|
|
|
|
|
|
|
$a->CHECKBOX |
75
|
|
|
|
|
|
|
); |
76
|
|
|
|
|
|
|
} |
77
|
|
|
|
|
|
|
|
78
|
|
|
|
|
|
|
sub open_page { |
79
|
10
|
|
|
10
|
0
|
53
|
my ($self, $page) = @_; |
80
|
10
|
50
|
|
|
|
55
|
if ($self->pages) { |
81
|
10
|
|
|
|
|
55
|
$self->page($self->pages->[$page - 1]); |
82
|
|
|
|
|
|
|
} |
83
|
10
|
|
|
|
|
43
|
return $self; |
84
|
|
|
|
|
|
|
} |
85
|
|
|
|
|
|
|
|
86
|
|
|
|
|
|
|
sub set_columns { |
87
|
2
|
|
|
2
|
0
|
8
|
my ($self, $columns) = @_; |
88
|
2
|
|
|
|
|
13
|
$self->page->columns($columns); |
89
|
2
|
|
|
|
|
12
|
$self->page->column_y($self->page->y); |
90
|
2
|
|
|
|
|
18
|
return $self; |
91
|
|
|
|
|
|
|
} |
92
|
|
|
|
|
|
|
|
93
|
|
|
|
|
|
|
sub add_page { |
94
|
90
|
|
|
90
|
0
|
462
|
my ($self, %args) = @_; |
95
|
|
|
|
|
|
|
|
96
|
|
|
|
|
|
|
my $page = $self->page(Khonsu::Page->new( |
97
|
|
|
|
|
|
|
header => $self->page && $self->page->header ? $self->page->header->clone() : undef, |
98
|
|
|
|
|
|
|
footer => $self->page && $self->page->footer ? $self->page->footer->clone() : undef, |
99
|
|
|
|
|
|
|
columns => $self->page ? $self->page->columns : 1, |
100
|
|
|
|
|
|
|
page_size =>'A4', |
101
|
90
|
|
|
|
|
483
|
num => scalar @{$self->pages} + 1, |
102
|
90
|
100
|
100
|
|
|
489
|
%{ $self->page_args }, |
|
90
|
100
|
100
|
|
|
440
|
|
|
|
100
|
|
|
|
|
|
103
|
|
|
|
|
|
|
%args |
104
|
|
|
|
|
|
|
))->add($self); |
105
|
90
|
|
|
|
|
332
|
splice @{$self->pages}, $page->num - 1, 0, $page; |
|
90
|
|
|
|
|
379
|
|
106
|
|
|
|
|
|
|
|
107
|
90
|
|
|
|
|
357
|
return $self; |
108
|
|
|
|
|
|
|
} |
109
|
|
|
|
|
|
|
|
110
|
|
|
|
|
|
|
sub remove_page_header_and_footer { |
111
|
3
|
|
|
3
|
0
|
52
|
my ($self) = @_; |
112
|
3
|
|
|
|
|
20
|
$self->remove_page_header(); |
113
|
3
|
|
|
|
|
60
|
$self->remove_page_footer(); |
114
|
|
|
|
|
|
|
} |
115
|
|
|
|
|
|
|
|
116
|
|
|
|
|
|
|
sub remove_page_header { |
117
|
3
|
|
|
3
|
0
|
8
|
my ($self, %args) = @_; |
118
|
3
|
|
|
|
|
18
|
$self->page->header->active(0); |
119
|
3
|
|
|
|
|
9
|
return $self; |
120
|
|
|
|
|
|
|
} |
121
|
|
|
|
|
|
|
|
122
|
|
|
|
|
|
|
sub remove_page_footer { |
123
|
3
|
|
|
3
|
0
|
19
|
my ($self, %args) = @_; |
124
|
3
|
|
|
|
|
19
|
$self->page->footer->active(0); |
125
|
3
|
|
|
|
|
38
|
return $self; |
126
|
|
|
|
|
|
|
} |
127
|
|
|
|
|
|
|
|
128
|
|
|
|
|
|
|
sub add_page_header { |
129
|
4
|
|
|
4
|
0
|
45
|
my ($self, %args) = @_; |
130
|
4
|
|
|
|
|
29
|
$self->page->header(Khonsu::Page::Header->new( |
131
|
|
|
|
|
|
|
%args |
132
|
|
|
|
|
|
|
)); |
133
|
4
|
50
|
|
|
|
35
|
if ($self->page->y < $self->page->header->h) { |
134
|
4
|
|
|
|
|
23
|
$self->page->column_y($self->page->y($self->page->header->h)); |
135
|
|
|
|
|
|
|
} |
136
|
4
|
|
|
|
|
18
|
return $self; |
137
|
|
|
|
|
|
|
} |
138
|
|
|
|
|
|
|
|
139
|
|
|
|
|
|
|
sub add_page_footer { |
140
|
4
|
|
|
4
|
0
|
21
|
my ($self, %args) = @_; |
141
|
|
|
|
|
|
|
|
142
|
4
|
|
|
|
|
20
|
$self->page->footer(Khonsu::Page::Footer->new( |
143
|
|
|
|
|
|
|
%args |
144
|
|
|
|
|
|
|
)); |
145
|
|
|
|
|
|
|
|
146
|
4
|
|
|
|
|
20
|
return $self; |
147
|
|
|
|
|
|
|
} |
148
|
|
|
|
|
|
|
|
149
|
|
|
|
|
|
|
sub add_toc { |
150
|
4
|
|
|
4
|
0
|
29
|
my ($self, %args) = @_; |
151
|
4
|
|
|
|
|
26
|
$self->toc->add($self, %args); |
152
|
4
|
|
|
|
|
13
|
return $self; |
153
|
|
|
|
|
|
|
} |
154
|
|
|
|
|
|
|
|
155
|
|
|
|
|
|
|
sub add_line { |
156
|
2
|
|
|
2
|
0
|
15
|
my ($self, %args) = @_; |
157
|
2
|
|
|
|
|
18
|
$self->line->add($self, %args); |
158
|
2
|
|
|
|
|
7
|
return $self; |
159
|
|
|
|
|
|
|
} |
160
|
|
|
|
|
|
|
|
161
|
|
|
|
|
|
|
sub add_box { |
162
|
2
|
|
|
2
|
0
|
13
|
my ($self, %args) = @_; |
163
|
2
|
|
|
|
|
16
|
$self->box->add($self, %args); |
164
|
2
|
|
|
|
|
8
|
return $self; |
165
|
|
|
|
|
|
|
} |
166
|
|
|
|
|
|
|
|
167
|
|
|
|
|
|
|
sub add_circle { |
168
|
2
|
|
|
2
|
0
|
15
|
my ($self, %args) = @_; |
169
|
2
|
|
|
|
|
16
|
$self->circle->add($self, %args); |
170
|
2
|
|
|
|
|
8
|
return $self; |
171
|
|
|
|
|
|
|
} |
172
|
|
|
|
|
|
|
|
173
|
|
|
|
|
|
|
sub add_pie { |
174
|
4
|
|
|
4
|
0
|
30
|
my ($self, %args) = @_; |
175
|
4
|
|
|
|
|
30
|
$self->pie->add($self, %args); |
176
|
4
|
|
|
|
|
16
|
return $self; |
177
|
|
|
|
|
|
|
} |
178
|
|
|
|
|
|
|
|
179
|
|
|
|
|
|
|
sub add_ellipse { |
180
|
2
|
|
|
2
|
0
|
28
|
my ($self, %args) = @_; |
181
|
2
|
|
|
|
|
20
|
$self->ellipse->add($self, %args); |
182
|
2
|
|
|
|
|
6
|
return $self; |
183
|
|
|
|
|
|
|
} |
184
|
|
|
|
|
|
|
|
185
|
|
|
|
|
|
|
sub load_font { |
186
|
0
|
|
|
0
|
0
|
0
|
my ($self, %args) = @_; |
187
|
0
|
|
|
|
|
0
|
$self->font->load($self, %args); |
188
|
0
|
|
|
|
|
0
|
return $self; |
189
|
|
|
|
|
|
|
} |
190
|
|
|
|
|
|
|
|
191
|
|
|
|
|
|
|
sub add_text { |
192
|
18
|
|
|
18
|
0
|
102
|
my ($self, %args) = @_; |
193
|
18
|
|
|
|
|
124
|
$self->text->add($self, %args); |
194
|
18
|
|
|
|
|
100
|
return $self; |
195
|
|
|
|
|
|
|
} |
196
|
|
|
|
|
|
|
|
197
|
|
|
|
|
|
|
sub add_h1 { |
198
|
61
|
|
|
61
|
0
|
300
|
my ($self, %args) = @_; |
199
|
61
|
|
|
|
|
287
|
$self->h1->add($self, %args); |
200
|
61
|
|
|
|
|
244
|
return $self; |
201
|
|
|
|
|
|
|
} |
202
|
|
|
|
|
|
|
|
203
|
|
|
|
|
|
|
sub add_h2 { |
204
|
59
|
|
|
59
|
0
|
328
|
my ($self, %args) = @_; |
205
|
59
|
|
|
|
|
295
|
$self->h2->add($self, %args); |
206
|
59
|
|
|
|
|
230
|
return $self; |
207
|
|
|
|
|
|
|
} |
208
|
|
|
|
|
|
|
|
209
|
|
|
|
|
|
|
sub add_h3 { |
210
|
57
|
|
|
57
|
0
|
268
|
my ($self, %args) = @_; |
211
|
57
|
|
|
|
|
265
|
$self->h3->add($self, %args); |
212
|
57
|
|
|
|
|
232
|
return $self; |
213
|
|
|
|
|
|
|
} |
214
|
|
|
|
|
|
|
|
215
|
|
|
|
|
|
|
sub add_h4 { |
216
|
57
|
|
|
57
|
0
|
268
|
my ($self, %args) = @_; |
217
|
57
|
|
|
|
|
258
|
$self->h4->add($self, %args); |
218
|
57
|
|
|
|
|
232
|
return $self; |
219
|
|
|
|
|
|
|
} |
220
|
|
|
|
|
|
|
|
221
|
|
|
|
|
|
|
sub add_h5 { |
222
|
57
|
|
|
57
|
0
|
272
|
my ($self, %args) = @_; |
223
|
57
|
|
|
|
|
260
|
$self->h5->add($self, %args); |
224
|
57
|
|
|
|
|
220
|
return $self; |
225
|
|
|
|
|
|
|
} |
226
|
|
|
|
|
|
|
|
227
|
|
|
|
|
|
|
sub add_h6 { |
228
|
57
|
|
|
57
|
0
|
303
|
my ($self, %args) = @_; |
229
|
57
|
|
|
|
|
281
|
$self->h6->add($self, %args); |
230
|
57
|
|
|
|
|
308
|
return $self; |
231
|
|
|
|
|
|
|
} |
232
|
|
|
|
|
|
|
|
233
|
|
|
|
|
|
|
sub add_image { |
234
|
8
|
|
|
8
|
0
|
63
|
my ($self, %args) = @_; |
235
|
8
|
|
|
|
|
69
|
$self->image->add($self, %args); |
236
|
8
|
|
|
|
|
78
|
return $self; |
237
|
|
|
|
|
|
|
} |
238
|
|
|
|
|
|
|
|
239
|
|
|
|
|
|
|
sub add_form { |
240
|
0
|
|
|
0
|
0
|
0
|
my ($self, %args) = @_; |
241
|
0
|
|
|
|
|
0
|
$self->form->add($self, %args); |
242
|
0
|
|
|
|
|
0
|
return $self; |
243
|
|
|
|
|
|
|
} |
244
|
|
|
|
|
|
|
|
245
|
|
|
|
|
|
|
sub add_input { |
246
|
3
|
|
|
3
|
0
|
18
|
my ($self, %args) = @_; |
247
|
3
|
|
|
|
|
26
|
$self->input->add($self, %args); |
248
|
3
|
|
|
|
|
17
|
return $self; |
249
|
|
|
|
|
|
|
} |
250
|
|
|
|
|
|
|
|
251
|
|
|
|
|
|
|
sub add_select { |
252
|
3
|
|
|
3
|
0
|
19
|
my ($self, %args) = @_; |
253
|
3
|
|
|
|
|
22
|
$self->select->add($self, %args); |
254
|
3
|
|
|
|
|
15
|
return $self; |
255
|
|
|
|
|
|
|
} |
256
|
|
|
|
|
|
|
|
257
|
|
|
|
|
|
|
sub add_checkbox { |
258
|
1
|
|
|
1
|
0
|
6
|
my ($self, %args) = @_; |
259
|
1
|
|
|
|
|
9
|
$self->checkbox->add($self, %args); |
260
|
1
|
|
|
|
|
5
|
return $self; |
261
|
|
|
|
|
|
|
} |
262
|
|
|
|
|
|
|
|
263
|
|
|
|
|
|
|
sub onsave { |
264
|
7
|
|
|
7
|
0
|
43
|
my ($self, $plug, $meth, %args) = @_; |
265
|
7
|
|
50
|
|
|
48
|
my $cbs = $self->onsave_cbs || []; |
266
|
7
|
|
|
|
|
20
|
push @{$cbs}, [$plug, $meth, \%args]; |
|
7
|
|
|
|
|
29
|
|
267
|
7
|
|
|
|
|
45
|
$self->onsave_cbs($cbs); |
268
|
7
|
|
|
|
|
27
|
return $self; |
269
|
|
|
|
|
|
|
} |
270
|
|
|
|
|
|
|
|
271
|
|
|
|
|
|
|
sub handle_onsave { |
272
|
4
|
|
|
4
|
0
|
14
|
my ($self) = shift; |
273
|
4
|
50
|
|
|
|
29
|
if ($self->onsave_cbs) { |
274
|
4
|
|
|
|
|
15
|
for my $cb (@{$self->onsave_cbs}) { |
|
4
|
|
|
|
|
23
|
|
275
|
7
|
|
|
|
|
20
|
my ($plug, $meth, $args) = @{$cb}; |
|
7
|
|
|
|
|
34
|
|
276
|
7
|
|
|
|
|
47
|
$self->$plug->$meth($self, %{$args}); |
|
7
|
|
|
|
|
81
|
|
277
|
|
|
|
|
|
|
} |
278
|
|
|
|
|
|
|
} |
279
|
|
|
|
|
|
|
|
280
|
4
|
|
|
|
|
21
|
for my $page (@{$self->pages}) { |
|
4
|
|
|
|
|
24
|
|
281
|
90
|
|
|
|
|
536
|
$self->page($page); |
282
|
90
|
100
|
100
|
|
|
553
|
$page->num($page->num + ($self->page_offset || 0)) if !$page->toc; |
283
|
90
|
|
|
|
|
499
|
$page->render($self); |
284
|
|
|
|
|
|
|
} |
285
|
|
|
|
|
|
|
} |
286
|
|
|
|
|
|
|
|
287
|
|
|
|
|
|
|
sub save { |
288
|
4
|
|
|
4
|
0
|
15
|
my ($self) = shift; |
289
|
4
|
|
|
|
|
40
|
$self->handle_onsave(); |
290
|
4
|
|
|
|
|
29
|
$self->pdf->saveas(); |
291
|
4
|
|
|
|
|
20076331
|
$self->pdf->end(); |
292
|
|
|
|
|
|
|
} |
293
|
|
|
|
|
|
|
|
294
|
|
|
|
|
|
|
1; |