Branch Coverage

blib/lib/Image/ExifTool/WritePDF.pl
Criterion Covered Total %
branch 171 326 52.4


line true false branch
47 0 101 if (not $format) { }
70 31 elsif ($format eq 'string') { }
31 0 elsif ($format eq 'date') { }
0 0 elsif ($format eq 'integer') { }
0 0 elsif ($format eq 'real') { }
0 0 elsif ($format eq 'boolean') { }
0 0 elsif ($format eq 'name') { }
53 0 31 unless $$valPtr =~ /^\d{4}/
55 0 0 unless &Image::ExifTool::IsInt($$valPtr)
57 0 0 unless $$valPtr =~ /^[+-]?(?=\d|\.\d)\d*(\.\d*)?$/
59 0 0 $$valPtr && !($$valPtr =~ /^f/i) ? :
61 0 0 if $$valPtr =~ /\0/
76 0 13 if (not $format) { }
11 2 elsif ($format eq 'string') { }
2 0 elsif ($format eq 'date') { }
0 0 elsif ($format =~ /^(integer|real|boolean)$/) { }
0 0 elsif ($format eq 'name') { }
80 0 11 if $val =~ /[\x80-\xff]/
92 0 0 if $val =~ /\0/
93 0 0 if ($pdfVer >= 1.2) { }
96 0 0 if $val =~ m([\t\n\f\r ()<>[\]{}/%])
112 0 13 if (ref $$strPt eq "ARRAY")
121 0 13 if ($$strPt =~ /[\x00-\x08\x0a-\x1f\x7f\xff]/) { }
127 0 0 unless my $n = $len - $i
128 0 0 if $n > 40
129 0 0 if $i
148 0 0 if (not ref $obj) { }
0 0 elsif (ref $obj eq 'HASH') { }
0 0 elsif (ref $obj eq 'ARRAY') { }
150 0 0 if ($obj =~ /^[(<]/)
160 0 0 if $myDictTags{$tag}
166 0 0 if ($needCrypt)
167 0 0 defined $needCrypt->{$tag} ? :
0 0 unless defined $needCrypt->{$tag} ? $needCrypt->{$tag} : $needCrypt->{'*'}
190 0 0 if (ref $w eq "ARRAY")
193 0 0 if ($bytes eq '1 4 2') { }
0 0 elsif ($bytes eq '1 8 2') { }
211 0 0 if $pos + $size > $len
213 0 0 if (@t == 4)
219 0 0 if $t[0] == 0
235 43 165 if (ref $obj eq 'SCALAR') { }
12 153 elsif (ref $obj eq 'ARRAY') { }
47 106 elsif (ref $obj eq 'HASH') { }
236 0 43 unless &Write($outfile, " ", $$obj)
239 0 12 @$obj > 10 ? :
0 12 unless &Write($outfile, @$obj > 10 ? $/ : " ", "[")
242 0 22 unless &WriteObject($outfile, $item)
244 0 12 unless &Write($outfile, " ]")
248 0 47 unless &Write($outfile, $/, "<<")
250 9 38 if ($obj->{'_stream'})
252 9 0 if $obj->{'_decrypted'}
266 200 139 if $wrote{$tag} or not defined $obj->{$tag}
267 0 139 unless &Write($outfile, $/, "/$tag")
268 0 139 unless &WriteObject($outfile, $obj->{$tag})
271 0 47 unless &Write($outfile, $/, ">>")
272 9 38 if ($obj->{'_stream'})
275 0 9 unless &Write($outfile, $/, "stream\r\n")
276 0 9 unless &Write($outfile, $obj->{'_stream'}, $/, "endstream")
301 0 19 unless $raf->Read($buff, 1024) >= 8
302 0 19 unless $buff =~ /^(\s*)%PDF-(\d+\.\d+)/
315 0 19 unless $pdfVer
317 0 19 if ($pdfVer > 2)
318 0 0 if $et->Error("Writing PDF $pdfVer is untested", 1)
321 0 19 if ($capture{'Error'} or $info->{'Error'})
327 57 0 if $capture{$obj}
329 0 0 if $info->{'Warning'}
337 0 19 unless $raf->Seek(-64, 2) and $raf->Read($buff, 64) and $raf->Seek(0, 0)
341 16 3 if ($buff =~ /$endComment(\d+)\s+(startxref\s+\d+\s+%%EOF\s+)?$/s) { }
0 3 elsif ($et->{'DEL_GROUP'}{'PDF-update'}) { }
344 0 16 unless &Image::ExifTool::CopyBlock($raf, $outfile, $prevUpdate + $et->{'PDFBase'})
346 0 16 unless ($raf->Read($buff, length $beginComment) and $buff eq $beginComment)
350 0 16 unless $raf->Seek($prevUpdate + $et->{'PDFBase'}, 0)
351 2 14 if ($et->{'DEL_GROUP'}{'PDF-update'})
362 0 3 unless &Write($outfile, $buff)
365 0 17 if $et->Options("Verbose")
377 14 3 if ($prevUpdate) { }
378 0 14 unless ($capture{'Prev'})
387 5 4 if $metaRef and $$metaRef =~ /^(\d+)/ and $1 >= $nextObject
395 4 1 if ($et->{'DEL_GROUP'}{'PDF'} and $capture{'Info'})
398 0 4 if $out
403 10 7 unless $capture{'Info'}
408 0 17 unless (ref $infoRef eq "SCALAR")
415 0 17 if $infoDict->{'_needCrypt'}
425 0 11 if ($pdfVer >= 2 and not $tagInfo->{'PDF2'})
426 0 0 if $et->Warn("Writing PDF:$tagInfo->{'Name'} is deprecated for PDF 2.0 documents", 2)
433 9 2 unless (defined $val)
436 5 4 if $tagKey
438 7 4 if (defined $val) { }
0 4 elsif ($nvHash->{'EditOnly'}) { }
440 3 4 if (ref $val eq "ARRAY")
445 5 6 if ($et->IsOverwriting($nvHash, $val) > 0) { }
452 7 4 unless @oldVals
456 3 4 unless @vals
462 0 6 unless $deleted or $tagInfo->{'List'} or not exists $infoDict->{$tagID}
466 9 2 if (@newVals)
469 0 9 if ($out)
475 0 11 unless (@vals)
482 5 6 if (not $tagInfo->{'List'}) { }
3 3 elsif ($tagInfo->{'List'} eq 'array') { }
487 0 5 unless defined $val
489 3 0 @vals ? :
493 11 0 if (defined $val) { }
500 10 7 if ($infoChanged) { }
6 1 elsif ($prevUpdate) { }
505 4 2 if $oldPos and $oldPos > $prevUpdate
509 14 3 if ($infoChanged)
511 10 4 if (scalar keys %{$capture{'Info'};} > 1) { }
514 3 7 unless $prevInfoRef
519 2 2 if $prevInfoRef
531 4 2 $info->{'XMP'} ? :
6 11 unless defined $newXMP
535 3 5 unless ($newXMP or $info->{'XMP'})
541 10 7 if ($et->{'CHANGED'} != $oldChanged and defined $newXMP) { }
4 3 elsif ($prevUpdate and $capture{'Root'}{'Metadata'}) { }
546 4 0 if $oldPos and $oldPos > $prevUpdate
548 14 3 if ($metaChanged)
549 9 5 if ($newXMP) { }
5 0 elsif ($capture{'Root'}{'Metadata'}) { }
550 5 4 unless (ref $metaRef)
575 0 17 unless ($rootRef)
579 6 11 if (not $rootChanged and $prevUpdate)
582 3 3 if $oldPos and $oldPos > $prevUpdate
584 13 4 if $rootChanged
588 16 1 if ($et->{'CHANGED'}) { }
1 0 elsif ($prevUpdate) { }
591 0 16 unless &Write($outfile, $beginComment)
595 0 38 unless $objRef =~ /^(\d+) (\d+)/
597 7 31 unless ($newObj{$objRef})
598 7 0 if $gen < 65535
606 0 31 unless &Write($outfile, $/, $keyExt)
607 0 31 unless &WriteObject($outfile, $newObj{$objRef})
608 0 31 unless &Write($outfile, $/, "endobj")
612 3 13 unless $prevUpdate
618 13 3 if ($prevUpdate)
621 0 13 if ($mainDict->{'Type'} and $mainDict->{'Type'} eq '/XRef') { }
628 5 14 unless $newXRef{$id}
635 31 28 unless $newXRef{$id}[2] eq "f"
638 3 25 if ($id >= $nextObject)
649 6 10 if (ref $mainDict->{'ID'} eq "ARRAY" and @{$mainDict->{'ID'};} > 1)
652 6 0 if ($id =~ /^<([0-9a-f]{2})/i) { }
0 0 elsif ($id =~ /^\((.)/s and $1 ne '\\' and $1 ne ')' and $1 ne '(') { }
658 0 0 if $ch =~ /[()\\\x00-\x08\x0a-\x1f\x7f\xff]/
668 0 16 if ($mainDict->{'Type'} and $mainDict->{'Type'} eq '/XRef') { }
685 0 0 if ($pos > 4294967295)
686 0 0 if ($bits == 4)
692 0 0 if ($bits == 4) { }
693 0 0 $type eq 'f' ? :
697 0 0 $type eq 'f' ? :
699 0 0 if not @ids or $ids[0] != $id + 1
708 0 0 unless &Write($outfile, $/, $keyExt)
709 0 0 unless &WriteObject($outfile, $mainDict)
710 0 0 unless &Write($outfile, $/, "endobj")
715 0 16 unless &Write($outfile, $/, "xref", $/)
717 16 0 length $/ == 1 ? :
725 34 22 if not @ids or $ids[0] != $id + 1
728 0 34 unless &Write($outfile, $startID, " ", $id - $startID + 1, $/, $buff)
732 0 16 unless &Write($outfile, "trailer")
733 0 16 unless &WriteObject($outfile, $mainDict)
736 0 16 unless &Write($outfile, $/, $endComment, $oldEOF, $/)
739 0 16 unless &Write($outfile, "startxref", $/, $startxref, $/, "%%EOF", $/)
744 0 1 unless $raf->Seek($prevUpdate + $et->{'PDFBase'}, 0)
746 0 1 unless &Write($outfile, $buff)
749 6 10 if ($rtn > 0 and $et->{'CHANGED'} and $et->{'DEL_GROUP'}{'PDF'} || $et->{'DEL_GROUP'}{'XMP'})