| 1 | #! perl | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3 | 2 | ▶ | use v5.26; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 4 | 2 | ▶ | use Object::Pad; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 5 | 2 | ▶ | use utf8; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 6 | class SVGPDF::Element; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 7 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 8 | 2 | ▶ | use Carp; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 9 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 10 | 379 | ▶ | field $xo :mutator; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
xo: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 11 | 41 | ▶ | field $style :accessor; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
style: called CC=2 SCAR=7.1
Pod
undocumented
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 12 | 529 | ▶ | field $name :param :accessor; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
name: called CC=2 SCAR=7.1
Pod
undocumented
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 13 | 231 | ▶ | field $atts :param :accessor; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
atts: called CC=2 SCAR=7.1
Pod
undocumented
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 14 | 0 | ▶ | field $css :accessor; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
css: not called CC=2 SCAR=14.0
Pod
undocumented
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 15 | 130 | ▶ | field $content :param :accessor; # array of children | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
content: called CC=2 SCAR=7.1
Pod
undocumented
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 16 | 2171 | ▶ | field $root :param :accessor; # top module | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
root: called CC=2 SCAR=7.1
Pod
undocumented
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 17 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 18 | BUILD { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 19 | $css = $root->css; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 20 | $xo = $root->xoforms->[-1]->{xo}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 21 | 2 | }; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 22 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 23 | 1801 | ▶ | method _dbg (@args) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_dbg: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 24 | 1801 | $root->_dbg(@args); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 25 | 2 | } | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 26 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 27 | 211 | ▶ | method css_push ( $updated_atts = undef ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
css_push: called CC=3 SCAR=11.3
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 28 | 211 | ▶ | $style = $css->push( element => $name, %{$updated_atts // $atts} ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition33%1/3
$updated_atts // $atts
MC/DC0%0/2
$updated_atts // $atts
$updated_atts
$atts
Truth table33%1/3
A // B
A= $updated_attsB= $atts
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 29 | 2 | } | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 30 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 31 | 211 | ▶ | method css_pop () { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
css_pop: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 32 | 211 | $css->pop; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 33 | 2 | } | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 34 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 35 | 58 | ▶ | method set_transform ( $tf ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
set_transform: called CC=24 SCAR=50.2
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 36 | 58 | ▶ | return unless $tf; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 37 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 38 | 8 | my $nooptimize = 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 39 | 8 | $tf =~ s/\s+/ /g; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 40 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 41 | # The parts of the transform need to be executed in order. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 42 | 8 | ▶ | while ( $tf =~ /\S/ ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 43 | 9 | ▶ | if ( $tf =~ /^\s*translate\s*\((.*?)\)(.*)/ ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 5 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 44 | 7 | $tf = $2; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 45 | 7 | my ( $x, $y ) = $self->getargs($1); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 46 | 7 | ▶ | $y ||= 0; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition100%2/2
$y ||= 0
MC/DC100%1/1
$y ||= 0
$y
Truth table100%2/2
A
A= $y
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 47 | 7 | ▶ | if ( $nooptimize || $x || $y ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%2/6
$nooptimize or $x or $y
$nooptimize or $x
MC/DC0%0/3
$nooptimize or $x or $y
$nooptimize
$x
$y
Truth table25%1/4
A or B or C
A= $nooptimizeB= $xC= $y
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 48 | 7 | $xo->transform( translate => [ $x, $y ] ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 49 | 7 | $self->_dbg( "transform translate(%.2f,%.2f)", $x, $y ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 50 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 51 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 52 | elsif ( $tf =~ /^\s*rotate\s*\((.*?)\)(.*)/ ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 53 | 2 | $tf = $2; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 54 | 2 | my ( $r, $x, $y ) = $self->getargs($1); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 55 | 2 | ▶ | if ( $nooptimize || $r ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
$nooptimize or $r
MC/DC0%0/2
$nooptimize or $r
$nooptimize
$r
Truth table33%1/3
A or B
A= $nooptimizeB= $r
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 56 | 2 | ▶ | if ( $x || $y ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
$x or $y
MC/DC0%0/2
$x or $y
$x
$y
Truth table33%1/3
A or B
A= $xB= $y
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 57 | 0 | $xo->transform( translate => [ $x, $y ] ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 58 | 0 | $self->_dbg( "transform translate(%.2f,%.2f)", $x, $y ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 59 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 60 | 2 | $self->_dbg( "transform rotate(%.2f)", $r ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 61 | 2 | $xo->transform( rotate => $r ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 62 | 2 | ▶ | if ( $x || $y ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
$x or $y
MC/DC0%0/2
$x or $y
$x
$y
Truth table33%1/3
A or B
A= $xB= $y
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 63 | 0 | $xo->transform( translate => [ -$x, -$y ] ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 64 | 0 | $self->_dbg( "transform translate(%.2f,%.2f)", -$x, -$y ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 65 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 66 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 67 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 68 | elsif ( $tf =~ /^\s*scale\s*\((.*?)\)(.*)/ ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 69 | 0 | $tf = $2; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 70 | 0 | my ( $x, $y ) = $self->getargs($1); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 71 | 0 | ▶ | $y ||= $x; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/3
$y ||= $x
MC/DC0%0/2
$y ||= $x
$y
$x
Truth table0%0/3
A ||= B
A= $yB= $x
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 72 | 0 | ▶ | if ( $nooptimize || $x != 1 && $y != 1 ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/6
$nooptimize or $x != 1 and $y != 1
$x != 1 and $y != 1
MC/DC0%0/3
$nooptimize or $x != 1 and $y != 1
$nooptimize
$x != 1
$y != 1
Truth table0%0/4
A or B and C
A= $nooptimizeB= $x != 1C= $y != 1
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 73 | 0 | $self->_dbg( "transform scale(%.2f,%.2f)", $x, $y ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 74 | 0 | $xo->transform( scale => [ $x, $y ] ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 75 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 76 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 77 | elsif ( $tf =~ /^\s*matrix\s*\((.*?)\)(.*)/ ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 78 | 0 | $tf = $2; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 79 | 0 | my ( @m ) = $self->getargs($1); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 80 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 81 | # 1 0 0 1 dx dy translate | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 82 | # sx 0 0 sy 0 0 scale | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 83 | # c s -s c 0 0 rotate (s = sin, c = cos) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 84 | # 1 a b 1 0 0 skew (a = tan a, b = tan b) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 85 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 86 | 0 | $self->_dbg( "transform matrix(%.2f,%.2f %.2f,%.2f %.2f,%.2f)", @m); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 87 | 0 | $xo->matrix(@m); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 88 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 89 | elsif ( $tf =~ /^\s*skew([XY])\s*\((.*?)\)(.*)/i ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 90 | 0 | $tf = $3; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 91 | 0 | my ( $x ) = $self->getargs($2); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 92 | 0 | my $y = 0; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 93 | 0 | ▶ | if ( $1 eq "X" ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 94 | 0 | $y = $x; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 95 | 0 | $x = 0; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 96 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 97 | 0 | $self->_dbg( "transform skew(%.2f %.2f)", $x, $y ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 98 | 0 | $xo->transform( skew => [ $x, $y ] ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 99 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 100 | else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 101 | 0 | ▶ | warn("Ignoring transform: $tf") | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 102 | if $self->root->verbose; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 103 | 0 | $self->_dbg("Ignoring transform: \"$tf\""); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 104 | 0 | $tf = ""; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 105 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 106 | # %rel = ( relative => 1 ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 107 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 108 | 2 | } | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 109 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 110 | # <g matrix = m1> | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 111 | # <g matrix = m2> | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 112 | # <g matrix = m3> | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 113 | # result = multiply_matrices( $m1, $m2, $m3 ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 114 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 115 | 0 | ▶ | method multiply_matrices :common (@m) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
multiply_matrices: not called CC=4 SCAR=30.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 116 | 0 | my $i = @m; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 117 | 0 | my $m2 = pop(@m); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 118 | 0 | ▶ | die("Matrix$i must have 6 elements\n") unless @$m2 == 6; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 119 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 120 | 0 | ▶ | while ( --$i > 0 ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 121 | 0 | my $m1 = pop(@m); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 122 | 0 | ▶ | die("Matrix$i must have 6 elements\n") unless @$m1 == 6; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 123 | 0 | $m2 = [ $m1->[0] * $m2->[0] + $m1->[2] * $m2->[1], | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 124 | $m1->[1] * $m2->[0] + $m1->[3] * $m2->[1], | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 125 | $m1->[0] * $m2->[2] + $m1->[2] * $m2->[3], | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 126 | $m1->[1] * $m2->[2] + $m1->[3] * $m2->[3], | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 127 | $m1->[0] * $m2->[4] + $m1->[2] * $m2->[5] + $m1->[4], | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 128 | $m1->[1] * $m2->[4] + $m1->[3] * $m2->[5] + $m1->[5] ]; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 129 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 130 | 0 | $m2; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 131 | 2 | } | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 132 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 133 | 144 | ▶ | method set_graphics () { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
set_graphics: called CC=23 SCAR=33.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 134 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 135 | 144 | my $msg = $name; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 136 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 137 | 144 | ▶ | if ( defined( my $lw = $style->{'stroke-width'} ) ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 138 | my $w = $self->u( $lw, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 139 | fontsize => $style->{'font-size'}, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 140 | 62 | width => $self->root->xoforms->[-1]->{diag}); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 141 | 62 | $msg .= sprintf(" stroke-width=%.2f", $w); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 142 | 62 | ▶ | if ( $lw =~ /e[mx]/ ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 143 | $msg .= sprintf("(%s\@%.2f)", $lw, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 144 | $self->u( $style->{'font-size'}|| $self->root->fontsize, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 145 | fontsize => $style->{'font-size'}, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 146 | 0 | ▶ | width => $self->root->xoforms->[-1]->{diag})); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/3
$style->{'font-size'} || $self->root->fontsize
MC/DC0%0/2
$style->{'font-size'} || $self->root->fontsize
$style->{'font-size'}
$self->root->fontsize
Truth table0%0/3
A || B
A= $style->{'font-size'}B= $self->root->fontsize
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 147 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 148 | 62 | ▶ | if ( $lw =~ /\%/ ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 149 | $msg .= sprintf("(%s\@%.2f)", $lw, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 150 | $self->u( $self->root->xoforms->[-1]->{diag}, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 151 | fontsize => $style->{'font-size'}, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 152 | 0 | width => $self->root->xoforms->[-1]->{diag})); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 153 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 154 | 62 | $xo->line_width($w); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 155 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 156 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 157 | 144 | ▶ | if ( defined( my $linecap = $style->{'stroke-linecap'} ) ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 158 | 8 | $linecap = lc($linecap); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 159 | 8 | ▶ | if ( $linecap eq "round" ) { $linecap = 1 } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 4 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 160 | 0 | elsif ( $linecap eq "r" ) { $linecap = 1 } | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 161 | 2 | elsif ( $linecap eq "square" ) { $linecap = 2 } | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 162 | 0 | elsif ( $linecap eq "s" ) { $linecap = 2 } | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 163 | 2 | else { $linecap = 0 } # b butt | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 164 | 8 | $msg .= " linecap=$linecap"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 165 | 8 | $xo->line_cap($linecap); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 166 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 167 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 168 | 144 | ▶ | if ( defined( my $linejoin = $style->{'stroke-linejoin'} ) ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 169 | 3 | $linejoin = lc($linejoin); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 170 | 3 | ▶ | if ( $linejoin eq "round" ) { $linejoin = 1 } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 4 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 171 | 0 | elsif ( $linejoin eq "r" ) { $linejoin = 1 } | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 172 | 1 | elsif ( $linejoin eq "bevel" ) { $linejoin = 2 } | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 173 | 0 | elsif ( $linejoin eq "b" ) { $linejoin = 2 } | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 174 | 1 | else { $linejoin = 0 } # m miter | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 175 | 3 | $msg .= " linejoin=$linejoin"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 176 | 3 | $xo->line_join($linejoin); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 177 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 178 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 179 | 144 | my $color = $style->{color}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 180 | 144 | my $stroke = $style->{stroke}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 181 | 144 | ▶ | if ( lc($stroke) eq "currentcolor" ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 182 | # Nothing. Use current. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 183 | 0 | $msg .= " stroke=(current)"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 184 | 0 | $stroke = $color; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 185 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 186 | 144 | ▶ | if ( $stroke ne "none" ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 187 | 81 | $stroke = SVGPDF::Colour->new( colour => $stroke )->rgb; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 188 | 81 | $xo->stroke_color($stroke); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 189 | 81 | $msg .= " stroke=$stroke"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 190 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 191 | else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 192 | 63 | $msg .= " stroke=none"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 193 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 194 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 195 | 144 | my $fill = $style->{fill}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 196 | 144 | ▶ | if ( lc($fill) eq "currentcolor" ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 197 | # Nothing. Use current. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 198 | 55 | $msg .= " fill=(current)"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 199 | 55 | $fill = $color; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 200 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 201 | 144 | ▶ | if ( lc($fill) ne "none" && $fill ne "transparent" ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%3/3
lc $fill ne "none" and $fill ne "transparent"
MC/DC100%2/2
lc $fill ne "none" and $fill ne "transparent"
lc $fill ne "none"
$fill ne "transparent"
Truth table100%3/3
A and B
A= lc $fill ne "none"B= $fill ne "transparent"
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 202 | 75 | $fill = SVGPDF::Colour->new( colour => $fill )->rgb; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 203 | 75 | $xo->fill_color($fill); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 204 | 75 | $msg .= " fill=$fill"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 205 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 206 | else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 207 | 69 | $msg .= " fill=none"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 208 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 209 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 210 | 144 | ▶ | if ( my $sda = $style->{'stroke-dasharray'} ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 211 | 6 | my @sda; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 212 | 6 | ▶ | if ( $sda && $sda ne "none" ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
$sda and $sda ne "none"
MC/DC0%0/2
$sda and $sda ne "none"
$sda
$sda ne "none"
Truth table33%1/3
A and B
A= $sdaB= $sda ne "none"
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 213 | 6 | $sda =~ s/,/ /g; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 214 | 6 | @sda = split( ' ', $sda ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 215 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 216 | 6 | $msg .= " sda=@sda"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 217 | 6 | $xo->line_dash_pattern(@sda); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 218 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 219 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 220 | 144 | $self->_dbg( "%s", $msg ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 221 | 144 | return $style; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 222 | 2 | } | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 223 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 224 | # Return a stroke/fill/paint sub depending on the fill stroke styles. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 225 | 99 | ▶ | method _paintsub () { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_paintsub: called CC=12 SCAR=26.4
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 226 | 99 | ▶ | if ( $style->{stroke} | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
Condition81%9/11
$style->{"stroke"} && $style->{"stroke"} ne "none" && $style->{"stroke"} ne "transparent" && $style->{"stroke-width"} //
$style->{"stroke"} and $style->{"stroke"} ne "none" and $style->{"stroke"} ne "transparent" and $style->{"stroke-width"}
$style->{"stroke"} and $style->{"stroke"} ne "none" and $style->{"stroke"} ne "transparent"
$style->{"stroke"} and $style->{"stroke"} ne "none"
MC/DC50%2/4
$style->{"stroke"} && $style->{"stroke"} ne "none" && $style->{"stroke"} ne "transparent" && $style->{"stroke-width"} //
$style->{"stroke"}
$style->{"stroke"} ne "none"
$style->{"stroke"} ne "transparent"
$style->{"stroke-width"}
Truth table60%3/5
A and B and C and D
A= $style->{"stroke"}B= $style->{"stroke"} ne "none"C= $style->{"stroke"} ne "transparent"D= $style->{"stroke-width"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 227 | && $style->{stroke} ne 'none' | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 228 | && $style->{stroke} ne 'transparent' | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 229 | # Hmm. Saw a note somewhere that it defaults to 0 but other notes | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 230 | # say that it should be 1px... | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 231 | && $style->{'stroke-width'}//1 != 0 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 232 | ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 233 | 81 | ▶ | if ( $style->{fill} | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition83%5/6
$style->{"fill"} and $style->{"fill"} ne "none" and $style->{"fill"} ne "transparent"
$style->{"fill"} and $style->{"fill"} ne "none"
MC/DC66%2/3
$style->{"fill"} and $style->{"fill"} ne "none" and $style->{"fill"} ne "transparent"
$style->{"fill"}
$style->{"fill"} ne "none"
$style->{"fill"} ne "transparent"
Truth table75%3/4
A and B and C
A= $style->{"fill"}B= $style->{"fill"} ne "none"C= $style->{"fill"} ne "transparent"
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 234 | && $style->{fill} ne 'none' | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 235 | && $style->{fill} ne 'transparent' | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 236 | ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 237 | 12 | ▶ | return sub { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 238 | $self->_dbg("xo paint (", | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 239 | 12 | join(" ", $style->{stroke}, $style->{fill} ), ")"); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 240 | 12 | $xo->paint; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 241 | 12 | }; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 242 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 243 | else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 244 | 69 | ▶ | return sub { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 245 | 69 | $self->_dbg("xo stroke (", $style->{stroke}, ")"); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 246 | 69 | $xo->stroke; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 247 | 69 | }; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 248 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 249 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 250 | ▶ | elsif ( $style->{fill} | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition33%2/6
$style->{"fill"} and $style->{"fill"} ne "none" and $style->{"fill"} ne "transparent"
$style->{"fill"} and $style->{"fill"} ne "none"
MC/DC0%0/3
$style->{"fill"} and $style->{"fill"} ne "none" and $style->{"fill"} ne "transparent"
$style->{"fill"}
$style->{"fill"} ne "none"
$style->{"fill"} ne "transparent"
Truth table25%1/4
A and B and C
A= $style->{"fill"}B= $style->{"fill"} ne "none"C= $style->{"fill"} ne "transparent"
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 251 | && $style->{fill} ne 'none' | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 252 | && $style->{fill} ne 'transparent' | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 253 | ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 254 | 18 | ▶ | return sub { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 255 | 18 | $self->_dbg("xo fill (", $style->{stroke}, ")"); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 256 | 18 | $xo->fill; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 257 | 18 | }; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 258 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 259 | else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 260 | 0 | ▶ | return sub { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 261 | 0 | $self->_dbg("xo end"); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 262 | 0 | $xo->end; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 263 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 264 | 0 | } | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 265 | 2 | } | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 266 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 267 | 5 | ▶ | method process () { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
process: called CC=3 SCAR=11.6
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 268 | # Unless overridden in a subclass there's not much we can do. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 269 | 5 | state $warned = { desc => 1, title => 1, metadata => 1 }; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 270 | warn("SVG: Skipping element \"$name\" (not implemented)\n") | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 271 | 5 | ▶ | unless $warned->{$name}++ || !$self->root->verbose; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
$warned->{$name}++ or not $self->root->verbose
MC/DC0%0/2
$warned->{$name}++ or not $self->root->verbose
$warned->{$name}++
not $self->root->verbose
Truth table33%1/3
A or not(B)
A= $warned->{$name}++B= not $self->root->verbose
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 272 | 5 | $self->_dbg("skipping $name (not implemented)"); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 273 | # $self->traverse; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 274 | 2 | } | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 275 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 276 | 130 | ▶ | method get_children () { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
get_children: called CC=5 SCAR=16.1
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 277 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 278 | # Note: This is the only place where these objects are created. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 279 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 280 | 130 | my @res; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 281 | 130 | for my $e ( @{$self->content} ) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 282 | 729 | ▶ | if ( $e->{type} eq 'e' ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 283 | 300 | my $pkg = "SVGPDF::" . ucfirst(lc $e->{name}); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 284 | 300 | ▶ | $pkg = "SVGPDF::Element" unless $pkg->can("process"); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 285 | push( @res, $pkg->new | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 286 | ( name => $e->{name}, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 287 | 1138 | atts => { map { lc($_) => $e->{attrib}->{$_} } keys %{$e->{attrib}} }, | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 288 | content => $e->{content}, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 289 | 300 | root => $self->root, | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 290 | ) ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 291 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 292 | elsif ( $e->{type} eq 't' ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 293 | push( @res, SVGPDF::TextElement->new | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 294 | ( content => $e->{content}, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 295 | 429 | ) ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 296 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 297 | else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 298 | # Basically a 'cannot happen', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 299 | 0 | croak("Unhandled node type ", $e->{type}); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 300 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 301 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 302 | 130 | return @res; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 303 | 2 | } | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 304 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 305 | 49 | ▶ | method traverse () { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
traverse: called CC=3 SCAR=11.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 306 | 49 | for my $c ( $self->get_children ) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 307 | 391 | ▶ | next if ref($c) eq "SVGPDF::TextElement"; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 308 | 171 | $self->_dbg("+ start handling ", $c->name, " (", ref($c), ")"); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 309 | 171 | $c->process; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 310 | 171 | $self->_dbg("- end handling ", $c->name); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 311 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 312 | 2 | } | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 313 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 314 | 826 | ▶ | method u ( $a, %args ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
u: called CC=17 SCAR=46.3
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 315 | 826 | ▶ | confess("Undef in units") unless defined $a; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 316 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 317 | # Pixels per point. Usually 96/72. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 318 | 826 | my $pxpt = $self->root->pxpi / $self->root->ptpi; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 319 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 320 | 826 | ▶ | return undef unless $a =~ /^([-+]?[\d.]+)(.*)$/; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 321 | 826 | ▶ | return $1*$pxpt if $2 eq "pt"; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 322 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 323 | # default is px | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 324 | 826 | ▶ | return $1 if $2 eq "" || $2 eq "px"; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%3/3
$2 eq "" or $2 eq "px"
MC/DC100%2/2
$2 eq "" or $2 eq "px"
$2 eq ""
$2 eq "px"
Truth table100%3/3
A or B
A= $2 eq ""B= $2 eq "px"
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 325 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 326 | # 1 inch = pxpi px. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 327 | 8 | ▶ | return $1/2.54 * $self->root->pxpi if $2 eq "cm"; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 328 | 0 | ▶ | return $1/25.4 * $self->root->pxpi if $2 eq "mm"; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 329 | 0 | ▶ | return $1 * $self->root->pxpi if $2 eq "in"; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 330 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 331 | 0 | ▶ | if ( $2 eq '%' ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 332 | 0 | ▶ | my $w = $args{width} || $self->root->xoforms->[-1]->{diag}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/3
$args{'width'} || $self->root->xoforms->[-1]{'diag'}
MC/DC0%0/2
$args{'width'} || $self->root->xoforms->[-1]{'diag'}
$args{'width'}
$self->root->xoforms->[-1]{'diag'}
Truth table0%0/3
A || B
A= $args{'width'}B= $self->root->xoforms->[-1]{'diag'}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 333 | 0 | return $1/100 * $w * $pxpt; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 334 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 335 | # Font dependent. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 336 | # CSS defines em to be the font size. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 337 | 0 | ▶ | if ( $2 eq "em" ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 338 | return $1 * ( $args{fontsize} | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 339 | 0 | ▶ | || $style->{'font-size'} | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/6
$args{'fontsize'} || $style->{'font-size'} || $self->root->fontsize
$args{"fontsize"} or $style->{"font-size"}
MC/DC0%0/3
$args{'fontsize'} || $style->{'font-size'} || $self->root->fontsize
$args{"fontsize"}
$style->{"font-size"}
$self->root->fontsize
Truth table0%0/4
A or B || C
A= $args{"fontsize"}B= $style->{"font-size"}C= $self->root->fontsize
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 340 | || $self->root->fontsize ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 341 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 342 | # CSS defines ex to be half the font size. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 343 | 0 | ▶ | if ( $2 eq "ex" ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 344 | return $1 * 0.5 * ( $args{fontsize} | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 345 | 0 | ▶ | || $style->{'font-size'} | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/6
$args{'fontsize'} || $style->{'font-size'} || $self->root->fontsize
$args{"fontsize"} or $style->{"font-size"}
MC/DC0%0/3
$args{'fontsize'} || $style->{'font-size'} || $self->root->fontsize
$args{"fontsize"}
$style->{"font-size"}
$self->root->fontsize
Truth table0%0/4
A or B || C
A= $args{"fontsize"}B= $style->{"font-size"}C= $self->root->fontsize
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 346 | || $self->root->fontsize ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 347 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 348 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 349 | 0 | confess("Unhandled units in \"$a\""); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 350 | 0 | return $a; # will hopefully crash somewhere... | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 351 | 2 | } | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 352 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 353 | 27 | ▶ | method getargs ( $a ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
getargs: called CC=2 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 354 | 27 | ▶ | confess("Null attr?") unless defined $a; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 355 | 27 | $a =~ s/^\s+//; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 356 | 27 | $a =~ s/\s+$//; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 357 | 27 | map { $self->u($_) } split( /\s*[,\s]\s*/, $a ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 358 | 2 | } | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 359 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 360 | # Initial fiddling with entity attributes. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 361 | 177 | ▶ | method get_params ( @desc ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
get_params: called CC=18 SCAR=30.7
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 362 | 177 | ▶ | my $atts = shift(@desc) if ref($desc[0]) eq 'HASH'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 363 | 177 | my @res; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 364 | 177 | ▶ | my %atts = %{ $atts // $self->atts }; # copy | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition33%1/3
$atts // $self->atts
MC/DC0%0/2
$atts // $self->atts
$atts
$self->atts
Truth table33%1/3
A // B
A= $attsB= $self->atts
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 365 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 366 | # xlink:href is obsoleted in favour of href. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 367 | 177 | ▶ | $atts{href} //= delete $atts{"xlink:href"} if exists $atts{"xlink:href"}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
$atts{"href"} //= delete $atts{"xlink:href"}
MC/DC0%0/2
$atts{"href"} //= delete $atts{"xlink:href"}
$atts{"href"}
delete $atts{"xlink:href"}
Truth table33%1/3
A //= B
A= $atts{"href"}B= delete $atts{"xlink:href"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 368 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 369 | 177 | my @todo; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 370 | 177 | for my $param ( @desc ) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 371 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 372 | # Attribute may be followed by ':' and flags. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 373 | # 0 undef -> 0 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 374 | # h process units, % is viewBox height | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 375 | # s undef -> "" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 376 | # u process units | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 377 | # v process units, % is viewBox width | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 378 | # U undef -> 0, process units | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 379 | # ! barf if undef | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 380 | 695 | my $flags = ""; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 381 | 695 | ▶ | ( $param, $flags ) = ( $1, $2 ) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 382 | if $param =~ /^(.*):(.*)$/; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 383 | 695 | $param = lc($param); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 384 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 385 | # Get and remove the attribute. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 386 | 695 | my $p = delete( $atts{$param} ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 387 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 388 | # Queue. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 389 | 695 | push( @todo, [ $param, $flags, $p ] ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 390 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 391 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 392 | # CSS push with updated attributes. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 393 | 177 | $self->css_push( \%atts ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 394 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 395 | # Now we can process the values. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 396 | 177 | for ( @todo ) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 397 | 695 | my ( $param, $flags, $p ) = @$_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 398 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 399 | 695 | ▶ | unless ( defined $p ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 400 | 282 | ▶ | if ( $flags =~ /s/ ) { $p = ""; } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 401 | 109 | elsif ( $flags =~ /[0HUV]/ ) { $p = 0; } | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 402 | else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 403 | 0 | ▶ | croak("Undefined mandatory attribute: $param") | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 404 | if $flags =~ /\!/; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 405 | 0 | push( @res, $p ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 406 | 0 | next; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 407 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 408 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 409 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 410 | 695 | $flags = lc($flags); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 411 | # Convert units if 'u' flag. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 412 | 695 | ▶ | if ( $flags =~ /([huv])/ ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 413 | 372 | my $flag = $1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 414 | 372 | ▶ | if ( $p =~ /^([\d.]+)\%$/ ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 415 | 2 | $p = $1/100; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 416 | 2 | ▶ | if ( $flags eq "w" || $param =~ /^(?:w(?:idth)|x)?$/i ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
Condition66%2/3
$flags eq "w" or $param =~ /^(?:w(?:idth)|x)?$/iu
MC/DC50%1/2
$flags eq "w" or $param =~ /^(?:w(?:idth)|x)?$/iu
$flags eq "w"
$param =~ /^(?:w(?:idth)|x)?$/iu
Truth table66%2/3
A or B
A= $flags eq "w"B= $param =~ /^(?:w(?:idth)|x)?$/iu
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 417 | # Percentage of viewBox width. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 418 | 1 | $p *= $root->xoforms->[-1]->{width}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 419 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 420 | ▶ | elsif ( $flag eq "h" || $param =~ /^(?:h(?:eight)?|y)$/i ) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition33%1/3
$flag eq "h" or $param =~ /^(?:h(?:eight)?|y)$/iu
MC/DC0%0/2
$flag eq "h" or $param =~ /^(?:h(?:eight)?|y)$/iu
$flag eq "h"
$param =~ /^(?:h(?:eight)?|y)$/iu
Truth table33%1/3
A or B
A= $flag eq "h"B= $param =~ /^(?:h(?:eight)?|y)$/iu
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 421 | # Percentage of viewBox height. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 422 | 1 | $p *= $root->xoforms->[-1]->{height}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 423 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 424 | else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 425 | # Percentage of viewBox diagonal. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 426 | 0 | $p *= $root->xoforms->[-1]->{diag}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 427 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 428 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 429 | else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 430 | 370 | $p = $self->u($p); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 431 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 432 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 433 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 434 | 695 | push( @res, $p ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 435 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 436 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 437 | # Return param values. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 438 | 177 | return @res; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 439 | 2 | } | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 440 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 441 | 0 | ▶ | method get_cdata () { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
get_cdata: not called CC=3 SCAR=24.8
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 442 | 0 | my $res = ""; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 443 | 0 | for ( $self->get_children ) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 444 | 0 | ▶ | $res .= "\n" . $_->content if ref($_) eq "SVGPDF::TextElement"; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 445 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 446 | 0 | $res; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 447 | 2 | } | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 448 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 449 | 1 | ▶ | method nfi ( $tag ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
nfi: called CC=3 SCAR=11.6
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 450 | 1 | state $aw = {}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 451 | warn("SVG: $tag - not fully implemented, expect strange results.\n") | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 452 | 1 | ▶ | unless !$self->root->verbose || $aw->{$tag}++; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
not $self->root->verbose or $aw->{$tag}++
MC/DC0%0/2
not $self->root->verbose or $aw->{$tag}++
not $self->root->verbose
$aw->{$tag}++
Truth table33%1/3
not(A) or B
A= not $self->root->verboseB= $aw->{$tag}++
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 453 | 2 | } | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 454 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 455 | 51 | ▶ | method set_font ( $xo, $style ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
set_font: called CC=3 SCAR=11.5
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 456 | 51 | my $msg =""; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 457 | 51 | my $ret; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 458 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 459 | 0 | ▶ | local $SIG{__WARN__} = sub { $msg .= "@_" }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=0.4
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 460 | 51 | $ret = $self->root->fontmanager->set_font( $xo, $style ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 461 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 462 | 51 | ▶ | if ( $msg && $self->root->verbose ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
$msg and $self->root->verbose
MC/DC0%0/2
$msg and $self->root->verbose
$msg
$self->root->verbose
Truth table33%1/3
A and B
A= $msgB= $self->root->verbose
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 463 | 0 | warn($msg); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 464 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 465 | 51 | $ret; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 466 | 2 | } | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 467 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 468 | ################ Bounding Box ################ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 469 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 470 | # method bb ( $x, $y, $t = 0 ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 471 | # my $bb = $self->root->xoforms->[-1]->{bb}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 472 | # | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 473 | # $t = $self->u($t) unless $t =~ /^[-+]?\d*(?:\.\d*)$/; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 474 | # $t /= 2; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 475 | # $bb->[0] = $x-$t if $bb->[0] > $x-$t; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 476 | # $bb->[1] = $y-$t if $bb->[1] > $y-$t; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 477 | # $bb->[2] = $x+$t if $bb->[2] < $x+$t; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 478 | # $bb->[3] = $y+$t if $bb->[3] < $y+$t; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 479 | # | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 480 | # return $bb; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 481 | # } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 482 | # | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 483 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 484 | ################ Utility ################ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 485 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 486 | 8 | ▶ | method data_inline($src) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
data_inline: called CC=3 SCAR=11.3
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 487 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 488 | 8 | my %info; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 489 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 490 | 8 | ▶ | unless ( $src =~ m! ^ data: | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 491 | (?<mimetype> [^/]+ ) / | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 492 | (?<subtype> [^;]+ ) ; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 493 | (?<encoding> [^,]+ ) , | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 494 | (?<data> . + ) $ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 495 | !sx ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 496 | 0 | return { error => "Malformed inline data" }; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 497 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 498 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 499 | 8 | ▶ | if ( $+{encoding} eq "base64" ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 500 | 8 | require MIME::Base64; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 501 | 8 | $info{data} = MIME::Base64::decode($+{data}); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 502 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 503 | else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 504 | 0 | return { error => "Unhandled encoding \"$+{encoding}\" in inline data" }; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 505 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 506 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 507 | 8 | $info{mimetype} = $+{mimetype}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 508 | 8 | $info{subtype} = $+{subtype}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 509 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 510 | 8 | return \%info; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 511 | 2 | } | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 512 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 513 | ################ TextElement ################ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 514 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 515 | class SVGPDF::TextElement; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 516 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 517 | 52 | ▶ | field $content :param :accessor; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
content: called CC=2 SCAR=7.0
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 518 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 519 | # Actually, we should take style->{white-space} into account... | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 520 | BUILD { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 521 | # Reduce whitespace. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 522 | $content =~ s/\s+/ /g; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 523 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 524 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 525 | 0 | ▶ | method process () { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
process: not called CC=1 SCAR=2.6
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 526 | # Nothing to process. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 527 | 2 | } | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 528 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 529 | 2 | 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||