1
package Text::PDF::Array;
5
# no warnings qw(uninitialized);
8
@ISA = qw(Text::PDF::Objind);
12
Text::PDF::Array - Corresponds to a PDF array. Inherits from L<PDF::Objind>
14
=head1 INSTANCE VARIABLES
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
22
Contains the actual array of elements
26
=head2 PDF::Array->new($parent, @vals)
28
Creates an array with the given storage parent and an optional list of values to
29
initialise the array with.
35
my ($class, @vals) = @_;
38
$self->{' val'} = [@vals];
39
$self->{' realised'} = 1;
44
=head2 $a->outobjdeep($fh, $pdf)
46
Outputs an array as a PDF array to the given filehandle.
52
my ($self, $fh, $pdf, %opts) = @_;
56
foreach $obj (@{$self->{' val'}})
58
$obj->outobj($fh, $pdf, %opts);
65
=head2 $a->removeobj($elem)
67
Removes all occurrences of an element from an array.
73
my ($self, $elem) = @_;
75
$self->{' val'} = [grep($_ ne $elem, @{$self->{' val'}})];
81
Returns a list of all the elements in the array. Notice that this is
82
not the array itself but the elements in the array.
87
{ wantarray ? @{$_[0]->{' val'}} : scalar @{$_[0]->{' val'}}; }
90
=head2 $a->add_elements
92
Appends the given elements to the array. An element is only added if it
103
{ push (@{$self->{' val'}}, $e) if defined $e; }
110
Returns the value of the array, this is a reference to the actual array
111
containing the elements.
119
=head2 $d->copy($inpdf, $res, $unique, $outpdf, %opts)
121
Copies an object. See Text::PDF::Objind::Copy() for details
127
my ($self, $inpdf, $res, $unique, $outpdf, %opts) = @_;
130
$res = $self->SUPER::copy($inpdf, $res, $unique, $outpdf, %opts);
132
$path = delete $opts{'path'};
133
for ($i = 0; $i < scalar @{$self->{' val'}}; $i++)
135
if (UNIVERSAL::can($self->{'val'}[$i], "is_obj") && !grep {"$path\[$i\]" =~ m|$_|} @{$opts{'clip'}})
136
{ push (@{$res->{' val'}}, $self->{' val'}[$i]->realise->copy($inpdf, undef, $unique ? $unique + 1 : 0,
137
$outpdf, %opts, 'path' => "$path\[$i\]")); }
139
{ push (@{$res->{' val'}}, $self->{' val'}[$i]); }
141
$res->{' realised'} = 1;