line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
# Code in the PDF::API2::Basic::PDF namespace was originally copied from the |
2
|
|
|
|
|
|
|
# Text::PDF distribution. |
3
|
|
|
|
|
|
|
# |
4
|
|
|
|
|
|
|
# Copyright Martin Hosken |
5
|
|
|
|
|
|
|
# |
6
|
|
|
|
|
|
|
# Martin Hosken's code may be used under the terms of the MIT license. |
7
|
|
|
|
|
|
|
# Subsequent versions of the code have the same license as PDF::API2. |
8
|
|
|
|
|
|
|
|
9
|
|
|
|
|
|
|
package PDF::API2::Basic::PDF::Array; |
10
|
|
|
|
|
|
|
|
11
|
40
|
|
|
40
|
|
285
|
use base 'PDF::API2::Basic::PDF::Objind'; |
|
40
|
|
|
|
|
101
|
|
|
40
|
|
|
|
|
18426
|
|
12
|
|
|
|
|
|
|
|
13
|
40
|
|
|
40
|
|
287
|
use strict; |
|
40
|
|
|
|
|
85
|
|
|
40
|
|
|
|
|
747
|
|
14
|
40
|
|
|
40
|
|
191
|
use warnings; |
|
40
|
|
|
|
|
92
|
|
|
40
|
|
|
|
|
20894
|
|
15
|
|
|
|
|
|
|
|
16
|
|
|
|
|
|
|
our $VERSION = '2.044'; # VERSION |
17
|
|
|
|
|
|
|
|
18
|
|
|
|
|
|
|
=head1 NAME |
19
|
|
|
|
|
|
|
|
20
|
|
|
|
|
|
|
PDF::API2::Basic::PDF::Array - Low-level PDF array object |
21
|
|
|
|
|
|
|
|
22
|
|
|
|
|
|
|
=head1 METHODS |
23
|
|
|
|
|
|
|
|
24
|
|
|
|
|
|
|
=head2 PDF::Array->new($parent, @values) |
25
|
|
|
|
|
|
|
|
26
|
|
|
|
|
|
|
Creates an array with the given storage parent and an optional list of values to |
27
|
|
|
|
|
|
|
initialise the array with. |
28
|
|
|
|
|
|
|
|
29
|
|
|
|
|
|
|
=cut |
30
|
|
|
|
|
|
|
|
31
|
|
|
|
|
|
|
sub new { |
32
|
1095
|
|
|
1095
|
1
|
2316
|
my ($class, @values) = @_; |
33
|
1095
|
|
|
|
|
1801
|
my $self = {}; |
34
|
|
|
|
|
|
|
|
35
|
1095
|
|
|
|
|
3271
|
$self->{' val'} = [@values]; |
36
|
1095
|
|
|
|
|
1866
|
$self->{' realised'} = 1; |
37
|
|
|
|
|
|
|
|
38
|
1095
|
|
|
|
|
1956
|
bless $self, $class; |
39
|
1095
|
|
|
|
|
3718
|
return $self; |
40
|
|
|
|
|
|
|
} |
41
|
|
|
|
|
|
|
|
42
|
|
|
|
|
|
|
=head2 $a->outobjdeep($fh, $pdf) |
43
|
|
|
|
|
|
|
|
44
|
|
|
|
|
|
|
Outputs an array as a PDF array to the given filehandle. |
45
|
|
|
|
|
|
|
|
46
|
|
|
|
|
|
|
=cut |
47
|
|
|
|
|
|
|
|
48
|
|
|
|
|
|
|
sub outobjdeep { |
49
|
619
|
|
|
619
|
1
|
1083
|
my ($self, $fh, $pdf) = @_; |
50
|
|
|
|
|
|
|
|
51
|
619
|
|
|
|
|
1543
|
$fh->print('[ '); |
52
|
619
|
|
|
|
|
3277
|
foreach my $obj (@{$self->{' val'}}) { |
|
619
|
|
|
|
|
1365
|
|
53
|
1841
|
|
|
|
|
9936
|
$obj->outobj($fh, $pdf); |
54
|
1841
|
|
|
|
|
12462
|
$fh->print(' '); |
55
|
|
|
|
|
|
|
} |
56
|
619
|
|
|
|
|
3753
|
$fh->print(']'); |
57
|
|
|
|
|
|
|
} |
58
|
|
|
|
|
|
|
|
59
|
|
|
|
|
|
|
=head2 $a->elements() |
60
|
|
|
|
|
|
|
|
61
|
|
|
|
|
|
|
Returns the contents of the array. |
62
|
|
|
|
|
|
|
|
63
|
|
|
|
|
|
|
=cut |
64
|
|
|
|
|
|
|
|
65
|
0
|
|
|
0
|
0
|
0
|
sub elementsof { return elements(@_) } |
66
|
|
|
|
|
|
|
|
67
|
|
|
|
|
|
|
sub elements { |
68
|
665
|
|
|
665
|
1
|
1041
|
my $self = shift(); |
69
|
665
|
|
|
|
|
917
|
return @{$self->{' val'}}; |
|
665
|
|
|
|
|
2143
|
|
70
|
|
|
|
|
|
|
} |
71
|
|
|
|
|
|
|
|
72
|
|
|
|
|
|
|
=head2 $a->add_elements(@elements) |
73
|
|
|
|
|
|
|
|
74
|
|
|
|
|
|
|
Appends the given elements to the array. An element is only added if it |
75
|
|
|
|
|
|
|
is defined. |
76
|
|
|
|
|
|
|
|
77
|
|
|
|
|
|
|
=cut |
78
|
|
|
|
|
|
|
|
79
|
|
|
|
|
|
|
sub add_elements { |
80
|
27380
|
|
|
27380
|
1
|
37606
|
my $self = shift(); |
81
|
|
|
|
|
|
|
|
82
|
27380
|
|
|
|
|
41512
|
foreach my $element (@_) { |
83
|
27382
|
50
|
|
|
|
47762
|
next unless defined $element; |
84
|
27382
|
|
|
|
|
34076
|
push @{$self->{' val'}}, $element; |
|
27382
|
|
|
|
|
55996
|
|
85
|
|
|
|
|
|
|
} |
86
|
|
|
|
|
|
|
|
87
|
27380
|
|
|
|
|
51013
|
return $self; |
88
|
|
|
|
|
|
|
} |
89
|
|
|
|
|
|
|
|
90
|
|
|
|
|
|
|
=head2 $a->remove_element($element) |
91
|
|
|
|
|
|
|
|
92
|
|
|
|
|
|
|
Removes all occurrences of an element from an array. |
93
|
|
|
|
|
|
|
|
94
|
|
|
|
|
|
|
=cut |
95
|
|
|
|
|
|
|
|
96
|
0
|
|
|
0
|
0
|
0
|
sub removeobj { return remove_element(@_) } |
97
|
|
|
|
|
|
|
|
98
|
|
|
|
|
|
|
sub remove_element { |
99
|
0
|
|
|
0
|
1
|
0
|
my ($self, $element) = @_; |
100
|
|
|
|
|
|
|
|
101
|
0
|
|
|
|
|
0
|
$self->{' val'} = [ grep { $_ ne $element } @{$self->{' val'}} ]; |
|
0
|
|
|
|
|
0
|
|
|
0
|
|
|
|
|
0
|
|
102
|
|
|
|
|
|
|
} |
103
|
|
|
|
|
|
|
|
104
|
|
|
|
|
|
|
=head2 $a->val() |
105
|
|
|
|
|
|
|
|
106
|
|
|
|
|
|
|
Returns a reference to the contents of the array. |
107
|
|
|
|
|
|
|
|
108
|
|
|
|
|
|
|
=cut |
109
|
|
|
|
|
|
|
|
110
|
|
|
|
|
|
|
sub val { |
111
|
4
|
|
|
4
|
1
|
14
|
return $_[0]->{' val'}; |
112
|
|
|
|
|
|
|
} |
113
|
|
|
|
|
|
|
|
114
|
|
|
|
|
|
|
=head2 $a->copy($pdf) |
115
|
|
|
|
|
|
|
|
116
|
|
|
|
|
|
|
Copies the array with deep-copy on elements which are not full PDF objects |
117
|
|
|
|
|
|
|
with respect to a particular $pdf output context |
118
|
|
|
|
|
|
|
|
119
|
|
|
|
|
|
|
=cut |
120
|
|
|
|
|
|
|
|
121
|
|
|
|
|
|
|
sub copy { |
122
|
144
|
|
|
144
|
1
|
350
|
my ($self, $pdf) = @_; |
123
|
144
|
|
|
|
|
526
|
my $res = $self->SUPER::copy($pdf); |
124
|
|
|
|
|
|
|
|
125
|
144
|
|
|
|
|
329
|
$res->{' val'} = []; |
126
|
144
|
|
|
|
|
267
|
foreach my $e (@{$self->{' val'}}) { |
|
144
|
|
|
|
|
356
|
|
127
|
718
|
50
|
33
|
|
|
3627
|
if (ref($e) and $e->can('is_obj') and not $e->is_obj($pdf)) { |
|
|
|
33
|
|
|
|
|
128
|
718
|
|
|
|
|
1114
|
push(@{$res->{' val'}}, $e->copy($pdf)); |
|
718
|
|
|
|
|
1673
|
|
129
|
|
|
|
|
|
|
} |
130
|
|
|
|
|
|
|
else { |
131
|
0
|
|
|
|
|
0
|
push(@{$res->{' val'}}, $e); |
|
0
|
|
|
|
|
0
|
|
132
|
|
|
|
|
|
|
} |
133
|
|
|
|
|
|
|
} |
134
|
144
|
|
|
|
|
503
|
return $res; |
135
|
|
|
|
|
|
|
} |
136
|
|
|
|
|
|
|
|
137
|
|
|
|
|
|
|
1; |