| line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
|
1
|
|
|
|
|
|
|
#======================================================================= |
|
2
|
|
|
|
|
|
|
# |
|
3
|
|
|
|
|
|
|
# THIS IS A REUSED PERL MODULE, FOR PROPER LICENCING TERMS SEE BELOW: |
|
4
|
|
|
|
|
|
|
# |
|
5
|
|
|
|
|
|
|
# Copyright Martin Hosken |
|
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::Array; |
|
17
|
|
|
|
|
|
|
|
|
18
|
41
|
|
|
41
|
|
254
|
use base 'PDF::Builder::Basic::PDF::Objind'; |
|
|
41
|
|
|
|
|
75
|
|
|
|
41
|
|
|
|
|
16676
|
|
|
19
|
|
|
|
|
|
|
|
|
20
|
41
|
|
|
41
|
|
258
|
use strict; |
|
|
41
|
|
|
|
|
71
|
|
|
|
41
|
|
|
|
|
669
|
|
|
21
|
41
|
|
|
41
|
|
165
|
use warnings; |
|
|
41
|
|
|
|
|
70
|
|
|
|
41
|
|
|
|
|
18783
|
|
|
22
|
|
|
|
|
|
|
|
|
23
|
|
|
|
|
|
|
our $VERSION = '3.024'; # VERSION |
|
24
|
|
|
|
|
|
|
our $LAST_UPDATE = '3.024'; # manually update whenever code is changed |
|
25
|
|
|
|
|
|
|
|
|
26
|
|
|
|
|
|
|
=head1 NAME |
|
27
|
|
|
|
|
|
|
|
|
28
|
|
|
|
|
|
|
PDF::Builder::Basic::PDF::Array - Corresponds to a PDF array. |
|
29
|
|
|
|
|
|
|
Inherits from L |
|
30
|
|
|
|
|
|
|
|
|
31
|
|
|
|
|
|
|
=head1 METHODS |
|
32
|
|
|
|
|
|
|
|
|
33
|
|
|
|
|
|
|
=over |
|
34
|
|
|
|
|
|
|
|
|
35
|
|
|
|
|
|
|
=item PDF::Array->new($parent, @values) |
|
36
|
|
|
|
|
|
|
|
|
37
|
|
|
|
|
|
|
Creates an array with the given storage parent and an optional list of values to |
|
38
|
|
|
|
|
|
|
initialise the array with. |
|
39
|
|
|
|
|
|
|
|
|
40
|
|
|
|
|
|
|
=cut |
|
41
|
|
|
|
|
|
|
|
|
42
|
|
|
|
|
|
|
sub new { |
|
43
|
1583
|
|
|
1583
|
1
|
2910
|
my ($class, @values) = @_; |
|
44
|
1583
|
|
|
|
|
2464
|
my $self = {}; |
|
45
|
|
|
|
|
|
|
|
|
46
|
1583
|
|
|
|
|
3594
|
$self->{' val'} = [@values]; |
|
47
|
1583
|
|
|
|
|
2373
|
$self->{' realised'} = 1; |
|
48
|
1583
|
|
|
|
|
2180
|
bless $self, $class; |
|
49
|
1583
|
|
|
|
|
4710
|
return $self; |
|
50
|
|
|
|
|
|
|
} |
|
51
|
|
|
|
|
|
|
|
|
52
|
|
|
|
|
|
|
=item $a->outobjdeep($fh, $pdf) |
|
53
|
|
|
|
|
|
|
|
|
54
|
|
|
|
|
|
|
Outputs an array as a PDF array to the given filehandle. |
|
55
|
|
|
|
|
|
|
|
|
56
|
|
|
|
|
|
|
=cut |
|
57
|
|
|
|
|
|
|
|
|
58
|
|
|
|
|
|
|
sub outobjdeep { |
|
59
|
952
|
|
|
952
|
1
|
1560
|
my ($self, $fh, $pdf) = @_; |
|
60
|
|
|
|
|
|
|
|
|
61
|
952
|
|
|
|
|
2002
|
$fh->print('[ '); |
|
62
|
952
|
|
|
|
|
4147
|
foreach my $obj (@{$self->{' val'}}) { |
|
|
952
|
|
|
|
|
1998
|
|
|
63
|
11100
|
|
|
|
|
53108
|
$obj->outobj($fh, $pdf); |
|
64
|
11100
|
|
|
|
|
16268
|
$fh->print(' '); |
|
65
|
|
|
|
|
|
|
} |
|
66
|
952
|
|
|
|
|
5246
|
$fh->print(']'); |
|
67
|
952
|
|
|
|
|
4258
|
return; |
|
68
|
|
|
|
|
|
|
} |
|
69
|
|
|
|
|
|
|
|
|
70
|
|
|
|
|
|
|
=item $a->elements() |
|
71
|
|
|
|
|
|
|
|
|
72
|
|
|
|
|
|
|
Returns the contents of the array. |
|
73
|
|
|
|
|
|
|
|
|
74
|
|
|
|
|
|
|
Formerly called C, which is now B. |
|
75
|
|
|
|
|
|
|
|
|
76
|
|
|
|
|
|
|
=cut |
|
77
|
|
|
|
|
|
|
|
|
78
|
1
|
|
|
1
|
0
|
5
|
sub elementsof { return elements(@_); } |
|
79
|
|
|
|
|
|
|
|
|
80
|
|
|
|
|
|
|
sub elements { |
|
81
|
1168
|
|
|
1168
|
1
|
1621
|
my $self = shift(); |
|
82
|
1168
|
|
|
|
|
1364
|
return @{$self->{' val'}}; |
|
|
1168
|
|
|
|
|
3392
|
|
|
83
|
|
|
|
|
|
|
} |
|
84
|
|
|
|
|
|
|
|
|
85
|
|
|
|
|
|
|
=item $a->add_elements(@elements) |
|
86
|
|
|
|
|
|
|
|
|
87
|
|
|
|
|
|
|
Appends the given elements to the array. An element is only added if it |
|
88
|
|
|
|
|
|
|
is defined. |
|
89
|
|
|
|
|
|
|
|
|
90
|
|
|
|
|
|
|
=cut |
|
91
|
|
|
|
|
|
|
|
|
92
|
|
|
|
|
|
|
sub add_elements { |
|
93
|
28504
|
|
|
28504
|
1
|
32383
|
my $self = shift(); |
|
94
|
|
|
|
|
|
|
|
|
95
|
28504
|
|
|
|
|
36812
|
foreach my $element (@_) { |
|
96
|
28506
|
50
|
|
|
|
41638
|
next unless defined $element; |
|
97
|
28506
|
|
|
|
|
30361
|
push @{$self->{' val'}}, $element; |
|
|
28506
|
|
|
|
|
47243
|
|
|
98
|
|
|
|
|
|
|
} |
|
99
|
28504
|
|
|
|
|
43855
|
return $self; |
|
100
|
|
|
|
|
|
|
} |
|
101
|
|
|
|
|
|
|
|
|
102
|
|
|
|
|
|
|
=item $a->remove_element($element) |
|
103
|
|
|
|
|
|
|
|
|
104
|
|
|
|
|
|
|
Removes all occurrences of an element from an array. |
|
105
|
|
|
|
|
|
|
|
|
106
|
|
|
|
|
|
|
Formerly called C, which is now B and will be removed. |
|
107
|
|
|
|
|
|
|
|
|
108
|
|
|
|
|
|
|
=cut |
|
109
|
|
|
|
|
|
|
|
|
110
|
|
|
|
|
|
|
# not listed as deprecated, not used internally, should not have been |
|
111
|
|
|
|
|
|
|
# used in external code. remove after July 2021. |
|
112
|
0
|
|
|
0
|
0
|
0
|
sub removeobj { return remove_element(@_); } |
|
113
|
|
|
|
|
|
|
|
|
114
|
|
|
|
|
|
|
sub remove_element { |
|
115
|
0
|
|
|
0
|
1
|
0
|
my ($self, $element) = @_; |
|
116
|
|
|
|
|
|
|
|
|
117
|
0
|
|
|
|
|
0
|
$self->{' val'} = [ grep { $_ ne $element } @{$self->{' val'}} ]; |
|
|
0
|
|
|
|
|
0
|
|
|
|
0
|
|
|
|
|
0
|
|
|
118
|
0
|
|
|
|
|
0
|
return $self; |
|
119
|
|
|
|
|
|
|
} |
|
120
|
|
|
|
|
|
|
|
|
121
|
|
|
|
|
|
|
=item $a->val() |
|
122
|
|
|
|
|
|
|
|
|
123
|
|
|
|
|
|
|
Returns a reference to the contents of the array. |
|
124
|
|
|
|
|
|
|
|
|
125
|
|
|
|
|
|
|
=cut |
|
126
|
|
|
|
|
|
|
|
|
127
|
|
|
|
|
|
|
sub val { |
|
128
|
4
|
|
|
4
|
1
|
12
|
return $_[0]->{' val'}; |
|
129
|
|
|
|
|
|
|
} |
|
130
|
|
|
|
|
|
|
|
|
131
|
|
|
|
|
|
|
=item $a->copy($pdf) |
|
132
|
|
|
|
|
|
|
|
|
133
|
|
|
|
|
|
|
Copies the array with deep-copy on elements which are not full PDF objects |
|
134
|
|
|
|
|
|
|
with respect to a particular $pdf output context. |
|
135
|
|
|
|
|
|
|
|
|
136
|
|
|
|
|
|
|
=cut |
|
137
|
|
|
|
|
|
|
|
|
138
|
|
|
|
|
|
|
sub copy { |
|
139
|
204
|
|
|
204
|
1
|
477
|
my ($self, $pdf) = @_; |
|
140
|
|
|
|
|
|
|
|
|
141
|
204
|
|
|
|
|
673
|
my $res = $self->SUPER::copy($pdf); |
|
142
|
|
|
|
|
|
|
|
|
143
|
204
|
|
|
|
|
433
|
$res->{' val'} = []; |
|
144
|
204
|
|
|
|
|
308
|
foreach my $e (@{$self->{' val'}}) { |
|
|
204
|
|
|
|
|
430
|
|
|
145
|
2209
|
50
|
33
|
|
|
8863
|
if (ref($e) and $e->can('is_obj') and not $e->is_obj($pdf)) { |
|
|
|
|
33
|
|
|
|
|
|
146
|
2209
|
|
|
|
|
2622
|
push @{$res->{' val'}}, $e->copy($pdf); |
|
|
2209
|
|
|
|
|
4071
|
|
|
147
|
|
|
|
|
|
|
} else { |
|
148
|
0
|
|
|
|
|
0
|
push @{$res->{' val'}}, $e; |
|
|
0
|
|
|
|
|
0
|
|
|
149
|
|
|
|
|
|
|
} |
|
150
|
|
|
|
|
|
|
} |
|
151
|
204
|
|
|
|
|
605
|
return $res; |
|
152
|
|
|
|
|
|
|
} |
|
153
|
|
|
|
|
|
|
|
|
154
|
|
|
|
|
|
|
=back |
|
155
|
|
|
|
|
|
|
|
|
156
|
|
|
|
|
|
|
=cut |
|
157
|
|
|
|
|
|
|
|
|
158
|
|
|
|
|
|
|
1; |