| 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
| |||||||||||||||||||||||||||||
| 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
| |||||||||||||||||||||||||||||
| 22 | 0 | $dx = $1 * $style->{'font-size'}; | |||||||||||||||||||||||||||
| 23 | } | ||||||||||||||||||||||||||||
| 24 | else { | ||||||||||||||||||||||||||||
| 25 | 0 | ▶ | $dx = $self->u($dx||0); | ||||||||||||||||||||||||||
|
Condition0%0/2
$dx || 0
MC/DC0%0/1
$dx || 0
$dx
Truth table0%0/2
A
A= $dx
| |||||||||||||||||||||||||||||
| 26 | } | ||||||||||||||||||||||||||||
| 27 | 0 | ▶ | if ( $dy =~ /^([.\d]+)em$/ ) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 28 | 0 | $dy = $1 * $style->{'font-size'}; | |||||||||||||||||||||||||||
| 29 | } | ||||||||||||||||||||||||||||
| 30 | else { | ||||||||||||||||||||||||||||
| 31 | 0 | ▶ | $dy = $self->u($dy||0); | ||||||||||||||||||||||||||
|
Condition0%0/2
$dy || 0
MC/DC0%0/1
$dy || 0
$dy
Truth table0%0/2
A
A= $dy
| |||||||||||||||||||||||||||||
| 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
Condition0%0/3
$color and $color eq "currentColor"
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"
| |||||||||||||||||||||||||||||
| 38 | 0 | ▶ | my $anchor = $style->{'text-anchor'} || "left"; | ||||||||||||||||||||||||||
|
Condition0%0/2
$style->{'text-anchor'} || 'left'
MC/DC0%0/1
$style->{'text-anchor'} || 'left'
$style->{'text-anchor'}
Truth table0%0/2
A
A= $style->{'text-anchor'}
| |||||||||||||||||||||||||||||
| 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
| |||||||||||||||||||||||||||||
| 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
| |||||||||||||||||||||||||||||
| 58 | ? "right" | ||||||||||||||||||||||||||||
| 59 | : $anchor eq "middle" ? "center" : "left"; | ||||||||||||||||||||||||||||
| 60 | |||||||||||||||||||||||||||||
| 61 | 0 | ▶ | if ( 0 && $x && !$y && $o{align} eq "left" ) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 62 | $o{indent} = $x; | ||||||||||||||||||||||||||||
| 63 | $self->_dbg( "txt indent %.2f", $x ); | ||||||||||||||||||||||||||||
| 64 | } | ||||||||||||||||||||||||||||
| 65 | 0 | ▶ | elsif ( $x || $y ) { | ||||||||||||||||||||||||||
|
Condition0%0/3
$x || $y
MC/DC0%0/2
$x || $y
$x
$y
Truth table0%0/3
A || B
A= $xB= $y
| |||||||||||||||||||||||||||||
| 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
| |||||||||||||||||||||||||||||
| 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
| |||||||||||||||||||||||||||||
| 90 | |||||||||||||||||||||||||||||
| 91 | } | ||||||||||||||||||||||||||||
| 92 | 12 | } | |||||||||||||||||||||||||||
| 93 | |||||||||||||||||||||||||||||
| 94 | 12 | 1; | |||||||||||||||||||||||||||