blib/lib/PDF/Reuse/Barcode.pm

filter: Statementstmt 35.5% 147 / 413 Branchbran 25.4% 31 / 122 Conditioncond 55.5% 5 / 9 MC/DCmcdc 40.0% 2 / 5 Subroutinesub 56.0% 14 / 25 Podpod 65.0% 13 / 20 totaltotal 35.6% 212 / 594 SCAR 76.0
CC
81
Cov
34%
UPCE
72.0
EAN13
56.0
EAN8
56.0
CRAP 1998.3
↑ Summary
1 package PDF::Reuse::Barcode;
2  
3 2 ▶use 5.006;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 2 ▶use PDF::Reuse;
Subroutine BEGIN: called CC=1 SCAR=0.0
5 2 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
6 2 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
7 2 ▶use Carp;
Subroutine BEGIN: called CC=1 SCAR=0.0
8  
9 2 our $VERSION = '0.10';
10  
11 2 my ($str, $xsize, $ysize, $height, $sPtn, @sizes, $length, $value, %default);
12 2 my $qrcode = 0;
13  
14 # The point size barcode text has always used. The overflow handling below
15 # keys off this so pre-0.10 output stays byte-identical; the two must not
16 # drift apart.
17 2 our $DEFAULT_TEXTSIZE = 10;
18  
19 sub init
20 6 ▶{ %default = ( value => '0000000',
Subroutine init: called CC=1 SCAR=0.0
Pod undocumented
21 x => 0,
22 y => 0,
23 size => 1,
24 xsize => 1,
25 ysize => 1,
26 rotate => 0,
27 background => '1 1 1',
28 graybackground => 1,
29 drawbackground => 1,
30 text => 'yes',
31 prolong => 0,
32 hide_asterisk => 0,
33 modulesize => 1,
34 textsize => $DEFAULT_TEXTSIZE,
35 qr_ecc => 'M',
36 qr_version => 1,
37 qr_padding => 0,
38 mode => 'graphic');
39 6 $str = '';
40 6 $xsize = 1;
41 6 $ysize = 1;
42 6 $height = 37;
43 6 $sPtn = '';
44 6 @sizes = ();
45 6 $length = 0;
46 6 $value = ''
47 }
48  
49  
50 sub general1
51 6 ▶{ $default{'xsize'} = 1 unless ($default{'xsize'} != 0);
Subroutine general1: called CC=5 SCAR=19.4
Pod undocumented
Branch: 1 branch
BranchTrueFalseTotal
unless $default{"xsize"} != 0 0 6 6
52 6 ▶ $default{'ysize'} = 1 unless ($default{'ysize'} != 0);
Branch: 1 branch
BranchTrueFalseTotal
unless $default{"ysize"} != 0 0 6 6
53 6 ▶ $default{'size'} = 1 unless ($default{'size'} != 0);
Branch: 1 branch
BranchTrueFalseTotal
unless $default{"size"} != 0 0 6 6
54 6 $xsize = $default{'xsize'} * $default{'size'};
55 6 $ysize = $default{'ysize'} * $default{'size'};
56 6 $str = "q\n";
57 6 $str .= "$xsize 0 0 $ysize $default{'x'} $default{'y'} cm\n";
58 6 ▶ if ($default{'rotate'} != 0)
Branch: 1 branch
BranchTrueFalseTotal
if ($default{"rotate"} != 0) 0 6 6
59 0 { my $radian = sprintf("%.6f", $default{'rotate'} / 57.2957795); # approx.
60 0 my $Cos = sprintf("%.6f", cos($radian));
61 0 my $Sin = sprintf("%.6f", sin($radian));
62 0 my $negSin = $Sin * -1;
63 0 $str .= "$Cos $Sin $negSin $Cos 0 0 cm\n";
64 }
65 }
66  
67 sub general2
68 6 ▶{ if ($qrcode)
Subroutine general2: called CC=8 SCAR=22.9
Pod undocumented
Branch: 1 branch
BranchTrueFalseTotal
if ($qrcode) { } 2 4 6
69 2 { my $m = $default{'modulesize'};
70 2 my @rows = split(/\n/, $sPtn);
71 2 $length = length($rows[0]) * $m;
72 2 $height = (1 + scalar(@rows)) * $m;
73 2 my $step = 1;
74  
75 2 ▶ if ($default{'drawbackground'})
Branch: 1 branch
BranchTrueFalseTotal
if ($default{"drawbackground"}) 1 1 2
76 1 { $str .= "$default{'graybackground'} g\n";
77 1 $str .= "0 0 $length $height re\n";
78 1 $str .= 'f*' . "\n";
79 1 $str .= "0 g\n";
80 }
81 2 prAdd($str);
82  
83 2 @sizes = prFontSize(12);
84  
85 2 $str = Qr( 0, $step, $sPtn);
86 }
87 else
88 4 { $length = 20 + (length($sPtn) * 0.9);
89 4 my $height = 38;
90 4 my $step = 9;
91 4 my $prolong = 0;
92 4 ▶ if ($default{'prolong'} > 1)
Branch: 1 branch
BranchTrueFalseTotal
if ($default{"prolong"} > 1) 0 4 4
93 0 { $prolong = $default{'prolong'};
94 0 $height = 26 + ($prolong * 12);
95 }
96 4 ▶ if ($default{'drawbackground'})
Branch: 1 branch
BranchTrueFalseTotal
if ($default{"drawbackground"}) 4 0 4
97 4 { $str .= "$default{'background'} rg\n";
98 4 $str .= "0 0 $length $height re\n";
99 4 $str .= 'f*' . "\n";
100 4 $str .= "0 0 0 rg\n";
101 }
102  
103 4 prAdd($str);
104  
105 4 @sizes = prFontSize(12);
106  
107 4 $str = Bar( 10, $step, $sPtn);
108  
109 4 $prolong--;
110  
111 4 ▶ if ($prolong > 0)
Branch: 1 branch
BranchTrueFalseTotal
if ($prolong > 0) 0 4 4
112 0 { $sPtn =~ s/G/1/go;
113 0 ▶ while ($prolong > 0)
Branch: 1 branch
BranchTrueFalseTotal
if ($prolong > 0) 0 0 0
114 0 ▶ { if ($prolong > 1)
Branch: 1 branch
BranchTrueFalseTotal
if ($prolong > 1) { } 0 0 0
115 0 { $prolong--;
116 0 $step += 12;
117 }
118 else
119 0 { $step += (12 * $prolong);
120 0 $prolong = 0;
121 }
122 0 $str .= Bar( 10, $step, $sPtn);
123 }
124 }
125 }
126  
127 6 $str .= "B\n";
128 6 prAdd($str);
129  
130 }
131  
132  
133 sub general3
134 6 ▶{ $str = "Q\n";
Subroutine general3: called CC=1 SCAR=0.0
Pod undocumented
135 6 prAdd($str);
136 6 prFontSize($sizes[1]);
137 }
138  
139 sub standardEnd
140 6 ▶{ general2();
Subroutine standardEnd: called CC=11 SCAR=25.0
Pod undocumented
141  
142 6 ▶ if ($default{'text'})
Branch: 1 branch
BranchTrueFalseTotal
if ($default{"text"}) 5 1 6
143 5 { my @vec = prFont('C');
144 # textsize reaches a PDF text operator directly, so a non-numeric
145 # or non-positive value would emit an invalid or invisible Tf
146 # rather than failing anywhere useful.
147 5 my $textsize = $default{'textsize'};
148 5 ▶ unless (defined $textsize && $textsize =~ /^\d*\.?\d+$/ && $textsize > 0)
Branch: 1 branch
BranchTrueFalseTotal
unless (defined $textsize and $textsize =~ /^\d*\.?\d+$/ and $textsize > 0) 0 5 5
Condition33%2/6
defined $textsize and $textsize =~ /^\d*\.?\d+$/ and $textsize > 0
!ll&&!rl&&r
005
defined $textsize and $textsize =~ /^\d*\.?\d+$/
!ll&&!rl&&r
005
MC/DC0%0/3
defined $textsize and $textsize =~ /^\d*\.?\d+$/ and $textsize > 0
defined $textsize $textsize =~ /^\d*\.?\d+$/ $textsize > 0
Truth table25%1/4
A and B and C
A= defined $textsizeB= $textsize =~ /^\d*\.?\d+$/C= $textsize > 0
ABCresult
0XX0
10X0
1100
1111
149 0 ▶ { carp "Ignoring invalid textsize '"
Branch: 1 branch
BranchTrueFalseTotal
defined $textsize ? : 0 0 0
150 . (defined $textsize ? $textsize : 'undef')
151 . "', using $DEFAULT_TEXTSIZE";
152 0 $textsize = $DEFAULT_TEXTSIZE;
153 }
154 5 prFontSize($textsize);
155 # Courier is monospaced at 600/1000 em, so this is the exact
156 # rendered width, not an estimate. At the default size of 10 it
157 # reproduces the constant 6 this replaced.
158 5 my $textLength = length($value) * $textsize * 0.6;
159 5 my $start = ($length - $textLength) / 2;
160 # Text wider than the barcode overflows the background box. That has
161 # always been possible -- a short QR value at the default size
162 # already does it -- so the box is only extended when the caller
163 # asked for a larger size than the default. Extending it
164 # unconditionally would change pre-0.10 output, and clamping would
165 # silently ignore what was asked for.
166 #
167 # Only the two side strips are painted, never the span the barcode
168 # occupies: this runs after general2() has drawn the bars, so a
169 # full-width rectangle here would cover them.
170 5 ▶ if ($textsize > $DEFAULT_TEXTSIZE && $textLength > $length)
Branch: 1 branch
BranchTrueFalseTotal
if ($textsize > $PDF::Reuse::Barcode::DEFAULT_TEXTSIZE and $textLength > $length) 2 3 5
Condition100%3/3
$textsize > $PDF::Reuse::Barcode::DEFAULT_TEXTSIZE and $textLength > $length
!ll&&!rl&&r
212
MC/DC100%2/2
$textsize > $PDF::Reuse::Barcode::DEFAULT_TEXTSIZE and $textLength > $length
$textsize > $PDF::Reuse::Barcode::DEFAULT_TEXTSIZE $textLength > $length
Truth table100%3/3
A and B
A= $textsize > $PDF::Reuse::Barcode::DEFAULT_TEXTSIZEB= $textLength > $length
ABresult
0X0
100
111
171 2 { my $extra = ($textLength - $length) / 2;
172 2 $start = 0 - $extra;
173 2 ▶ if ($default{'drawbackground'})
Branch: 1 branch
BranchTrueFalseTotal
if ($default{"drawbackground"}) 1 1 2
174 { my ($colour, $op) = $qrcode
175 ? ($default{'graybackground'}, 'g')
176 1 ▶ : ($default{'background'}, 'rg');
Branch: 1 branch
BranchTrueFalseTotal
$qrcode ? : 1 0 1
177 1 prAdd(sprintf("q %s %s %s 0 %s %s re f* %s 0 %s %s re f* Q\n",
178 $colour, $op,
179 -$extra, $extra, $height,
180 $length, $extra, $height));
181 }
182 }
183 5 ▶ if ($qrcode) {
Branch: 1 branch
BranchTrueFalseTotal
if ($qrcode) { } 2 3 5
184 2 my $quiet = sprintf("%.2f", 4 * $default{'modulesize'});
185 2 prText($start, 0-$quiet, $value);
186 }
187 else {
188 3 prText($start, 1.5, $value);
189 }
190 5 prFont($vec[3]);
191 }
192 6 general3();
193  
194 6 1;
195 }
196  
197 sub Bar
198 4 ▶{ my ($x, $y, $pattern) = @_;
Subroutine Bar: called CC=4 SCAR=14.0
Pod undocumented
199 4 my $yEnd = $y + 20;
200 4 my $yG = $y - 3;
201  
202 4 my $string = "0.92 w\n 0 0 0 RG\n";
203 4 for (split(//, $pattern))
204 576 ▶ { if ($_ eq '1')
Branch: 2 branches
BranchTrueFalseTotal
if ($_ eq '1') { } 324 252 576
elsif ($_ eq 'G') { } 0 252 252
205 324 { $string .= "$x $yEnd m\n $x $y l\n";
206 }
207 elsif($_ eq 'G')
208 0 { $string .= "$x $yEnd m\n $x $yG l\n";
209 }
210 576 $x = sprintf("%.2f", $x + 0.91);
211 }
212 4 return $string;
213 }
214  
215  
216 sub Qr
217 2 ▶{ my ($x, $y, $pattern) = @_;
Subroutine Qr: called CC=4 SCAR=13.9
Pod undocumented
218 2 my $xStart = sprintf("%.2f", $x);
219  
220 2 my $m = $default{'modulesize'};
221 2 my $s = $default{'qr_padding'};
222 2 my $space = sprintf('%.2f', $m + $s);#
223  
224 2 my $string = "0.01 w\n 0 G\n";
225 2 my @rows = split(/\n/, $pattern);
226 2 for my $row (reverse @rows) {
227 58 my $yEnd = sprintf("%.2f", $y + $m);
228 58 for (split(//, $row))
229 1682 { my $xEnd = sprintf("%.2f", $x + $m);
230 1682 ▶ if ($_ eq '1')
Branch: 1 branch
BranchTrueFalseTotal
if ($_ eq 1) 460 1222 1682
231 460 { $string .= "$x $y $m $m re\nf\n";
232 }
233 1682 $x = sprintf("%.2f", $x + $space);
234 }
235 58 $x = $xStart;
236 58 $y = sprintf("%.2f", $y + $space);
237 }
238 2 return $string;
239 }
240  
241 sub Code128
242 0 ▶{ eval 'require Barcode::Code128';
Subroutine Code128: not called CC=4 SCAR=30.0
Pod documented
243 0 init();
244 0 my %param = @_;
245 0 for (keys %param)
246 0 { my $lc = lc($_);
247 0 ▶ if (exists $default{$lc})
Branch: 1 branch
BranchTrueFalseTotal
if (exists $default{$lc}) { } 0 0 0
248 0 { $default{$lc} = $param{$_};
249 }
250 else
251 0 { print STDERR "Unknown parameter $_ , not used \n";
252 }
253 }
254 0 $value = $default{'value'};
255  
256 0 general1();
257  
258 0 my $oGDBar = Barcode::Code128->new();
259 0 ▶ if (! $oGDBar)
Branch: 1 branch
BranchTrueFalseTotal
if (not $oGDBar) { } 0 0 0
260 0 { die "The translation of $value to barcodes didn't succeed, aborts\n";
261 }
262 else
263 {
264 0 $sPtn = $oGDBar->barcode($value);
265 0 $sPtn =~ tr/#/1/;
266 0 $sPtn =~ tr/ /0/;
267 }
268 0 standardEnd();
269 0 1;
270 }
271  
272  
273 sub Code39
274 4 ▶{ eval 'require GD::Barcode::Code39';
Subroutine Code39: called CC=5 SCAR=17.1
Pod documented
275 4 init();
276 4 my %param = @_;
277 4 for (keys %param)
278 16 { my $lc = lc($_);
279 16 ▶ if (exists $default{$lc})
Branch: 1 branch
BranchTrueFalseTotal
if (exists $default{$lc}) { } 16 0 16
280 16 { $default{$lc} = $param{$_};
281 }
282 else
283 0 { print STDERR "Unknown parameter $_ , not used \n";
284 }
285 }
286 4 $value = $default{'value'};
287  
288 4 general1();
289  
290 4 my $oGDBar = GD::Barcode::Code39->new($value);
291 4 ▶ if (! $oGDBar)
Branch: 1 branch
BranchTrueFalseTotal
if (not $oGDBar) { } 0 4 4
292 0 { die "$GD::Barcode::Code39::errStr\n";
293 }
294 else
295 4 { $sPtn = $oGDBar->barcode();
296 }
297 4 ▶ if ($default{hide_asterisk})
Branch: 1 branch
BranchTrueFalseTotal
if ($default{"hide_asterisk"}) 0 4 4
298 0 { $value =~ s/^\*//;
299 0 $value =~ s/\*$//;
300 }
301 4 standardEnd();
302 4 1;
303 }
304  
305 sub COOP2of5
306 0 ▶{ eval 'require GD::Barcode::COOP2of5';
Subroutine COOP2of5: not called CC=4 SCAR=30.0
Pod documented
307 0 init();
308 0 my %param = @_;
309 0 for (keys %param)
310 0 { my $lc = lc($_);
311 0 ▶ if (exists $default{$lc})
Branch: 1 branch
BranchTrueFalseTotal
if (exists $default{$lc}) { } 0 0 0
312 0 { $default{$lc} = $param{$_};
313 }
314 else
315 0 { print STDERR "Unknown parameter $_ , not used \n";
316 }
317 }
318 0 $value = $default{'value'};
319  
320 0 general1();
321  
322 0 my $oGDBar = GD::Barcode::COOP2of5->new($value);
323 0 ▶ if (! $oGDBar)
Branch: 1 branch
BranchTrueFalseTotal
if (not $oGDBar) { } 0 0 0
324 0 { die "$GD::Barcode::COOP2of5::errStr\n";
325 }
326 else
327 0 { $sPtn = $oGDBar->barcode();
328 }
329  
330 0 standardEnd();
331 0 1;
332 }
333  
334 sub IATA2of5
335 0 ▶{ eval 'require GD::Barcode::IATA2of5';
Subroutine IATA2of5: not called CC=4 SCAR=30.0
Pod documented
336 0 init();
337 0 my %param = @_;
338 0 for (keys %param)
339 0 { my $lc = lc($_);
340 0 ▶ if (exists $default{$lc})
Branch: 1 branch
BranchTrueFalseTotal
if (exists $default{$lc}) { } 0 0 0
341 0 { $default{$lc} = $param{$_};
342 }
343 else
344 0 { print STDERR "Unknown parameter $_ , not used \n";
345 }
346 }
347 0 $value = $default{'value'};
348  
349 0 general1();
350  
351 0 my $oGDBar = GD::Barcode::IATA2of5->new($value);
352 0 ▶ if (! $oGDBar)
Branch: 1 branch
BranchTrueFalseTotal
if (not $oGDBar) { } 0 0 0
353 0 { die "$GD::Barcode::IATA2of5::errStr\n";
354 }
355 else
356 0 { $sPtn = $oGDBar->barcode();
357 }
358  
359 0 standardEnd();
360 0 1;
361  
362 }
363  
364 sub Industrial2of5
365 0 ▶{ eval 'require GD::Barcode::Industrial2of5';
Subroutine Industrial2of5: not called CC=4 SCAR=30.0
Pod documented
366 0 init();
367 0 my %param = @_;
368 0 for (keys %param)
369 0 { my $lc = lc($_);
370 0 ▶ if (exists $default{$lc})
Branch: 1 branch
BranchTrueFalseTotal
if (exists $default{$lc}) { } 0 0 0
371 0 { $default{$lc} = $param{$_};
372 }
373 else
374 0 { print STDERR "Unknown parameter $_ , not used \n";
375 }
376 }
377 0 $value = $default{'value'};
378  
379 0 general1();
380  
381 0 my $oGDBar = GD::Barcode::Industrial2of5->new($value);
382 0 ▶ if (! $oGDBar)
Branch: 1 branch
BranchTrueFalseTotal
if (not $oGDBar) { } 0 0 0
383 0 { die "$GD::Barcode::Industrial2of5::errStr\n";
384 }
385 else
386 0 { $sPtn = $oGDBar->barcode();
387 }
388  
389 0 standardEnd();
390 0 1;
391 }
392  
393 sub Matrix2of5
394 0 ▶{ eval 'require GD::Barcode::Matrix2of5';
Subroutine Matrix2of5: not called CC=4 SCAR=30.0
Pod documented
395 0 init();
396 0 my %param = @_;
397 0 for (keys %param)
398 0 { my $lc = lc($_);
399 0 ▶ if (exists $default{$lc})
Branch: 1 branch
BranchTrueFalseTotal
if (exists $default{$lc}) { } 0 0 0
400 0 { $default{$lc} = $param{$_};
401 }
402 else
403 0 { print STDERR "Unknown parameter $_ , not used \n";
404 }
405 }
406 0 $value = $default{'value'};
407  
408 0 general1();
409  
410 0 my $oGDBar = GD::Barcode::Matrix2of5->new($value);
411 0 ▶ if (! $oGDBar)
Branch: 1 branch
BranchTrueFalseTotal
if (not $oGDBar) { } 0 0 0
412 0 { die "$GD::Barcode::Matrix2of5::errStr\n";
413 }
414 else
415 0 { $sPtn = $oGDBar->barcode();
416 }
417  
418 0 standardEnd();
419 0 1;
420 }
421  
422 sub NW7
423 0 ▶{ eval 'require GD::Barcode::NW7';
Subroutine NW7: not called CC=4 SCAR=30.0
Pod documented
424 0 init();
425 0 my %param = @_;
426 0 for (keys %param)
427 0 { my $lc = lc($_);
428 0 ▶ if (exists $default{$lc})
Branch: 1 branch
BranchTrueFalseTotal
if (exists $default{$lc}) { } 0 0 0
429 0 { $default{$lc} = $param{$_};
430 }
431 else
432 0 { print STDERR "Unknown parameter $_ , not used \n";
433 }
434 }
435 0 $value = $default{'value'};
436  
437 0 general1();
438  
439 0 my $oGDBar = GD::Barcode::NW7->new($value);
440 0 ▶ if (! $oGDBar)
Branch: 1 branch
BranchTrueFalseTotal
if (not $oGDBar) { } 0 0 0
441 0 { die "$GD::Barcode::NW7::errStr\n";
442 }
443 else
444 0 { $sPtn = $oGDBar->barcode();
445 }
446  
447 0 standardEnd();
448 0 1;
449 }
450  
451  
452  
453 sub EAN13
454 0 ▶{ eval 'require GD::Barcode::EAN13';
Subroutine EAN13: not called CC=7 SCAR=40.3
Pod documented
455 0 init();
456 0 my %param = @_;
457 0 for (keys %param)
458 0 { my $lc = lc($_);
459 0 ▶ if (exists $default{$lc})
Branch: 1 branch
BranchTrueFalseTotal
if (exists $default{$lc}) { } 0 0 0
460 0 { $default{$lc} = $param{$_};
461 }
462 else
463 0 { print STDERR "Unknown parameter $_ , not used \n";
464 }
465 }
466 0 $value = $default{'value'};
467  
468 0 general1();
469  
470 0 ▶ if ($value =~ m'([^0-9]+)'o)
Branch: 1 branch
BranchTrueFalseTotal
if ($value =~ /([^0-9]+)/o) 0 0 0
471 0 { die "Invalid character $1, aborts\n";
472 }
473  
474 0 ▶ if (length($value) == 12)
Branch: 1 branch
BranchTrueFalseTotal
if (length $value == 12) 0 0 0
475 0 { $value .= GD::Barcode::EAN13::calcEAN13CD($value);
476 }
477 0 my $oGDBar = GD::Barcode::EAN13->new($value);
478 0 ▶ if (! $oGDBar)
Branch: 1 branch
BranchTrueFalseTotal
if (not $oGDBar) { } 0 0 0
479 0 { die "$GD::Barcode::EAN13::errStr\n";
480 }
481 else
482 0 { $sPtn = $oGDBar->barcode();
483 }
484 0 general2();
485  
486 0 ▶ if ($default{'text'})
Branch: 1 branch
BranchTrueFalseTotal
if ($default{"text"}) 0 0 0
487 0 { my $siffra = substr($value, 0, 1);
488 0 my $del1 = substr($value, 1, 6);
489 0 my $del2 = substr($value, 7, 6);
490  
491 0 my @vec = prFont('C');
492  
493 0 prFontSize(10);
494  
495 0 prText(1, 2, $siffra);
496 0 prText(14, 2, $del1);
497 0 prText(56, 2, $del2);
498  
499 0 prFont($vec[3]);
500 }
501 0 general3;
502 0 1;
503 }
504  
505 sub EAN8
506 0 ▶{ eval 'require GD::Barcode::EAN8';
Subroutine EAN8: not called CC=7 SCAR=40.3
Pod documented
507 0 init();
508 0 my %param = @_;
509 0 for (keys %param)
510 0 { my $lc = lc($_);
511 0 ▶ if (exists $default{$lc})
Branch: 1 branch
BranchTrueFalseTotal
if (exists $default{$lc}) { } 0 0 0
512 0 { $default{$lc} = $param{$_};
513 }
514 else
515 0 { print STDERR "Unknown parameter $_ , not used \n";
516 }
517 }
518 0 $value = $default{'value'};
519  
520 0 general1();
521  
522 0 ▶ if ($value =~ m'([^0-9]+)'o)
Branch: 1 branch
BranchTrueFalseTotal
if ($value =~ /([^0-9]+)/o) 0 0 0
523 0 { die "Invalid character $1, aborts\n";
524 }
525  
526 0 ▶ if (length($value) == 7)
Branch: 1 branch
BranchTrueFalseTotal
if (length $value == 7) 0 0 0
527 0 { $value .= GD::Barcode::EAN8::calcEAN8CD($value);
528 }
529 0 my $oGDBar = GD::Barcode::EAN8->new($value);
530 0 ▶ if (! $oGDBar)
Branch: 1 branch
BranchTrueFalseTotal
if (not $oGDBar) { } 0 0 0
531 0 { die "$GD::Barcode::EAN8::errStr\n";
532 }
533 else
534 0 { $sPtn = $oGDBar->barcode();
535 }
536 0 general2();
537  
538 0 ▶ if ($default{'text'})
Branch: 1 branch
BranchTrueFalseTotal
if ($default{"text"}) 0 0 0
539 0 { my $del1 = substr($value, 0, 4);
540 0 my $del2 = substr($value, 4, 4);
541 0 my @vec = prFont('C');
542 0 prFontSize(10);
543 0 prText(14, 2, $del1);
544 0 prText(42.5, 2, $del2);
545 0 prFont($vec[3]);
546 }
547 0 general3;
548 0 1;
549 }
550  
551 sub ITF
552 0 ▶{ eval 'require GD::Barcode::ITF';
Subroutine ITF: not called CC=4 SCAR=30.0
Pod documented
553 0 init();
554 0 my %param = @_;
555 0 for (keys %param)
556 0 { my $lc = lc($_);
557 0 ▶ if (exists $default{$lc})
Branch: 1 branch
BranchTrueFalseTotal
if (exists $default{$lc}) { } 0 0 0
558 0 { $default{$lc} = $param{$_};
559 }
560 else
561 0 { print STDERR "Unknown parameter $_ , not used \n";
562 }
563 }
564 0 $value = $default{'value'};
565  
566 0 general1();
567  
568 0 my $oGDBar = GD::Barcode::ITF->new($value);
569 0 ▶ if (! $oGDBar)
Branch: 1 branch
BranchTrueFalseTotal
if (not $oGDBar) { } 0 0 0
570 0 { die "$GD::Barcode::ITF::errStr\n";
571 }
572 else
573 0 { $sPtn = $oGDBar->barcode();
574 }
575  
576 0 standardEnd();
577 0 1;
578 }
579  
580 sub UPCA
581 0 ▶{ eval 'require GD::Barcode::UPCA';
Subroutine UPCA: not called CC=7 SCAR=40.3
Pod documented
582 0 init();
583 0 my %param = @_;
584 0 for (keys %param)
585 0 { my $lc = lc($_);
586 0 ▶ if (exists $default{$lc})
Branch: 1 branch
BranchTrueFalseTotal
if (exists $default{$lc}) { } 0 0 0
587 0 { $default{$lc} = $param{$_};
588 }
589 else
590 0 { print STDERR "Unknown parameter $_ , not used \n";
591 }
592 }
593 0 $value = $default{'value'};
594  
595 0 general1();
596  
597 0 ▶ if ($value =~ m'([^0-9]+)'o)
Branch: 1 branch
BranchTrueFalseTotal
if ($value =~ /([^0-9]+)/o) 0 0 0
598 0 { die "Invalid character $1, aborts\n";
599 }
600  
601 0 ▶ if (length($value) == 11)
Branch: 1 branch
BranchTrueFalseTotal
if (length $value == 11) 0 0 0
602 0 { $value .= GD::Barcode::UPCA::calcUPCACD($value);
603 }
604 0 my $oGDBar = GD::Barcode::UPCA->new($value);
605 0 ▶ if (! $oGDBar)
Branch: 1 branch
BranchTrueFalseTotal
if (not $oGDBar) { } 0 0 0
606 0 { die "$GD::Barcode::UPCA::errStr\n";
607 }
608 else
609 0 { $sPtn = $oGDBar->barcode();
610 }
611 0 general2();
612  
613 0 ▶ if ($default{'text'})
Branch: 1 branch
BranchTrueFalseTotal
if ($default{"text"}) 0 0 0
614 0 { my $siffra1 = substr($value, 0, 1);
615 0 my $del1 = substr($value, 1, 5);
616 0 my $del2 = substr($value, 6, 5);
617 0 my $siffra2 = substr($value, 11, 1);
618  
619 0 my @vec = prFont('C');
620  
621 0 prFontSize(10);
622  
623 0 prText(2, 2, $siffra1);
624 0 prText(20, 2, $del1);
625 0 prText(56, 2, $del2);
626 0 prText(97, 2, $siffra2);
627  
628 0 prFont($vec[3]);
629 }
630 0 general3;
631 0 1;
632 }
633  
634 sub UPCE
635 0 ▶{ eval 'require GD::Barcode::UPCE';
Subroutine UPCE: not called CC=8 SCAR=42.8
Pod documented
636 0 init();
637 0 my %param = @_;
638 0 for (keys %param)
639 0 { my $lc = lc($_);
640 0 ▶ if (exists $default{$lc})
Branch: 1 branch
BranchTrueFalseTotal
if (exists $default{$lc}) { } 0 0 0
641 0 { $default{$lc} = $param{$_};
642 }
643 else
644 0 { print STDERR "Unknown parameter $_ , not used \n";
645 }
646 }
647 0 $value = $default{'value'};
648  
649 0 general1();
650  
651 0 ▶ if ($value =~ m'([^0-9]+)'o)
Branch: 1 branch
BranchTrueFalseTotal
if ($value =~ /([^0-9]+)/o) 0 0 0
652 0 { die "Invalid character $1, aborts\n";
653 }
654  
655 0 ▶ if (length($value) == 6)
Branch: 2 branches
BranchTrueFalseTotal
if (length $value == 6) { } 0 0 0
elsif (length $value == 7) { } 0 0 0
656 0 { $value = '0' . $value;
657 0 my $cd = GD::Barcode::UPCE::calcUPCECD($value);
658 0 $value .= $cd;
659 }
660 elsif (length($value) == 7)
661 0 { my $cd = GD::Barcode::UPCE::calcUPCECD($value);
662 0 $value .= $cd;
663 }
664 0 my $oGDBar = GD::Barcode::UPCE->new($value);
665 0 ▶ if (! $oGDBar)
Branch: 1 branch
BranchTrueFalseTotal
if (not $oGDBar) { } 0 0 0
666 0 { die "$GD::Barcode::UPCE::errStr\n";
667 }
668 else
669 0 { $sPtn = $oGDBar->barcode();
670 }
671 0 general2();
672  
673 0 ▶ if ($default{'text'})
Branch: 1 branch
BranchTrueFalseTotal
if ($default{"text"}) 0 0 0
674 0 { my $siffra = substr($value, 0, 1);
675 0 my $del1 = substr($value, 1, 6);
676 0 my $del2 = substr($value, 7, 1);
677  
678 0 my @vec = prFont('C');
679  
680 0 prFontSize(10);
681  
682 0 prText(2, 2, $siffra);
683 0 prText(14, 2, $del1);
684 0 prText(58, 2, $del2);
685  
686 0 prFont($vec[3]);
687 }
688 0 general3;
689 0 1;
690 }
691  
692 sub QRcode
693 2 ▶{ eval 'require GD::Barcode::QRcode';
Subroutine QRcode: called CC=4 SCAR=14.1
Pod documented
694 2 $qrcode = 1;
695 2 init();
696 2 my %param = @_;
697 2 for (keys %param)
698 9 { my $lc = lc($_);
699 9 ▶ if (exists $default{$lc})
Branch: 1 branch
BranchTrueFalseTotal
if (exists $default{$lc}) { } 9 0 9
700 9 { $default{$lc} = $param{$_};
701 }
702 else
703 0 { print STDERR "Unknown parameter $_ , not used \n";
704 }
705 }
706 2 $value = $default{'value'};
707  
708 2 general1();
709  
710 2 my $oGDBar = GD::Barcode::QRcode->new($value, {Ecc => $default{'qr_ecc'}, Version=>$default{'qr_version'}, ModuleSize => $default{'size'}});
711 2 ▶ if (! $oGDBar)
Branch: 1 branch
BranchTrueFalseTotal
if (not $oGDBar) { } 0 2 2
712 0 { die "$GD::Barcode::QRcode::errStr\n";
713 }
714 else
715 2 { $sPtn = $oGDBar->barcode();
716 }
717 2 standardEnd();
718 2 1;
719 }
720  
721  
722 2 1;
723  
724  
725 __END__
↑ Summary