line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
#=======================================================================
|
2
|
|
|
|
|
|
|
# ____ ____ _____ _ ____ ___ ____
|
3
|
|
|
|
|
|
|
# | _ \| _ \| ___| _ _ / \ | _ \_ _| |___ \
|
4
|
|
|
|
|
|
|
# | |_) | | | | |_ (_) (_) / _ \ | |_) | | __) |
|
5
|
|
|
|
|
|
|
# | __/| |_| | _| _ _ / ___ \| __/| | / __/
|
6
|
|
|
|
|
|
|
# |_| |____/|_| (_) (_) /_/ \_\_| |___| |_____|
|
7
|
|
|
|
|
|
|
#
|
8
|
|
|
|
|
|
|
# A Perl Module Chain to faciliate the Creation and Modification
|
9
|
|
|
|
|
|
|
# of High-Quality "Portable Document Format (PDF)" Files.
|
10
|
|
|
|
|
|
|
#
|
11
|
|
|
|
|
|
|
#=======================================================================
|
12
|
|
|
|
|
|
|
#
|
13
|
|
|
|
|
|
|
# THIS IS A REUSED PERL MODULE, FOR PROPER LICENCING TERMS SEE BELOW:
|
14
|
|
|
|
|
|
|
#
|
15
|
|
|
|
|
|
|
#
|
16
|
|
|
|
|
|
|
# Copyright Martin Hosken
|
17
|
|
|
|
|
|
|
#
|
18
|
|
|
|
|
|
|
# No warranty or expression of effectiveness, least of all regarding
|
19
|
|
|
|
|
|
|
# anyone's safety, is implied in this software or documentation.
|
20
|
|
|
|
|
|
|
#
|
21
|
|
|
|
|
|
|
# This specific module is licensed under the Perl Artistic License.
|
22
|
|
|
|
|
|
|
#
|
23
|
|
|
|
|
|
|
#
|
24
|
|
|
|
|
|
|
# $Id: Array.pm,v 2.0 2005/11/16 02:16:00 areibens Exp $
|
25
|
|
|
|
|
|
|
#
|
26
|
|
|
|
|
|
|
#=======================================================================
|
27
|
|
|
|
|
|
|
package PDF::API3::Compat::API2::Basic::PDF::Array;
|
28
|
|
|
|
|
|
|
|
29
|
1
|
|
|
1
|
|
6
|
use strict;
|
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
43
|
|
30
|
1
|
|
|
1
|
|
6
|
use vars qw(@ISA);
|
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
47
|
|
31
|
|
|
|
|
|
|
|
32
|
1
|
|
|
1
|
|
6
|
use PDF::API3::Compat::API2::Basic::PDF::Objind;
|
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
39
|
|
33
|
|
|
|
|
|
|
@ISA = qw(PDF::API3::Compat::API2::Basic::PDF::Objind);
|
34
|
|
|
|
|
|
|
|
35
|
1
|
|
|
1
|
|
21
|
no warnings qw[ deprecated recursion uninitialized ];
|
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
856
|
|
36
|
|
|
|
|
|
|
|
37
|
|
|
|
|
|
|
=head1 NAME
|
38
|
|
|
|
|
|
|
|
39
|
|
|
|
|
|
|
PDF::API3::Compat::API2::Basic::PDF::Array - Corresponds to a PDF array. Inherits from L
|
40
|
|
|
|
|
|
|
|
41
|
|
|
|
|
|
|
=head1 INSTANCE VARIABLES
|
42
|
|
|
|
|
|
|
|
43
|
|
|
|
|
|
|
This object is not an array but an associative array containing the array of
|
44
|
|
|
|
|
|
|
elements. Thus, there are special instance variables for an array object, beginning
|
45
|
|
|
|
|
|
|
with a space
|
46
|
|
|
|
|
|
|
|
47
|
|
|
|
|
|
|
=item var
|
48
|
|
|
|
|
|
|
|
49
|
|
|
|
|
|
|
Contains the actual array of elements
|
50
|
|
|
|
|
|
|
|
51
|
|
|
|
|
|
|
=head1 METHODS
|
52
|
|
|
|
|
|
|
|
53
|
|
|
|
|
|
|
=head2 PDF::Array->new($parent, @vals)
|
54
|
|
|
|
|
|
|
|
55
|
|
|
|
|
|
|
Creates an array with the given storage parent and an optional list of values to
|
56
|
|
|
|
|
|
|
initialise the array with.
|
57
|
|
|
|
|
|
|
|
58
|
|
|
|
|
|
|
=cut
|
59
|
|
|
|
|
|
|
|
60
|
|
|
|
|
|
|
sub new
|
61
|
|
|
|
|
|
|
{
|
62
|
0
|
|
|
0
|
1
|
|
my ($class, @vals) = @_;
|
63
|
0
|
|
|
|
|
|
my ($self);
|
64
|
|
|
|
|
|
|
|
65
|
0
|
|
|
|
|
|
$self->{' val'} = [@vals];
|
66
|
0
|
|
|
|
|
|
$self->{' realised'} = 1;
|
67
|
0
|
|
|
|
|
|
bless $self, $class;
|
68
|
|
|
|
|
|
|
}
|
69
|
|
|
|
|
|
|
|
70
|
|
|
|
|
|
|
|
71
|
|
|
|
|
|
|
=head2 $a->outobjdeep($fh, $pdf)
|
72
|
|
|
|
|
|
|
|
73
|
|
|
|
|
|
|
Outputs an array as a PDF array to the given filehandle.
|
74
|
|
|
|
|
|
|
|
75
|
|
|
|
|
|
|
=cut
|
76
|
|
|
|
|
|
|
|
77
|
|
|
|
|
|
|
sub outobjdeep
|
78
|
|
|
|
|
|
|
{
|
79
|
0
|
|
|
0
|
1
|
|
my ($self, $fh, $pdf, %opts) = @_;
|
80
|
0
|
|
|
|
|
|
my ($obj);
|
81
|
|
|
|
|
|
|
|
82
|
0
|
|
|
|
|
|
$fh->print("[ ");
|
83
|
0
|
|
|
|
|
|
foreach $obj (@{$self->{' val'}})
|
|
0
|
|
|
|
|
|
|
84
|
|
|
|
|
|
|
{
|
85
|
0
|
|
|
|
|
|
$obj->outobj($fh, $pdf);
|
86
|
0
|
|
|
|
|
|
$fh->print(" ");
|
87
|
|
|
|
|
|
|
}
|
88
|
0
|
|
|
|
|
|
$fh->print("]");
|
89
|
|
|
|
|
|
|
}
|
90
|
|
|
|
|
|
|
|
91
|
|
|
|
|
|
|
sub outxmldeep
|
92
|
|
|
|
|
|
|
{
|
93
|
0
|
|
|
0
|
0
|
|
my ($self, $fh, $pdf, %opts) = @_;
|
94
|
0
|
|
|
|
|
|
my ($obj);
|
95
|
|
|
|
|
|
|
|
96
|
0
|
|
|
|
|
|
$opts{-xmlfh}->print("\n");
|
97
|
0
|
|
|
|
|
|
foreach $obj (@{$self->{' val'}})
|
|
0
|
|
|
|
|
|
|
98
|
|
|
|
|
|
|
{
|
99
|
0
|
|
|
|
|
|
$obj->outxml($fh, $pdf, %opts);
|
100
|
|
|
|
|
|
|
}
|
101
|
0
|
|
|
|
|
|
$opts{-xmlfh}->print("\n");
|
102
|
|
|
|
|
|
|
|
103
|
|
|
|
|
|
|
}
|
104
|
|
|
|
|
|
|
|
105
|
|
|
|
|
|
|
=head2 $a->removeobj($elem)
|
106
|
|
|
|
|
|
|
|
107
|
|
|
|
|
|
|
Removes all occurrences of an element from an array.
|
108
|
|
|
|
|
|
|
|
109
|
|
|
|
|
|
|
=cut
|
110
|
|
|
|
|
|
|
|
111
|
|
|
|
|
|
|
sub removeobj
|
112
|
|
|
|
|
|
|
{
|
113
|
0
|
|
|
0
|
1
|
|
my ($self, $elem) = @_;
|
114
|
|
|
|
|
|
|
|
115
|
0
|
|
|
|
|
|
$self->{' val'} = [grep($_ ne $elem, @{$self->{' val'}})];
|
|
0
|
|
|
|
|
|
|
116
|
|
|
|
|
|
|
}
|
117
|
|
|
|
|
|
|
|
118
|
|
|
|
|
|
|
|
119
|
|
|
|
|
|
|
=head2 $a->elementsof
|
120
|
|
|
|
|
|
|
|
121
|
|
|
|
|
|
|
Returns a list of all the elements in the array. Notice that this is
|
122
|
|
|
|
|
|
|
not the array itself but the elements in the array.
|
123
|
|
|
|
|
|
|
|
124
|
|
|
|
|
|
|
=cut
|
125
|
|
|
|
|
|
|
|
126
|
|
|
|
|
|
|
sub elementsof
|
127
|
0
|
0
|
|
0
|
1
|
|
{ wantarray ? @{$_[0]->{' val'}} : scalar @{$_[0]->{' val'}}; }
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
128
|
|
|
|
|
|
|
|
129
|
|
|
|
|
|
|
|
130
|
|
|
|
|
|
|
=head2 $a->add_elements
|
131
|
|
|
|
|
|
|
|
132
|
|
|
|
|
|
|
Appends the given elements to the array. An element is only added if it
|
133
|
|
|
|
|
|
|
is defined.
|
134
|
|
|
|
|
|
|
|
135
|
|
|
|
|
|
|
=cut
|
136
|
|
|
|
|
|
|
|
137
|
|
|
|
|
|
|
sub add_elements
|
138
|
|
|
|
|
|
|
{
|
139
|
0
|
|
|
0
|
1
|
|
my ($self) = shift;
|
140
|
0
|
|
|
|
|
|
my ($e);
|
141
|
|
|
|
|
|
|
|
142
|
0
|
|
|
|
|
|
foreach $e (@_)
|
143
|
0
|
0
|
|
|
|
|
{ push (@{$self->{' val'}}, $e) if defined $e; }
|
|
0
|
|
|
|
|
|
|
144
|
0
|
|
|
|
|
|
$self;
|
145
|
|
|
|
|
|
|
}
|
146
|
|
|
|
|
|
|
|
147
|
|
|
|
|
|
|
|
148
|
|
|
|
|
|
|
=head2 $a->val
|
149
|
|
|
|
|
|
|
|
150
|
|
|
|
|
|
|
Returns the value of the array, this is a reference to the actual array
|
151
|
|
|
|
|
|
|
containing the elements.
|
152
|
|
|
|
|
|
|
|
153
|
|
|
|
|
|
|
=cut
|
154
|
|
|
|
|
|
|
|
155
|
|
|
|
|
|
|
sub val
|
156
|
0
|
|
|
0
|
1
|
|
{ $_[0]->{' val'}; }
|
157
|
|
|
|
|
|
|
|
158
|
|
|
|
|
|
|
|
159
|
|
|
|
|
|
|
=head2 $a->copy($pdf)
|
160
|
|
|
|
|
|
|
|
161
|
|
|
|
|
|
|
Copies the array with deep-copy on elements which are not full PDF objects
|
162
|
|
|
|
|
|
|
with respect to a particular $pdf output context
|
163
|
|
|
|
|
|
|
|
164
|
|
|
|
|
|
|
=cut
|
165
|
|
|
|
|
|
|
|
166
|
|
|
|
|
|
|
sub copy
|
167
|
|
|
|
|
|
|
{
|
168
|
0
|
|
|
0
|
1
|
|
my ($self, $pdf) = @_;
|
169
|
0
|
|
|
|
|
|
my ($res) = $self->SUPER::copy($pdf);
|
170
|
0
|
|
|
|
|
|
my ($e);
|
171
|
|
|
|
|
|
|
|
172
|
0
|
|
|
|
|
|
$res->{' val'} = [];
|
173
|
0
|
|
|
|
|
|
foreach $e (@{$self->{' val'}})
|
|
0
|
|
|
|
|
|
|
174
|
|
|
|
|
|
|
{
|
175
|
0
|
0
|
0
|
|
|
|
if (UNIVERSAL::can($e, "is_obj") && !$e->is_obj($pdf))
|
176
|
0
|
|
|
|
|
|
{ push(@{$res->{' val'}}, $e->copy($pdf)); }
|
|
0
|
|
|
|
|
|
|
177
|
|
|
|
|
|
|
else
|
178
|
0
|
|
|
|
|
|
{ push(@{$res->{' val'}}, $e); }
|
|
0
|
|
|
|
|
|
|
179
|
|
|
|
|
|
|
}
|
180
|
0
|
|
|
|
|
|
$res;
|
181
|
|
|
|
|
|
|
}
|
182
|
|
|
|
|
|
|
|
183
|
|
|
|
|
|
|
1;
|
184
|
|
|
|
|
|
|
|
185
|
|
|
|
|
|
|
|