File Coverage

blib/lib/SVGPDF/Use.pm
Criterion Covered Total %
statement 34 39 87.1
branch 4 8 50.0
condition 1 3 33.3
subroutine 6 6 100.0
pod 0 1 0.0
total 45 57 78.9


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