Branch Coverage

blib/lib/PDF/Builder.pm
Criterion Covered Total %
branch 230 480 47.9


line true false branch
282 162 0 unless $self->{'pages'}{'Resources'}->is_obj($self->{'pdf'})
291 107 55 if (exists $options{'-compress'}) { }
300 0 162 if (exists $options{'-diaglevel'}) { }
302 0 0 if ($diaglevel < 0 or $diaglevel > 5)
312 2 160 if (defined $options{'-outver'})
313 2 0 if ($options{'-outver'} >= 1.4) { }
319 0 162 if (defined $options{'-msgver'})
320 0 0 if ($options{'-msgver'} == 0 or $options{'-msgver'} == 1) { }
326 0 162 if ($options{'-file'})
359 0 8 unless -f $file
360 0 8 unless -r $file
364 0 8 unless CORE::open $scalar_fh, '+<', \$content
368 0 8 unless CORE::open $disk_fh, '<', $file
377 8 0 if ($data =~ /%%EOF$/)
408 0 3 if ($PDFver > $outVer) { }
409 0 0 if ($msgVer)
439 0 15 if ($PDFver > $outVer) { }
440 0 0 if ($msgVer)
490 0 15 if (defined $self->{'diaglevel'})
491 0 15 if ($diaglevel < 0 or $diaglevel > 5)
496 0 15 if (defined $newVer)
499 0 0 if ($pos < 0)
503 0 0 if ($verStr =~ /^%PDF-(\d+)\.(\d+)/) { }
508 0 0 if ($newVer > $currentVer)
509 0 0 if (length $newVer > length $currentVer) { }
512 0 0 if (length $newVer < length $currentVer)
523 0 15 unless CORE::open $fh, '+<', \$content
542 3 12 if (exists $options{'-compress'}) { }
551 0 15 if (exists $options{'-diaglevel'}) { }
553 0 0 if ($self->{'diaglevel'} < 0 or $self->{'diaglevel'} > 5)
578 0 167 if ($options{'-fullscreen'}) { }
0 167 elsif ($options{'-thumbs'}) { }
0 167 elsif ($options{'-outlines'}) { }
589 0 167 if ($options{'-singlepage'}) { }
0 167 elsif ($options{'-onecolumn'}) { }
0 167 elsif ($options{'-twocolumnleft'}) { }
0 167 elsif ($options{'-twocolumnright'}) { }
605 0 167 if ($options{'-hidetoolbar'})
608 0 167 if ($options{'-hidemenubar'})
611 0 167 if ($options{'-hidewindowui'})
614 0 167 if ($options{'-fitwindow'})
617 0 167 if ($options{'-centerwindow'})
620 0 167 if ($options{'-displaytitle'})
623 0 167 if ($options{'-righttoleft'})
627 0 167 if ($options{'-afterfullscreenthumbs'}) { }
0 167 elsif ($options{'-afterfullscreenoutlines'}) { }
635 0 167 if ($options{'-printscalingnone'})
639 1 166 if ($options{'-simplex'}) { }
1 165 elsif ($options{'-duplexfliplongedge'}) { }
1 164 elsif ($options{'-duplexflipshortedge'}) { }
648 2 165 if ($options{'-firstpage'})
650 0 2 unless scalar keys %args
654 1 1 unless ref $page
656 2 0 if (defined $args{'-fit'}) { }
0 0 elsif (defined $args{'-fith'}) { }
0 0 elsif (defined $args{'-fitb'}) { }
0 0 elsif (defined $args{'-fitbh'}) { }
0 0 elsif (defined $args{'-fitv'}) { }
0 0 elsif (defined $args{'-fitbv'}) { }
0 0 elsif (defined $args{'-fitr'}) { }
0 0 elsif (defined $args{'-xyz'}) { }
669 0 0 unless scalar @{$args{'-fitr'};} == 4
672 0 0 unless scalar @{$args{'-xyz'};} == 3
721 3 8 if (defined $value)
744 0 0 if (scalar @_)
746 0 0 if ($version =~ /^\d+$/)
747 0 0 unless $version =~ /^(\d+\.\d+)$/
748 0 0 if ($outVer > $1)
765 0 0 defined $self->{'pdf'}{'Encrypt'} ? :
780 162 3 if (not defined $self->{'pdf'}{'Info'}) { }
789 165 0 if (scalar @_)
791 1157 163 unless defined $opt{$k}
797 165 0 if (defined $self->{'pdf'}{'Info'})
800 1155 165 unless defined $self->{'pdf'}{'Info'}{$k}
802 0 165 if (unpack('n', $opt{$k}) == 65534 or unpack('n', $opt{$k}) == 65279)
828 0 0 if (scalar @attr)
848 0 0 if (not defined $self->{'catalog'}{'Metadata'}) { }
862 0 0 if (defined $value)
942 5 2 if (defined $opts->{'-style'}) { }
946 1 1 $opts->{'-style'} eq 'alpha' ? :
1 2 $opts->{'-style'} eq 'Alpha' ? :
1 3 $opts->{'-style'} eq 'roman' ? :
1 4 $opts->{'-style'} eq 'Roman' ? :
951 1 6 if (defined $opts->{'-prefix'})
955 1 6 if (defined $opts->{'-start'})
982 0 0 if ($self->{'opened_scalar'}) { }
0 0 elsif ($self->{'partial_save'}) { }
996 15 0 if (defined $object->{'Resources'})
1006 0 16 if ($page->{'Type'}->val eq 'Pages') { }
1012 16 0 if (defined $page->{'Resources'})
1061 1 0 if ($self->{'opened_scalar'}) { }
0 0 elsif ($self->{'partial_save'}) { }
1064 0 1 unless CORE::open $fh, '>', $file
1098 0 0 if ($self->{'opened_scalar'}) { }
0 0 elsif ($self->{'partial_save'}) { }
1142 7 119 if ($self->{'opened_scalar'}) { }
1148 0 119 unless CORE::open $fh, '>', \$str
1179 127 0 if defined $self->{'pdf'}
1225 139 2 if ($index == 0) { }
1236 139 2 if ($index == 0) { }
0 2 elsif ($index < 0) { }
1275 0 7 if ($index == 0) { }
0 7 elsif ($index < 0) { }
1282 0 7 unless ref $page
1284 6 1 if (ref $page ne 'PDF::Builder::Page')
1291 0 6 if ($rotate = $page->find_prop('Rotate') and not $page->{' opened'}) { }
1294 0 0 if ($rotate != 0 and not $self->default('nounrotate')) { }
1297 0 0 if ($media = $page->find_prop($mediatype)) { }
1301 0 0 if $mediatype ne 'MediaBox'
1303 0 0 if ($rotate == 90) { }
0 0 elsif ($rotate == 180) { }
0 0 elsif ($rotate == 270) { }
1304 0 0 if $mediatype eq 'MediaBox'
1307 0 0 if $mediatype eq 'MediaBox'
1309 0 0 if $mediatype eq 'MediaBox'
1321 4 2 if (defined $page->{'Contents'} and not $page->{' opened'})
1327 0 4 if ($self->default('pageencaps'))
1334 0 4 if ($self->default('pageencaps'))
1339 4 0 if ($self->{'forcecompress'} eq 'flate' or $self->{'forcecompress'} =~ /^[1-9]\d*$/)
1374 1 517 if (ref($source_object) =~ /Objind$/)
1378 0 518 if defined $$object_cache{scalar $source_object}
1384 1 517 if $source_object->is_obj($source_pdf)
1388 7 511 if (ref($source_object) =~ /Array$/) { }
2 509 elsif (ref($source_object) =~ /Dict$/) { }
1391 0 501 if ref($k) =~ /Objind$/
1395 2 0 unless scalar @keys
1397 1 11 if $k =~ /^ /
1398 0 11 unless defined $source_object->{$k}
1401 0 2 if ($source_object->{' stream'})
1402 0 0 if ($target_object->{'Filter'}) { }
1451 0 4 unless (ref $s_pdf and $s_pdf->isa('PDF::Builder'))
1459 1 3 if (ref $s_idx eq 'PDF::Builder::Page') { }
1472 0 4 unless defined $s_page->find_prop($k)
1477 0 4 unless defined $xo->{'BBox'}
1481 0 4 unless defined $s_page->{$k}
1482 0 4 if ref($s_page->{$k}) =~ /Objind$/
1485 27 5 unless defined $s_page->{$k}{$sk}
1486 0 5 if ref($s_page->{$k}{$sk}) =~ /Objind$/
1488 9 1 if $ssk =~ /^ /
1498 0 4 unless ($s_page->{' opened'})
1504 3 1 if (defined $s_page->{'Contents'})
1511 3 0 if ($k->{' nofilt'}) { }
1520 2 1 if $self->{'forcecompress'} eq 'flate' or $self->{'forcecompress'} =~ /^[1-9]\d*$/
1571 0 1 unless (ref $s_pdf and $s_pdf->isa('PDF::Builder'))
1575 0 1 if (ref $s_idx eq 'PDF::Builder::Page') { }
1581 0 1 if (ref $t_idx eq 'PDF::Builder::Page') { }
1584 0 1 if ($self->pages < $t_idx) { }
1602 4 1 unless defined $prop
1613 0 0 if (exists $s_page->{'Annots'} and $s_page->{'Annots'} and $self->{'copyannots'})
1616 0 0 if (my $a = $s_pdf->{'pdf'}{'Root'}->realise->{'AcroForm'})
1648 0 0 if $AcroForm
1664 0 0 unless defined $a->{$k}
1670 0 0 if $AcroForm and $t_a->{'Subtype'}->val eq 'Widget'
1673 0 0 if $AcroForm
1710 0 0 if (float($value) <= 0)
1718 0 0 if (defined $self->{'pages'}{'MediaBox'})
1719 0 0 if ($value != 1)
1734 163 16 if (scalar @corners and $corners[0] =~ /[a-z]/i)
1736 0 179 if (scalar @corners == 3) { }
1740 0 0 if (defined $opts{'-orient'})
1741 0 0 if ($opts{'-orient'} =~ /^l/i)
1754 0 179 if ($isName and $UU != 1)
1769 8 193 unless (defined $self->{'pages'}{$boxname})
1770 2 6 if ($boxname eq 'CropBox') { }
6 0 elsif ($boxname eq 'BleedBox' or $boxname eq 'TrimBox' or $boxname eq 'ArtBox') { }
1775 0 6 if (defined $self->{'pages'}{'CropBox'}) { }
1812 167 6 if (defined $corners[0])
1840 3 4 if (defined $corners[0])
1868 3 4 if (defined $corners[0])
1896 3 4 if (defined $corners[0])
1924 3 4 if (defined $corners[0])
1978 0 52 if $opts{'-unicodemap'}
1998 0 0 unless defined $opts{$o}
2006 0 0 if $opts{'-unicodemap'}
2027 0 0 unless exists $opts{'-unicodemap'}
2034 0 0 if $opts{'-unicodemap'}
2058 0 1 if $opts{'-unicodemap'}
2084 0 0 unless exists $opts{'-unicodemap'}
2090 0 0 if $opts{'-unicodemap'}
2200 0 4 if ($rc)
2202 0 0 if (defined $opts{'-nouseGT'} and $opts{'-nouseGT'} == 1)
2206 0 4 if ($rc == 1) { }
2217 1 2 if ($rc == 0 and $MSG_COUNT[0]++ == 0)
2220 0 1 if (not defined $opts{'-silent'} or $opts{'-silent'} == 0)
2258 4 0 unless (defined $rc)
2259 0 4 if ($rc)
2261 0 0 if ($Graphics::TIFF::VERSION < $GrTFversion)
2312 0 3 if ($rc)
2314 0 0 if (defined $opts{'-nouseIPL'} and $opts{'-nouseIPL'} == 1)
2318 0 3 if ($rc == 1) { }
2329 1 1 if ($rc == 0 and $MSG_COUNT[1]++ == 0)
2332 0 1 if (not defined $opts{'-silent'} or $opts{'-silent'} == 0)
2369 3 0 unless (defined $rc)
2370 0 3 if ($rc)
2372 0 0 if ($Image::PNG::Libpng::VERSION < $LpngVersion)
2725 1 0 unless $obj->is_obj($self->{'pdf'})
2748 0 0 unless (defined $obj)
2805 0 15 unless length $string
2814 0 32 unless length $_
2821 0 140 unless length $rawObject
2824 21 119 if ($rawObject =~ /^(.*)stream\s.*\sendstream(.*)$/s)
2829 108 32 if ($rawObject =~ /^(.*?)\s?(\d+) (\d+) obj\s(.*)$/s or $rawObject =~ /^(.*?)\s?(\d+) (\d+) obj(.*)$/s) { }
2838 9 99 if (defined $objList{$objKey} and $update > 0)
2845 42 66 unless (defined $objList{$objKey})
2860 17 91 if ($rawObject =~ m[/Parent(\s+)(\d+)(\s+)(\d+)(\s+)R])
2876 17 91 if ($rawObject =~ m(/Kids(\s+)\[(.*)\]))
2884 18 17 if ($str2 =~ /(\s+)(\d+)(\s+)(\d+)(\s+)R/) { }
2907 15 93 if ($rawObject =~ m[/Type(\s+)/Catalog])
2909 0 15 if ($rawObject =~ m[/Version /(\d+)\.(\d+)])
2920 3 105 if ($rawObject =~ m[/Type(\s+)/XRef] or $rawObject =~ m[/Type/XRef])
2922 3 0 if ($rawObject =~ m[/Root(\s+)(\d+)(\s+)(\d+)(\s+)R])
2928 3 0 if ($rawObject =~ m[/Info(\s+)(\d+)(\s+)(\d+)(\s+)R])
2939 54 108 if ($rawObject =~ /(\d+)(\s+)(\d+)(\s+)R/) { }
2951 49 5 unless (defined $objList{$_})
2957 15 80 unless (defined $objList{$_})
2966 15 17 if ($rawObject =~ /trailer/)
2967 15 0 if ($rawObject =~ m[trailer(.*)/Info(\s+)(\d+)(\s+)(\d+)(\s+)R]s)
2970 15 0 if ($rawObject =~ m[trailer(.*)/Root(\s+)(\d+)(\s+)(\d+)(\s+)R]s)
2980 0 15 if (not defined $Root) { }
2981 0 0 if $level >= $level_error
2983 0 15 unless (defined $objList{$Root})
2985 0 0 if $level >= $level_error
2991 0 15 if (not defined $Info) { }
2992 0 0 if $level >= $level_note
2994 0 15 unless (defined $objList{$Info})
2996 0 0 if $level >= $level_note
3013 2 104 if ($objList{$thisObj}[$idx_defined] == 0)
3014 0 2 if $level >= $level_note
3020 14 92 if ($objList{$thisObj}[$idx_kid_cnt] > 0)
3025 16 0 if ($objList{$child}[$idx_par_clmd] == -1) { }
3030 0 0 if $level >= $level_error
3033 16 0 if ($objList{$child}[$idx_defined] == 1)
3035 0 16 if ($objList{$child}[$idx_parent] == -1) { }
0 16 elsif ($objList{$child}[$idx_parent] != $thisObj) { }
3036 0 0 if $level >= $level_error
3039 0 0 if $level >= $level_error
3045 8 98 if ($objList{$thisObj}[$idx_parent] == -1 and $objList{$thisObj}[$idx_refcount] == 0)
3047 0 8 if $level >= $level_note
3051 0 15 if ($level >= $level_dump)
3060 0 15 if ($level >= $level_dumpself)