| 1 | # Literal PDF Object for Dirty Hacks ... | ||||||||||||||||||||
| 2 | package PDF::API2::Basic::PDF::Literal; | ||||||||||||||||||||
| 3 | |||||||||||||||||||||
| 4 | 40 | ▶ | use base 'PDF::API2::Basic::PDF::Objind'; | ||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 5 | |||||||||||||||||||||
| 6 | 40 | ▶ | use strict; | ||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 7 | |||||||||||||||||||||
| 8 | 40 | our $VERSION = '2.044'; # VERSION | |||||||||||||||||||
| 9 | |||||||||||||||||||||
| 10 | 40 | ▶ | use PDF::API2::Basic::PDF::Filter; | ||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 11 | 40 | ▶ | use PDF::API2::Basic::PDF::Name; | ||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 12 | 40 | ▶ | use Scalar::Util qw(blessed); | ||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 13 | |||||||||||||||||||||
| 14 | 40 | ▶ | no warnings qw[ deprecated recursion uninitialized ]; | ||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 15 | |||||||||||||||||||||
| 16 | sub new | ||||||||||||||||||||
| 17 | { | ||||||||||||||||||||
| 18 | 0 | ▶ | my ($class, @opts) = @_; | ||||||||||||||||||
|
Subroutine
new: not called CC=5 SCAR=34.0
Pod
documented
| |||||||||||||||||||||
| 19 | 0 | my ($self); | |||||||||||||||||||
| 20 | |||||||||||||||||||||
| 21 | 0 | ▶ | $class = ref $class if ref $class; | ||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||
| 22 | 0 | $self = $class->SUPER::new(@_); | |||||||||||||||||||
| 23 | 0 | $self->{' realised'} = 1; | |||||||||||||||||||
| 24 | 0 | ▶ | if(scalar @opts > 1) { | ||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||
| 25 | 0 | $self->{-isdict}=1; | |||||||||||||||||||
| 26 | 0 | my %opt=@opts; | |||||||||||||||||||
| 27 | 0 | foreach my $k (keys %opt) { | |||||||||||||||||||
| 28 | 0 | $self->{$k} = $opt{$k}; | |||||||||||||||||||
| 29 | } | ||||||||||||||||||||
| 30 | } elsif(scalar @opts == 1) { | ||||||||||||||||||||
| 31 | 0 | $self->{-literal}=$opts[0]; | |||||||||||||||||||
| 32 | } | ||||||||||||||||||||
| 33 | 0 | return $self; | |||||||||||||||||||
| 34 | } | ||||||||||||||||||||
| 35 | |||||||||||||||||||||
| 36 | sub outobjdeep | ||||||||||||||||||||
| 37 | { | ||||||||||||||||||||
| 38 | 0 | ▶ | my ($self, $fh, $pdf) = @_; | ||||||||||||||||||
|
Subroutine
outobjdeep: not called CC=10 SCAR=47.0
Pod
documented
| |||||||||||||||||||||
| 39 | 0 | ▶ | if($self->{-isdict}) | ||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||
| 40 | { | ||||||||||||||||||||
| 41 | 0 | ▶ | if(defined $self->{' stream'}) | ||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||
| 42 | { | ||||||||||||||||||||
| 43 | 0 | $self->{Length} = length($self->{' stream'}) + 1; | |||||||||||||||||||
| 44 | } | ||||||||||||||||||||
| 45 | else | ||||||||||||||||||||
| 46 | { | ||||||||||||||||||||
| 47 | 0 | delete $self->{Length}; | |||||||||||||||||||
| 48 | } | ||||||||||||||||||||
| 49 | 0 | $fh->print("<< "); | |||||||||||||||||||
| 50 | 0 | foreach my $k (sort keys %{$self}) | |||||||||||||||||||
| 51 | { | ||||||||||||||||||||
| 52 | 0 | ▶ | next if($k=~m|^[ \-]|o); | ||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||
| 53 | 0 | $fh->print('/'.PDF::API2::Basic::PDF::Name::string_to_name($k).' '); | |||||||||||||||||||
| 54 | 0 | ▶ | if(ref($self->{$k}) eq 'ARRAY') | ||||||||||||||||||
|
Branch: 3 branches
| |||||||||||||||||||||
| 55 | { | ||||||||||||||||||||
| 56 | 0 | $fh->print('['.join(' ',@{$self->{$k}})."]\n"); | |||||||||||||||||||
| 57 | } | ||||||||||||||||||||
| 58 | elsif(ref($self->{$k}) eq 'HASH') | ||||||||||||||||||||
| 59 | { | ||||||||||||||||||||
| 60 | 0 | $fh->print('<<'.join(' ', map { '/'.PDF::API2::Basic::PDF::Name::string_to_name($_).' '.$self->{$k}->{$_} } sort keys %{$self->{$k}})." >>\n"); | |||||||||||||||||||
| 61 | } | ||||||||||||||||||||
| 62 | ▶ | elsif(blessed($self->{$k}) and $self->{$k}->can('outobj')) | |||||||||||||||||||
|
Condition0%0/3
builtin::blessed($self->{$k}) and $self->{$k}->can("outobj")
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")
| |||||||||||||||||||||
| 63 | { | ||||||||||||||||||||
| 64 | 0 | $self->{$k}->outobj($fh, $pdf); | |||||||||||||||||||
| 65 | 0 | $fh->print("\n"); | |||||||||||||||||||
| 66 | } | ||||||||||||||||||||
| 67 | else | ||||||||||||||||||||
| 68 | { | ||||||||||||||||||||
| 69 | 0 | $fh->print("$self->{$k}\n"); | |||||||||||||||||||
| 70 | } | ||||||||||||||||||||
| 71 | } | ||||||||||||||||||||
| 72 | 0 | $fh->print(">>\n"); | |||||||||||||||||||
| 73 | 0 | ▶ | if(defined $self->{' stream'}) | ||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||
| 74 | { | ||||||||||||||||||||
| 75 | 0 | $fh->print("stream\n$self->{' stream'}\nendstream"); # next is endobj which has the final cr | |||||||||||||||||||
| 76 | } | ||||||||||||||||||||
| 77 | } | ||||||||||||||||||||
| 78 | else | ||||||||||||||||||||
| 79 | { | ||||||||||||||||||||
| 80 | 0 | $fh->print($self->{-literal}); # next is endobj which has the final cr | |||||||||||||||||||
| 81 | } | ||||||||||||||||||||
| 82 | } | ||||||||||||||||||||
| 83 | |||||||||||||||||||||
| 84 | sub val | ||||||||||||||||||||
| 85 | 0 | ▶ | { $_[0]; } | ||||||||||||||||||
|
Subroutine
val: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||
| 86 | |||||||||||||||||||||
| 87 | 40 | 1; | |||||||||||||||||||