lib/ChordPro/lib/SVGPDF/Tspan.pm

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