| 1 | #======================================================================= | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2 | # | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3 | # THIS IS A REUSED PERL MODULE, FOR PROPER LICENCING TERMS SEE BELOW: | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 4 | # | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 5 | # Copyright Martin Hosken <Martin_Hosken@sil.org> | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 6 | # | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 7 | # No warranty or expression of effectiveness, least of all regarding | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 8 | # anyone's safety, is implied in this software or documentation. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 9 | # | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 10 | # This specific module is licensed under the Perl Artistic License. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 11 | # Effective 28 January 2021, the original author and copyright holder, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 12 | # Martin Hosken, has given permission to use and redistribute this module | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 13 | # under the MIT license. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 14 | # | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 15 | #======================================================================= | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 16 | package PDF::Builder::Basic::PDF::Dict; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 17 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 18 | 42 | ▶ | use base 'PDF::Builder::Basic::PDF::Objind'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 19 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 20 | 42 | ▶ | use strict; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 21 | 42 | ▶ | use warnings; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 22 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 23 | 42 | our $VERSION = '3.028'; # VERSION | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 24 | 42 | our $LAST_UPDATE = '3.027'; # manually update whenever code is changed | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 25 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 26 | 42 | our $mincache = 16 * 1024 * 1024; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 27 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 28 | 42 | ▶ | use File::Temp; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 29 | 42 | ▶ | use PDF::Builder::Basic::PDF::Array; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 30 | 42 | ▶ | use PDF::Builder::Basic::PDF::Filter; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 31 | 42 | ▶ | use PDF::Builder::Basic::PDF::Name; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 32 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 33 | =head1 NAME | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 34 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 35 | PDF::Builder::Basic::PDF::Dict - PDF Dictionaries and Streams | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 36 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 37 | Inherits from L<PDF::Builder::Basic::PDF::Objind> | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 38 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 39 | =head1 INSTANCE VARIABLES | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 40 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 41 | There are various special instance variables which are used to look after, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 42 | particularly, streams. Each begins with a space: | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 43 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 44 | =over | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 45 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 46 | =item ' stream' | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 47 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 48 | Holds the stream contents for output | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 49 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 50 | =item ' streamfile' | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 51 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 52 | Holds the stream contents in an external file rather than in memory. This is | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 53 | not the same as a PDF file stream. The data is stored in its unfiltered form. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 54 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 55 | =item ' streamloc' | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 56 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 57 | If both ' stream' and ' streamfile' are empty, this indicates where in the | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 58 | source PDF the stream starts. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 59 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 60 | =back | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 61 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 62 | =head1 METHODS | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 63 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 64 | =head2 new | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 65 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 66 | $d = PDF::Builder::Basic::PDF->new() | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 67 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 68 | =over | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 69 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 70 | Creates a new instance of a dictionary. The usual practice is to call | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 71 | C<PDFDict()> instead. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 72 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 73 | =back | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 74 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 75 | =cut | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 76 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 77 | 2066 | ▶ | sub new { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
new: called CC=2 SCAR=7.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 78 | 2066 | my $class = shift(); # have @_ used, later | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 79 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 80 | 2066 | ▶ | $class = ref($class) if ref($class); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 81 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 82 | 2066 | my $self = $class->SUPER::new(@_); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 83 | 2066 | $self->{' realised'} = 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 84 | 2066 | return $self; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 85 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 86 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 87 | =head2 type | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 88 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 89 | $type = $d->type($type) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 90 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 91 | =over | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 92 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 93 | Get/Set the standard Type key. It can be passed, and will return, a text value rather than a Name object. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 94 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 95 | =back | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 96 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 97 | =cut | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 98 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 99 | 27 | ▶ | sub type { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
type: called CC=4 SCAR=14.5
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 100 | 27 | my $self = shift(); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 101 | 27 | ▶ | if (scalar @_) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 102 | 27 | my $type = shift(); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 103 | 27 | ▶ | $self->{'Type'} = ref($type)? $type: PDF::Builder::Basic::PDF::Name->new($type); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 104 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 105 | 27 | ▶ | return unless exists $self->{'Type'}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 106 | 27 | return $self->{'Type'}->val(); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 107 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 108 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 109 | # TBD per API2 PR #28, *may* need to copy sub find_prop from Page.pm to here | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 110 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 111 | =head2 filter | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 112 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 113 | @filters = $d->filter(@filters) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 114 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 115 | =over | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 116 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 117 | Get/Set one or more filters being used by the optional stream attached to the dictionary. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 118 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 119 | =back | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 120 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 121 | =cut | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 122 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 123 | 14 | ▶ | sub filter { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
filter: called CC=2 SCAR=7.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 124 | 14 | my ($self, @filters) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 125 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 126 | # Developer's Note: the PDF specification allows Filter to be | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 127 | # either a name or an array, but other parts of this codebase | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 128 | # expect an array. If these are updated, uncomment the | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 129 | # commented-out lines in order to accept both types. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 130 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 131 | # if (scalar @filters == 1) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 132 | # $self->{'Filter'} = ref($filters[0])? $filters[0]: PDF::Builder::Basic::PDF::Name->new($filters[0]); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 133 | # } elsif (scalar @filters) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 134 | 14 | ▶ | @filters = map { ref($_)? $_: PDF::Builder::Basic::PDF::Name->new($_) } @filters; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 135 | 14 | $self->{'Filter'} = PDF::Builder::Basic::PDF::Array->new(@filters); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 136 | # } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 137 | 14 | return $self->{'Filter'}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 138 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 139 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 140 | # Undocumented alias, which may be removed in a future release TBD | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 141 | 14 | ▶ | sub filters { return filter(@_); } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
filters: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 142 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 143 | =head2 outobjdeep | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 144 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 145 | $d->outobjdeep($fh, $pdf) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 146 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 147 | =over | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 148 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 149 | Outputs the contents of the dictionary to a PDF file. This is a recursive call. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 150 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 151 | It also outputs a stream if the dictionary has a stream element. If this occurs | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 152 | then this method will calculate the length of the stream and insert it into the | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 153 | stream's dictionary. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 154 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 155 | =back | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 156 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 157 | =cut | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 158 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 159 | 1642 | ▶ | sub outobjdeep { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
outobjdeep: called CC=44 SCAR=42.2
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 160 | 1642 | my ($self, $fh, $pdf) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 161 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 162 | 1642 | ▶ | if (defined $self->{' stream'} or defined $self->{' streamfile'} or defined $self->{' streamloc'}) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition83%5/6
defined $self->{" stream"} or defined $self->{" streamfile"} or defined $self->{" streamloc"}
defined $self->{" stream"} or defined $self->{" streamfile"}
MC/DC66%2/3
defined $self->{" stream"} or defined $self->{" streamfile"} or defined $self->{" streamloc"}
defined $self->{" stream"}
defined $self->{" streamfile"}
defined $self->{" streamloc"}
Truth table75%3/4
A or B or C
A= defined $self->{" stream"}B= defined $self->{" streamfile"}C= defined $self->{" streamloc"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 163 | 164 | ▶ | if ($self->{'Filter'} and $self->{' nofilt'}) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
Condition100%3/3
$self->{"Filter"} and $self->{" nofilt"}
MC/DC100%2/2
$self->{"Filter"} and $self->{" nofilt"}
$self->{"Filter"}
$self->{" nofilt"}
Truth table100%3/3
A and B
A= $self->{"Filter"}B= $self->{" nofilt"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 164 | 10 | ▶ | $self->{'Length'} ||= PDF::Builder::Basic::PDF::Number->new(length($self->{' stream'})); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition66%2/3
$self->{"Length"} ||= "PDF::Builder::Basic::PDF::Number"->new(length $self->{" stream"})
MC/DC0%0/2
$self->{"Length"} ||= "PDF::Builder::Basic::PDF::Number"->new(length $self->{" stream"})
$self->{"Length"}
"PDF::Builder::Basic::PDF::Number"->new(length $self->{" stream"})
Truth table66%2/3
A ||= B
A= $self->{"Length"}B= "PDF::Builder::Basic::PDF::Number"->new(length $self->{" stream"})
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 165 | ▶ | } elsif ($self->{'Filter'} or not defined $self->{' stream'}) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition66%2/3
$self->{"Filter"} or not defined $self->{" stream"}
MC/DC50%1/2
$self->{"Filter"} or not defined $self->{" stream"}
$self->{"Filter"}
not defined $self->{" stream"}
Truth table66%2/3
A or not(B)
A= $self->{"Filter"}B= not defined $self->{" stream"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 166 | 14 | ▶ | $self->{'Length'} = PDF::Builder::Basic::PDF::Number->new(0) unless defined $self->{'Length'}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 167 | 14 | ▶ | $pdf->new_obj($self->{'Length'}) unless $self->{'Length'}->is_obj($pdf); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 168 | } else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 169 | 140 | $self->{'Length'} = PDF::Builder::Basic::PDF::Number->new(length($self->{' stream'})); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 170 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 171 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 172 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 173 | 1642 | $fh->print('<< '); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 174 | 1642 | foreach my $key (sort { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 175 | 36934 | ▶ | $a eq 'Type' ? -1: $b eq 'Type' ? 1: | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 4 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 176 | $a eq 'Subtype'? -1: $b eq 'Subtype'? 1: $a cmp $b | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 177 | } keys %$self) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 178 | 13535 | ▶ | next if $key =~ m/^[\s\-]/o; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 179 | 4296 | ▶ | next unless $self->{$key}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 180 | # some unblessed objects were sometimes getting through | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 181 | 4296 | ▶ | next unless $self->{$key} =~ /^PDF::Builder/; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 182 | 4296 | $fh->print('/' . PDF::Builder::Basic::PDF::Name::string_to_name($key, $pdf) . ' '); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 183 | 4296 | $self->{$key}->outobj($fh, $pdf); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 184 | 4296 | $fh->print(' '); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 185 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 186 | 1642 | $fh->print('>>'); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 187 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 188 | # Now handle the stream (if any) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 189 | 1642 | my (@filters, $loc); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 190 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 191 | 1642 | ▶ | if (defined $self->{' streamloc'} and not defined $self->{' stream'}) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
defined $self->{" streamloc"} and not defined $self->{" stream"}
MC/DC0%0/2
defined $self->{" streamloc"} and not defined $self->{" stream"}
defined $self->{" streamloc"}
not defined $self->{" stream"}
Truth table33%1/3
A and not(B)
A= defined $self->{" streamloc"}B= not defined $self->{" stream"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 192 | # read a stream if in file | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 193 | 0 | $loc = $fh->tell(); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 194 | 0 | $self->read_stream(); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 195 | 0 | $fh->seek($loc, 0); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 196 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 197 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 198 | 1642 | ▶ | if (not $self->{' nofilt'} and defined $self->{'Filter'} and (defined $self->{' stream'} or defined $self->{' streamfile'})) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%6/9
not $self->{" nofilt"} and defined $self->{"Filter"} and defined $self->{" stream"} || defined $self->{" streamfile"}
not $self->{" nofilt"} and defined $self->{"Filter"}
defined $self->{" stream"} or defined $self->{" streamfile"}
MC/DC50%2/4
not $self->{" nofilt"} and defined $self->{"Filter"} and defined $self->{" stream"} || defined $self->{" streamfile"}
not $self->{" nofilt"}
defined $self->{"Filter"}
defined $self->{" stream"}
defined $self->{" streamfile"}
Truth table60%3/5
not(A) and B and C or D
A= not $self->{" nofilt"}B= defined $self->{"Filter"}C= defined $self->{" stream"}D= defined $self->{" streamfile"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 199 | 14 | my $hasflate = -1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 200 | 14 | for my $i (0 .. scalar(@{$self->{'Filter'}{' val'}}) - 1) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 201 | 14 | my $filter = $self->{'Filter'}{' val'}[$i]->val(); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 202 | # hack to get around LZW patent | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 203 | 14 | ▶ | if ($filter eq 'LZWDecode') { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 204 | 0 | ▶ | if ($hasflate < -1) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 205 | 0 | $hasflate = $i; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 206 | 0 | next; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 207 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 208 | 0 | $filter = 'FlateDecode'; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 209 | 0 | $self->{'Filter'}{' val'}[$i]{'val'} = $filter; # !!! | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 210 | } elsif ($filter eq 'FlateDecode') { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 211 | 13 | $hasflate = -2; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 212 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 213 | 14 | my $filter_class = "PDF::Builder::Basic::PDF::Filter::$filter"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 214 | 14 | push (@filters, $filter_class->new()); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 215 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 216 | 0 | ▶ | splice(@{$self->{'Filter'}{' val'}}, $hasflate, 1) if $hasflate > -1; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 217 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 218 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 219 | 1642 | ▶ | if (defined $self->{' stream'}) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 220 | 163 | $fh->print("\nstream\n"); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 221 | 163 | $loc = $fh->tell(); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 222 | 163 | my $stream = $self->{' stream'}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 223 | 163 | ▶ | unless ($self->{' nofilt'}) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 224 | 154 | foreach my $filter (reverse @filters) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 225 | 14 | $stream = $filter->outfilt($stream, 1); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 226 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 227 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 228 | 163 | $fh->print($stream); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 229 | ## $fh->print("\n"); # newline goes into endstream | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 230 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 231 | } elsif (defined $self->{' streamfile'}) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 232 | 1 | ▶ | open(my $dictfh, "<", $self->{' streamfile'}) || die "Unable to open $self->{' streamfile'}"; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 233 | 1 | binmode($dictfh, ':raw'); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 234 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 235 | 1 | $fh->print("\nstream\n"); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 236 | 1 | $loc = $fh->tell(); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 237 | 1 | my $stream; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 238 | 1 | ▶ | while (read($dictfh, $stream, 4096)) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 239 | 1 | ▶ | unless ($self->{' nofilt'}) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 240 | 0 | foreach my $filter (reverse @filters) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 241 | 0 | $stream = $filter->outfilt($stream, 0); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 242 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 243 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 244 | 1 | $fh->print($stream); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 245 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 246 | 1 | close $dictfh; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 247 | 1 | ▶ | unless ($self->{' nofilt'}) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 248 | 0 | $stream = ''; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 249 | 0 | foreach my $filter (reverse @filters) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 250 | 0 | $stream = $filter->outfilt($stream, 1); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 251 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 252 | 0 | $fh->print($stream); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 253 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 254 | ## $fh->print("\n"); # newline goes into endstream | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 255 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 256 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 257 | 1642 | ▶ | if (defined $self->{' stream'} or defined $self->{' streamfile'}) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%3/3
defined $self->{" stream"} or defined $self->{" streamfile"}
MC/DC100%2/2
defined $self->{" stream"} or defined $self->{" streamfile"}
defined $self->{" stream"}
defined $self->{" streamfile"}
Truth table100%3/3
A or B
A= defined $self->{" stream"}B= defined $self->{" streamfile"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 258 | 164 | my $length = $fh->tell() - $loc; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 259 | 164 | ▶ | unless ($self->{'Length'}{'val'} == $length) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 260 | 14 | $self->{'Length'}{'val'} = $length; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 261 | 14 | ▶ | $pdf->out_obj($self->{'Length'}) if $self->{'Length'}->is_obj($pdf); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 262 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 263 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 264 | 164 | $fh->print("\nendstream"); # next is endobj which has the final cr | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 265 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 266 | 1642 | return; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 267 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 268 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 269 | =head2 read_stream | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 270 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 271 | $d->read_stream($force_memory) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 272 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 273 | =over | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 274 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 275 | Reads in a stream from a PDF file. If the stream is greater than | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 276 | C<PDF::Dict::mincache> (defaults to 32768) bytes to be stored, then | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 277 | the default action is to create a file for it somewhere and to use that | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 278 | file as a data cache. If $force_memory is set, this caching will not | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 279 | occur and the data will all be stored in the $self->{' stream'} | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 280 | variable. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 281 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 282 | =back | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 283 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 284 | =cut | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 285 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 286 | 7 | ▶ | sub read_stream { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
read_stream: called CC=16 SCAR=34.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 287 | 7 | my ($self, $force_memory) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 288 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 289 | 7 | my $fh = $self->{' streamsrc'}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 290 | 7 | my $len = $self->{'Length'}->val(); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 291 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 292 | 7 | $self->{' stream'} = ''; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 293 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 294 | 7 | my @filters; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 295 | 7 | ▶ | if (defined $self->{'Filter'}) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 296 | 3 | my $i = 0; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 297 | 3 | foreach my $filter ($self->{'Filter'}->elements()) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 298 | 3 | my $filter_class = "PDF::Builder::Basic::PDF::Filter::" . $filter->val(); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 299 | 3 | ▶ | unless ($self->{'DecodeParms'}) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 3 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 300 | 3 | push(@filters, $filter_class->new()); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 301 | ▶ | } elsif ($self->{'Filter'}->isa('PDF::Builder::Basic::PDF::Name') and $self->{'DecodeParms'}->isa('PDF::Builder::Basic::PDF::Dict')) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/3
$self->{"Filter"}->isa("PDF::Builder::Basic::PDF::Name") and $self->{"DecodeParms"}->isa("PDF::Builder::Basic::PDF::Dict")
MC/DC0%0/2
$self->{"Filter"}->isa("PDF::Builder::Basic::PDF::Name") and $self->{"DecodeParms"}->isa("PDF::Builder::Basic::PDF::Dict")
$self->{"Filter"}->isa("PDF::Builder::Basic::PDF::Name")
$self->{"DecodeParms"}->isa("PDF::Builder::Basic::PDF::Dict")
Truth table0%0/3
A and B
A= $self->{"Filter"}->isa("PDF::Builder::Basic::PDF::Name")B= $self->{"DecodeParms"}->isa("PDF::Builder::Basic::PDF::Dict")
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 302 | 0 | push(@filters, $filter_class->new($self->{'DecodeParms'})); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 303 | } elsif ($self->{'DecodeParms'}->isa('PDF::Builder::Basic::PDF::Array')) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 304 | 0 | my $parms = $self->{'DecodeParms'}->val()->[$i]; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 305 | 0 | push(@filters, $filter_class->new($parms)); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 306 | } else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 307 | 0 | push(@filters, $filter_class->new()); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 308 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 309 | 3 | $i++; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 310 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 311 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 312 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 313 | 7 | my $last = 0; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 314 | 7 | ▶ | if (defined $self->{' streamfile'}) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 315 | 0 | unlink ($self->{' streamfile'}); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 316 | 0 | $self->{' streamfile'} = undef; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 317 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 318 | 7 | seek $fh, $self->{' streamloc'}, 0; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 319 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 320 | 7 | my $dictfh; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 321 | 7 | my $readlen = 4096; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 322 | 7 | ▶ | for (my $i = 0; $i < $len; $i += $readlen) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 323 | 7 | my $data; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 324 | 7 | ▶ | unless ($i + $readlen > $len) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 325 | 0 | read($fh, $data, $readlen); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 326 | } else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 327 | 7 | $last = 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 328 | 7 | read($fh, $data, $len - $i); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 329 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 330 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 331 | 7 | foreach my $filter (@filters) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 332 | 3 | $data = $filter->infilt($data, $last); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 333 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 334 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 335 | # Start using a temporary file if the stream gets too big | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 336 | 7 | ▶ | if (not $force_memory and | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%4/6
not $force_memory || defined $self->{" streamfile"} and length($self->{" stream"}) + length($data) > $PDF::Builder::Basic::PDF::Dict::mincache
$force_memory || defined $self->{' streamfile'}
MC/DC0%0/3
not $force_memory || defined $self->{" streamfile"} and length($self->{" stream"}) + length($data) > $PDF::Builder::Basic::PDF::Dict::mincache
$force_memory
defined $self->{' streamfile'}
length($self->{" stream"}) + length($data) > $PDF::Builder::Basic::PDF::Dict::mincache
Truth table50%2/4
not(A || B) and C
A= $force_memoryB= defined $self->{' streamfile'}C= length($self->{" stream"}) + length($data) > $PDF::Builder::Basic::PDF::Dict::mincache
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 337 | not defined $self->{' streamfile'} and | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 338 | (length($self->{' stream'}) + length($data)) > $mincache) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 339 | 0 | $dictfh = File::Temp->new(TEMPLATE => 'pdfXXXXX', SUFFIX => 'dat', TMPDIR => 1); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 340 | 0 | $self->{' streamfile'} = $dictfh->filename(); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 341 | 0 | print $dictfh $self->{' stream'}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 342 | 0 | undef $self->{' stream'}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 343 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 344 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 345 | 7 | ▶ | if (defined $self->{' streamfile'}) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 346 | 0 | print $dictfh $data; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 347 | } else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 348 | 7 | $self->{' stream'} .= $data; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 349 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 350 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 351 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 352 | 7 | ▶ | close $dictfh if defined $self->{' streamfile'}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 353 | 7 | $self->{' nofilt'} = 0; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 354 | 7 | return $self; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 355 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 356 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 357 | =head2 val | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 358 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 359 | $d->val() | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 360 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 361 | =over | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 362 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 363 | Returns the dictionary, which is itself. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 364 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 365 | =back | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 366 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 367 | =cut | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 368 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 369 | 0 | ▶ | sub val { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
val: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 370 | 0 | return $_[0]; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 371 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 372 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 373 | 42 | 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||