Builder/Basic/PDF/Literal.pm

filter: Statementstmt 36.2% 21 / 58 Branchbran 0.0% 0 / 20 Conditioncond 0.0% 0 / 3 MC/DCmcdc 0.0% 0 / 2 Subroutinesub 66.6% 6 / 9 Podpod 100% 3 / 3 totaltotal 31.5% 30 / 95 CC 14 SCAR 40.5
CC
14
Cov
26%
outobjdeep
110.0
new
30.0
val
2.0
CRAP 57.2
« Builder/Outline.pm ↑ Summary Builder/Resource/Font/CoreFont.pm »
1 # Literal PDF Object for Dirty Hacks ...
2 package PDF::Builder::Basic::PDF::Literal;
3  
4 42 ▶use base 'PDF::Builder::Basic::PDF::Objind';
Subroutine BEGIN: called CC=1 SCAR=0.0
5  
6 42 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
7 42 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
8  
9 42 our $VERSION = '3.028'; # VERSION
10 42 our $LAST_UPDATE = '3.027'; # manually update whenever code is changed
11  
12 42 ▶use PDF::Builder::Basic::PDF::Filter;
Subroutine BEGIN: called CC=1 SCAR=0.0
13 42 ▶use PDF::Builder::Basic::PDF::Name;
Subroutine BEGIN: called CC=1 SCAR=0.0
14 42 ▶use Scalar::Util qw(blessed);
Subroutine BEGIN: called CC=1 SCAR=0.0
15  
16 =head1 NAME
17  
18 PDF::Builder::Basic::PDF::Literal - Literal PDF Object
19  
20 Inherits from L<PDF::Builder::Basic::PDF::Objind>
21  
22 =cut
23  
24 0 ▶sub new {
Subroutine new: not called CC=5 SCAR=34.0
Pod documented
25 0 my ($class, @opts) = @_;
26 0 my ($self);
27  
28 0 ▶ $class = ref($class) if ref($class);
Branch: 1 branch
BranchTrueFalseTotal
if ref $class 0 0 0
29 0 $self = $class->SUPER::new(@_);
30 0 $self->{' realised'} = 1;
31 0 ▶ if (scalar @opts > 1) {
Branch: 2 branches
BranchTrueFalseTotal
if (scalar @opts > 1) { } 0 0 0
elsif (scalar @opts == 1) { } 0 0 0
32 0 $self->{'-isdict'} = 1;
33 0 my %opt = @opts;
34 0 foreach my $k (keys %opt) {
35 0 $self->{$k} = $opt{$k};
36 }
37 } elsif (scalar @opts == 1) {
38 0 $self->{'-literal'} = $opts[0];
39 }
40 0 return $self;
41 }
42  
43 0 ▶sub outobjdeep {
Subroutine outobjdeep: not called CC=10 SCAR=47.0
Pod documented
44 0 my ($self, $fh, $pdf) = @_;
45 0 ▶ if ($self->{'-isdict'}) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->{'-isdict'}) { } 0 0 0
46 0 ▶ if (defined $self->{' stream'}) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $self->{' stream'}) { } 0 0 0
47 0 $self->{'Length'} = length($self->{' stream'}) + 1;
48 } else {
49 0 delete $self->{'Length'};
50 }
51 0 $fh->print("<< ");
52 0 foreach my $k (sort keys %{$self}) {
53 0 ▶ next if $k=~m|^[ \-]|o;
Branch: 1 branch
BranchTrueFalseTotal
if $k =~ /^[ \-]/o 0 0 0
54 0 $fh->print('/'.PDF::Builder::Basic::PDF::Name::string_to_name($k).' ');
55 0 ▶ if (ref($self->{$k}) eq 'ARRAY') {
Branch: 3 branches
BranchTrueFalseTotal
if (ref $self->{$k} eq 'ARRAY') { } 0 0 0
elsif (ref $self->{$k} eq 'HASH') { } 0 0 0
elsif (builtin::blessed($self->{$k}) and $self->{$k}->can('outobj')) { } 0 0 0
56 0 $fh->print('[' . join(' ',@{$self->{$k}}) . "]\n");
57 } elsif (ref($self->{$k}) eq 'HASH') {
58 $fh->print('<<' .
59 join(' ', map { '/'.PDF::Builder::Basic::PDF::Name::string_to_name($_) .
60 0 ' ' . $self->{$k}->{$_} } sort keys %{$self->{$k}}) .
61 " >>\n");
62 ▶ } elsif (blessed($self->{$k}) and $self->{$k}->can('outobj')) {
Condition0%0/3
builtin::blessed($self->{$k}) and $self->{$k}->can("outobj")
!ll&&!rl&&r
000
MC/DC0%0/2
builtin::blessed($self->{$k}) and $self->{$k}->can("outobj")
builtin::blessed($self->{$k}) $self->{$k}->can("outobj")
Truth table0%0/3
A and B
A= builtin::blessed($self->{$k})B= $self->{$k}->can("outobj")
ABresult
0X0
100
111
63 0 $self->{$k}->outobj($fh, $pdf);
64 0 $fh->print("\n");
65 } else {
66 0 $fh->print("$self->{$k}\n");
67 }
68 }
69 0 $fh->print(">>\n");
70 0 ▶ if (defined $self->{' stream'}) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $self->{" stream"}) 0 0 0
71 0 $fh->print("stream\n$self->{' stream'}\nendstream"); # next is endobj which has the final cr
72 }
73 } else {
74 0 $fh->print($self->{'-literal'}); # next is endobj which has the final cr
75 }
76 0 return;
77 }
78  
79 0 ▶sub val { return $_[0]; }
Subroutine val: not called CC=1 SCAR=6.9
Pod documented
80  
81 42 1;
« Builder/Outline.pm ↑ Summary Builder/Resource/Font/CoreFont.pm »