| 1 | package Business::ReportWriter::Pdf; | ||||||||||||||||||||||||||||
| 2 | |||||||||||||||||||||||||||||
| 3 | 2 | ▶ | use strict; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 4 | 2 | ▶ | use POSIX qw(setlocale LC_NUMERIC); | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 5 | 2 | ▶ | use utf8; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 6 | |||||||||||||||||||||||||||||
| 7 | 2 | ▶ | use base 'Business::ReportWriter'; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 8 | |||||||||||||||||||||||||||||
| 9 | 0 | ▶ | sub init_fields { | ||||||||||||||||||||||||||
|
Subroutine
init_fields: not called CC=5 SCAR=34.0
Pod
undocumented
| |||||||||||||||||||||||||||||
| 10 | 0 | my ( $self, $parms ) = @_; | |||||||||||||||||||||||||||
| 11 | |||||||||||||||||||||||||||||
| 12 | 0 | $self->SUPER::fields($parms); | |||||||||||||||||||||||||||
| 13 | 0 | ▶ | my @fields = @$parms if $parms; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 14 | |||||||||||||||||||||||||||||
| 15 | # Find maximum line height | ||||||||||||||||||||||||||||
| 16 | 0 | $self->{font}{maxheight} = 8; | |||||||||||||||||||||||||||
| 17 | 0 | for ( 0 .. $#{ $self->{report}{fields} } ) { | |||||||||||||||||||||||||||
| 18 | 0 | $self->{fields}{ $fields[$_]{name} } = $_; | |||||||||||||||||||||||||||
| 19 | 0 | ▶ | if ( defined( $fields[$_]{font}{size} ) | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
defined $fields[$_]{"font"}{"size"} and $fields[$_]{"font"}{"size"} > $self->{"font"}{"_maxheight"}
MC/DC0%0/2
defined $fields[$_]{"font"}{"size"} and $fields[$_]{"font"}{"size"} > $self->{"font"}{"_maxheight"}
defined $fields[$_]{"font"}{"size"}
$fields[$_]{"font"}{"size"} > $self->{"font"}{"_maxheight"}
Truth table0%0/3
A and B
A= defined $fields[$_]{"font"}{"size"}B= $fields[$_]{"font"}{"size"} > $self->{"font"}{"_maxheight"}
| |||||||||||||||||||||||||||||
| 20 | && $fields[$_]{font}{size} > $self->{font}{_maxheight} ) | ||||||||||||||||||||||||||||
| 21 | { | ||||||||||||||||||||||||||||
| 22 | 0 | $self->{font}{_maxheight} = $fields[$_]{font}{size}; | |||||||||||||||||||||||||||
| 23 | } | ||||||||||||||||||||||||||||
| 24 | } | ||||||||||||||||||||||||||||
| 25 | } | ||||||||||||||||||||||||||||
| 26 | |||||||||||||||||||||||||||||
| 27 | 0 | ▶ | sub init_breaks { | ||||||||||||||||||||||||||
|
Subroutine
init_breaks: not called CC=4 SCAR=30.0
Pod
undocumented
| |||||||||||||||||||||||||||||
| 28 | 0 | my ( $self, $parms ) = @_; | |||||||||||||||||||||||||||
| 29 | |||||||||||||||||||||||||||||
| 30 | 0 | $self->SUPER::breaks($parms); | |||||||||||||||||||||||||||
| 31 | |||||||||||||||||||||||||||||
| 32 | # Find total break height | ||||||||||||||||||||||||||||
| 33 | 0 | $| = 1; | |||||||||||||||||||||||||||
| 34 | |||||||||||||||||||||||||||||
| 35 | 0 | for ( keys %$parms ) { | |||||||||||||||||||||||||||
| 36 | 0 | ▶ | next if /^_/; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 37 | 0 | my $brk = $parms->{$_}; | |||||||||||||||||||||||||||
| 38 | 0 | ▶ | my $hbs = $brk->{beforespace} || 0; | ||||||||||||||||||||||||||
|
Condition0%0/2
$brk->{'beforespace'} || 0
MC/DC0%0/1
$brk->{'beforespace'} || 0
$brk->{'beforespace'}
Truth table0%0/2
A
A= $brk->{'beforespace'}
| |||||||||||||||||||||||||||||
| 39 | 0 | my $hts = 10; | |||||||||||||||||||||||||||
| 40 | 0 | my $hfhs = 10; | |||||||||||||||||||||||||||
| 41 | 0 | my $ts = 10; | |||||||||||||||||||||||||||
| 42 | |||||||||||||||||||||||||||||
| 43 | # $self->{fields}{$fields[$_]{name}} = $_; | ||||||||||||||||||||||||||||
| 44 | # if (defined($fields[$_]{font}{size}) && | ||||||||||||||||||||||||||||
| 45 | # $fields[$_]{font}{size} > $self->{font}{_maxheight}) { | ||||||||||||||||||||||||||||
| 46 | # $self->{font}{_maxheight} = $fields[$_]{font}{size}; | ||||||||||||||||||||||||||||
| 47 | # } | ||||||||||||||||||||||||||||
| 48 | 0 | $brk->{breakheight} = $hbs + $hts + $hfhs + $ts; | |||||||||||||||||||||||||||
| 49 | } | ||||||||||||||||||||||||||||
| 50 | } | ||||||||||||||||||||||||||||
| 51 | |||||||||||||||||||||||||||||
| 52 | # Routines for report writing | ||||||||||||||||||||||||||||
| 53 | 0 | ▶ | sub calc_yoffset { | ||||||||||||||||||||||||||
|
Subroutine
calc_yoffset: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||
| 54 | 0 | my ( $self, $fontsize ) = @_; | |||||||||||||||||||||||||||
| 55 | |||||||||||||||||||||||||||||
| 56 | 0 | $self->{ypos} -= $fontsize + 2; | |||||||||||||||||||||||||||
| 57 | 0 | $self->check_page; | |||||||||||||||||||||||||||
| 58 | |||||||||||||||||||||||||||||
| 59 | 0 | return $self->{ypos}; | |||||||||||||||||||||||||||
| 60 | } | ||||||||||||||||||||||||||||
| 61 | |||||||||||||||||||||||||||||
| 62 | 0 | ▶ | sub page_footer { | ||||||||||||||||||||||||||
|
Subroutine
page_footer: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||
| 63 | 0 | my ( $self, $fontsize ) = @_; | |||||||||||||||||||||||||||
| 64 | |||||||||||||||||||||||||||||
| 65 | 0 | my $break = '_page'; | |||||||||||||||||||||||||||
| 66 | 0 | $self->{breaks}{$break} = '_break'; | |||||||||||||||||||||||||||
| 67 | 0 | my $text = $self->make_text( 0, $self->{report}{breaks}{$break}{text} ); | |||||||||||||||||||||||||||
| 68 | 0 | $self->{breaktext}{$break} = $text; | |||||||||||||||||||||||||||
| 69 | |||||||||||||||||||||||||||||
| 70 | #$self->print_break(); | ||||||||||||||||||||||||||||
| 71 | 0 | $self->{breaks}{$break} = ""; | |||||||||||||||||||||||||||
| 72 | } | ||||||||||||||||||||||||||||
| 73 | |||||||||||||||||||||||||||||
| 74 | 0 | ▶ | sub header_text { | ||||||||||||||||||||||||||
|
Subroutine
header_text: not called CC=2 SCAR=17.9
Pod
undocumented
| |||||||||||||||||||||||||||||
| 75 | 0 | my $self = shift; | |||||||||||||||||||||||||||
| 76 | |||||||||||||||||||||||||||||
| 77 | 0 | my $page = $self->{pageData}; | |||||||||||||||||||||||||||
| 78 | |||||||||||||||||||||||||||||
| 79 | 0 | for my $th ( @{ $self->{report}{page}{text} } ) { | |||||||||||||||||||||||||||
| 80 | 0 | $self->process_field( $th, $page ); | |||||||||||||||||||||||||||
| 81 | } | ||||||||||||||||||||||||||||
| 82 | } | ||||||||||||||||||||||||||||
| 83 | |||||||||||||||||||||||||||||
| 84 | 0 | ▶ | sub print_pagenumber { | ||||||||||||||||||||||||||
|
Subroutine
print_pagenumber: not called CC=2 SCAR=17.9
Pod
undocumented
| |||||||||||||||||||||||||||||
| 85 | 0 | my $self = shift; | |||||||||||||||||||||||||||
| 86 | |||||||||||||||||||||||||||||
| 87 | 0 | my $page = $self->{report}{page}; | |||||||||||||||||||||||||||
| 88 | |||||||||||||||||||||||||||||
| 89 | 0 | my $text = $page->{number}{text} . $self->{pageData}{pagenr}; | |||||||||||||||||||||||||||
| 90 | 0 | $self->out_field( $text, $page->{number} ); | |||||||||||||||||||||||||||
| 91 | $self->calc_yoffset( $self->{font}{size} ) | ||||||||||||||||||||||||||||
| 92 | 0 | ▶ | unless $page->{number}{sameline}; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 93 | } | ||||||||||||||||||||||||||||
| 94 | |||||||||||||||||||||||||||||
| 95 | 0 | ▶ | sub print_pageheader { | ||||||||||||||||||||||||||
|
Subroutine
print_pageheader: not called CC=2 SCAR=17.9
Pod
undocumented
| |||||||||||||||||||||||||||||
| 96 | 0 | my $self = shift; | |||||||||||||||||||||||||||
| 97 | |||||||||||||||||||||||||||||
| 98 | 0 | my $page = $self->{pageData}; | |||||||||||||||||||||||||||
| 99 | 0 | $self->{ypos} = $self->{paper}{topmargen}; | |||||||||||||||||||||||||||
| 100 | |||||||||||||||||||||||||||||
| 101 | $self->{ypos} -= mm_to_pt( $self->{report}{page}{number}{ypos} ) | ||||||||||||||||||||||||||||
| 102 | 0 | ▶ | if $page->{number}{ypos}; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 103 | |||||||||||||||||||||||||||||
| 104 | 0 | $self->header_text(); | |||||||||||||||||||||||||||
| 105 | 0 | $self->print_pagenumber; | |||||||||||||||||||||||||||
| 106 | } | ||||||||||||||||||||||||||||
| 107 | |||||||||||||||||||||||||||||
| 108 | 0 | ▶ | sub start_body { | ||||||||||||||||||||||||||
|
Subroutine
start_body: not called CC=5 SCAR=34.0
Pod
undocumented
| |||||||||||||||||||||||||||||
| 109 | 0 | my $self = shift; | |||||||||||||||||||||||||||
| 110 | |||||||||||||||||||||||||||||
| 111 | 0 | my $body = $self->{report}{body}; | |||||||||||||||||||||||||||
| 112 | |||||||||||||||||||||||||||||
| 113 | 0 | $self->set_font( $body->{font} ); | |||||||||||||||||||||||||||
| 114 | $self->{ypos} = $self->{paper}{topmargen} - mm_to_pt( $body->{ypos} ) | ||||||||||||||||||||||||||||
| 115 | 0 | ▶ | if $body->{ypos}; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 116 | 0 | ▶ | my $heigth = mm_to_pt( $body->{heigth} ) if $body->{heigth}; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 117 | 0 | ▶ | $heigth += mm_to_pt( $body->{ypos} ) if $body->{ypos}; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 118 | 0 | ▶ | $self->{paper}{heigth} = $heigth if $heigth; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 119 | |||||||||||||||||||||||||||||
| 120 | 0 | $self->make_field_headers( $body->{FieldHeaders} ); | |||||||||||||||||||||||||||
| 121 | |||||||||||||||||||||||||||||
| 122 | 0 | $self->{inHeader} = 0; | |||||||||||||||||||||||||||
| 123 | } | ||||||||||||||||||||||||||||
| 124 | |||||||||||||||||||||||||||||
| 125 | 0 | ▶ | sub draw_graphics { | ||||||||||||||||||||||||||
|
Subroutine
draw_graphics: not called CC=3 SCAR=24.8
Pod
undocumented
| |||||||||||||||||||||||||||||
| 126 | 0 | my $self = shift; | |||||||||||||||||||||||||||
| 127 | |||||||||||||||||||||||||||||
| 128 | 0 | my $p = $self->{pdf}; | |||||||||||||||||||||||||||
| 129 | 0 | my $graphics = $self->{report}{graphics}; | |||||||||||||||||||||||||||
| 130 | $p->set_gfxlinewidth( $graphics->{width} + 0 ) | ||||||||||||||||||||||||||||
| 131 | 0 | ▶ | if defined( $graphics->{width} ); | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 132 | 0 | for ( @{ $graphics->{boxes} } ) { | |||||||||||||||||||||||||||
| 133 | 0 | my $bottomy = $self->{paper}{topmargen} - mm_to_pt( $_->{bottomy} ); | |||||||||||||||||||||||||||
| 134 | 0 | my $topy = $self->{paper}{topmargen} - mm_to_pt( $_->{topy} ); | |||||||||||||||||||||||||||
| 135 | $p->draw_rect( | ||||||||||||||||||||||||||||
| 136 | mm_to_pt( $_->{topx} ), $bottomy, | ||||||||||||||||||||||||||||
| 137 | 0 | mm_to_pt( $_->{bottomx} ), $topy | |||||||||||||||||||||||||||
| 138 | ); | ||||||||||||||||||||||||||||
| 139 | } | ||||||||||||||||||||||||||||
| 140 | } | ||||||||||||||||||||||||||||
| 141 | |||||||||||||||||||||||||||||
| 142 | 0 | ▶ | sub draw_logos { | ||||||||||||||||||||||||||
|
Subroutine
draw_logos: not called CC=2 SCAR=17.9
Pod
undocumented
| |||||||||||||||||||||||||||||
| 143 | 0 | my $self = shift; | |||||||||||||||||||||||||||
| 144 | |||||||||||||||||||||||||||||
| 145 | 0 | my $p = $self->{pdf}; | |||||||||||||||||||||||||||
| 146 | 0 | my $logos = $self->{report}{logo}; | |||||||||||||||||||||||||||
| 147 | 0 | for ( @{ $logos->{logo} } ) { | |||||||||||||||||||||||||||
| 148 | 0 | my $x = mm_to_pt( $_->{x} ); | |||||||||||||||||||||||||||
| 149 | 0 | my $y = $self->{paper}{topmargen} - mm_to_pt( $_->{y} ); | |||||||||||||||||||||||||||
| 150 | 0 | $p->add_img_scaled( $_->{name}, $x, $y, $_->{scale} ); | |||||||||||||||||||||||||||
| 151 | } | ||||||||||||||||||||||||||||
| 152 | } | ||||||||||||||||||||||||||||
| 153 | |||||||||||||||||||||||||||||
| 154 | 0 | ▶ | sub new_page { | ||||||||||||||||||||||||||
|
Subroutine
new_page: not called CC=3 SCAR=24.8
Pod
undocumented
| |||||||||||||||||||||||||||||
| 155 | 0 | my $self = shift; | |||||||||||||||||||||||||||
| 156 | |||||||||||||||||||||||||||||
| 157 | 0 | $self->{inHeader} = 1; | |||||||||||||||||||||||||||
| 158 | 0 | my $p = $self->{pdf}; | |||||||||||||||||||||||||||
| 159 | 0 | $self->{pageData}{pagenr}++; | |||||||||||||||||||||||||||
| 160 | 0 | $self->{breaks}{'_page'} = ""; | |||||||||||||||||||||||||||
| 161 | 0 | ▶ | $self->page_footer() if $self->{pageData}{pagenr} > 1; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 162 | 0 | $self->{ypos} = $self->{paper}{topmargen}; | |||||||||||||||||||||||||||
| 163 | 0 | $p->new_page; | |||||||||||||||||||||||||||
| 164 | 0 | $self->set_font( $self->{report}{page}{font} ); | |||||||||||||||||||||||||||
| 165 | 0 | ▶ | $self->print_pageheader() if defined( $self->{report}{page} ); | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 166 | 0 | $self->start_body(); | |||||||||||||||||||||||||||
| 167 | 0 | $self->draw_graphics(); | |||||||||||||||||||||||||||
| 168 | 0 | $self->draw_logos(); | |||||||||||||||||||||||||||
| 169 | } | ||||||||||||||||||||||||||||
| 170 | |||||||||||||||||||||||||||||
| 171 | 0 | ▶ | sub text_color { | ||||||||||||||||||||||||||
|
Subroutine
text_color: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||
| 172 | 0 | my ( $self, $color ) = @_; | |||||||||||||||||||||||||||
| 173 | |||||||||||||||||||||||||||||
| 174 | 0 | my $p = $self->{pdf}; | |||||||||||||||||||||||||||
| 175 | 0 | $p->set_textcolor($color); | |||||||||||||||||||||||||||
| 176 | } | ||||||||||||||||||||||||||||
| 177 | |||||||||||||||||||||||||||||
| 178 | 0 | ▶ | sub set_linecolor { | ||||||||||||||||||||||||||
|
Subroutine
set_linecolor: not called CC=3 SCAR=24.8
Pod
undocumented
| |||||||||||||||||||||||||||||
| 179 | 0 | my ( $self, $fld_fgcolor ) = @_; | |||||||||||||||||||||||||||
| 180 | |||||||||||||||||||||||||||||
| 181 | my $fgcolor = | ||||||||||||||||||||||||||||
| 182 | $fld_fgcolor | ||||||||||||||||||||||||||||
| 183 | ? $fld_fgcolor | ||||||||||||||||||||||||||||
| 184 | 0 | ▶ | : $self->{report}{textcolor} || 'black'; | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/2
$self->{"report"}{"textcolor"} or "black"
MC/DC0%0/1
$self->{"report"}{"textcolor"} or "black"
$self->{"report"}{"textcolor"}
Truth table0%0/2
A
A= $self->{"report"}{"textcolor"}
| |||||||||||||||||||||||||||||
| 185 | 0 | $self->text_color($fgcolor); | |||||||||||||||||||||||||||
| 186 | } | ||||||||||||||||||||||||||||
| 187 | |||||||||||||||||||||||||||||
| 188 | 0 | ▶ | sub draw_topline { | ||||||||||||||||||||||||||
|
Subroutine
draw_topline: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||
| 189 | 0 | my ($self) = @_; | |||||||||||||||||||||||||||
| 190 | |||||||||||||||||||||||||||||
| 191 | 0 | my $p = $self->{pdf}; | |||||||||||||||||||||||||||
| 192 | 0 | my $width = $self->{paper}{width} - 20; | |||||||||||||||||||||||||||
| 193 | 0 | my $ypos = $self->{ypos} - 3; | |||||||||||||||||||||||||||
| 194 | 0 | $p->draw_line( 10, $ypos, $width, $ypos ); | |||||||||||||||||||||||||||
| 195 | } | ||||||||||||||||||||||||||||
| 196 | |||||||||||||||||||||||||||||
| 197 | 0 | ▶ | sub draw_underline { | ||||||||||||||||||||||||||
|
Subroutine
draw_underline: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||
| 198 | 0 | my ($self) = @_; | |||||||||||||||||||||||||||
| 199 | |||||||||||||||||||||||||||||
| 200 | 0 | my $p = $self->{pdf}; | |||||||||||||||||||||||||||
| 201 | 0 | my $width = $self->{paper}{width} - 20; | |||||||||||||||||||||||||||
| 202 | 0 | my $ypos = $self->{ypos} - $self->{font}{size} - 3; | |||||||||||||||||||||||||||
| 203 | 0 | $p->draw_line( 10, $ypos, $width, $ypos ); | |||||||||||||||||||||||||||
| 204 | } | ||||||||||||||||||||||||||||
| 205 | |||||||||||||||||||||||||||||
| 206 | 0 | ▶ | sub draw_linebox { | ||||||||||||||||||||||||||
|
Subroutine
draw_linebox: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||
| 207 | 0 | my ( $self, $shade ) = @_; | |||||||||||||||||||||||||||
| 208 | |||||||||||||||||||||||||||||
| 209 | 0 | my $p = $self->{pdf}; | |||||||||||||||||||||||||||
| 210 | 0 | my $width = $self->{paper}{width} - 20; | |||||||||||||||||||||||||||
| 211 | 0 | my $ypos = $self->{ypos} - 3; | |||||||||||||||||||||||||||
| 212 | 0 | my $fontsize = $self->{font}{size} + 2; | |||||||||||||||||||||||||||
| 213 | 0 | $p->shade_rect( 10, $ypos, $width, $ypos - $fontsize, $shade ); | |||||||||||||||||||||||||||
| 214 | } | ||||||||||||||||||||||||||||
| 215 | |||||||||||||||||||||||||||||
| 216 | 0 | ▶ | sub begin_break { | ||||||||||||||||||||||||||
|
Subroutine
begin_break: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||
| 217 | 0 | my ( $self, $rec, $fld ) = @_; | |||||||||||||||||||||||||||
| 218 | |||||||||||||||||||||||||||||
| 219 | 0 | $self->check_page( $fld->{breakheight} ); | |||||||||||||||||||||||||||
| 220 | } | ||||||||||||||||||||||||||||
| 221 | |||||||||||||||||||||||||||||
| 222 | 0 | ▶ | sub begin_line { | ||||||||||||||||||||||||||
|
Subroutine
begin_line: not called CC=5 SCAR=34.0
Pod
undocumented
| |||||||||||||||||||||||||||||
| 223 | 0 | my ( $self, $rec, $fld ) = @_; | |||||||||||||||||||||||||||
| 224 | |||||||||||||||||||||||||||||
| 225 | 0 | $self->set_font( $rec->{font} ); | |||||||||||||||||||||||||||
| 226 | 0 | ▶ | $self->calc_yoffset( $fld->{beforespace} ) if $fld->{beforespace}; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 227 | 0 | $self->set_linecolor( $fld->{fgcolor} ); | |||||||||||||||||||||||||||
| 228 | 0 | ▶ | $self->draw_linebox( $fld->{shade} ) if $fld->{shade}; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 229 | 0 | ▶ | $self->draw_topline if $rec->{topline}; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 230 | 0 | ▶ | $self->draw_underline if $rec->{underline}; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 231 | 0 | $self->calc_yoffset( $self->{font}{size} ); | |||||||||||||||||||||||||||
| 232 | } | ||||||||||||||||||||||||||||
| 233 | |||||||||||||||||||||||||||||
| 234 | 0 | ▶ | sub begin_field { | ||||||||||||||||||||||||||
|
Subroutine
begin_field: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||
| 235 | 0 | my ( $self, $field ) = @_; | |||||||||||||||||||||||||||
| 236 | |||||||||||||||||||||||||||||
| 237 | 0 | $self->set_font( $field->{font} ); | |||||||||||||||||||||||||||
| 238 | 0 | my $fontsize = $self->{font}{size}; | |||||||||||||||||||||||||||
| 239 | } | ||||||||||||||||||||||||||||
| 240 | |||||||||||||||||||||||||||||
| 241 | 0 | ▶ | sub out_field { | ||||||||||||||||||||||||||
|
Subroutine
out_field: not called CC=5 SCAR=34.0
Pod
undocumented
| |||||||||||||||||||||||||||||
| 242 | 0 | my ( $self, $text, $field, $alt ) = @_; | |||||||||||||||||||||||||||
| 243 | |||||||||||||||||||||||||||||
| 244 | 0 | ▶ | my $font = $alt->{font} || $field->{font}; | ||||||||||||||||||||||||||
|
Condition0%0/3
$alt->{'font'} || $field->{'font'}
MC/DC0%0/2
$alt->{'font'} || $field->{'font'}
$alt->{'font'}
$field->{'font'}
Truth table0%0/3
A || B
A= $alt->{'font'}B= $field->{'font'}
| |||||||||||||||||||||||||||||
| 245 | 0 | $self->set_font($font); | |||||||||||||||||||||||||||
| 246 | $self->{ypos} = $self->{paper}{topmargen} - mm_to_pt( $field->{ypos} ) | ||||||||||||||||||||||||||||
| 247 | 0 | ▶ | if $field->{ypos}; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 248 | $self->calc_yoffset( $self->{font}{size} ) | ||||||||||||||||||||||||||||
| 249 | 0 | ▶ | if defined( $field->{nl} ) && $text; | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
defined $field->{"nl"} and $text
MC/DC0%0/2
defined $field->{"nl"} and $text
defined $field->{"nl"}
$text
Truth table0%0/3
A and B
A= defined $field->{"nl"}B= $text
| |||||||||||||||||||||||||||||
| 250 | 0 | my $width = mm_to_pt( $field->{width} ); | |||||||||||||||||||||||||||
| 251 | $self->out_text( $text, $field->{xpos}, $self->{ypos}, $field->{align}, | ||||||||||||||||||||||||||||
| 252 | 0 | $width ); | |||||||||||||||||||||||||||
| 253 | |||||||||||||||||||||||||||||
| 254 | } | ||||||||||||||||||||||||||||
| 255 | |||||||||||||||||||||||||||||
| 256 | 0 | ▶ | sub set_font { | ||||||||||||||||||||||||||
|
Subroutine
set_font: not called CC=6 SCAR=37.4
Pod
undocumented
| |||||||||||||||||||||||||||||
| 257 | 0 | my ( $self, $font ) = @_; | |||||||||||||||||||||||||||
| 258 | |||||||||||||||||||||||||||||
| 259 | 0 | my $p = $self->{pdf}; | |||||||||||||||||||||||||||
| 260 | 0 | ▶ | if ( defined($font) ) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 261 | 0 | ▶ | if ( $font->{size} ) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 262 | 0 | my $font_size = $font->{size} + 0; | |||||||||||||||||||||||||||
| 263 | 0 | ▶ | $p->set_size( $font->{size} ) if $self->{font}{size} != $font_size; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 264 | 0 | $self->{font}{size} = $font_size; | |||||||||||||||||||||||||||
| 265 | } | ||||||||||||||||||||||||||||
| 266 | 0 | ▶ | if ( $font->{face} ) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 267 | $p->set_font( $font->{face} ) | ||||||||||||||||||||||||||||
| 268 | 0 | ▶ | if $self->{font}{face} ne $font->{face}; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 269 | 0 | $self->{font}{face} = $font->{face}; | |||||||||||||||||||||||||||
| 270 | } | ||||||||||||||||||||||||||||
| 271 | } | ||||||||||||||||||||||||||||
| 272 | } | ||||||||||||||||||||||||||||
| 273 | |||||||||||||||||||||||||||||
| 274 | 0 | ▶ | sub begin_list { | ||||||||||||||||||||||||||
|
Subroutine
begin_list: not called CC=3 SCAR=24.8
Pod
undocumented
| |||||||||||||||||||||||||||||
| 275 | 0 | my ($self) = @_; | |||||||||||||||||||||||||||
| 276 | |||||||||||||||||||||||||||||
| 277 | 0 | ▶ | my $papersize = $self->{report}{papersize} || 'A4'; | ||||||||||||||||||||||||||
|
Condition0%0/2
$self->{'report'}{'papersize'} || 'A4'
MC/DC0%0/1
$self->{'report'}{'papersize'} || 'A4'
$self->{'report'}{'papersize'}
Truth table0%0/2
A
A= $self->{'report'}{'papersize'}
| |||||||||||||||||||||||||||||
| 278 | 0 | ▶ | my $orientation = $self->{report}{orientation} || 'Portrait'; | ||||||||||||||||||||||||||
|
Condition0%0/2
$self->{'report'}{'orientation'} || 'Portrait'
MC/DC0%0/1
$self->{'report'}{'orientation'} || 'Portrait'
$self->{'report'}{'orientation'}
Truth table0%0/2
A
A= $self->{'report'}{'orientation'}
| |||||||||||||||||||||||||||||
| 279 | 0 | my $p = new Business::ReportWriter::Pdf::Report( | |||||||||||||||||||||||||||
| 280 | PageSize => $papersize, | ||||||||||||||||||||||||||||
| 281 | PageOrientation => $orientation | ||||||||||||||||||||||||||||
| 282 | ); | ||||||||||||||||||||||||||||
| 283 | |||||||||||||||||||||||||||||
| 284 | 0 | $self->{pdf} = $p; | |||||||||||||||||||||||||||
| 285 | 0 | $self->{ypos} = -1; | |||||||||||||||||||||||||||
| 286 | 0 | $self->set_papersize(); | |||||||||||||||||||||||||||
| 287 | } | ||||||||||||||||||||||||||||
| 288 | |||||||||||||||||||||||||||||
| 289 | 0 | ▶ | sub check_page { | ||||||||||||||||||||||||||
|
Subroutine
check_page: not called CC=3 SCAR=24.8
Pod
undocumented
| |||||||||||||||||||||||||||||
| 290 | 0 | my ( $self, $yplus ) = @_; | |||||||||||||||||||||||||||
| 291 | |||||||||||||||||||||||||||||
| 292 | 0 | ▶ | return if $self->{inHeader}; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 293 | 0 | my $bottommargen = $self->{paper}{topmargen} - $self->{paper}{heigth}; | |||||||||||||||||||||||||||
| 294 | 0 | ▶ | $self->new_page() if $self->{ypos} - $yplus < $bottommargen; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 295 | } | ||||||||||||||||||||||||||||
| 296 | |||||||||||||||||||||||||||||
| 297 | 0 | ▶ | sub get_doc { | ||||||||||||||||||||||||||
|
Subroutine
get_doc: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||
| 298 | 0 | my ($self) = @_; | |||||||||||||||||||||||||||
| 299 | |||||||||||||||||||||||||||||
| 300 | 0 | my $p = $self->{pdf}; | |||||||||||||||||||||||||||
| 301 | 0 | $p->finish_report("none"); | |||||||||||||||||||||||||||
| 302 | } | ||||||||||||||||||||||||||||
| 303 | |||||||||||||||||||||||||||||
| 304 | 0 | ▶ | sub print_doc { | ||||||||||||||||||||||||||
|
Subroutine
print_doc: not called CC=2 SCAR=17.9
Pod
undocumented
| |||||||||||||||||||||||||||||
| 305 | 0 | my ( $self, $filename ) = @_; | |||||||||||||||||||||||||||
| 306 | |||||||||||||||||||||||||||||
| 307 | 0 | my $p = $self->{pdf}; | |||||||||||||||||||||||||||
| 308 | 0 | ▶ | if ($filename) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 309 | 0 | open OUT, ">$filename"; | |||||||||||||||||||||||||||
| 310 | 0 | print OUT $p->finish_report("none"); | |||||||||||||||||||||||||||
| 311 | 0 | close OUT; | |||||||||||||||||||||||||||
| 312 | } | ||||||||||||||||||||||||||||
| 313 | } | ||||||||||||||||||||||||||||
| 314 | |||||||||||||||||||||||||||||
| 315 | 0 | ▶ | sub set_papersize { | ||||||||||||||||||||||||||
|
Subroutine
set_papersize: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||
| 316 | 0 | my $self = shift; | |||||||||||||||||||||||||||
| 317 | |||||||||||||||||||||||||||||
| 318 | 0 | my $p = $self->{pdf}; | |||||||||||||||||||||||||||
| 319 | 0 | my ( $pagewidth, $pageheigth ) = $p->get_pagedimensions(); | |||||||||||||||||||||||||||
| 320 | $self->{paper} = { | ||||||||||||||||||||||||||||
| 321 | width => $pagewidth, | ||||||||||||||||||||||||||||
| 322 | topmargen => $pageheigth - 20, | ||||||||||||||||||||||||||||
| 323 | heigth => $self->{paper}{topmargen} | ||||||||||||||||||||||||||||
| 324 | 0 | }; | |||||||||||||||||||||||||||
| 325 | } | ||||||||||||||||||||||||||||
| 326 | |||||||||||||||||||||||||||||
| 327 | 0 | ▶ | sub out_text { | ||||||||||||||||||||||||||
|
Subroutine
out_text: not called CC=5 SCAR=34.0
Pod
undocumented
| |||||||||||||||||||||||||||||
| 328 | 0 | my ( $self, $text, $x, $y, $align, $width ) = @_; | |||||||||||||||||||||||||||
| 329 | |||||||||||||||||||||||||||||
| 330 | 0 | my $p = $self->{pdf}; | |||||||||||||||||||||||||||
| 331 | 0 | $x = mm_to_pt($x); | |||||||||||||||||||||||||||
| 332 | ## | ||||||||||||||||||||||||||||
| 333 | ##print "$text er utf8\n" if utf8::is_utf8($text); | ||||||||||||||||||||||||||||
| 334 | ##print "$text er ikke utf8\n" unless utf8::is_utf8($text); | ||||||||||||||||||||||||||||
| 335 | 0 | utf8::decode($text); | |||||||||||||||||||||||||||
| 336 | 0 | ▶ | utf8::decode($text) if utf8::is_utf8($text); | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 337 | 0 | my $sw = 0; | |||||||||||||||||||||||||||
| 338 | 0 | ▶ | $sw = int( $p->get_stringwidth($text) + .5 ) if lc($align) eq 'right'; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 339 | 0 | $x -= $sw; | |||||||||||||||||||||||||||
| 340 | 0 | my $margen = 20; | |||||||||||||||||||||||||||
| 341 | 0 | ▶ | $width ||= $self->{paper}{width} - $x - 20; | ||||||||||||||||||||||||||
|
Condition0%0/3
$width ||= $self->{"paper"}{"width"} - $x - 20
MC/DC0%0/2
$width ||= $self->{"paper"}{"width"} - $x - 20
$width
$self->{"paper"}{"width"} - $x - 20
Truth table0%0/3
A ||= B
A= $widthB= $self->{"paper"}{"width"} - $x - 20
| |||||||||||||||||||||||||||||
| 342 | 0 | my $linespace = $self->{font}{size} + 2; | |||||||||||||||||||||||||||
| 343 | |||||||||||||||||||||||||||||
| 344 | $p->add_paragraph( | ||||||||||||||||||||||||||||
| 345 | $text, $x, $y, | ||||||||||||||||||||||||||||
| 346 | $self->{paper}{width} - $x - 20, | ||||||||||||||||||||||||||||
| 347 | 0 | $self->{paper}{topmargen} - $y, | |||||||||||||||||||||||||||
| 348 | 0, $linespace | ||||||||||||||||||||||||||||
| 349 | ); | ||||||||||||||||||||||||||||
| 350 | 0 | my ( $hPos, $vPos ) = $p->get_add_textpos(); | |||||||||||||||||||||||||||
| 351 | 0 | ▶ | $self->{ypos} = $vPos + $linespace if $self->{ypos} - $linespace > $vPos; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 352 | } | ||||||||||||||||||||||||||||
| 353 | |||||||||||||||||||||||||||||
| 354 | 0 | ▶ | sub mm_to_pt { | ||||||||||||||||||||||||||
|
Subroutine
mm_to_pt: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||
| 355 | 0 | my $mm = shift; | |||||||||||||||||||||||||||
| 356 | |||||||||||||||||||||||||||||
| 357 | 0 | return int( $mm / .3527777 ); | |||||||||||||||||||||||||||
| 358 | } | ||||||||||||||||||||||||||||
| 359 | |||||||||||||||||||||||||||||
| 360 | 2 | 1; | |||||||||||||||||||||||||||
| 361 | __END__ | ||||||||||||||||||||||||||||