API3/Compat/API2/Resource/XObject/Form/BarCode/int2of5.pm

filter: Statementstmt 45.8% 22 / 48 Branchbran 0.0% 0 / 8 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 77.7% 7 / 9 Podpod 50.0% 1 / 2 totaltotal 44.7% 30 / 67 CC 5 SCAR 20.3
CC
5
Cov
39%
encode
20.0
new
6.0
BEGIN
1.0
CRAP 7.6
« API3/Compat/API2/Resource/ColorSpace.pm ↑ Summary API3/Compat/API2/Basic/PDF/Name.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: int2of5.pm,v 2.0 2005/11/16 02:18:23 areibens Exp $
31 #
32 #=======================================================================
33 package PDF::API3::Compat::API2::Resource::XObject::Form::BarCode::int2of5;
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::XObject::Form::BarCode;
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::XObject::Form::BarCode );
46
47 1 ( $VERSION ) = sprintf '%i.%03i', split(/\./,('$Revision: 2.0 $' =~ /Revision: (\S+)\s/)[0]); # $Date: 2005/11/16 02:18:23 $
48
49 }
50 1 ▶no warnings qw[ deprecated recursion uninitialized ];
Subroutine BEGIN: called CC=1 SCAR=0.0
51
52 =item $res = PDF::API3::Compat::API2::Resource::XObject::Form::BarCode::int2of5->new $pdf
53
54 Returns a 2of5int object.
55
56 =cut
57
58 0 ▶sub new {
Subroutine new: not called CC=2 SCAR=17.9
Pod documented
59 0 my ($class,$pdf,%opts) = @_;
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,%opts);
65
66 0 my @bar = $self->encode($opts{-code});
67
68 0 $self->drawbar([@bar]);
69
70 0 return($self);
71 }
72
73
74 1 my @bar25interleaved=qw(
75 11221
76 21112
77 12112
78 22111
79 11212
80 21211
81 12211
82 11122
83 21121
84 12121
85 );
86
87 0 ▶sub encode {
Subroutine encode: not called CC=4 SCAR=30.0
Pod undocumented
88 0 my $self=shift @_;
89 0 my $string=shift @_;
90 0 $string=~ tr/0123456789//cd;
91 0 my ($enc,@bar);
92
93 0 push(@bar,'aaaa');
94 0 ▶ while(length($string)>0)
Branch: 1 branch
BranchTrueFalseTotal
if (length $string > 0) 0 0 0
95 {
96 0 $string=~ s/^(\d{1,1})(\d{0,1})(\d*?)$/$3/;
97 0 $c1=$1;
98 0 $c2=$2;
99 0 ▶ $c2='0' if ($c2 eq "");
Branch: 1 branch
BranchTrueFalseTotal
if $c2 eq "" 0 0 0
100 0 $s1=$bar25interleaved[$c1];
101 0 $s2=$bar25interleaved[$c2];
102 0 $o='';
103 0 ▶ for($cnt=0;$cnt<5;$cnt++)
Branch: 1 branch
BranchTrueFalseTotal
if ($cnt < 5) 0 0 0
104 {
105 0 $o.=substr($s1,$cnt,1);
106 0 $o.=substr($s2,$cnt,1);
107 }
108 0 push(@bar,[$o,($c1 . $c2)]);
109 }
110 0 push(@bar,'baaa');
111 0 return(@bar);
112 }
113
114 1 1;
115
116 __END__
« API3/Compat/API2/Resource/ColorSpace.pm ↑ Summary API3/Compat/API2/Basic/PDF/Name.pm »