| 1 | package SVG::Element; | ||||||||||||||||||||||||||||||||||
| 2 | |||||||||||||||||||||||||||||||||||
| 3 | 30 | ▶ | use strict; | ||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||
| 4 | 30 | ▶ | use warnings; | ||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||
| 5 | |||||||||||||||||||||||||||||||||||
| 6 | 30 | our $VERSION = '2.89'; | |||||||||||||||||||||||||||||||||
| 7 | |||||||||||||||||||||||||||||||||||
| 8 | =pod | ||||||||||||||||||||||||||||||||||
| 9 | |||||||||||||||||||||||||||||||||||
| 10 | =encoding UTF-8 | ||||||||||||||||||||||||||||||||||
| 11 | |||||||||||||||||||||||||||||||||||
| 12 | =head1 NAME | ||||||||||||||||||||||||||||||||||
| 13 | |||||||||||||||||||||||||||||||||||
| 14 | SVG::Element - Generate the element bits for SVG.pm | ||||||||||||||||||||||||||||||||||
| 15 | |||||||||||||||||||||||||||||||||||
| 16 | =head1 AUTHOR | ||||||||||||||||||||||||||||||||||
| 17 | |||||||||||||||||||||||||||||||||||
| 18 | Ronan Oger, cpan@roitsystems.com | ||||||||||||||||||||||||||||||||||
| 19 | |||||||||||||||||||||||||||||||||||
| 20 | =head1 SEE ALSO | ||||||||||||||||||||||||||||||||||
| 21 | |||||||||||||||||||||||||||||||||||
| 22 | For description of the methods see L<SVG>. | ||||||||||||||||||||||||||||||||||
| 23 | |||||||||||||||||||||||||||||||||||
| 24 | =cut | ||||||||||||||||||||||||||||||||||
| 25 | |||||||||||||||||||||||||||||||||||
| 26 | 30 | ▶ | use SVG::XML; | ||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||
| 27 | 30 | ▶ | use SVG::DOM; | ||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||
| 28 | 30 | ▶ | use SVG::Extension; | ||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||
| 29 | 30 | ▶ | use Scalar::Util qw/weaken/; | ||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||
| 30 | |||||||||||||||||||||||||||||||||||
| 31 | 30 | our $AUTOLOAD; | |||||||||||||||||||||||||||||||||
| 32 | |||||||||||||||||||||||||||||||||||
| 33 | 30 | my @autosubs = qw( | |||||||||||||||||||||||||||||||||
| 34 | animateMotion animateColor animateTransform circle ellipse rect polyline | ||||||||||||||||||||||||||||||||||
| 35 | path polygon line title desc defs | ||||||||||||||||||||||||||||||||||
| 36 | altGlyph altGlyphDef altGlyphItem clipPath color-profile | ||||||||||||||||||||||||||||||||||
| 37 | cursor definition-src font-face-format font-face-name | ||||||||||||||||||||||||||||||||||
| 38 | font-face-src font-face-url foreignObject glyph | ||||||||||||||||||||||||||||||||||
| 39 | glyphRef hkern marker mask metadata missing-glyph | ||||||||||||||||||||||||||||||||||
| 40 | mpath switch symbol textPath tref tspan view vkern marker textbox | ||||||||||||||||||||||||||||||||||
| 41 | flowText style script | ||||||||||||||||||||||||||||||||||
| 42 | image a g | ||||||||||||||||||||||||||||||||||
| 43 | ); | ||||||||||||||||||||||||||||||||||
| 44 | |||||||||||||||||||||||||||||||||||
| 45 | 30 | our %autosubs = map { $_ => 1 } @autosubs; | |||||||||||||||||||||||||||||||||
| 46 | |||||||||||||||||||||||||||||||||||
| 47 | #------------------------------------------------------------------------------- | ||||||||||||||||||||||||||||||||||
| 48 | |||||||||||||||||||||||||||||||||||
| 49 | 182 | ▶ | sub new { | ||||||||||||||||||||||||||||||||
|
Subroutine
new: called CC=11 SCAR=24.3
Pod
undocumented
| |||||||||||||||||||||||||||||||||||
| 50 | 182 | my ( $proto, $name, %attrs ) = @_; | |||||||||||||||||||||||||||||||||
| 51 | 182 | ▶ | my $class = ref($proto) || $proto; | ||||||||||||||||||||||||||||||||
|
Condition33%1/3
ref $proto || $proto
MC/DC0%0/2
ref $proto || $proto
ref $proto
$proto
Truth table33%1/3
A || B
A= ref $protoB= $proto
| |||||||||||||||||||||||||||||||||||
| 52 | 182 | my $self = { -name => $name }; | |||||||||||||||||||||||||||||||||
| 53 | 182 | foreach my $key ( keys %attrs ) { | |||||||||||||||||||||||||||||||||
| 54 | |||||||||||||||||||||||||||||||||||
| 55 | #handle escapes for special elements such as anchor | ||||||||||||||||||||||||||||||||||
| 56 | 923 | ▶ | if ( $key =~ /^-/ ) { | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||
| 57 | 687 | ▶ | if ( $key eq '-href' ) { | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||
| 58 | 4 | $self->{'xlink:href'} = $attrs{$key}; | |||||||||||||||||||||||||||||||||
| 59 | 4 | ▶ | $self->{'xlink:type'} = $attrs{-type} if $attrs{-type}; | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||
| 60 | 4 | ▶ | $self->{'xlink:role'} = $attrs{-role} if $attrs{-role}; | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||
| 61 | 4 | ▶ | $self->{'xlink:title'} = $attrs{-title} if $attrs{-title}; | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||
| 62 | 4 | ▶ | $self->{'xlink:show'} = $attrs{-show} if $attrs{-show}; | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||
| 63 | $self->{'xlink:arcrole'} = $attrs{-arcrole} | ||||||||||||||||||||||||||||||||||
| 64 | 4 | ▶ | if $attrs{-arcrole}; | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||
| 65 | $self->{'xlink:actuate'} = $attrs{-actuate} | ||||||||||||||||||||||||||||||||||
| 66 | 4 | ▶ | if $attrs{-actuate}; | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||
| 67 | 4 | next; | |||||||||||||||||||||||||||||||||
| 68 | } | ||||||||||||||||||||||||||||||||||
| 69 | } | ||||||||||||||||||||||||||||||||||
| 70 | 919 | $self->{$key} = $attrs{$key}; | |||||||||||||||||||||||||||||||||
| 71 | } | ||||||||||||||||||||||||||||||||||
| 72 | |||||||||||||||||||||||||||||||||||
| 73 | 182 | return bless( $self, $class ); | |||||||||||||||||||||||||||||||||
| 74 | } | ||||||||||||||||||||||||||||||||||
| 75 | |||||||||||||||||||||||||||||||||||
| 76 | #------------------------------------------------------------------------------- | ||||||||||||||||||||||||||||||||||
| 77 | |||||||||||||||||||||||||||||||||||
| 78 | 9 | ▶ | sub release { | ||||||||||||||||||||||||||||||||
|
Subroutine
release: called CC=4 SCAR=14.3
Pod
undocumented
| |||||||||||||||||||||||||||||||||||
| 79 | 9 | my $self = shift; | |||||||||||||||||||||||||||||||||
| 80 | |||||||||||||||||||||||||||||||||||
| 81 | 9 | foreach my $key ( keys( %{$self} ) ) { | |||||||||||||||||||||||||||||||||
| 82 | 84 | ▶ | next if $key =~ /^-/; | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||
| 83 | 5 | ▶ | if ( ref( $self->{$key} ) =~ /^SVG/ ) { | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||
| 84 | 0 | eval { $self->{$key}->release; }; | |||||||||||||||||||||||||||||||||
| 85 | } | ||||||||||||||||||||||||||||||||||
| 86 | 5 | delete( $self->{$key} ); | |||||||||||||||||||||||||||||||||
| 87 | } | ||||||||||||||||||||||||||||||||||
| 88 | |||||||||||||||||||||||||||||||||||
| 89 | 9 | return $self; | |||||||||||||||||||||||||||||||||
| 90 | } | ||||||||||||||||||||||||||||||||||
| 91 | |||||||||||||||||||||||||||||||||||
| 92 | 149 | ▶ | sub xmlify { | ||||||||||||||||||||||||||||||||
|
Subroutine
xmlify: called CC=28 SCAR=33.7
Pod
undocumented
| |||||||||||||||||||||||||||||||||||
| 93 | 149 | my $self = shift; | |||||||||||||||||||||||||||||||||
| 94 | 149 | ▶ | my $ns = $self->{-namespace} || $self->{-docref}->{-namespace} || undef; | ||||||||||||||||||||||||||||||||
|
Condition40%2/5
$self->{'-namespace'} || $self->{'-docref'}{'-namespace'} || undef
$self->{"-namespace"} or $self->{"-docref"}{"-namespace"}
MC/DC0%0/2
$self->{'-namespace'} || $self->{'-docref'}{'-namespace'} || undef
$self->{"-namespace"}
$self->{"-docref"}{"-namespace"}
Truth table33%1/3
A or B
A= $self->{"-namespace"}B= $self->{"-docref"}{"-namespace"}
| |||||||||||||||||||||||||||||||||||
| 95 | 149 | my $xml = ''; | |||||||||||||||||||||||||||||||||
| 96 | |||||||||||||||||||||||||||||||||||
| 97 | #prep the attributes | ||||||||||||||||||||||||||||||||||
| 98 | 149 | my %attrs; | |||||||||||||||||||||||||||||||||
| 99 | 149 | foreach my $k ( keys( %{$self} ) ) { | |||||||||||||||||||||||||||||||||
| 100 | 2041 | ▶ | if ( $k =~ /^-/ ) { next; } | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||
| 101 | 309 | ▶ | if ( ref( $self->{$k} ) eq 'ARRAY' ) { | ||||||||||||||||||||||||||||||||
|
Branch: 3 branches
| |||||||||||||||||||||||||||||||||||
| 102 | 0 | $attrs{$k} = join( ', ', @{ $self->{$k} } ); | |||||||||||||||||||||||||||||||||
| 103 | } | ||||||||||||||||||||||||||||||||||
| 104 | elsif ( ref( $self->{$k} ) eq 'HASH' ) { | ||||||||||||||||||||||||||||||||||
| 105 | 5 | $attrs{$k} = cssstyle( %{ $self->{$k} } ); | |||||||||||||||||||||||||||||||||
| 106 | } | ||||||||||||||||||||||||||||||||||
| 107 | elsif ( ref( $self->{$k} ) eq '' ) { | ||||||||||||||||||||||||||||||||||
| 108 | 304 | $attrs{$k} = $self->{$k}; | |||||||||||||||||||||||||||||||||
| 109 | } | ||||||||||||||||||||||||||||||||||
| 110 | } | ||||||||||||||||||||||||||||||||||
| 111 | |||||||||||||||||||||||||||||||||||
| 112 | #prep the tag | ||||||||||||||||||||||||||||||||||
| 113 | 149 | ▶ | if ( $self->{-name} eq 'comment' && $self->{-comment} ) { | ||||||||||||||||||||||||||||||||
|
Branch: 2 branches
Condition66%2/3
$self->{"-name"} eq "comment" and $self->{"-comment"}
MC/DC50%1/2
$self->{"-name"} eq "comment" and $self->{"-comment"}
$self->{"-name"} eq "comment"
$self->{"-comment"}
Truth table66%2/3
A and B
A= $self->{"-name"} eq "comment"B= $self->{"-comment"}
| |||||||||||||||||||||||||||||||||||
| 114 | 27 | return $self->xmlcomment( $self->{-comment} ); | |||||||||||||||||||||||||||||||||
| 115 | } | ||||||||||||||||||||||||||||||||||
| 116 | elsif ( $self->{-name} eq 'document' ) { | ||||||||||||||||||||||||||||||||||
| 117 | |||||||||||||||||||||||||||||||||||
| 118 | #write the xml header | ||||||||||||||||||||||||||||||||||
| 119 | 29 | ▶ | $xml .= $self->xmldecl unless $self->{-inline}; | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||
| 120 | |||||||||||||||||||||||||||||||||||
| 121 | $xml .= $self->xmlpi( $self->{-document}->{-pi} ) | ||||||||||||||||||||||||||||||||||
| 122 | 29 | ▶ | if $self->{-document}->{-pi}; | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||
| 123 | |||||||||||||||||||||||||||||||||||
| 124 | #and write the dtd if this is inline | ||||||||||||||||||||||||||||||||||
| 125 | 29 | ▶ | $xml .= $self->dtddecl unless $self->{-inline}; | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||
| 126 | |||||||||||||||||||||||||||||||||||
| 127 | #rest of the xml | ||||||||||||||||||||||||||||||||||
| 128 | 29 | foreach my $k ( @{ $self->{-childs} } ) { | |||||||||||||||||||||||||||||||||
| 129 | 29 | ▶ | if ( ref($k) =~ /^SVG::Element/ ) { | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||
| 130 | 29 | $xml .= $k->xmlify($ns); | |||||||||||||||||||||||||||||||||
| 131 | } | ||||||||||||||||||||||||||||||||||
| 132 | } | ||||||||||||||||||||||||||||||||||
| 133 | |||||||||||||||||||||||||||||||||||
| 134 | 29 | return $xml; | |||||||||||||||||||||||||||||||||
| 135 | } | ||||||||||||||||||||||||||||||||||
| 136 | my $is_cdataish | ||||||||||||||||||||||||||||||||||
| 137 | = defined $self->{-cdata} | ||||||||||||||||||||||||||||||||||
| 138 | || defined $self->{-CDATA} | ||||||||||||||||||||||||||||||||||
| 139 | 93 | ▶ | || defined $self->{-cdata_noxmlesc}; | ||||||||||||||||||||||||||||||||
|
Condition100%6/6
defined $self->{'-cdata'} || defined $self->{'-CDATA'} || defined $self->{'-cdata_noxmlesc'}
defined $self->{"-cdata"} or defined $self->{"-CDATA"}
MC/DC100%3/3
defined $self->{'-cdata'} || defined $self->{'-CDATA'} || defined $self->{'-cdata_noxmlesc'}
defined $self->{"-cdata"}
defined $self->{"-CDATA"}
defined $self->{'-cdata_noxmlesc'}
Truth table100%4/4
A or B || C
A= defined $self->{"-cdata"}B= defined $self->{"-CDATA"}C= defined $self->{'-cdata_noxmlesc'}
| |||||||||||||||||||||||||||||||||||
| 140 | 93 | ▶ | if ( defined $self->{-childs} || $is_cdataish ) { | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%3/3
defined $self->{"-childs"} or $is_cdataish
MC/DC100%2/2
defined $self->{"-childs"} or $is_cdataish
defined $self->{"-childs"}
$is_cdataish
Truth table100%3/3
A or B
A= defined $self->{"-childs"}B= $is_cdataish
| |||||||||||||||||||||||||||||||||||
| 141 | $xml .= $self->{-docref}->{-elsep} | ||||||||||||||||||||||||||||||||||
| 142 | 54 | ▶ | unless ( $self->{-inline} && $self->{-name} ); | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
$self->{"-inline"} and $self->{"-name"}
MC/DC50%1/2
$self->{"-inline"} and $self->{"-name"}
$self->{"-inline"}
$self->{"-name"}
Truth table66%2/3
A and B
A= $self->{"-inline"}B= $self->{"-name"}
| |||||||||||||||||||||||||||||||||||
| 143 | 54 | $xml .= $self->{-docref}->{-indent} x $self->{-docref}->{-level}; | |||||||||||||||||||||||||||||||||
| 144 | 54 | $xml .= xmltagopen_ln( $self->{-name}, $ns, %attrs ); | |||||||||||||||||||||||||||||||||
| 145 | 54 | $self->{-docref}->{-level}++; | |||||||||||||||||||||||||||||||||
| 146 | 54 | foreach my $k ( @{ $self->{-childs} } ) { | |||||||||||||||||||||||||||||||||
| 147 | 77 | ▶ | if ( ref($k) =~ /^SVG::Element/ ) { | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||
| 148 | 77 | $xml .= $k->xmlify($ns); | |||||||||||||||||||||||||||||||||
| 149 | } | ||||||||||||||||||||||||||||||||||
| 150 | } | ||||||||||||||||||||||||||||||||||
| 151 | |||||||||||||||||||||||||||||||||||
| 152 | 54 | ▶ | if ( defined $self->{-cdata} ) { | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||
| 153 | 13 | $xml .= $self->xmlescp( $self->{-cdata} ); | |||||||||||||||||||||||||||||||||
| 154 | } | ||||||||||||||||||||||||||||||||||
| 155 | 54 | ▶ | if ( defined $self->{-CDATA} ) { | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||
| 156 | 3 | $xml .= '<![CDATA[' . $self->{-CDATA} . ']]>'; | |||||||||||||||||||||||||||||||||
| 157 | } | ||||||||||||||||||||||||||||||||||
| 158 | 54 | ▶ | if ( defined $self->{-cdata_noxmlesc} ) { | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||
| 159 | 1 | $xml .= $self->{-cdata_noxmlesc}; | |||||||||||||||||||||||||||||||||
| 160 | } | ||||||||||||||||||||||||||||||||||
| 161 | |||||||||||||||||||||||||||||||||||
| 162 | #return without writing the tag out if it the document tag | ||||||||||||||||||||||||||||||||||
| 163 | 54 | $self->{-docref}->{-level}--; | |||||||||||||||||||||||||||||||||
| 164 | 54 | ▶ | unless ($is_cdataish) { | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||
| 165 | 37 | $xml .= $self->{-docref}->{-elsep}; | |||||||||||||||||||||||||||||||||
| 166 | 37 | $xml .= $self->{-docref}->{-indent} x $self->{-docref}->{-level}; | |||||||||||||||||||||||||||||||||
| 167 | } | ||||||||||||||||||||||||||||||||||
| 168 | 54 | $xml .= xmltagclose_ln( $self->{-name}, $ns ); | |||||||||||||||||||||||||||||||||
| 169 | } | ||||||||||||||||||||||||||||||||||
| 170 | else { | ||||||||||||||||||||||||||||||||||
| 171 | 39 | $xml .= $self->{-docref}->{-elsep}; | |||||||||||||||||||||||||||||||||
| 172 | 39 | $xml .= $self->{-docref}->{-indent} x $self->{-docref}->{-level}; | |||||||||||||||||||||||||||||||||
| 173 | 39 | $xml .= xmltag_ln( $self->{-name}, $ns, %attrs ); | |||||||||||||||||||||||||||||||||
| 174 | } | ||||||||||||||||||||||||||||||||||
| 175 | |||||||||||||||||||||||||||||||||||
| 176 | #return the finished tag | ||||||||||||||||||||||||||||||||||
| 177 | 93 | return $xml; | |||||||||||||||||||||||||||||||||
| 178 | } | ||||||||||||||||||||||||||||||||||
| 179 | |||||||||||||||||||||||||||||||||||
| 180 | 0 | ▶ | sub perlify { | ||||||||||||||||||||||||||||||||
|
Subroutine
perlify: not called CC=17 SCAR=57.2
Pod
undocumented
| |||||||||||||||||||||||||||||||||||
| 181 | 0 | my $self = shift; | |||||||||||||||||||||||||||||||||
| 182 | 0 | my $code = ''; | |||||||||||||||||||||||||||||||||
| 183 | |||||||||||||||||||||||||||||||||||
| 184 | #prep the attributes | ||||||||||||||||||||||||||||||||||
| 185 | 0 | my %attrs; | |||||||||||||||||||||||||||||||||
| 186 | 0 | foreach my $k ( keys( %{$self} ) ) { | |||||||||||||||||||||||||||||||||
| 187 | 0 | ▶ | next if $k =~ /^-/; | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||
| 188 | 0 | ▶ | if ( ref( $self->{$k} ) eq 'ARRAY' ) { | ||||||||||||||||||||||||||||||||
|
Branch: 3 branches
| |||||||||||||||||||||||||||||||||||
| 189 | 0 | $attrs{$k} = join( ', ', @{ $self->{$k} } ); | |||||||||||||||||||||||||||||||||
| 190 | } | ||||||||||||||||||||||||||||||||||
| 191 | elsif ( ref( $self->{$k} ) eq 'HASH' ) { | ||||||||||||||||||||||||||||||||||
| 192 | 0 | $attrs{$k} = cssstyle( %{ $self->{$k} } ); | |||||||||||||||||||||||||||||||||
| 193 | } | ||||||||||||||||||||||||||||||||||
| 194 | elsif ( ref( $self->{$k} ) eq '' ) { | ||||||||||||||||||||||||||||||||||
| 195 | 0 | $attrs{$k} = $self->{$k}; | |||||||||||||||||||||||||||||||||
| 196 | } | ||||||||||||||||||||||||||||||||||
| 197 | } | ||||||||||||||||||||||||||||||||||
| 198 | |||||||||||||||||||||||||||||||||||
| 199 | 0 | ▶ | if ( $self->{-comment} ) { | ||||||||||||||||||||||||||||||||
|
Branch: 3 branches
| |||||||||||||||||||||||||||||||||||
| 200 | 0 | $code .= "->comment($self->{-comment})"; | |||||||||||||||||||||||||||||||||
| 201 | 0 | return $code; | |||||||||||||||||||||||||||||||||
| 202 | } | ||||||||||||||||||||||||||||||||||
| 203 | elsif ( $self->{-pi} ) { | ||||||||||||||||||||||||||||||||||
| 204 | 0 | $code .= "->pi($self->{-pi})"; | |||||||||||||||||||||||||||||||||
| 205 | 0 | return $code; | |||||||||||||||||||||||||||||||||
| 206 | } | ||||||||||||||||||||||||||||||||||
| 207 | elsif ( $self->{-name} eq 'document' ) { | ||||||||||||||||||||||||||||||||||
| 208 | |||||||||||||||||||||||||||||||||||
| 209 | #write the xml header | ||||||||||||||||||||||||||||||||||
| 210 | #$xml .= $self->xmldecl; | ||||||||||||||||||||||||||||||||||
| 211 | #and write the dtd if this is inline | ||||||||||||||||||||||||||||||||||
| 212 | #$xml .= $self->dtddecl unless $self->{-inline}; | ||||||||||||||||||||||||||||||||||
| 213 | 0 | foreach my $k ( @{ $self->{-childs} } ) { | |||||||||||||||||||||||||||||||||
| 214 | 0 | ▶ | if ( ref($k) =~ /^SVG::Element/ ) { | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||
| 215 | 0 | $code .= $k->perlify(); | |||||||||||||||||||||||||||||||||
| 216 | } | ||||||||||||||||||||||||||||||||||
| 217 | } | ||||||||||||||||||||||||||||||||||
| 218 | 0 | return $code; | |||||||||||||||||||||||||||||||||
| 219 | } | ||||||||||||||||||||||||||||||||||
| 220 | |||||||||||||||||||||||||||||||||||
| 221 | 0 | ▶ | if ( defined $self->{-childs} ) { | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||
| 222 | 0 | $code .= $self->{-docref}->{-elsep}; | |||||||||||||||||||||||||||||||||
| 223 | 0 | $code .= $self->{-docref}->{-indent} x $self->{-docref}->{-level}; | |||||||||||||||||||||||||||||||||
| 224 | $code | ||||||||||||||||||||||||||||||||||
| 225 | .= $self->{-name} . '(' | ||||||||||||||||||||||||||||||||||
| 226 | 0 | . ( join ', ', ( map {"$_=>'$attrs{$_}'"} sort keys %attrs ) ) | |||||||||||||||||||||||||||||||||
| 227 | . ')'; | ||||||||||||||||||||||||||||||||||
| 228 | 0 | ▶ | if ( $self->{-cdata} ) { | ||||||||||||||||||||||||||||||||
|
Branch: 3 branches
| |||||||||||||||||||||||||||||||||||
| 229 | 0 | $code .= "->cdata($self->{-cdata})"; | |||||||||||||||||||||||||||||||||
| 230 | } | ||||||||||||||||||||||||||||||||||
| 231 | elsif ( $self->{-CDATA} ) { | ||||||||||||||||||||||||||||||||||
| 232 | 0 | $code .= "->CDATA($self->{-CDATA})"; | |||||||||||||||||||||||||||||||||
| 233 | } | ||||||||||||||||||||||||||||||||||
| 234 | elsif ( $self->{-cdata_noxmlesc} ) { | ||||||||||||||||||||||||||||||||||
| 235 | 0 | $code .= "->cdata_noxmlesc($self->{-cdata_noxmlesc})"; | |||||||||||||||||||||||||||||||||
| 236 | } | ||||||||||||||||||||||||||||||||||
| 237 | |||||||||||||||||||||||||||||||||||
| 238 | 0 | $self->{-docref}->{-level}++; | |||||||||||||||||||||||||||||||||
| 239 | 0 | foreach my $k ( @{ $self->{-childs} } ) { | |||||||||||||||||||||||||||||||||
| 240 | 0 | ▶ | if ( ref($k) =~ /^SVG::Element/ ) { | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||
| 241 | 0 | $code .= $k->perlify(); | |||||||||||||||||||||||||||||||||
| 242 | } | ||||||||||||||||||||||||||||||||||
| 243 | } | ||||||||||||||||||||||||||||||||||
| 244 | 0 | $self->{-docref}->{-level}--; | |||||||||||||||||||||||||||||||||
| 245 | } | ||||||||||||||||||||||||||||||||||
| 246 | else { | ||||||||||||||||||||||||||||||||||
| 247 | 0 | $code .= $self->{-docref}->{-elsep}; | |||||||||||||||||||||||||||||||||
| 248 | 0 | $code .= $self->{-docref}->{-indent} x $self->{-docref}->{-level}; | |||||||||||||||||||||||||||||||||
| 249 | $code | ||||||||||||||||||||||||||||||||||
| 250 | .= $self->{-name} . '(' | ||||||||||||||||||||||||||||||||||
| 251 | 0 | . ( join ', ', ( map {"$_=>'$attrs{$_}'"} sort keys %attrs ) ) | |||||||||||||||||||||||||||||||||
| 252 | . ')'; | ||||||||||||||||||||||||||||||||||
| 253 | } | ||||||||||||||||||||||||||||||||||
| 254 | |||||||||||||||||||||||||||||||||||
| 255 | 0 | return $code; | |||||||||||||||||||||||||||||||||
| 256 | } | ||||||||||||||||||||||||||||||||||
| 257 | 30 | *toperl = \&perlify; | |||||||||||||||||||||||||||||||||
| 258 | |||||||||||||||||||||||||||||||||||
| 259 | 138 | ▶ | sub addchilds { | ||||||||||||||||||||||||||||||||
|
Subroutine
addchilds: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||
| 260 | 138 | my $self = shift; | |||||||||||||||||||||||||||||||||
| 261 | 138 | push @{ $self->{-childs} }, @_; | |||||||||||||||||||||||||||||||||
| 262 | 138 | return $self; | |||||||||||||||||||||||||||||||||
| 263 | } | ||||||||||||||||||||||||||||||||||
| 264 | |||||||||||||||||||||||||||||||||||
| 265 | 140 | ▶ | sub tag { | ||||||||||||||||||||||||||||||||
|
Subroutine
tag: called CC=10 SCAR=23.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||
| 266 | 140 | my ( $self, $name, %attrs ) = @_; | |||||||||||||||||||||||||||||||||
| 267 | |||||||||||||||||||||||||||||||||||
| 268 | 140 | ▶ | unless ( $self->{-parent} ) { | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||
| 269 | |||||||||||||||||||||||||||||||||||
| 270 | #traverse down the tree until you find a non-document entry | ||||||||||||||||||||||||||||||||||
| 271 | 118 | ▶ | while ( $self->{-document} ) { $self = $self->{-document} } | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||
| 272 | } | ||||||||||||||||||||||||||||||||||
| 273 | 140 | my $tag = new SVG::Element( $name, %attrs ); | |||||||||||||||||||||||||||||||||
| 274 | |||||||||||||||||||||||||||||||||||
| 275 | #define the element namespace | ||||||||||||||||||||||||||||||||||
| 276 | 140 | ▶ | $tag->{-namespace} = $attrs{-namespace} if ( $attrs{-namespace} ); | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||
| 277 | |||||||||||||||||||||||||||||||||||
| 278 | #add the tag to the document element | ||||||||||||||||||||||||||||||||||
| 279 | 140 | $tag->{-docref} = $self->{-docref}; | |||||||||||||||||||||||||||||||||
| 280 | 140 | weaken( $tag->{-docref} ); | |||||||||||||||||||||||||||||||||
| 281 | |||||||||||||||||||||||||||||||||||
| 282 | #create the empty idlist hash ref unless it already exists | ||||||||||||||||||||||||||||||||||
| 283 | $tag->{-docref}->{-idlist} = {} | ||||||||||||||||||||||||||||||||||
| 284 | 140 | ▶ | unless ( defined $tag->{-docref}->{-idlist} ); | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||
| 285 | |||||||||||||||||||||||||||||||||||
| 286 | #verify that the current id is unique. compain on exception | ||||||||||||||||||||||||||||||||||
| 287 | #>>>TBD: add -strictids option to disable this check if desired | ||||||||||||||||||||||||||||||||||
| 288 | 140 | ▶ | if ( $tag->{id} ) { | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||
| 289 | 14 | ▶ | if ( $self->getElementByID( $tag->{id} ) ) { | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||
| 290 | 2 | $self->error( $tag->{id} => 'ID already exists in document' ); | |||||||||||||||||||||||||||||||||
| 291 | 1 | return; | |||||||||||||||||||||||||||||||||
| 292 | } | ||||||||||||||||||||||||||||||||||
| 293 | } | ||||||||||||||||||||||||||||||||||
| 294 | |||||||||||||||||||||||||||||||||||
| 295 | #add the current id reference to the document id hash | ||||||||||||||||||||||||||||||||||
| 296 | 138 | ▶ | if ( defined( $tag->{id} ) ) { | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||
| 297 | 12 | $tag->{-docref}->{-idlist}->{ $tag->{id} } = $tag; | |||||||||||||||||||||||||||||||||
| 298 | } | ||||||||||||||||||||||||||||||||||
| 299 | |||||||||||||||||||||||||||||||||||
| 300 | #create the empty idlist hash ref unless it already exists | ||||||||||||||||||||||||||||||||||
| 301 | $tag->{-docref}->{-elist} = {} | ||||||||||||||||||||||||||||||||||
| 302 | 138 | ▶ | unless ( defined $tag->{-docref}->{-elist} ); | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||
| 303 | |||||||||||||||||||||||||||||||||||
| 304 | #create the empty idlist hash ref unless it already exists | ||||||||||||||||||||||||||||||||||
| 305 | $tag->{-docref}->{-elist}->{ $tag->{-name} } = [] | ||||||||||||||||||||||||||||||||||
| 306 | 138 | ▶ | unless ( defined $tag->{-docref}->{-elist}->{ $tag->{-name} } ); | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||
| 307 | |||||||||||||||||||||||||||||||||||
| 308 | #add the current element ref to the corresponding element-hash array | ||||||||||||||||||||||||||||||||||
| 309 | # -elist is a hash of element names. key name is element, content is object ref. | ||||||||||||||||||||||||||||||||||
| 310 | |||||||||||||||||||||||||||||||||||
| 311 | # add the reference to $tag to the array of refs that belong to the | ||||||||||||||||||||||||||||||||||
| 312 | # key $tag->{-name}. | ||||||||||||||||||||||||||||||||||
| 313 | 138 | unshift @{ $tag->{-docref}->{-elist}->{ $tag->{-name} } }, $tag; | |||||||||||||||||||||||||||||||||
| 314 | |||||||||||||||||||||||||||||||||||
| 315 | # attach element to the DOM of the document | ||||||||||||||||||||||||||||||||||
| 316 | 138 | $tag->{-parent} = $self; | |||||||||||||||||||||||||||||||||
| 317 | 138 | weaken( $tag->{-parent} ); | |||||||||||||||||||||||||||||||||
| 318 | 138 | $tag->{-parentname} = $self->{-name}; | |||||||||||||||||||||||||||||||||
| 319 | 138 | $self->addchilds($tag); | |||||||||||||||||||||||||||||||||
| 320 | |||||||||||||||||||||||||||||||||||
| 321 | 138 | return ($tag); | |||||||||||||||||||||||||||||||||
| 322 | } | ||||||||||||||||||||||||||||||||||
| 323 | |||||||||||||||||||||||||||||||||||
| 324 | 30 | *element = \&tag; | |||||||||||||||||||||||||||||||||
| 325 | |||||||||||||||||||||||||||||||||||
| 326 | 3 | ▶ | sub anchor { | ||||||||||||||||||||||||||||||||
|
Subroutine
anchor: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||
| 327 | 3 | my ( $self, %attrs ) = @_; | |||||||||||||||||||||||||||||||||
| 328 | 3 | my $an = $self->tag( 'a', %attrs ); | |||||||||||||||||||||||||||||||||
| 329 | |||||||||||||||||||||||||||||||||||
| 330 | #$an->{'xlink:href'}=$attrs{-href} if(defined $attrs{-href}); | ||||||||||||||||||||||||||||||||||
| 331 | #$an->{'target'}=$attrs{-target} if(defined $attrs{-target}); | ||||||||||||||||||||||||||||||||||
| 332 | 3 | return ($an); | |||||||||||||||||||||||||||||||||
| 333 | } | ||||||||||||||||||||||||||||||||||
| 334 | |||||||||||||||||||||||||||||||||||
| 335 | 42 | ▶ | sub svg { | ||||||||||||||||||||||||||||||||
|
Subroutine
svg: called CC=3 SCAR=11.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||
| 336 | 42 | my ( $self, %attrs ) = @_; | |||||||||||||||||||||||||||||||||
| 337 | 42 | my $svg = $self->tag( 'svg', %attrs ); | |||||||||||||||||||||||||||||||||
| 338 | 42 | ▶ | $svg->{'height'} = '100%' unless ( $svg->{'height'} ); | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||
| 339 | 42 | ▶ | $svg->{'width'} = '100%' unless ( $svg->{'width'} ); | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||
| 340 | 42 | return ($svg); | |||||||||||||||||||||||||||||||||
| 341 | } | ||||||||||||||||||||||||||||||||||
| 342 | |||||||||||||||||||||||||||||||||||
| 343 | 1 | ▶ | sub rectangle { | ||||||||||||||||||||||||||||||||
|
Subroutine
rectangle: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||
| 344 | 1 | my ( $self, %attrs ) = @_; | |||||||||||||||||||||||||||||||||
| 345 | 1 | return $self->tag( 'rect', %attrs ); | |||||||||||||||||||||||||||||||||
| 346 | } | ||||||||||||||||||||||||||||||||||
| 347 | |||||||||||||||||||||||||||||||||||
| 348 | #sub image { | ||||||||||||||||||||||||||||||||||
| 349 | # my ($self,%attrs)=@_; | ||||||||||||||||||||||||||||||||||
| 350 | # my $im=$self->tag('image',%attrs); | ||||||||||||||||||||||||||||||||||
| 351 | # #$im->{'xlink:href'}=$attrs{-href} if(defined $attrs{-href}); | ||||||||||||||||||||||||||||||||||
| 352 | # return $im; | ||||||||||||||||||||||||||||||||||
| 353 | #} | ||||||||||||||||||||||||||||||||||
| 354 | |||||||||||||||||||||||||||||||||||
| 355 | 0 | ▶ | sub use { | ||||||||||||||||||||||||||||||||
|
Subroutine
use: not called CC=2 SCAR=17.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||
| 356 | 0 | my ( $self, %attrs ) = @_; | |||||||||||||||||||||||||||||||||
| 357 | 0 | my $u = $self->tag( 'use', %attrs ); | |||||||||||||||||||||||||||||||||
| 358 | 0 | ▶ | $u->{'xlink:href'} = $attrs{-href} if ( defined $attrs{-href} ); | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||
| 359 | 0 | return $u; | |||||||||||||||||||||||||||||||||
| 360 | } | ||||||||||||||||||||||||||||||||||
| 361 | |||||||||||||||||||||||||||||||||||
| 362 | 20 | ▶ | sub text { | ||||||||||||||||||||||||||||||||
|
Subroutine
text: called CC=4 SCAR=14.2
Pod
undocumented
| |||||||||||||||||||||||||||||||||||
| 363 | 20 | my ( $self, %attrs ) = @_; | |||||||||||||||||||||||||||||||||
| 364 | 20 | my $pre = ''; | |||||||||||||||||||||||||||||||||
| 365 | 20 | ▶ | $pre = $attrs{-type} || 'std'; | ||||||||||||||||||||||||||||||||
|
Condition50%1/2
$attrs{'-type'} || 'std'
MC/DC0%0/1
$attrs{'-type'} || 'std'
$attrs{'-type'}
Truth table50%1/2
A
A= $attrs{'-type'}
| |||||||||||||||||||||||||||||||||||
| 366 | 20 | my %get_pre = ( | |||||||||||||||||||||||||||||||||
| 367 | std => 'text', | ||||||||||||||||||||||||||||||||||
| 368 | path => 'textPath', | ||||||||||||||||||||||||||||||||||
| 369 | span => 'tspan', | ||||||||||||||||||||||||||||||||||
| 370 | ); | ||||||||||||||||||||||||||||||||||
| 371 | |||||||||||||||||||||||||||||||||||
| 372 | 20 | $pre = $get_pre{ lc($pre) }; | |||||||||||||||||||||||||||||||||
| 373 | 20 | my $text = $self->tag( $pre, %attrs ); | |||||||||||||||||||||||||||||||||
| 374 | 20 | ▶ | $text->{'xlink:href'} = $attrs{-href} if ( defined $attrs{-href} ); | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||
| 375 | 20 | ▶ | $text->{'target'} = $attrs{-target} if ( defined $attrs{-target} ); | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||
| 376 | 20 | return ($text); | |||||||||||||||||||||||||||||||||
| 377 | } | ||||||||||||||||||||||||||||||||||
| 378 | |||||||||||||||||||||||||||||||||||
| 379 | 24 | ▶ | sub comment { | ||||||||||||||||||||||||||||||||
|
Subroutine
comment: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||
| 380 | 24 | my ( $self, @text ) = @_; | |||||||||||||||||||||||||||||||||
| 381 | 24 | my $tag = $self->tag('comment'); | |||||||||||||||||||||||||||||||||
| 382 | 24 | $tag->{-comment} = [@text]; | |||||||||||||||||||||||||||||||||
| 383 | 24 | return $tag; | |||||||||||||||||||||||||||||||||
| 384 | } | ||||||||||||||||||||||||||||||||||
| 385 | |||||||||||||||||||||||||||||||||||
| 386 | 4 | ▶ | sub pi { | ||||||||||||||||||||||||||||||||
|
Subroutine
pi: called CC=4 SCAR=13.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||
| 387 | 4 | my ( $self, @text ) = @_; | |||||||||||||||||||||||||||||||||
| 388 | 4 | ▶ | return $self->{-document}->{-pi} unless scalar @text; | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||
| 389 | 2 | my @pi; | |||||||||||||||||||||||||||||||||
| 390 | 2 | ▶ | @pi = @{ $self->{-document}->{-pi} } if $self->{-document}->{-pi}; | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||
| 391 | 2 | ▶ | unshift( @text, @pi ) if @pi; | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||
| 392 | 2 | $self->{-document}->{-pi} = \@text; | |||||||||||||||||||||||||||||||||
| 393 | 2 | my $tag = $self->tag('pi'); | |||||||||||||||||||||||||||||||||
| 394 | 2 | return $tag; | |||||||||||||||||||||||||||||||||
| 395 | } | ||||||||||||||||||||||||||||||||||
| 396 | |||||||||||||||||||||||||||||||||||
| 397 | =pod | ||||||||||||||||||||||||||||||||||
| 398 | |||||||||||||||||||||||||||||||||||
| 399 | =head2 get_path | ||||||||||||||||||||||||||||||||||
| 400 | |||||||||||||||||||||||||||||||||||
| 401 | Documented as L<SVG/get_path>. | ||||||||||||||||||||||||||||||||||
| 402 | |||||||||||||||||||||||||||||||||||
| 403 | =cut | ||||||||||||||||||||||||||||||||||
| 404 | |||||||||||||||||||||||||||||||||||
| 405 | 1 | ▶ | sub get_path { | ||||||||||||||||||||||||||||||||
|
Subroutine
get_path: called CC=12 SCAR=38.4
Pod
documented
| |||||||||||||||||||||||||||||||||||
| 406 | 1 | my ( $self, %attrs ) = @_; | |||||||||||||||||||||||||||||||||
| 407 | |||||||||||||||||||||||||||||||||||
| 408 | 1 | ▶ | my $type = $attrs{-type} || 'path'; | ||||||||||||||||||||||||||||||||
|
Condition50%1/2
$attrs{'-type'} || 'path'
MC/DC0%0/1
$attrs{'-type'} || 'path'
$attrs{'-type'}
Truth table50%1/2
A
A= $attrs{'-type'}
| |||||||||||||||||||||||||||||||||||
| 409 | 1 | my @x = @{ $attrs{x} }; | |||||||||||||||||||||||||||||||||
| 410 | 1 | my @y = @{ $attrs{y} }; | |||||||||||||||||||||||||||||||||
| 411 | 1 | my $points; | |||||||||||||||||||||||||||||||||
| 412 | |||||||||||||||||||||||||||||||||||
| 413 | # we need a path-like point string returned | ||||||||||||||||||||||||||||||||||
| 414 | 1 | ▶ | if ( lc($type) eq 'path' ) { | ||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||
| 415 | 0 | my $char = 'M'; | |||||||||||||||||||||||||||||||||
| 416 | $char = ' m ' | ||||||||||||||||||||||||||||||||||
| 417 | 0 | ▶ | if ( defined $attrs{-relative} && lc( $attrs{-relative} ) ); | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
defined $attrs{"-relative"} and lc $attrs{"-relative"}
MC/DC0%0/2
defined $attrs{"-relative"} and lc $attrs{"-relative"}
defined $attrs{"-relative"}
lc $attrs{"-relative"}
Truth table0%0/3
A and B
A= defined $attrs{"-relative"}B= lc $attrs{"-relative"}
| |||||||||||||||||||||||||||||||||||
| 418 | 0 | ▶ | while (@x) { | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||
| 419 | |||||||||||||||||||||||||||||||||||
| 420 | #scale each value | ||||||||||||||||||||||||||||||||||
| 421 | 0 | my $x = shift @x; | |||||||||||||||||||||||||||||||||
| 422 | 0 | my $y = shift @y; | |||||||||||||||||||||||||||||||||
| 423 | |||||||||||||||||||||||||||||||||||
| 424 | #append the scaled value to the graph | ||||||||||||||||||||||||||||||||||
| 425 | 0 | $points .= "$char $x $y "; | |||||||||||||||||||||||||||||||||
| 426 | 0 | $char = ' L '; | |||||||||||||||||||||||||||||||||
| 427 | $char = ' l ' | ||||||||||||||||||||||||||||||||||
| 428 | if ( defined $attrs{-relative} | ||||||||||||||||||||||||||||||||||
| 429 | 0 | ▶ | && lc( $attrs{-relative} ) ); | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
defined $attrs{"-relative"} and lc $attrs{"-relative"}
MC/DC0%0/2
defined $attrs{"-relative"} and lc $attrs{"-relative"}
defined $attrs{"-relative"}
lc $attrs{"-relative"}
Truth table0%0/3
A and B
A= defined $attrs{"-relative"}B= lc $attrs{"-relative"}
| |||||||||||||||||||||||||||||||||||
| 430 | } | ||||||||||||||||||||||||||||||||||
| 431 | $points .= ' z ' | ||||||||||||||||||||||||||||||||||
| 432 | 0 | ▶ | if ( defined $attrs{-closed} && lc( $attrs{-closed} ) ); | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
defined $attrs{"-closed"} and lc $attrs{"-closed"}
MC/DC0%0/2
defined $attrs{"-closed"} and lc $attrs{"-closed"}
defined $attrs{"-closed"}
lc $attrs{"-closed"}
Truth table0%0/3
A and B
A= defined $attrs{"-closed"}B= lc $attrs{"-closed"}
| |||||||||||||||||||||||||||||||||||
| 433 | 0 | my %out = ( d => $points ); | |||||||||||||||||||||||||||||||||
| 434 | 0 | return \%out; | |||||||||||||||||||||||||||||||||
| 435 | } | ||||||||||||||||||||||||||||||||||
| 436 | elsif ( lc($type) =~ /^poly/ ) { | ||||||||||||||||||||||||||||||||||
| 437 | 1 | ▶ | while (@x) { | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||
| 438 | |||||||||||||||||||||||||||||||||||
| 439 | #scale each value | ||||||||||||||||||||||||||||||||||
| 440 | 5 | my $x = shift @x; | |||||||||||||||||||||||||||||||||
| 441 | 5 | my $y = shift @y; | |||||||||||||||||||||||||||||||||
| 442 | |||||||||||||||||||||||||||||||||||
| 443 | #append the scaled value to the graph | ||||||||||||||||||||||||||||||||||
| 444 | 5 | $points .= "$x,$y "; | |||||||||||||||||||||||||||||||||
| 445 | } | ||||||||||||||||||||||||||||||||||
| 446 | } | ||||||||||||||||||||||||||||||||||
| 447 | 1 | my %out = ( points => $points ); | |||||||||||||||||||||||||||||||||
| 448 | 1 | return \%out; | |||||||||||||||||||||||||||||||||
| 449 | } | ||||||||||||||||||||||||||||||||||
| 450 | |||||||||||||||||||||||||||||||||||
| 451 | 0 | ▶ | sub make_path { | ||||||||||||||||||||||||||||||||
|
Subroutine
make_path: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||
| 452 | 0 | my ( $self, %attrs ) = @_; | |||||||||||||||||||||||||||||||||
| 453 | 0 | return get_path(%attrs); | |||||||||||||||||||||||||||||||||
| 454 | } | ||||||||||||||||||||||||||||||||||
| 455 | |||||||||||||||||||||||||||||||||||
| 456 | 0 | ▶ | sub set_path { | ||||||||||||||||||||||||||||||||
|
Subroutine
set_path: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||
| 457 | 0 | my ( $self, %attrs ) = @_; | |||||||||||||||||||||||||||||||||
| 458 | 0 | return get_path(%attrs); | |||||||||||||||||||||||||||||||||
| 459 | } | ||||||||||||||||||||||||||||||||||
| 460 | |||||||||||||||||||||||||||||||||||
| 461 | 0 | ▶ | sub animate { | ||||||||||||||||||||||||||||||||
|
Subroutine
animate: not called CC=5 SCAR=34.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||
| 462 | 0 | my ( $self, %attrs ) = @_; | |||||||||||||||||||||||||||||||||
| 463 | 0 | my %rtr = %attrs; | |||||||||||||||||||||||||||||||||
| 464 | 0 | my $method = $rtr{'-method'}; # Set | Transform | Motion | Color | |||||||||||||||||||||||||||||||||
| 465 | |||||||||||||||||||||||||||||||||||
| 466 | 0 | $method = lc($method); | |||||||||||||||||||||||||||||||||
| 467 | |||||||||||||||||||||||||||||||||||
| 468 | # we do not want this to pollute the generation of the tag | ||||||||||||||||||||||||||||||||||
| 469 | 0 | delete $rtr{-method}; #bug report from briac. | |||||||||||||||||||||||||||||||||
| 470 | |||||||||||||||||||||||||||||||||||
| 471 | 0 | my %animation_method = ( | |||||||||||||||||||||||||||||||||
| 472 | transform => 'animateTransform', | ||||||||||||||||||||||||||||||||||
| 473 | motion => 'animateMotion', | ||||||||||||||||||||||||||||||||||
| 474 | color => 'animateColor', | ||||||||||||||||||||||||||||||||||
| 475 | set => 'set', | ||||||||||||||||||||||||||||||||||
| 476 | attribute => 'animate', | ||||||||||||||||||||||||||||||||||
| 477 | ); | ||||||||||||||||||||||||||||||||||
| 478 | |||||||||||||||||||||||||||||||||||
| 479 | 0 | ▶ | my $name = $animation_method{$method} || 'animate'; | ||||||||||||||||||||||||||||||||
|
Condition0%0/2
$animation_method{$method} || 'animate'
MC/DC0%0/1
$animation_method{$method} || 'animate'
$animation_method{$method}
Truth table0%0/2
A
A= $animation_method{$method}
| |||||||||||||||||||||||||||||||||||
| 480 | |||||||||||||||||||||||||||||||||||
| 481 | #list of legal entities for each of the 5 methods of animations | ||||||||||||||||||||||||||||||||||
| 482 | 0 | my %legal = ( | |||||||||||||||||||||||||||||||||
| 483 | animate => q{ begin dur end min max restart repeatCount | ||||||||||||||||||||||||||||||||||
| 484 | repeatDur fill attributeType attributeName additive | ||||||||||||||||||||||||||||||||||
| 485 | accumulate calcMode values keyTimes keySplines | ||||||||||||||||||||||||||||||||||
| 486 | from to by }, | ||||||||||||||||||||||||||||||||||
| 487 | animateTransform => q{ begin dur end min max restart repeatCount | ||||||||||||||||||||||||||||||||||
| 488 | repeatDur fill additive accumulate calcMode values | ||||||||||||||||||||||||||||||||||
| 489 | keyTimes keySplines from to by calcMode path keyPoints | ||||||||||||||||||||||||||||||||||
| 490 | rotate origin type attributeName attributeType }, | ||||||||||||||||||||||||||||||||||
| 491 | animateMotion => q{ begin dur end min max restart repeatCount | ||||||||||||||||||||||||||||||||||
| 492 | repeatDur fill additive accumulate calcMode values | ||||||||||||||||||||||||||||||||||
| 493 | to by keyTimes keySplines from path keyPoints | ||||||||||||||||||||||||||||||||||
| 494 | rotate origin }, | ||||||||||||||||||||||||||||||||||
| 495 | animateColor => q{ begin dur end min max restart repeatCount | ||||||||||||||||||||||||||||||||||
| 496 | repeatDur fill additive accumulate calcMode values | ||||||||||||||||||||||||||||||||||
| 497 | keyTimes keySplines from to by }, | ||||||||||||||||||||||||||||||||||
| 498 | set => q{ begin dur end min max restart repeatCount repeatDur | ||||||||||||||||||||||||||||||||||
| 499 | fill to }, | ||||||||||||||||||||||||||||||||||
| 500 | ); | ||||||||||||||||||||||||||||||||||
| 501 | |||||||||||||||||||||||||||||||||||
| 502 | 0 | foreach my $k ( keys %rtr ) { | |||||||||||||||||||||||||||||||||
| 503 | 0 | ▶ | next if ( $k =~ /\-/ ); | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||
| 504 | |||||||||||||||||||||||||||||||||||
| 505 | 0 | ▶ | if ( $legal{$name} !~ /\b$k\b/ ) { | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||
| 506 | 0 | $self->error( "$name.$k" => 'Illegal animation command' ); | |||||||||||||||||||||||||||||||||
| 507 | } | ||||||||||||||||||||||||||||||||||
| 508 | } | ||||||||||||||||||||||||||||||||||
| 509 | |||||||||||||||||||||||||||||||||||
| 510 | 0 | return $self->tag( $name, %rtr ); | |||||||||||||||||||||||||||||||||
| 511 | } | ||||||||||||||||||||||||||||||||||
| 512 | |||||||||||||||||||||||||||||||||||
| 513 | 12 | ▶ | sub group { | ||||||||||||||||||||||||||||||||
|
Subroutine
group: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||
| 514 | 12 | my ( $self, %attrs ) = @_; | |||||||||||||||||||||||||||||||||
| 515 | 12 | return $self->tag( 'g', %attrs ); | |||||||||||||||||||||||||||||||||
| 516 | } | ||||||||||||||||||||||||||||||||||
| 517 | |||||||||||||||||||||||||||||||||||
| 518 | 0 | ▶ | sub STYLE { | ||||||||||||||||||||||||||||||||
|
Subroutine
STYLE: not called CC=3 SCAR=24.8
Pod
undocumented
| |||||||||||||||||||||||||||||||||||
| 519 | 0 | my ( $self, %attrs ) = @_; | |||||||||||||||||||||||||||||||||
| 520 | |||||||||||||||||||||||||||||||||||
| 521 | 0 | ▶ | $self->{style} = $self->{style} || {}; | ||||||||||||||||||||||||||||||||
|
Condition0%0/2
$self->{'style'} || {}
MC/DC0%0/1
$self->{'style'} || {}
$self->{'style'}
Truth table0%0/2
A
A= $self->{'style'}
| |||||||||||||||||||||||||||||||||||
| 522 | 0 | foreach my $k ( keys %attrs ) { | |||||||||||||||||||||||||||||||||
| 523 | 0 | $self->{style}->{$k} = $attrs{$k}; | |||||||||||||||||||||||||||||||||
| 524 | } | ||||||||||||||||||||||||||||||||||
| 525 | |||||||||||||||||||||||||||||||||||
| 526 | 0 | return $self; | |||||||||||||||||||||||||||||||||
| 527 | } | ||||||||||||||||||||||||||||||||||
| 528 | |||||||||||||||||||||||||||||||||||
| 529 | 0 | ▶ | sub mouseaction { | ||||||||||||||||||||||||||||||||
|
Subroutine
mouseaction: not called CC=3 SCAR=24.8
Pod
undocumented
| |||||||||||||||||||||||||||||||||||
| 530 | 0 | my ( $self, %attrs ) = @_; | |||||||||||||||||||||||||||||||||
| 531 | |||||||||||||||||||||||||||||||||||
| 532 | 0 | ▶ | $self->{mouseaction} = $self->{mouseaction} || {}; | ||||||||||||||||||||||||||||||||
|
Condition0%0/2
$self->{'mouseaction'} || {}
MC/DC0%0/1
$self->{'mouseaction'} || {}
$self->{'mouseaction'}
Truth table0%0/2
A
A= $self->{'mouseaction'}
| |||||||||||||||||||||||||||||||||||
| 533 | 0 | foreach my $k ( keys %attrs ) { | |||||||||||||||||||||||||||||||||
| 534 | 0 | $self->{mouseaction}->{$k} = $attrs{$k}; | |||||||||||||||||||||||||||||||||
| 535 | } | ||||||||||||||||||||||||||||||||||
| 536 | |||||||||||||||||||||||||||||||||||
| 537 | 0 | return $self; | |||||||||||||||||||||||||||||||||
| 538 | } | ||||||||||||||||||||||||||||||||||
| 539 | |||||||||||||||||||||||||||||||||||
| 540 | 3 | ▶ | sub attrib { | ||||||||||||||||||||||||||||||||
|
Subroutine
attrib: called CC=5 SCAR=19.3
Pod
undocumented
| |||||||||||||||||||||||||||||||||||
| 541 | 3 | my ( $self, $name, $val ) = @_; | |||||||||||||||||||||||||||||||||
| 542 | |||||||||||||||||||||||||||||||||||
| 543 | #verify that the current id is unique. compain on exception | ||||||||||||||||||||||||||||||||||
| 544 | 3 | ▶ | if ( $name eq 'id' ) { | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||
| 545 | 0 | ▶ | if ( $self->getElementByID($val) ) { | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||
| 546 | 0 | $self->error( $val => 'ID already exists in document' ); | |||||||||||||||||||||||||||||||||
| 547 | 0 | return; | |||||||||||||||||||||||||||||||||
| 548 | } | ||||||||||||||||||||||||||||||||||
| 549 | } | ||||||||||||||||||||||||||||||||||
| 550 | |||||||||||||||||||||||||||||||||||
| 551 | 3 | ▶ | if ( not defined $val ) { | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||
| 552 | 2 | ▶ | if ( scalar(@_) == 2 ) { | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||
| 553 | |||||||||||||||||||||||||||||||||||
| 554 | # two arguments only - retrieve | ||||||||||||||||||||||||||||||||||
| 555 | 2 | return $self->{$name}; | |||||||||||||||||||||||||||||||||
| 556 | } | ||||||||||||||||||||||||||||||||||
| 557 | else { | ||||||||||||||||||||||||||||||||||
| 558 | |||||||||||||||||||||||||||||||||||
| 559 | # 3rd argument is undef - delete | ||||||||||||||||||||||||||||||||||
| 560 | 0 | delete $self->{$name}; | |||||||||||||||||||||||||||||||||
| 561 | } | ||||||||||||||||||||||||||||||||||
| 562 | } | ||||||||||||||||||||||||||||||||||
| 563 | else { | ||||||||||||||||||||||||||||||||||
| 564 | |||||||||||||||||||||||||||||||||||
| 565 | # 3 defined arguments - set | ||||||||||||||||||||||||||||||||||
| 566 | 1 | $self->{$name} = $val; | |||||||||||||||||||||||||||||||||
| 567 | } | ||||||||||||||||||||||||||||||||||
| 568 | |||||||||||||||||||||||||||||||||||
| 569 | 1 | return $self; | |||||||||||||||||||||||||||||||||
| 570 | } | ||||||||||||||||||||||||||||||||||
| 571 | 30 | *attr = \&attrib; | |||||||||||||||||||||||||||||||||
| 572 | 30 | *attribute = \&attrib; | |||||||||||||||||||||||||||||||||
| 573 | |||||||||||||||||||||||||||||||||||
| 574 | 20 | ▶ | sub cdata { | ||||||||||||||||||||||||||||||||
|
Subroutine
cdata: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||
| 575 | 20 | my ( $self, @txt ) = @_; | |||||||||||||||||||||||||||||||||
| 576 | 20 | $self->{-cdata} = join( ' ', @txt ); | |||||||||||||||||||||||||||||||||
| 577 | 20 | return ($self); | |||||||||||||||||||||||||||||||||
| 578 | } | ||||||||||||||||||||||||||||||||||
| 579 | |||||||||||||||||||||||||||||||||||
| 580 | 2 | ▶ | sub CDATA { | ||||||||||||||||||||||||||||||||
|
Subroutine
CDATA: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||
| 581 | 2 | my ( $self, @txt ) = @_; | |||||||||||||||||||||||||||||||||
| 582 | 2 | $self->{-CDATA} = join( '\n', @txt ); | |||||||||||||||||||||||||||||||||
| 583 | 2 | return ($self); | |||||||||||||||||||||||||||||||||
| 584 | } | ||||||||||||||||||||||||||||||||||
| 585 | |||||||||||||||||||||||||||||||||||
| 586 | 1 | ▶ | sub cdata_noxmlesc { | ||||||||||||||||||||||||||||||||
|
Subroutine
cdata_noxmlesc: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||
| 587 | 1 | my ( $self, @txt ) = @_; | |||||||||||||||||||||||||||||||||
| 588 | 1 | $self->{-cdata_noxmlesc} = join( '\n', @txt ); | |||||||||||||||||||||||||||||||||
| 589 | 1 | return ($self); | |||||||||||||||||||||||||||||||||
| 590 | } | ||||||||||||||||||||||||||||||||||
| 591 | |||||||||||||||||||||||||||||||||||
| 592 | 0 | ▶ | sub filter { | ||||||||||||||||||||||||||||||||
|
Subroutine
filter: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||
| 593 | 0 | my ( $self, %attrs ) = @_; | |||||||||||||||||||||||||||||||||
| 594 | 0 | return $self->tag( 'filter', %attrs ); | |||||||||||||||||||||||||||||||||
| 595 | } | ||||||||||||||||||||||||||||||||||
| 596 | |||||||||||||||||||||||||||||||||||
| 597 | 1 | ▶ | sub fe { | ||||||||||||||||||||||||||||||||
|
Subroutine
fe: called CC=3 SCAR=11.2
Pod
undocumented
| |||||||||||||||||||||||||||||||||||
| 598 | 1 | my ( $self, %attrs ) = @_; | |||||||||||||||||||||||||||||||||
| 599 | |||||||||||||||||||||||||||||||||||
| 600 | 1 | ▶ | return 0 unless ( $attrs{'-type'} ); | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||
| 601 | 1 | my %allowed = ( | |||||||||||||||||||||||||||||||||
| 602 | blend => 'feBlend', | ||||||||||||||||||||||||||||||||||
| 603 | colormatrix => 'feColorMatrix', | ||||||||||||||||||||||||||||||||||
| 604 | componenttrans => 'feComponentTrans', | ||||||||||||||||||||||||||||||||||
| 605 | Componenttrans => 'feComponentTrans', | ||||||||||||||||||||||||||||||||||
| 606 | composite => 'feComposite', | ||||||||||||||||||||||||||||||||||
| 607 | convolvematrix => 'feConvolveMatrix', | ||||||||||||||||||||||||||||||||||
| 608 | diffuselighting => 'feDiffuseLighting', | ||||||||||||||||||||||||||||||||||
| 609 | displacementmap => 'feDisplacementMap', | ||||||||||||||||||||||||||||||||||
| 610 | distantlight => 'feDistantLight', | ||||||||||||||||||||||||||||||||||
| 611 | flood => 'feFlood', | ||||||||||||||||||||||||||||||||||
| 612 | funca => 'feFuncA', | ||||||||||||||||||||||||||||||||||
| 613 | funcb => 'feFuncB', | ||||||||||||||||||||||||||||||||||
| 614 | funcg => 'feFuncG', | ||||||||||||||||||||||||||||||||||
| 615 | funcr => 'feFuncR', | ||||||||||||||||||||||||||||||||||
| 616 | gaussianblur => 'feGaussianBlur', | ||||||||||||||||||||||||||||||||||
| 617 | image => 'feImage', | ||||||||||||||||||||||||||||||||||
| 618 | merge => 'feMerge', | ||||||||||||||||||||||||||||||||||
| 619 | mergenode => 'feMergeNode', | ||||||||||||||||||||||||||||||||||
| 620 | morphology => 'feMorphology', | ||||||||||||||||||||||||||||||||||
| 621 | offset => 'feOffset', | ||||||||||||||||||||||||||||||||||
| 622 | pointlight => 'fePointLight', | ||||||||||||||||||||||||||||||||||
| 623 | specularlighting => 'feSpecularLighting', | ||||||||||||||||||||||||||||||||||
| 624 | spotlight => 'feSpotLight', | ||||||||||||||||||||||||||||||||||
| 625 | tile => 'feTile', | ||||||||||||||||||||||||||||||||||
| 626 | turbulence => 'feTurbulence', | ||||||||||||||||||||||||||||||||||
| 627 | ); | ||||||||||||||||||||||||||||||||||
| 628 | |||||||||||||||||||||||||||||||||||
| 629 | 1 | my $key = lc( $attrs{'-type'} ); | |||||||||||||||||||||||||||||||||
| 630 | 1 | ▶ | my $fe_name = $allowed{ lc($key) } || 'error:illegal_filter_element'; | ||||||||||||||||||||||||||||||||
|
Condition50%1/2
$allowed{lc $key} || 'error:illegal_filter_element'
MC/DC0%0/1
$allowed{lc $key} || 'error:illegal_filter_element'
$allowed{lc $key}
Truth table50%1/2
A
A= $allowed{lc $key}
| |||||||||||||||||||||||||||||||||||
| 631 | 1 | delete $attrs{'-type'}; | |||||||||||||||||||||||||||||||||
| 632 | |||||||||||||||||||||||||||||||||||
| 633 | 1 | return $self->tag( $fe_name, %attrs ); | |||||||||||||||||||||||||||||||||
| 634 | } | ||||||||||||||||||||||||||||||||||
| 635 | |||||||||||||||||||||||||||||||||||
| 636 | 0 | ▶ | sub pattern { | ||||||||||||||||||||||||||||||||
|
Subroutine
pattern: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||
| 637 | 0 | my ( $self, %attrs ) = @_; | |||||||||||||||||||||||||||||||||
| 638 | 0 | return $self->tag( 'pattern', %attrs ); | |||||||||||||||||||||||||||||||||
| 639 | } | ||||||||||||||||||||||||||||||||||
| 640 | |||||||||||||||||||||||||||||||||||
| 641 | 0 | ▶ | sub set { | ||||||||||||||||||||||||||||||||
|
Subroutine
set: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||
| 642 | 0 | my ( $self, %attrs ) = @_; | |||||||||||||||||||||||||||||||||
| 643 | 0 | return $self->tag( 'set', %attrs ); | |||||||||||||||||||||||||||||||||
| 644 | } | ||||||||||||||||||||||||||||||||||
| 645 | |||||||||||||||||||||||||||||||||||
| 646 | 0 | ▶ | sub stop { | ||||||||||||||||||||||||||||||||
|
Subroutine
stop: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||
| 647 | 0 | my ( $self, %attrs ) = @_; | |||||||||||||||||||||||||||||||||
| 648 | 0 | return $self->tag( 'stop', %attrs ); | |||||||||||||||||||||||||||||||||
| 649 | } | ||||||||||||||||||||||||||||||||||
| 650 | |||||||||||||||||||||||||||||||||||
| 651 | 0 | ▶ | sub gradient { | ||||||||||||||||||||||||||||||||
|
Subroutine
gradient: not called CC=3 SCAR=24.8
Pod
undocumented
| |||||||||||||||||||||||||||||||||||
| 652 | 0 | my ( $self, %attrs ) = @_; | |||||||||||||||||||||||||||||||||
| 653 | |||||||||||||||||||||||||||||||||||
| 654 | 0 | ▶ | my $type = $attrs{'-type'} || 'linear'; | ||||||||||||||||||||||||||||||||
|
Condition0%0/2
$attrs{'-type'} || 'linear'
MC/DC0%0/1
$attrs{'-type'} || 'linear'
$attrs{'-type'}
Truth table0%0/2
A
A= $attrs{'-type'}
| |||||||||||||||||||||||||||||||||||
| 655 | 0 | ▶ | unless ( $type =~ /^(linear|radial)$/ ) { | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||
| 656 | 0 | $type = 'linear'; | |||||||||||||||||||||||||||||||||
| 657 | } | ||||||||||||||||||||||||||||||||||
| 658 | 0 | delete $attrs{'-type'}; | |||||||||||||||||||||||||||||||||
| 659 | |||||||||||||||||||||||||||||||||||
| 660 | 0 | return $self->tag( $type . 'Gradient', %attrs ); | |||||||||||||||||||||||||||||||||
| 661 | } | ||||||||||||||||||||||||||||||||||
| 662 | |||||||||||||||||||||||||||||||||||
| 663 | #------------------------------------------------------------------------------- | ||||||||||||||||||||||||||||||||||
| 664 | # Internal methods | ||||||||||||||||||||||||||||||||||
| 665 | |||||||||||||||||||||||||||||||||||
| 666 | 12 | ▶ | sub error { | ||||||||||||||||||||||||||||||||
|
Subroutine
error: called CC=3 SCAR=11.3
Pod
undocumented
| |||||||||||||||||||||||||||||||||||
| 667 | 12 | my ( $self, $command, $error ) = @_; | |||||||||||||||||||||||||||||||||
| 668 | |||||||||||||||||||||||||||||||||||
| 669 | 12 | ▶ | if ( $self->{-docref}->{-raiseerror} ) { | ||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||
| 670 | 1 | die "$command: $error\n"; | |||||||||||||||||||||||||||||||||
| 671 | } | ||||||||||||||||||||||||||||||||||
| 672 | elsif ( $self->{-docref}->{-printerror} ) { | ||||||||||||||||||||||||||||||||||
| 673 | 0 | print STDERR "$command: $error\n"; | |||||||||||||||||||||||||||||||||
| 674 | } | ||||||||||||||||||||||||||||||||||
| 675 | |||||||||||||||||||||||||||||||||||
| 676 | 11 | $self->{errors}{$command} = $error; | |||||||||||||||||||||||||||||||||
| 677 | } | ||||||||||||||||||||||||||||||||||
| 678 | |||||||||||||||||||||||||||||||||||
| 679 | # This AUTOLOAD method is activated when '-auto' is passed to SVG.pm | ||||||||||||||||||||||||||||||||||
| 680 | 2943 | ▶ | sub autoload { | ||||||||||||||||||||||||||||||||
|
Subroutine
autoload: called CC=4 SCAR=13.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||
| 681 | 2943 | my $self = shift; | |||||||||||||||||||||||||||||||||
| 682 | 2943 | my ( $package, $sub ) = ( $AUTOLOAD =~ /(.*)::([^:]+)$/ ); | |||||||||||||||||||||||||||||||||
| 683 | |||||||||||||||||||||||||||||||||||
| 684 | 2943 | ▶ | if ( $sub eq 'DESTROY' ) { | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||
| 685 | 9 | return $self->release(); | |||||||||||||||||||||||||||||||||
| 686 | } | ||||||||||||||||||||||||||||||||||
| 687 | else { | ||||||||||||||||||||||||||||||||||
| 688 | |||||||||||||||||||||||||||||||||||
| 689 | # the import routine may call us with a tag name involving '-'s | ||||||||||||||||||||||||||||||||||
| 690 | 2934 | my $tag = $sub; | |||||||||||||||||||||||||||||||||
| 691 | 2934 | $sub =~ tr/-/_/; | |||||||||||||||||||||||||||||||||
| 692 | |||||||||||||||||||||||||||||||||||
| 693 | # N.B.: The \ on \@_ makes sure that the incoming arguments are | ||||||||||||||||||||||||||||||||||
| 694 | # used and not the ones passed when the subroutine was created. | ||||||||||||||||||||||||||||||||||
| 695 | # eval "sub $package\:\:$sub (\$;\@) { return shift->tag('$tag',\@_) }"; | ||||||||||||||||||||||||||||||||||
| 696 | #per rt.perl.org comment by slaven. | ||||||||||||||||||||||||||||||||||
| 697 | |||||||||||||||||||||||||||||||||||
| 698 | 2934 | ▶ | if ( !$package->can($sub) ) { | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||
| 699 | ## no critic (TestingAndDebugging::ProhibitNoStrict) | ||||||||||||||||||||||||||||||||||
| 700 | 30 | ▶ | no strict 'refs'; | ||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||
| 701 | 1424 | *{ $package . '::' . $sub } | |||||||||||||||||||||||||||||||||
| 702 | 1424 | ▶ | = sub { return shift->tag( $tag, @_ ) }; | ||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||
| 703 | } | ||||||||||||||||||||||||||||||||||
| 704 | 2934 | ▶ | return $self->$sub(@_) if $self; | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||
| 705 | } | ||||||||||||||||||||||||||||||||||
| 706 | } | ||||||||||||||||||||||||||||||||||
| 707 | |||||||||||||||||||||||||||||||||||
| 708 | #------------------------------------------------------------------------------- | ||||||||||||||||||||||||||||||||||
| 709 | # GD Routines | ||||||||||||||||||||||||||||||||||
| 710 | |||||||||||||||||||||||||||||||||||
| 711 | 0 | ▶ | sub colorAllocate { | ||||||||||||||||||||||||||||||||
|
Subroutine
colorAllocate: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||
| 712 | 0 | my ( $self, $red, $green, $blue ) = @_; | |||||||||||||||||||||||||||||||||
| 713 | 0 | return 'rgb(' . int($red) . ',' . int($green) . ',' . int($blue) . ')'; | |||||||||||||||||||||||||||||||||
| 714 | } | ||||||||||||||||||||||||||||||||||
| 715 | |||||||||||||||||||||||||||||||||||
| 716 | #------------------------------------------------------------------------------- | ||||||||||||||||||||||||||||||||||
| 717 | |||||||||||||||||||||||||||||||||||
| 718 | # Predeclare all known built-in element methods at load time | ||||||||||||||||||||||||||||||||||
| 719 | # so they work regardless of how SVG.pm is imported | ||||||||||||||||||||||||||||||||||
| 720 | # (e.g. 'use SVG ()' suppresses import() but still loads this module). | ||||||||||||||||||||||||||||||||||
| 721 | 30 | foreach my $sub ( keys %SVG::Element::autosubs ) { | |||||||||||||||||||||||||||||||||
| 722 | 1410 | $SVG::Element::AUTOLOAD = "SVG::Element::$sub"; | |||||||||||||||||||||||||||||||||
| 723 | 1410 | SVG::Element::autoload(); | |||||||||||||||||||||||||||||||||
| 724 | } | ||||||||||||||||||||||||||||||||||
| 725 | |||||||||||||||||||||||||||||||||||
| 726 | 30 | 1; | |||||||||||||||||||||||||||||||||