line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Text::PDF::Array; |
2
|
|
|
|
|
|
|
|
3
|
1
|
|
|
1
|
|
3
|
use strict; |
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
22
|
|
4
|
1
|
|
|
1
|
|
3
|
use vars qw(@ISA); |
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
34
|
|
5
|
|
|
|
|
|
|
# no warnings qw(uninitialized); |
6
|
|
|
|
|
|
|
|
7
|
1
|
|
|
1
|
|
325
|
use Text::PDF::Objind; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
391
|
|
8
|
|
|
|
|
|
|
@ISA = qw(Text::PDF::Objind); |
9
|
|
|
|
|
|
|
|
10
|
|
|
|
|
|
|
=head1 NAME |
11
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
Text::PDF::Array - Corresponds to a PDF array. Inherits from L |
13
|
|
|
|
|
|
|
|
14
|
|
|
|
|
|
|
=head1 INSTANCE VARIABLES |
15
|
|
|
|
|
|
|
|
16
|
|
|
|
|
|
|
This object is not an array but an associative array containing the array of |
17
|
|
|
|
|
|
|
elements. Thus, there are special instance variables for an array object, beginning |
18
|
|
|
|
|
|
|
with a space |
19
|
|
|
|
|
|
|
|
20
|
|
|
|
|
|
|
=over |
21
|
|
|
|
|
|
|
|
22
|
|
|
|
|
|
|
=item var |
23
|
|
|
|
|
|
|
|
24
|
|
|
|
|
|
|
Contains the actual array of elements |
25
|
|
|
|
|
|
|
|
26
|
|
|
|
|
|
|
=back |
27
|
|
|
|
|
|
|
|
28
|
|
|
|
|
|
|
=head1 METHODS |
29
|
|
|
|
|
|
|
|
30
|
|
|
|
|
|
|
=head2 PDF::Array->new($parent, @vals) |
31
|
|
|
|
|
|
|
|
32
|
|
|
|
|
|
|
Creates an array with the given storage parent and an optional list of values to |
33
|
|
|
|
|
|
|
initialise the array with. |
34
|
|
|
|
|
|
|
|
35
|
|
|
|
|
|
|
=cut |
36
|
|
|
|
|
|
|
|
37
|
|
|
|
|
|
|
sub new |
38
|
|
|
|
|
|
|
{ |
39
|
5
|
|
|
5
|
1
|
8
|
my ($class, @vals) = @_; |
40
|
5
|
|
|
|
|
1
|
my ($self); |
41
|
|
|
|
|
|
|
|
42
|
5
|
|
|
|
|
12
|
$self->{' val'} = [@vals]; |
43
|
5
|
|
|
|
|
6
|
$self->{' realised'} = 1; |
44
|
5
|
|
|
|
|
9
|
bless $self, $class; |
45
|
|
|
|
|
|
|
} |
46
|
|
|
|
|
|
|
|
47
|
|
|
|
|
|
|
|
48
|
|
|
|
|
|
|
=head2 $a->outobjdeep($fh, $pdf) |
49
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
Outputs an array as a PDF array to the given filehandle. |
51
|
|
|
|
|
|
|
|
52
|
|
|
|
|
|
|
=cut |
53
|
|
|
|
|
|
|
|
54
|
|
|
|
|
|
|
sub outobjdeep |
55
|
|
|
|
|
|
|
{ |
56
|
4
|
|
|
4
|
1
|
7
|
my ($self, $fh, $pdf, %opts) = @_; |
57
|
4
|
|
|
|
|
4
|
my ($obj); |
58
|
|
|
|
|
|
|
|
59
|
4
|
|
|
|
|
7
|
$fh->print("[ "); |
60
|
4
|
|
|
|
|
13
|
foreach $obj (@{$self->{' val'}}) |
|
4
|
|
|
|
|
7
|
|
61
|
|
|
|
|
|
|
{ |
62
|
8
|
|
|
|
|
28
|
$obj->outobj($fh, $pdf, %opts); |
63
|
8
|
|
|
|
|
36
|
$fh->print(" "); |
64
|
|
|
|
|
|
|
} |
65
|
4
|
|
|
|
|
21
|
$fh->print("]"); |
66
|
|
|
|
|
|
|
} |
67
|
|
|
|
|
|
|
|
68
|
|
|
|
|
|
|
|
69
|
|
|
|
|
|
|
=head2 $a->removeobj($elem) |
70
|
|
|
|
|
|
|
|
71
|
|
|
|
|
|
|
Removes all occurrences of an element from an array. |
72
|
|
|
|
|
|
|
|
73
|
|
|
|
|
|
|
=cut |
74
|
|
|
|
|
|
|
|
75
|
|
|
|
|
|
|
sub removeobj |
76
|
|
|
|
|
|
|
{ |
77
|
0
|
|
|
0
|
1
|
0
|
my ($self, $elem) = @_; |
78
|
|
|
|
|
|
|
|
79
|
0
|
|
|
|
|
0
|
$self->{' val'} = [grep($_ ne $elem, @{$self->{' val'}})]; |
|
0
|
|
|
|
|
0
|
|
80
|
|
|
|
|
|
|
} |
81
|
|
|
|
|
|
|
|
82
|
|
|
|
|
|
|
|
83
|
|
|
|
|
|
|
=head2 $a->elementsof |
84
|
|
|
|
|
|
|
|
85
|
|
|
|
|
|
|
Returns a list of all the elements in the array. Notice that this is |
86
|
|
|
|
|
|
|
not the array itself but the elements in the array. |
87
|
|
|
|
|
|
|
|
88
|
|
|
|
|
|
|
=cut |
89
|
|
|
|
|
|
|
|
90
|
|
|
|
|
|
|
sub elementsof |
91
|
3
|
100
|
|
3
|
1
|
4
|
{ wantarray ? @{$_[0]->{' val'}} : scalar @{$_[0]->{' val'}}; } |
|
1
|
|
|
|
|
4
|
|
|
2
|
|
|
|
|
6
|
|
92
|
|
|
|
|
|
|
|
93
|
|
|
|
|
|
|
|
94
|
|
|
|
|
|
|
=head2 $a->add_elements |
95
|
|
|
|
|
|
|
|
96
|
|
|
|
|
|
|
Appends the given elements to the array. An element is only added if it |
97
|
|
|
|
|
|
|
is defined. |
98
|
|
|
|
|
|
|
|
99
|
|
|
|
|
|
|
=cut |
100
|
|
|
|
|
|
|
|
101
|
|
|
|
|
|
|
sub add_elements |
102
|
|
|
|
|
|
|
{ |
103
|
7
|
|
|
7
|
1
|
7
|
my ($self) = shift; |
104
|
7
|
|
|
|
|
8
|
my ($e); |
105
|
|
|
|
|
|
|
|
106
|
7
|
|
|
|
|
7
|
foreach $e (@_) |
107
|
7
|
50
|
|
|
|
12
|
{ push (@{$self->{' val'}}, $e) if defined $e; } |
|
7
|
|
|
|
|
12
|
|
108
|
7
|
|
|
|
|
10
|
$self; |
109
|
|
|
|
|
|
|
} |
110
|
|
|
|
|
|
|
|
111
|
|
|
|
|
|
|
|
112
|
|
|
|
|
|
|
=head2 $a->val |
113
|
|
|
|
|
|
|
|
114
|
|
|
|
|
|
|
Returns the value of the array, this is a reference to the actual array |
115
|
|
|
|
|
|
|
containing the elements. |
116
|
|
|
|
|
|
|
|
117
|
|
|
|
|
|
|
=cut |
118
|
|
|
|
|
|
|
|
119
|
|
|
|
|
|
|
sub val |
120
|
0
|
|
|
0
|
1
|
|
{ $_[0]->{' val'}; } |
121
|
|
|
|
|
|
|
|
122
|
|
|
|
|
|
|
|
123
|
|
|
|
|
|
|
=head2 $d->copy($inpdf, $res, $unique, $outpdf, %opts) |
124
|
|
|
|
|
|
|
|
125
|
|
|
|
|
|
|
Copies an object. See Text::PDF::Objind::Copy() for details |
126
|
|
|
|
|
|
|
|
127
|
|
|
|
|
|
|
=cut |
128
|
|
|
|
|
|
|
|
129
|
|
|
|
|
|
|
sub copy |
130
|
|
|
|
|
|
|
{ |
131
|
0
|
|
|
0
|
1
|
|
my ($self, $inpdf, $res, $unique, $outpdf, %opts) = @_; |
132
|
0
|
|
|
|
|
|
my ($i, $path); |
133
|
|
|
|
|
|
|
|
134
|
0
|
|
|
|
|
|
$res = $self->SUPER::copy($inpdf, $res, $unique, $outpdf, %opts); |
135
|
0
|
|
|
|
|
|
$res->{' val'} = []; |
136
|
0
|
|
|
|
|
|
$path = delete $opts{'path'}; |
137
|
0
|
|
|
|
|
|
for ($i = 0; $i < scalar @{$self->{' val'}}; $i++) |
|
0
|
|
|
|
|
|
|
138
|
|
|
|
|
|
|
{ |
139
|
0
|
0
|
0
|
|
|
|
if (UNIVERSAL::can($self->{'val'}[$i], "is_obj") && !grep {"$path\[$i\]" =~ m|$_|} @{$opts{'clip'}}) |
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
140
|
0
|
0
|
|
|
|
|
{ push (@{$res->{' val'}}, $self->{' val'}[$i]->realise->copy($inpdf, undef, $unique ? $unique + 1 : 0, |
|
0
|
|
|
|
|
|
|
141
|
|
|
|
|
|
|
$outpdf, %opts, 'path' => "$path\[$i\]")); } |
142
|
|
|
|
|
|
|
else |
143
|
0
|
|
|
|
|
|
{ push (@{$res->{' val'}}, $self->{' val'}[$i]); } |
|
0
|
|
|
|
|
|
|
144
|
|
|
|
|
|
|
} |
145
|
0
|
|
|
|
|
|
$res->{' realised'} = 1; |
146
|
0
|
|
|
|
|
|
$res; |
147
|
|
|
|
|
|
|
} |
148
|
|
|
|
|
|
|
|
149
|
|
|
|
|
|
|
1; |
150
|
|
|
|
|
|
|
|
151
|
|
|
|
|
|
|
|