File Coverage

blib/lib/PDF/API3/Compat/API2/Basic/PDF/Literal.pm
Criterion Covered Total %
statement 18 56 32.1
branch 0 20 0.0
condition n/a
subroutine 6 10 60.0
pod 3 4 75.0
total 27 90 30.0


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             # Copyright 1999-2005 Alfred Reibenschuh .
12             #
13             #=======================================================================
14             #
15             # This library is free software; you can redistribute it and/or
16             # modify it under the terms of the GNU Lesser General Public
17             # License as published by the Free Software Foundation; either
18             # version 2 of the License, or (at your option) any later version.
19             #
20             # This library is distributed in the hope that it will be useful,
21             # but WITHOUT ANY WARRANTY; without even the implied warranty of
22             # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
23             # Lesser General Public License for more details.
24             #
25             # You should have received a copy of the GNU Lesser General Public
26             # License along with this library; if not, write to the
27             # Free Software Foundation, Inc., 59 Temple Place - Suite 330,
28             # Boston, MA 02111-1307, USA.
29             #
30             # $Id: Literal.pm,v 2.0 2005/11/16 02:16:00 areibens Exp $
31             #
32             #=======================================================================
33             # Literal PDF Object for Dirty Hacks ...
34             package PDF::API3::Compat::API2::Basic::PDF::Literal;
35            
36 1     1   6 use strict;
  1         2  
  1         43  
37 1     1   5 use vars qw( @ISA );
  1         2  
  1         45  
38            
39 1     1   6 use PDF::API3::Compat::API2::Basic::PDF::Objind;
  1         2  
  1         50  
40            
41             @ISA = qw(PDF::API3::Compat::API2::Basic::PDF::Objind);
42            
43 1     1   5 use PDF::API3::Compat::API2::Basic::PDF::Filter;
  1         2  
  1         21  
44 1     1   4 use PDF::API3::Compat::API2::Basic::PDF::Name;
  1         2  
  1         29  
45            
46 1     1   4 no warnings qw[ deprecated recursion uninitialized ];
  1         2  
  1         633  
47            
48             sub new
49             {
50 0     0 1   my ($class, @opts) = @_;
51 0           my ($self);
52            
53 0 0         $class = ref $class if ref $class;
54 0           $self = $class->SUPER::new(@_);
55 0           $self->{' realised'} = 1;
56 0 0         if(scalar @opts > 1) {
    0          
57 0           $self->{-isdict}=1;
58 0           my %opt=@opts;
59 0           foreach my $k (sort keys %opt) {
60 0           $self->{$k} = $opt{$k};
61             }
62             } elsif(scalar @opts == 1) {
63 0           $self->{-literal}=$opts[0];
64             }
65 0           return $self;
66             }
67            
68             sub outobjdeep
69             {
70 0     0 1   my ($self, $fh, $pdf, %opts) = @_;
71 0 0         if($self->{-isdict})
72             {
73 0 0         if(defined $self->{' stream'})
74             {
75 0           $self->{Length} = length($self->{' stream'}) + 1;
76             }
77             else
78             {
79 0           delete $self->{Length};
80             }
81 0           $fh->print("<< ");
82 0           foreach my $k (sort keys %{$self})
  0            
83             {
84 0 0         next if($k=~m|^[ \-]|o);
85 0           $fh->print('/'.PDF::API3::Compat::API2::Basic::PDF::Name::string_to_name($k).' ');
86 0 0         if(ref($self->{$k}) eq 'ARRAY')
    0          
    0          
87             {
88 0           $fh->print('['.join(' ',@{$self->{$k}})."]\n");
  0            
89             }
90             elsif(ref($self->{$k}) eq 'HASH')
91             {
92 0           $fh->print('<<'.join(' ', map { '/'.PDF::API3::Compat::API2::Basic::PDF::Name::string_to_name($_).' '.$self->{$k}->{$_} } sort keys %{$self->{$k}})." >>\n");
  0            
  0            
93             }
94             elsif(UNIVERSAL::can($self->{$k},'outobj'))
95             {
96 0           $self->{$k}->outobj($fh, $pdf, %opts);
97 0           $fh->print("\n");
98             }
99             else
100             {
101 0           $fh->print("$self->{$k}\n");
102             }
103             }
104 0           $fh->print(">>\n");
105 0 0         if(defined $self->{' stream'})
106             {
107 0           $fh->print("stream\n$self->{' stream'}\nendstream"); # next is endobj which has the final cr
108             }
109             }
110             else
111             {
112 0           $fh->print($self->{-literal}); # next is endobj which has the final cr
113             }
114             }
115            
116             sub outxmldeep
117             {
118 0     0 0   my ($self, $fh, $pdf, %opts) = @_;
119 0           $opts{-xmlfh}->print("NOT HANDLED HERE.\n");
120             }
121            
122             sub val
123 0     0 1   { $_[0]; }
124            
125            
126