line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package GD::Barcode::NW7; |
2
|
1
|
|
|
1
|
|
228854
|
use strict; |
|
1
|
|
|
|
|
7
|
|
|
1
|
|
|
|
|
30
|
|
3
|
1
|
|
|
1
|
|
6
|
use warnings; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
24
|
|
4
|
|
|
|
|
|
|
|
5
|
1
|
|
|
1
|
|
393
|
use GD::Barcode; |
|
1
|
|
|
|
|
3
|
|
|
1
|
|
|
|
|
48
|
|
6
|
1
|
|
|
1
|
|
6
|
use parent qw(Exporter); |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
4
|
|
7
|
1
|
|
|
1
|
|
48
|
use vars qw($VERSION @ISA $errStr); |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
623
|
|
8
|
|
|
|
|
|
|
@ISA = qw(GD::Barcode Exporter); |
9
|
|
|
|
|
|
|
our $VERSION = '2.00'; |
10
|
|
|
|
|
|
|
my $nw7Bar = { |
11
|
|
|
|
|
|
|
'0' => '0000011', |
12
|
|
|
|
|
|
|
'1' => '0000110', |
13
|
|
|
|
|
|
|
'2' => '0001001', |
14
|
|
|
|
|
|
|
'3' => '1100000', |
15
|
|
|
|
|
|
|
'4' => '0010010', |
16
|
|
|
|
|
|
|
'5' => '1000010', |
17
|
|
|
|
|
|
|
'6' => '010000ß1', |
18
|
|
|
|
|
|
|
'7' => '0100100', |
19
|
|
|
|
|
|
|
'8' => '0110000', |
20
|
|
|
|
|
|
|
'9' => '1001000', |
21
|
|
|
|
|
|
|
'-' => '0001100', |
22
|
|
|
|
|
|
|
'$' => '0011000', |
23
|
|
|
|
|
|
|
':' => '1000101', |
24
|
|
|
|
|
|
|
'/' => '1010001', |
25
|
|
|
|
|
|
|
'.' => '1010100', |
26
|
|
|
|
|
|
|
'+' => '0010101', |
27
|
|
|
|
|
|
|
'A' => '0011010', |
28
|
|
|
|
|
|
|
'B' => '0101001', |
29
|
|
|
|
|
|
|
'C' => '0001011', |
30
|
|
|
|
|
|
|
'D' => '0001110' |
31
|
|
|
|
|
|
|
}; |
32
|
|
|
|
|
|
|
|
33
|
|
|
|
|
|
|
sub new { |
34
|
1
|
|
|
1
|
1
|
109
|
my ( $sClass, $sTxt ) = @_; |
35
|
1
|
|
|
|
|
11
|
$errStr = ''; |
36
|
1
|
|
|
|
|
3
|
my $oThis = {}; |
37
|
1
|
|
|
|
|
4
|
bless $oThis, $sClass; |
38
|
1
|
50
|
|
|
|
4
|
return if ( $errStr = $oThis->init($sTxt) ); |
39
|
1
|
|
|
|
|
5
|
return $oThis; |
40
|
|
|
|
|
|
|
} |
41
|
|
|
|
|
|
|
|
42
|
|
|
|
|
|
|
sub init { |
43
|
1
|
|
|
1
|
0
|
3
|
my ( $oThis, $sTxt ) = @_; |
44
|
|
|
|
|
|
|
|
45
|
|
|
|
|
|
|
#Check |
46
|
1
|
50
|
|
|
|
5
|
return 'Invalid Characters' if ( $sTxt =~ /[^0-9\-\$:\/.+ABCD]/ ); |
47
|
|
|
|
|
|
|
|
48
|
|
|
|
|
|
|
#CalcCd |
49
|
1
|
|
|
|
|
11
|
$oThis->{text} = $sTxt; |
50
|
1
|
|
|
|
|
4
|
return ''; |
51
|
|
|
|
|
|
|
} |
52
|
|
|
|
|
|
|
|
53
|
|
|
|
|
|
|
sub barcode { |
54
|
1
|
|
|
1
|
1
|
3
|
my ($oThis) = @_; |
55
|
|
|
|
|
|
|
|
56
|
1
|
|
|
|
|
2
|
my $sTxt = $oThis->{text}; |
57
|
1
|
|
|
|
|
2
|
my $sRes = ''; |
58
|
1
|
|
|
|
|
5
|
foreach my $sWk ( split( //, $sTxt ) ) { |
59
|
9
|
|
|
|
|
28
|
$sRes .= GD::Barcode::dumpCode( $nw7Bar->{$sWk} . '0' ); |
60
|
|
|
|
|
|
|
} |
61
|
1
|
|
|
|
|
6
|
return $sRes; |
62
|
|
|
|
|
|
|
} |
63
|
|
|
|
|
|
|
|
64
|
|
|
|
|
|
|
sub plot { |
65
|
0
|
|
|
0
|
1
|
|
my ( $oThis, %hParam ) = @_; |
66
|
|
|
|
|
|
|
|
67
|
0
|
|
|
|
|
|
my $sTxt = $oThis->{text}; |
68
|
0
|
|
|
|
|
|
my $sPtn = $oThis->barcode(); |
69
|
|
|
|
|
|
|
|
70
|
|
|
|
|
|
|
#Create Image |
71
|
0
|
0
|
|
|
|
|
my $iHeight = ( $hParam{Height} ) ? $hParam{Height} : 50; |
72
|
0
|
|
|
|
|
|
my ( $oGd, $cBlack ); |
73
|
0
|
0
|
|
|
|
|
if ( $hParam{NoText} ) { |
74
|
0
|
|
|
|
|
|
( $oGd, $cBlack ) = |
75
|
|
|
|
|
|
|
GD::Barcode::plot( $sPtn, length($sPtn), $iHeight, 0, 0 ); |
76
|
|
|
|
|
|
|
} |
77
|
|
|
|
|
|
|
else { |
78
|
0
|
|
|
|
|
|
my ( $fW, $fH ) = ( GD::Font->Small->width, GD::Font->Small->height ); |
79
|
0
|
|
|
|
|
|
my $iWidth = length($sPtn); |
80
|
|
|
|
|
|
|
|
81
|
|
|
|
|
|
|
#Bar Image |
82
|
0
|
|
|
|
|
|
( $oGd, $cBlack ) = |
83
|
|
|
|
|
|
|
GD::Barcode::plot( $sPtn, $iWidth, $iHeight, $fH, 0 ); |
84
|
|
|
|
|
|
|
|
85
|
|
|
|
|
|
|
#String |
86
|
0
|
|
|
|
|
|
$oGd->string( |
87
|
|
|
|
|
|
|
GD::Font->Small, |
88
|
|
|
|
|
|
|
( length($sPtn) - $fW * ( length($sTxt) ) ) / 2, |
89
|
|
|
|
|
|
|
$iHeight - $fH, |
90
|
|
|
|
|
|
|
$sTxt, $cBlack |
91
|
|
|
|
|
|
|
); |
92
|
|
|
|
|
|
|
} |
93
|
0
|
|
|
|
|
|
return $oGd; |
94
|
|
|
|
|
|
|
} |
95
|
|
|
|
|
|
|
1; |
96
|
|
|
|
|
|
|
|
97
|
|
|
|
|
|
|
__END__ |