API2/Resource/XObject/Form.pm

filter: Statementstmt 67.5% 25 / 37 Branchbran 20.0% 2 / 10 Conditioncond 0.0% 0 / 11 MC/DCmcdc 0.0% 0 / 7 Subroutinesub 85.7% 6 / 7 Podpod 100% 3 / 3 totaltotal 48.0% 36 / 75 SCAR 32.3
CC
10
Cov
47%
resource
90.0
bbox
2.0
BEGIN
1.0
CRAP 25.3
« API2/Basic/PDF/Filter/ASCII85Decode.pm ↑ Summary API2/Basic/PDF/Filter.pm »
1 package PDF::API2::Resource::XObject::Form;
2  
3 38 ▶use base 'PDF::API2::Resource::XObject';
Subroutine BEGIN: called CC=1 SCAR=0.0
4  
5 38 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
6 38 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
7  
8 38 our $VERSION = '2.044'; # VERSION
9  
10 38 ▶use PDF::API2::Basic::PDF::Utils;
Subroutine BEGIN: called CC=1 SCAR=0.0
11  
12 =head1 NAME
13  
14 PDF::API2::Resource::XObject::Form - Base class for external form objects
15  
16 =head1 METHODS
17  
18 =over
19  
20 =item $form = PDF::API2::Resource::XObject::Form->new($pdf)
21  
22 Creates a form resource.
23  
24 =cut
25  
26 sub new {
27 10 ▶ my ($class, $pdf, $name) = @_;
Subroutine new: called CC=1 SCAR=0.0
Pod documented
28 10 my $self = $class->SUPER::new($pdf, $name);
29  
30 10 $self->subtype('Form');
31 10 $self->{'FormType'} = PDFNum(1);
32  
33 10 return $self;
34 }
35  
36 =item ($llx, $lly, $urx, $ury) = $form->bbox($llx, $lly, $urx, $ury)
37  
38 Get or set the coordinates of the form object's bounding box
39  
40 =cut
41  
42 sub bbox {
43 11 ▶ my $self = shift();
Subroutine bbox: called CC=2 SCAR=6.9
Pod documented
44  
45 11 ▶ if (scalar @_) {
Branch: 1 branch
BranchTrueFalseTotal
if (scalar @_) 10 1 11
46 10 $self->{'BBox'} = PDFArray(map { PDFNum($_) } @_);
47 }
48  
49 11 return map { $_->val() } $self->{'BBox'}->elements();
50 }
51  
52 =item $resource = $form->resource($type, $key)
53  
54 =item $form->resource($type, $key, $object, $force)
55  
56 Get or add a resource required by the form's contents, such as a Font, XObject, ColorSpace, etc.
57  
58 By default, an existing C<$key> will not be overwritten. Set C<$force> to override this behavior.
59  
60 =cut
61  
62 sub resource {
63 0 ▶ my ($self, $type, $key, $object, $force) = @_;
Subroutine resource: not called CC=9 SCAR=45.0
Pod documented
64 # we are a self-contained content stream.
65  
66 0 ▶ $self->{'Resources'} ||= PDFDict();
Condition0%0/3
$self->{"Resources"} ||= PDFDict()
l!l&&r!l&&!r
000
MC/DC0%0/2
$self->{"Resources"} ||= PDFDict()
$self->{"Resources"} PDFDict()
Truth table0%0/3
A ||= B
A= $self->{"Resources"}B= PDFDict()
ABresult
1X1
011
000
67  
68 0 my $dict = $self->{'Resources'};
69 0 ▶ $dict->realise() if ref($dict) =~ /Objind$/;
Branch: 1 branch
BranchTrueFalseTotal
if ref($dict) =~ /Objind$/ 0 0 0
70  
71 0 ▶ $dict->{$type} ||= PDFDict();
Condition0%0/3
$dict->{$type} ||= PDFDict()
l!l&&r!l&&!r
000
MC/DC0%0/2
$dict->{$type} ||= PDFDict()
$dict->{$type} PDFDict()
Truth table0%0/3
A ||= B
A= $dict->{$type}B= PDFDict()
ABresult
1X1
011
000
72 0 ▶ $dict->{$type}->realise() if ref($dict->{$type}) =~ /Objind$/;
Branch: 1 branch
BranchTrueFalseTotal
if ref($dict->{$type}) =~ /Objind$/ 0 0 0
73  
74 0 ▶ unless (defined $object) {
Branch: 1 branch
BranchTrueFalseTotal
unless (defined $object) 0 0 0
75 0 ▶ return $dict->{$type}->{$key} || undef;
Condition0%0/2
$dict->{$type}{$key} || undef
l!l
00
MC/DC0%0/1
$dict->{$type}{$key} || undef
$dict->{$type}{$key}
Truth table0%0/2
A
A= $dict->{$type}{$key}
Aresult
11
00
76 }
77  
78 0 ▶ if ($force) {
Branch: 1 branch
BranchTrueFalseTotal
if ($force) { } 0 0 0
79 0 $dict->{$type}->{$key} = $object;
80 }
81 else {
82 0 ▶ $dict->{$type}->{$key} ||= $object;
Condition0%0/3
$dict->{$type}{$key} ||= $object
l!l&&r!l&&!r
000
MC/DC0%0/2
$dict->{$type}{$key} ||= $object
$dict->{$type}{$key} $object
Truth table0%0/3
A ||= B
A= $dict->{$type}{$key}B= $object
ABresult
1X1
011
000
83 }
84  
85 0 return $dict;
86 }
87  
88 =back
89  
90 =cut
91  
92 38 1;
« API2/Basic/PDF/Filter/ASCII85Decode.pm ↑ Summary API2/Basic/PDF/Filter.pm »