Khonsu/Form/Field.pm

filter: Statementstmt 100% 33 / 33 Branchbran 50.0% 1 / 2 Conditioncond 40.0% 2 / 5 MC/DCmcdc 0.0% 0 / 3 Subroutinesub 100% 6 / 6 Podpod 0.0% 0 / 3 totaltotal 80.7% 42 / 52 CC 4 SCAR 8.6
CC
4
Cov
90%
add
4.1
BEGIN
1.0
BEGIN
1.0
CRAP 2.4
« Khonsu/Image.pm ↑ Summary Khonsu/Font.pm »
1 package Khonsu::Form::Field;
2  
3 3 ▶use parent 'Khonsu::Text';
Subroutine BEGIN: called CC=1 SCAR=0.0
4  
5 3 ▶use PDF::API2::Basic::PDF::Utils;
Subroutine BEGIN: called CC=1 SCAR=0.0
6 3 ▶use PDF::API2::Basic::PDF::Utils;
Subroutine BEGIN: called CC=1 SCAR=0.0
7  
8 sub attributes {
9 2 ▶ my $a = shift;
Subroutine attributes: called CC=1 SCAR=0.0
Pod undocumented
10 return (
11 2 $a->SUPER::attributes(),
12 xo => { $a->RW, $a->OBJ },
13 annotate => { $a->RW, $a->OBJ },
14 name => { $a->RW, $a->STR },
15 );
16 }
17  
18 sub add {
19 1 ▶ my ($self, $file, %args) = @_;
Subroutine add: called CC=4 SCAR=14.1
Pod undocumented
20  
21 1 my %position = $self->get_points();
22  
23 1 my $field = $self->xo(
24 $file->pdf->xo_form()
25 );
26  
27 1 $self->SUPER::add($file, pad => '_', %args);
28  
29 1 my $annotate = $self->annotate(
30 $file->page->current->annotation
31 );
32 1 $field->{OpenAction} = PDFArray($self->annotate, PDFName('XYZ'), PDFNull, PDFNull, PDFNum(0));
33 1 $field->bbox(0, 0, 149.8, 14.4);
34 1 $annotate->{DR} = $self->font->load();
35 1 ▶ $annotate->{T} = PDFStr($self->name || $args{text});
Condition33%1/3
$self->name || $args{'text'}
l!l&&r!l&&!r
010
MC/DC0%0/2
$self->name || $args{'text'}
$self->name $args{'text'}
Truth table33%1/3
A || B
A= $self->nameB= $args{'text'}
ABresult
1X1
011
000
36 1 $annotate->{Subtype} = PDFName('Widget');
37 1 $annotate->{P} = $file->page->current;
38 1 ▶ $args{position} ||= \@pps;
Condition50%1/2
$args{"position"} ||= \@pps
l!l
01
MC/DC0%0/1
$args{"position"} ||= \@pps
$args{"position"}
Truth table50%1/2
A
A= $args{"position"}
Aresult
11
00
39 1 ▶ $self->configure(%args) if $self->can('configure');
Branch: 1 branch
BranchTrueFalseTotal
if $self->can("configure") 1 0 1
40 1 $self->set_rect($file, %args);
41 1 $file->form->add_to_fields($file, $self->annotate);
42 1 return $file;
43 }
44  
45 sub set_rect {
46 1 ▶ my ($self, $file, %args) = @_;
Subroutine set_rect: called CC=1 SCAR=0.0
Pod undocumented
47 1 my %position = $self->get_points();
48 1 $position{y} = $file->page->h - $position{y};
49 my @pos = (
50 $self->end_w + 2,
51 $position{y} + ($self->font->size*0.2),
52 $position{w},
53 1 $position{y} - ($self->font->size*1.4)
54 );
55 1 $self->annotate->rect(@pos);
56 }
57  
58 3 1;
« Khonsu/Image.pm ↑ Summary Khonsu/Font.pm »