File Coverage

lib/ChordPro/lib/SVGPDF/Use.pm
Criterion Covered Total %
statement 14 39 35.9
branch 0 8 0.0
condition 0 3 0.0
subroutine 5 6 83.3
pod 0 1 0.0
total 19 57 33.3


line stmt bran cond sub pod time code
1             #! perl
2              
3 1     1   12 use v5.26;
  1         4  
4 1     1   12 use Object::Pad;
  1         2  
  1         7  
5 1     1   98 use utf8;
  1         2  
  1         5  
6 1     1   24 use Carp;
  1         2  
  1         50  
7 1     1   6 use Storable;
  1         2  
  1         148  
8              
9             class SVGPDF::Use :isa(SVGPDF::Element);
10              
11 0     0 0   method process () {
  0            
  0            
12 0           my $atts = $self->atts;
13 0           my $xo = $self->xo;
14 0 0         return if $atts->{omit}; # for testing/debugging.
15              
16 0           my ( $x, $y, $hr, $tf ) =
17             $self->get_params( $atts, qw( x:H y:V href:! transform:s ) );
18              
19 0           my $r = $self->root->defs->{$hr};
20 0 0         unless ( $r ) {
21 0           warn("SVG: Missing def for use \"$hr\" (skipped)\n");
22 0           $self->css_pop;
23 0           return;
24             }
25              
26             # Update its xo.
27 0           $r->xo = $self->xo;
28              
29 0           $self->_dbg( $self->name, " \"$hr\" (", $r->name, "), x=$x, y=$y" );
30              
31 0           $self->_dbg("+ xo save");
32 0           $xo->save;
33 0 0 0       if ( $x || $y ) {
34 0           $self->_dbg( "translate( %.2f %.2f )", $x, $y );
35 0           $xo->transform( translate => [ $x, $y ] );
36             }
37 0 0         $self->set_transform($tf) if $tf;
38 0           $self->set_graphics;
39 0           $r->process;
40 0           $self->_dbg("- xo restore");
41 0           $xo->restore;
42 0           $self->css_pop;
43             }
44              
45              
46             1;