| 1 | |||||||||||
| 2 | package PDF::Labels::Layout; | ||||||||||
| 3 | |||||||||||
| 4 | 1 | ▶ | use base qw(PDF::Labels::base); | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 5 | |||||||||||
| 6 | 0 | ▶ | sub _new { | ||||||||
|
Subroutine
_new: not called CC=1 SCAR=6.9
| |||||||||||
| 7 | |||||||||||
| 8 | 0 | my $self=shift; | |||||||||
| 9 | |||||||||||
| 10 | 0 | $self->{'font_default'} = "Helvetica-Bold"; | |||||||||
| 11 | 0 | $self->{'fontsize_default'} = 14; | |||||||||
| 12 | 0 | $self->{'background_image'} = ""; | |||||||||
| 13 | 0 | $self->{'bleed'} = 5; | |||||||||
| 14 | |||||||||||
| 15 | 0 | $self->{'outline'} = 1; | |||||||||
| 16 | 0 | $self->{'outline_colour'} = "#0000000"; | |||||||||
| 17 | 0 | $self->{'outline_width'} = 0.1; | |||||||||
| 18 | 0 | $self->{'outline_cap'} = 1; | |||||||||
| 19 | 0 | $self->{'outline_dash'} = [ 20, 20 ]; | |||||||||
| 20 | |||||||||||
| 21 | 0 | $self->{'align_default'} = "left"; | |||||||||
| 22 | |||||||||||
| 23 | 0 | $self->{'margin_left'} = 18; | |||||||||
| 24 | 0 | $self->{'margin_right'} = 18; | |||||||||
| 25 | 0 | $self->{'margin_top'} = 18; | |||||||||
| 26 | 0 | $self->{'margin_bottom'} = 18; | |||||||||
| 27 | } | ||||||||||
| 28 | |||||||||||
| 29 | 0 | ▶ | sub print { | ||||||||
|
Subroutine
print: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||
| 30 | |||||||||||
| 31 | 0 | my $self=shift; | |||||||||
| 32 | |||||||||||
| 33 | 0 | my %opts=@_; | |||||||||
| 34 | |||||||||||
| 35 | 0 | $self->{'_opts'} = \%opts; | |||||||||
| 36 | 0 | $self->{'_pos'} = $opts{'loc'}; | |||||||||
| 37 | 0 | $self->{'_gfx'} = $opts{'page'}->gfx; | |||||||||
| 38 | 0 | $self->{'_page'} = $opts{'page'}; | |||||||||
| 39 | 0 | $self->{'_data'} = $opts{'data'}; | |||||||||
| 40 | |||||||||||
| 41 | 0 | $self->print_background; | |||||||||
| 42 | 0 | $self->print_outline; | |||||||||
| 43 | |||||||||||
| 44 | } | ||||||||||
| 45 | |||||||||||
| 46 | |||||||||||
| 47 | =item $self->print_background( $x, $y, $h, $w ) | ||||||||||
| 48 | |||||||||||
| 49 | =cut | ||||||||||
| 50 | |||||||||||
| 51 | 0 | ▶ | sub print_background { | ||||||||
|
Subroutine
print_background: not called CC=3 SCAR=24.8
Pod
documented
| |||||||||||
| 52 | |||||||||||
| 53 | 0 | my $self=shift; | |||||||||
| 54 | |||||||||||
| 55 | 0 | eval { $self->{'_bg'}{ $self->background_image } = $self->{'_pdf'}->image( $self->background_image ) } | |||||||||
| 56 | 0 | ▶ | unless $self->{'_bg'}{ $self->background_image }; | ||||||||
|
Branch: 1 branch
| |||||||||||
| 57 | 0 | ▶ | return unless $self->{'_bg'}{ $self->background_image }; | ||||||||
|
Branch: 1 branch
| |||||||||||
| 58 | |||||||||||
| 59 | 0 | my @p = @{$self->{'_pos'}}; | |||||||||
| 60 | |||||||||||
| 61 | 0 | my $bgBleed=$self->{'bleed'}; | |||||||||
| 62 | 0 | $p[0] -= $bgBleed / 2; | |||||||||
| 63 | 0 | $p[1] += $bgBleed / 2; | |||||||||
| 64 | 0 | $p[2] += $bgBleed; | |||||||||
| 65 | 0 | $p[3] -= $bgBleed; | |||||||||
| 66 | |||||||||||
| 67 | 0 | $self->{'_gfx'}->image( $self->{'_bg'}{ $self->background_image }, @p ); | |||||||||
| 68 | |||||||||||
| 69 | } | ||||||||||
| 70 | |||||||||||
| 71 | 0 | ▶ | sub print_outline { | ||||||||
|
Subroutine
print_outline: not called CC=2 SCAR=17.9
Pod
undocumented
| |||||||||||
| 72 | |||||||||||
| 73 | 0 | my $self=shift; | |||||||||
| 74 | 0 | ▶ | return unless $self->outline; | ||||||||
|
Branch: 1 branch
| |||||||||||
| 75 | |||||||||||
| 76 | 0 | my @p = @{$self->{'_pos'}}; | |||||||||
| 77 | |||||||||||
| 78 | 0 | $self->{'_gfx'}->strokecolor( $self->outline_colour); | |||||||||
| 79 | 0 | $self->{'_gfx'}->linewidth( $self->outline_width ); | |||||||||
| 80 | 0 | $self->{'_gfx'}->linecap( $self->outline_cap); | |||||||||
| 81 | 0 | $self->{'_gfx'}->linedash( $self->outline_dash); | |||||||||
| 82 | |||||||||||
| 83 | 0 | $self->{'_gfx'}->rect( @p ); | |||||||||
| 84 | |||||||||||
| 85 | 0 | $self->{'_gfx'}->stroke; | |||||||||
| 86 | 0 | $self->{'_gfx'}->endpath; | |||||||||
| 87 | |||||||||||
| 88 | } | ||||||||||
| 89 | |||||||||||
| 90 | 0 | ▶ | sub font_default { | ||||||||
|
Subroutine
font_default: not called CC=2 SCAR=17.9
Pod
undocumented
| |||||||||||
| 91 | |||||||||||
| 92 | 0 | my $self=shift; | |||||||||
| 93 | 0 | ▶ | if (@_) { | ||||||||
|
Branch: 1 branch
| |||||||||||
| 94 | 0 | $self->{'font_default'}=shift; | |||||||||
| 95 | } | ||||||||||
| 96 | 0 | return $self->{'font_default'}; | |||||||||
| 97 | |||||||||||
| 98 | } | ||||||||||
| 99 | |||||||||||
| 100 | 0 | ▶ | sub fontsize_default { | ||||||||
|
Subroutine
fontsize_default: not called CC=2 SCAR=17.9
Pod
undocumented
| |||||||||||
| 101 | |||||||||||
| 102 | 0 | my $self=shift; | |||||||||
| 103 | 0 | ▶ | if (@_) { | ||||||||
|
Branch: 1 branch
| |||||||||||
| 104 | 0 | $self->{'fontsize_default'}=shift; | |||||||||
| 105 | } | ||||||||||
| 106 | 0 | return $self->{'fontsize_default'}; | |||||||||
| 107 | |||||||||||
| 108 | } | ||||||||||
| 109 | |||||||||||
| 110 | 0 | ▶ | sub background_image { | ||||||||
|
Subroutine
background_image: not called CC=4 SCAR=30.0
Pod
undocumented
| |||||||||||
| 111 | |||||||||||
| 112 | 0 | my $self=shift; | |||||||||
| 113 | |||||||||||
| 114 | 0 | ▶ | if (@_) { | ||||||||
|
Branch: 1 branch
| |||||||||||
| 115 | |||||||||||
| 116 | 0 | $self->{'background_image'}=shift; | |||||||||
| 117 | |||||||||||
| 118 | 0 | ▶ | if ( ! -f $self->{'background_image'} ) { | ||||||||
|
Branch: 1 branch
| |||||||||||
| 119 | 0 | warn "Background image $self->{'background_image'} does not exist\n"; | |||||||||
| 120 | 0 | delete $self->{'background_image'}; | |||||||||
| 121 | } | ||||||||||
| 122 | |||||||||||
| 123 | 0 | ▶ | if ( ! -f $self->{'background_image'} ) { | ||||||||
|
Branch: 1 branch
| |||||||||||
| 124 | 0 | warn "Cannot read background image $self->{'background_image'}\n"; | |||||||||
| 125 | 0 | delete $self->{'background_image'}; | |||||||||
| 126 | } | ||||||||||
| 127 | |||||||||||
| 128 | } | ||||||||||
| 129 | |||||||||||
| 130 | 0 | return $self->{'background_image'}; | |||||||||
| 131 | |||||||||||
| 132 | } | ||||||||||
| 133 | |||||||||||
| 134 | 0 | ▶ | sub outline { | ||||||||
|
Subroutine
outline: not called CC=2 SCAR=17.9
Pod
undocumented
| |||||||||||
| 135 | |||||||||||
| 136 | 0 | my $self=shift; | |||||||||
| 137 | 0 | ▶ | if (@_) { | ||||||||
|
Branch: 1 branch
| |||||||||||
| 138 | 0 | $self->{'outline'}=shift; | |||||||||
| 139 | } | ||||||||||
| 140 | 0 | return $self->{'outline'}; | |||||||||
| 141 | |||||||||||
| 142 | } | ||||||||||
| 143 | |||||||||||
| 144 | 0 | ▶ | sub outline_colour { | ||||||||
|
Subroutine
outline_colour: not called CC=2 SCAR=17.9
Pod
undocumented
| |||||||||||
| 145 | |||||||||||
| 146 | 0 | my $self=shift; | |||||||||
| 147 | 0 | ▶ | if (@_) { | ||||||||
|
Branch: 1 branch
| |||||||||||
| 148 | 0 | $self->{'outline_colour'}=shift; | |||||||||
| 149 | } | ||||||||||
| 150 | 0 | return $self->{'outline_colour'}; | |||||||||
| 151 | |||||||||||
| 152 | } | ||||||||||
| 153 | |||||||||||
| 154 | # 'cause I ain't from the US | ||||||||||
| 155 | 0 | ▶ | sub outline_color { outline_colour( @_ ) } | ||||||||
|
Subroutine
outline_color: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||
| 156 | |||||||||||
| 157 | 0 | ▶ | sub outline_width { | ||||||||
|
Subroutine
outline_width: not called CC=2 SCAR=17.9
Pod
undocumented
| |||||||||||
| 158 | |||||||||||
| 159 | 0 | my $self=shift; | |||||||||
| 160 | 0 | ▶ | if (@_) { | ||||||||
|
Branch: 1 branch
| |||||||||||
| 161 | 0 | $self->{'outline_width'}=shift; | |||||||||
| 162 | } | ||||||||||
| 163 | 0 | return $self->{'outline_width'}; | |||||||||
| 164 | |||||||||||
| 165 | } | ||||||||||
| 166 | |||||||||||
| 167 | 0 | ▶ | sub outline_cap { | ||||||||
|
Subroutine
outline_cap: not called CC=2 SCAR=17.9
Pod
undocumented
| |||||||||||
| 168 | |||||||||||
| 169 | 0 | my $self=shift; | |||||||||
| 170 | 0 | ▶ | if (@_) { | ||||||||
|
Branch: 1 branch
| |||||||||||
| 171 | 0 | $self->{'outline_cap'}=shift; | |||||||||
| 172 | } | ||||||||||
| 173 | 0 | return $self->{'outline_cap'}; | |||||||||
| 174 | |||||||||||
| 175 | } | ||||||||||
| 176 | |||||||||||
| 177 | 0 | ▶ | sub outline_dash { | ||||||||
|
Subroutine
outline_dash: not called CC=2 SCAR=17.9
Pod
undocumented
| |||||||||||
| 178 | |||||||||||
| 179 | 0 | my $self=shift; | |||||||||
| 180 | 0 | ▶ | if (@_) { | ||||||||
|
Branch: 1 branch
| |||||||||||
| 181 | 0 | $self->{'outline_dash'}=[ @_ ]; | |||||||||
| 182 | } | ||||||||||
| 183 | 0 | return @{$self->{'outline_dash'}}; | |||||||||
| 184 | |||||||||||
| 185 | } | ||||||||||
| 186 | |||||||||||
| 187 | 0 | ▶ | sub align_default { | ||||||||
|
Subroutine
align_default: not called CC=2 SCAR=17.9
Pod
undocumented
| |||||||||||
| 188 | |||||||||||
| 189 | 0 | my $self=shift; | |||||||||
| 190 | 0 | ▶ | if (@_) { | ||||||||
|
Branch: 1 branch
| |||||||||||
| 191 | 0 | $self->{'align_default'}=shift; | |||||||||
| 192 | } | ||||||||||
| 193 | 0 | return $self->{'align_default'}; | |||||||||
| 194 | |||||||||||
| 195 | } | ||||||||||
| 196 | |||||||||||
| 197 | 0 | ▶ | sub margin_left { | ||||||||
|
Subroutine
margin_left: not called CC=2 SCAR=17.9
Pod
undocumented
| |||||||||||
| 198 | |||||||||||
| 199 | 0 | my $self=shift; | |||||||||
| 200 | 0 | ▶ | if (@_) { | ||||||||
|
Branch: 1 branch
| |||||||||||
| 201 | 0 | $self->{'margin_left'}=shift; | |||||||||
| 202 | } | ||||||||||
| 203 | 0 | return $self->{'margin_left'}; | |||||||||
| 204 | |||||||||||
| 205 | } | ||||||||||
| 206 | |||||||||||
| 207 | 0 | ▶ | sub margin_right { | ||||||||
|
Subroutine
margin_right: not called CC=2 SCAR=17.9
Pod
undocumented
| |||||||||||
| 208 | |||||||||||
| 209 | 0 | my $self=shift; | |||||||||
| 210 | 0 | ▶ | if (@_) { | ||||||||
|
Branch: 1 branch
| |||||||||||
| 211 | 0 | $self->{'margin_right'}=shift; | |||||||||
| 212 | } | ||||||||||
| 213 | 0 | return $self->{'margin_right'}; | |||||||||
| 214 | |||||||||||
| 215 | } | ||||||||||
| 216 | |||||||||||
| 217 | 0 | ▶ | sub margin_top { | ||||||||
|
Subroutine
margin_top: not called CC=2 SCAR=17.9
Pod
undocumented
| |||||||||||
| 218 | |||||||||||
| 219 | 0 | my $self=shift; | |||||||||
| 220 | 0 | ▶ | if (@_) { | ||||||||
|
Branch: 1 branch
| |||||||||||
| 221 | 0 | $self->{'margin_top'}=shift; | |||||||||
| 222 | } | ||||||||||
| 223 | 0 | return $self->{'margin_top'}; | |||||||||
| 224 | |||||||||||
| 225 | } | ||||||||||
| 226 | |||||||||||
| 227 | 0 | ▶ | sub margin_bottom { | ||||||||
|
Subroutine
margin_bottom: not called CC=2 SCAR=17.9
Pod
undocumented
| |||||||||||
| 228 | |||||||||||
| 229 | 0 | my $self=shift; | |||||||||
| 230 | 0 | ▶ | if (@_) { | ||||||||
|
Branch: 1 branch
| |||||||||||
| 231 | 0 | $self->{'margin_bottom'}=shift; | |||||||||
| 232 | } | ||||||||||
| 233 | 0 | return $self->{'margin_bottom'}; | |||||||||
| 234 | |||||||||||
| 235 | } | ||||||||||
| 236 | |||||||||||
| 237 | 1 | 1; | |||||||||
| 238 | |||||||||||