File Coverage

blib/lib/Paper/Specs/base/label.pm
Criterion Covered Total %
statement 9 37 24.3
branch 0 12 0.0
condition 0 6 0.0
subroutine 3 16 18.7
pod 0 13 0.0
total 12 84 14.2


line stmt bran cond sub pod time code
1              
2             package Paper::Specs::base::label;
3 1     1   8 use strict;
  1         2  
  1         41  
4 1     1   5 use base qw(Paper::Specs::base::sheet);
  1         3  
  1         927  
5              
6 1     1   5 use vars qw($VERSION);
  1         2  
  1         611  
7             $VERSION=0.01;
8              
9 0     0 0   sub type { return 'label' }
10              
11             # No unit conversion support yet
12              
13             sub gutter_cols {
14              
15 0     0 0   my $self=shift;
16 0 0         return 0 if $self->label_cols <= 1;
17 0           return ($self->sheet_width - $self->margin_left - $self->margin_right - $self->label_cols * $self->label_width )
18             / ($self->label_cols - 1);
19              
20             }
21              
22             sub gutter_rows {
23              
24 0     0 0   my $self=shift;
25 0 0         return 0 if $self->label_rows <= 1;
26 0           return ($self->sheet_height - $self->margin_top - $self->margin_bottom - $self->label_rows * $self->label_height )
27             / ($self->label_rows - 1);
28              
29             }
30              
31 0     0 0   sub margin_left { Paper::Specs::convert ($_[0]->specs->{'margin_left'} , $_[0]->specs->{'units'}) }
32 0     0 0   sub margin_right { Paper::Specs::convert ($_[0]->specs->{'margin_right'} , $_[0]->specs->{'units'}) }
33 0     0 0   sub margin_top { Paper::Specs::convert ($_[0]->specs->{'margin_top'} , $_[0]->specs->{'units'}) }
34 0     0 0   sub margin_bottom { Paper::Specs::convert ($_[0]->specs->{'margin_bottom'}, $_[0]->specs->{'units'}) }
35              
36 0     0 0   sub label_height { Paper::Specs::convert ($_[0]->specs->{'label_height'}, $_[0]->specs->{'units'}) }
37 0     0 0   sub label_width { Paper::Specs::convert ($_[0]->specs->{'label_width'}, $_[0]->specs->{'units'}) }
38              
39 0     0 0   sub label_rows { $_[0]->specs->{'label_rows'} }
40 0     0 0   sub label_cols { $_[0]->specs->{'label_cols'} }
41              
42              
43             sub label_location {
44              
45 0     0 0   my $self=shift;
46 0           my ($r, $c) = @_;
47              
48 0 0 0       return () if $r > $self->label_rows || $r < 1;
49 0 0 0       return () if $c > $self->label_cols || $c < 1;
50              
51 0           my $pos_row = $self->margin_top + ($self->label_height + $self->gutter_rows) * ( $r - 1 );
52 0           my $pos_col = $self->margin_left + ($self->label_width + $self->gutter_cols) * ( $c - 1 );
53              
54 0 0         if ( Paper::Specs->layout eq 'pdf' ) {
55              
56 0           return ( $pos_col, $self->sheet_height - $pos_row );
57              
58             }
59              
60 0           return ($pos_col, $pos_row);
61              
62              
63             }
64              
65             sub label_size {
66              
67 0     0 0   my $self=shift;
68              
69 0 0         if ( Paper::Specs->layout eq 'pdf' ) {
70 0           return ( $self->label_width, -$self->label_height );
71             } else {
72 0           return ( $self->label_width, $self->label_height );
73             }
74              
75             }
76              
77             1;