API3/Compat/API2/Resource/XObject.pm

filter: Statementstmt 48.8% 21 / 43 Branchbran 0.0% 0 / 8 Conditioncond 0.0% 0 / 3 MC/DCmcdc 0.0% 0 / 2 Subroutinesub 63.6% 7 / 11 Podpod 100% 4 / 4 totaltotal 45.0% 32 / 71 CC 7 SCAR 19.3
CC
7
Cov
39%
new
12.0
subtype
12.0
outobjdeep
12.0
CRAP 6.9
« API3/Compat/API2/Basic/PDF/Name.pm ↑ Summary API3/Compat/API2/Resource/ColorSpace/Indexed/ACTFile.pm »
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 <areibens@cpan.org>.
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: XObject.pm,v 2.0 2005/11/16 02:16:04 areibens Exp $
31 #
32 #=======================================================================
33 package PDF::API3::Compat::API2::Resource::XObject;
34
35 1 ▶BEGIN {
Subroutine BEGIN: called CC=1 SCAR=0.0
36
37 1 ▶ use PDF::API3::Compat::API2::Util;
Subroutine BEGIN: called CC=1 SCAR=0.0
38 1 ▶ use PDF::API3::Compat::API2::Basic::PDF::Utils;
Subroutine BEGIN: called CC=1 SCAR=0.0
39 1 ▶ use PDF::API3::Compat::API2::Resource;
Subroutine BEGIN: called CC=1 SCAR=0.0
40
41 1 ▶ use POSIX;
Subroutine BEGIN: called CC=1 SCAR=0.0
42
43 1 ▶ use vars qw(@ISA $VERSION);
Subroutine BEGIN: called CC=1 SCAR=0.0
44
45 1 @ISA = qw( PDF::API3::Compat::API2::Resource );
46
47 1 ( $VERSION ) = sprintf '%i.%03i', split(/\./,('$Revision: 2.0 $' =~ /Revision: (\S+)\s/)[0]); # $Date: 2005/11/16 02:16:04 $
48
49 }
50 1 ▶no warnings qw[ deprecated recursion uninitialized ];
Subroutine BEGIN: called CC=1 SCAR=0.0
51
52 =head1 $res = PDF::API3::Compat::API2::Resource::XObject->new $pdf, $name
53
54 Returns a xobject-resource object.
55
56 =cut
57
58 0 ▶sub new {
Subroutine new: not called CC=3 SCAR=24.8
Pod documented
59 0 my ($class,$pdf,$name) = @_;
60 0 my $self;
61
62 0 ▶ $class = ref $class if ref $class;
Branch: 1 branch
BranchTrueFalseTotal
if ref $class 0 0 0
63
64 0 $self=$class->SUPER::new($pdf,$name);
65 0 ▶ $pdf->new_obj($self) unless($self->is_obj($pdf));
Branch: 1 branch
BranchTrueFalseTotal
unless $self->is_obj($pdf) 0 0 0
66
67 0 $self->{Type}=PDFName('XObject');
68
69 0 $self->{' apipdf'}=$pdf;
70
71 0 return($self);
72 }
73
74 =item $res = PDF::API3::Compat::API2::Resource::XObject->new_api $api, $name
75
76 Returns a xobject resource object. This method is different from 'new' that
77 it needs an PDF::API3::Compat::API2-object rather than a Text::PDF::File-object.
78
79 =cut
80
81 0 ▶sub new_api {
Subroutine new_api: not called CC=1 SCAR=6.9
Pod documented
82 0 my ($class,$api,@opts)=@_;
83
84 0 my $obj=$class->new($api->{pdf},@opts);
85 0 $obj->{' api'}=$api;
86
87 0 return($obj);
88 }
89
90 =item $name = $res->subtype $typename
91
92 Returns or sets the Subtype of the xobject resource.
93
94 =cut
95
96 0 ▶sub subtype {
Subroutine subtype: not called CC=3 SCAR=24.8
Pod documented
97 0 my $self=shift @_;
98 0 ▶ if(scalar @_ >0 && defined($_[0])) {
Branch: 1 branch
BranchTrueFalseTotal
if (scalar @_ > 0 and defined $_[0]) 0 0 0
Condition0%0/3
scalar @_ > 0 and defined $_[0]
!ll&&!rl&&r
000
MC/DC0%0/2
scalar @_ > 0 and defined $_[0]
scalar @_ > 0 defined $_[0]
Truth table0%0/3
A and B
A= scalar @_ > 0B= defined $_[0]
ABresult
0X0
100
111
99 0 $self->{Subtype}=PDFName($_[0]);
100 }
101 0 return($self->{Subtype}->val);
102 }
103
104 0 ▶sub outobjdeep {
Subroutine outobjdeep: not called CC=3 SCAR=24.8
Pod documented
105 0 my ($self, $fh, $pdf, %opts) = @_;
106
107 0 ▶ return $self->SUPER::outobjdeep($fh, $pdf) if defined $opts{'passthru'};
Branch: 1 branch
BranchTrueFalseTotal
if defined $opts{"passthru"} 0 0 0
108 0 foreach my $k (qw/ api apipdf /) {
109 0 $self->{" $k"}=undef;
110 0 delete($self->{" $k"});
111 }
112 0 $self->SUPER::outobjdeep($fh, $pdf, %opts);
113 }
114
115 1 1;
116
117 __END__
« API3/Compat/API2/Basic/PDF/Name.pm ↑ Summary API3/Compat/API2/Resource/ColorSpace/Indexed/ACTFile.pm »