SVGPDF/Tspan.pm

filter: Statementstmt 95.0% 58 / 61 Branchbran 76.6% 23 / 30 Conditioncond 83.3% 10 / 12 MC/DCmcdc 71.4% 5 / 7 Subroutinesub 100% 5 / 5 Podpod 0.0% 0 / 1 totaltotal 87.0% 101 / 116 CC 22 SCAR 29.8
CC
22
Cov
88%
process
23.1
BEGIN
1.0
BEGIN
1.0
CRAP 19.7
« SVGPDF/Path.pm ↑ Summary SVGPDF/Colour.pm »
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 2 ▶use Carp;
Subroutine BEGIN: called CC=1 SCAR=0.0
7  
8 class SVGPDF::Tspan :isa(SVGPDF::Element);
9  
10 9 ▶method process () {
Subroutine process: called CC=22 SCAR=31.4
Pod undocumented
11 9 my $atts = $self->atts;
12 9 my $xo = $self->xo;
13 9 ▶ return if $atts->{omit}; # for testing/debugging.
Branch: 1 branch
BranchTrueFalseTotal
if $atts->{"omit"} 0 9 9
14  
15 9 my ( $x, $y, $dx, $dy ) =
16 $self->get_params( $atts, qw( x:H y:V dx:s dy:s ) );
17 9 my $style = $self->style;
18  
19 # Scale dx/dy to font size, if using em units.
20 9 $style->{'font-size'} = 0+$self->u($style->{'font-size'});
21 9 ▶ if ( $dx =~ /^([.\d]+)em$/ ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($dx =~ /^([.\d]+)em$/u) { } 0 9 9
22 0 $dx = $1 * $style->{'font-size'};
23 }
24 else {
25 9 ▶ $dx = $self->u($dx||0);
Condition100%2/2
$dx || 0
l!l
18
MC/DC100%1/1
$dx || 0
$dx
Truth table100%2/2
A
A= $dx
Aresult
11
00
26 }
27 9 ▶ if ( $dy =~ /^([.\d]+)em$/ ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($dy =~ /^([.\d]+)em$/u) { } 0 9 9
28 0 $dy = $1 * $style->{'font-size'};
29 }
30 else {
31 9 ▶ $dy = $self->u($dy||0);
Condition100%2/2
$dy || 0
l!l
54
MC/DC100%1/1
$dy || 0
$dy
Truth table100%2/2
A
A= $dy
Aresult
11
00
32 }
33  
34 9 my $text = "";
35  
36 9 my $color = $style->{fill};
37 9 ▶ $color = $style->{color} if $color && $color eq "currentColor";
Branch: 1 branch
BranchTrueFalseTotal
if $color and $color eq "currentColor" 8 1 9
Condition66%2/3
$color and $color eq "currentColor"
!ll&&!rl&&r
018
MC/DC50%1/2
$color and $color eq "currentColor"
$color $color eq "currentColor"
Truth table66%2/3
A and B
A= $colorB= $color eq "currentColor"
ABresult
0X0
100
111
38 9 ▶ my $anchor = $style->{'text-anchor'} || "left";
Condition100%2/2
$style->{'text-anchor'} || 'left'
l!l
45
MC/DC100%1/1
$style->{'text-anchor'} || 'left'
$style->{'text-anchor'}
Truth table100%2/2
A
A= $style->{'text-anchor'}
Aresult
11
00
39 9 $self->set_graphics;
40  
41 $self->_dbg( $self->name, " ",
42 defined($atts->{x}) ? ( " x=$x" ) : (),
43 defined($atts->{y}) ? ( " y=$y" ) : (),
44 defined($atts->{dx}) ? ( " dx=$dx" ) : (),
45 defined($atts->{dy}) ? ( " dy=$dy" ) : (),
46 9 ▶ defined($style->{"text-anchor"})
Branch: 5 branches
BranchTrueFalseTotal
defined $atts->{'x'} ? : 4 5 9
defined $atts->{'y'} ? : 0 9 9
defined $atts->{'dx'} ? : 1 8 9
defined $atts->{'dy'} ? : 5 4 9
defined $style->{'text-anchor'} ? : 4 5 9
47 ? ( " anchor=\"$anchor\"" ) : (),
48 );
49  
50 9 my @c = $self->get_children;
51  
52 {
53 9 my $x = $dx + $x;
54 9 my $y = $dy + $y;
55  
56 9 my %o = ();
57 9 ▶ $o{align} = $anchor eq "end"
Branch: 2 branches
BranchTrueFalseTotal
$anchor eq 'end' ? : 0 9 9
$anchor eq 'middle' ? : 4 5 9
58 ? "right"
59 : $anchor eq "middle" ? "center" : "left";
60  
61 9 ▶ if ( 0 && $x && !$y && $o{align} eq "left" ) {
Branch: 1 branch
BranchTrueFalseTotal
if (do { $x or $y }) 5 4 9
62 $o{indent} = $x;
63 $self->_dbg( "txt indent %.2f", $x );
64 }
65 0 ▶ elsif ( $x || $y ) {
Condition66%2/3
$x || $y
l!l&&r!l&&!r
504
MC/DC50%1/2
$x || $y
$x $y
Truth table66%2/3
A || B
A= $xB= $y
ABresult
1X1
011
000
66 5 $self->_dbg( "txt translate( %.2f, %.2f )", $x, $y );
67 }
68  
69 9 for my $c ( @c ) {
70 10 $self->_dbg( "+ xo save" );
71 10 $xo->save;
72 10 $xo->transform( translate => [ $x, -$y ] );
73 10 ▶ if ( ref($c) eq 'SVGPDF::TextElement' ) {
Branch: 2 branches
BranchTrueFalseTotal
if (ref $c eq 'SVGPDF::TextElement') { } 9 1 10
elsif (ref $c eq 'SVGPDF::Tspan') { } 1 0 1
74 9 $xo->textstart;
75 9 $self->set_font( $xo, $style );
76 9 $x += $xo->text( $c->content, %o );
77 9 $xo->textend;
78 }
79 elsif ( ref($c) eq 'SVGPDF::Tspan' ) {
80 1 my ( $x0, $y0 ) = $c->process;
81 1 $x += $x0; $y += $y0;
82 1 $self->_dbg("tspan moved to $x, $y");
83 }
84 10 $self->_dbg( "- xo restore" );
85 10 $xo->restore;
86 }
87  
88 9 $self->css_pop;
89 9 ▶ return wantarray ? ( $x, $y ) : $x;
Branch: 1 branch
BranchTrueFalseTotal
wantarray ? : 9 0 9
90  
91 }
92 2 }
93  
94 2 1;
« SVGPDF/Path.pm ↑ Summary SVGPDF/Colour.pm »