line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package SVG::Parser::SAX::Handler; |
2
|
6
|
|
|
6
|
|
30
|
use strict; |
|
6
|
|
|
|
|
43
|
|
|
6
|
|
|
|
|
233
|
|
3
|
6
|
|
|
6
|
|
31
|
use vars qw(@ISA $VERSION); |
|
6
|
|
|
|
|
12
|
|
|
6
|
|
|
|
|
384
|
|
4
|
|
|
|
|
|
|
|
5
|
|
|
|
|
|
|
require 5.004; |
6
|
|
|
|
|
|
|
|
7
|
6
|
|
|
6
|
|
32
|
use base qw(XML::SAX::Base SVG::Parser::Base); |
|
6
|
|
|
|
|
9
|
|
|
6
|
|
|
|
|
9690
|
|
8
|
6
|
|
|
6
|
|
140329
|
use SVG::Parser::Base; |
|
6
|
|
|
|
|
16
|
|
|
6
|
|
|
|
|
174
|
|
9
|
6
|
|
|
6
|
|
6786
|
use SVG 2.0; |
|
6
|
|
|
|
|
121044
|
|
|
6
|
|
|
|
|
130
|
|
10
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
$VERSION="1.03"; |
12
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
#------------------------------------------------------------------------------- |
14
|
|
|
|
|
|
|
|
15
|
|
|
|
|
|
|
sub new { |
16
|
4
|
|
|
4
|
0
|
10
|
my $proto=shift; |
17
|
4
|
|
33
|
|
|
35
|
my $class=ref($proto) || $proto; |
18
|
4
|
|
|
|
|
9
|
my %attrs=@_; |
19
|
|
|
|
|
|
|
|
20
|
|
|
|
|
|
|
# pass on non-minus-prefixed attributes to handler |
21
|
4
|
|
|
|
|
8
|
my %handler_attrs; |
22
|
4
|
|
|
|
|
18
|
foreach (keys %attrs) { |
23
|
0
|
0
|
|
|
|
0
|
$handler_attrs{$_}=delete $attrs{$_} unless /^-/; |
24
|
|
|
|
|
|
|
} |
25
|
|
|
|
|
|
|
|
26
|
4
|
|
|
|
|
54
|
my $self=$class->SUPER::new(%handler_attrs); |
27
|
|
|
|
|
|
|
|
28
|
|
|
|
|
|
|
# minus-prefixed attributes stay here, double-minus to SVG object |
29
|
4
|
|
|
|
|
375
|
foreach (keys %attrs) { |
30
|
0
|
0
|
|
|
|
0
|
if (/^-(-.+)$/) { |
31
|
0
|
|
|
|
|
0
|
$self->{__svg_attr}{$1}=$attrs{$_}; |
32
|
|
|
|
|
|
|
} else { |
33
|
0
|
|
|
|
|
0
|
$self->{$_}=$attrs{$_}; |
34
|
|
|
|
|
|
|
} |
35
|
|
|
|
|
|
|
} |
36
|
|
|
|
|
|
|
|
37
|
4
|
|
|
|
|
15
|
return $self; |
38
|
|
|
|
|
|
|
} |
39
|
|
|
|
|
|
|
|
40
|
|
|
|
|
|
|
#------------------------------------------------------------------------------- |
41
|
|
|
|
|
|
|
|
42
|
|
|
|
|
|
|
sub start_document { |
43
|
4
|
|
|
4
|
1
|
1317
|
my ($self,$document)=@_; |
44
|
4
|
|
|
|
|
36
|
return $self->SVG::Parser::Base::StartDocument(); |
45
|
|
|
|
|
|
|
} |
46
|
|
|
|
|
|
|
|
47
|
|
|
|
|
|
|
sub start_element { |
48
|
160
|
|
|
160
|
1
|
8669094
|
my ($self,$element)=@_; |
49
|
|
|
|
|
|
|
|
50
|
160
|
|
|
|
|
296
|
my $name=$element->{Name}; |
51
|
972
|
|
|
|
|
3719
|
my %attrs=map { |
52
|
160
|
|
|
|
|
666
|
$element->{Attributes}{$_}{Name} => $element->{Attributes}{$_}{Value} |
53
|
160
|
|
|
|
|
187
|
} keys %{$element->{Attributes}}; |
54
|
|
|
|
|
|
|
|
55
|
160
|
|
|
|
|
1515
|
$self->SVG::Parser::Base::StartTag($name,%attrs); |
56
|
|
|
|
|
|
|
} |
57
|
|
|
|
|
|
|
|
58
|
|
|
|
|
|
|
sub end_element { |
59
|
160
|
|
|
160
|
1
|
14105
|
my ($self,$element)=@_; |
60
|
160
|
|
|
|
|
675
|
return $self->SVG::Parser::Base::EndTag($element); |
61
|
|
|
|
|
|
|
} |
62
|
|
|
|
|
|
|
|
63
|
|
|
|
|
|
|
sub characters { |
64
|
260
|
|
|
260
|
1
|
19714
|
my ($self,$text)=@_; |
65
|
260
|
|
|
|
|
1211
|
return $self->SVG::Parser::Base::Text($text->{Data}); |
66
|
|
|
|
|
|
|
} |
67
|
|
|
|
|
|
|
|
68
|
|
|
|
|
|
|
sub start_cdata { |
69
|
0
|
|
|
0
|
1
|
0
|
my $self=shift; |
70
|
0
|
|
|
|
|
0
|
return $self->SVG::Parser::Base::CdataStart(); |
71
|
|
|
|
|
|
|
} |
72
|
|
|
|
|
|
|
|
73
|
|
|
|
|
|
|
sub end_cdata { |
74
|
0
|
|
|
0
|
1
|
0
|
my $self=shift; |
75
|
0
|
|
|
|
|
0
|
return $self->SVG::Parser::Base::CdataEnd(); |
76
|
|
|
|
|
|
|
} |
77
|
|
|
|
|
|
|
|
78
|
|
|
|
|
|
|
sub processing_instruction { |
79
|
0
|
|
|
0
|
1
|
0
|
my ($self,$pi)=@_; |
80
|
0
|
|
|
|
|
0
|
return $self->SVG::Parser::Base::PI( |
81
|
|
|
|
|
|
|
$pi->{Target}, |
82
|
|
|
|
|
|
|
$pi->{Data} |
83
|
|
|
|
|
|
|
); |
84
|
|
|
|
|
|
|
} |
85
|
|
|
|
|
|
|
|
86
|
|
|
|
|
|
|
sub comment { |
87
|
8
|
|
|
8
|
1
|
15041
|
my ($self,$comment)=@_; |
88
|
8
|
|
|
|
|
58
|
return $self->SVG::Parser::Base::Comment($comment->{Data}); |
89
|
|
|
|
|
|
|
} |
90
|
|
|
|
|
|
|
|
91
|
|
|
|
|
|
|
sub end_document { |
92
|
4
|
|
|
4
|
1
|
645
|
my ($self,$document)=@_; |
93
|
4
|
|
|
|
|
28
|
return $self->SVG::Parser::Base::FinishDocument(); |
94
|
|
|
|
|
|
|
} |
95
|
|
|
|
|
|
|
|
96
|
|
|
|
|
|
|
#------------------------------------------------------------------------------- |
97
|
|
|
|
|
|
|
|
98
|
|
|
|
|
|
|
# handle XML declaration, if present |
99
|
|
|
|
|
|
|
sub xml_decl { |
100
|
0
|
|
|
0
|
1
|
|
my ($self,$decl)=@_; |
101
|
|
|
|
|
|
|
|
102
|
0
|
|
|
|
|
|
$self->SVG::Parser::Base::XMLDecl( |
103
|
|
|
|
|
|
|
$decl->{Version}, |
104
|
|
|
|
|
|
|
$decl->{Encoding}, |
105
|
|
|
|
|
|
|
$decl->{Standalone} |
106
|
|
|
|
|
|
|
); |
107
|
|
|
|
|
|
|
} |
108
|
|
|
|
|
|
|
|
109
|
|
|
|
|
|
|
# handle Doctype declaration, if present (and if parser handles it) |
110
|
|
|
|
|
|
|
sub doctype_decl { |
111
|
0
|
|
|
0
|
1
|
|
my ($self,$dtd)=@_; |
112
|
|
|
|
|
|
|
|
113
|
0
|
|
|
|
|
|
$self->SVG::Parser::Base::Doctype( |
114
|
|
|
|
|
|
|
$dtd->{Name}, |
115
|
|
|
|
|
|
|
$dtd->{SystemId}, |
116
|
|
|
|
|
|
|
$dtd->{PublicId}, |
117
|
|
|
|
|
|
|
$dtd->{Internal} |
118
|
|
|
|
|
|
|
); |
119
|
|
|
|
|
|
|
} |
120
|
|
|
|
|
|
|
|
121
|
|
|
|
|
|
|
#------------------------------------------------------------------------------- |
122
|
|
|
|
|
|
|
|
123
|
|
|
|
|
|
|
sub entity_decl { |
124
|
0
|
|
|
0
|
1
|
|
my ($self,$edecl)=@_; |
125
|
|
|
|
|
|
|
|
126
|
0
|
0
|
|
|
|
|
if (defined $edecl->{Notation}) { |
127
|
|
|
|
|
|
|
# unparsed entity decl |
128
|
0
|
|
|
|
|
|
$self->SVG::Parser::Base::Unparsed( |
129
|
|
|
|
|
|
|
$edecl->{Name}, |
130
|
|
|
|
|
|
|
$edecl->{Value}, |
131
|
|
|
|
|
|
|
$edecl->{SystemID}, |
132
|
|
|
|
|
|
|
$edecl->{PublicID}, |
133
|
|
|
|
|
|
|
$edecl->{Notation}, |
134
|
|
|
|
|
|
|
0, |
135
|
|
|
|
|
|
|
); |
136
|
|
|
|
|
|
|
} else { |
137
|
|
|
|
|
|
|
# internal/external entity decl |
138
|
0
|
|
|
|
|
|
my $isp=0; |
139
|
0
|
0
|
|
|
|
|
if (defined $edecl->{Name}) { |
140
|
0
|
0
|
|
|
|
|
$isp=1 if $edecl->{Name} =~ s/^%//; |
141
|
|
|
|
|
|
|
} |
142
|
|
|
|
|
|
|
|
143
|
|
|
|
|
|
|
$self->SVG::Parser::Base::Entity( |
144
|
0
|
|
|
|
|
|
$edecl->{Name}, |
145
|
|
|
|
|
|
|
$edecl->{Value}, |
146
|
|
|
|
|
|
|
$edecl->{SystemID}, |
147
|
|
|
|
|
|
|
$edecl->{PublicID}, |
148
|
|
|
|
|
|
|
$edecl->{Notation}, |
149
|
|
|
|
|
|
|
$isp |
150
|
|
|
|
|
|
|
); |
151
|
|
|
|
|
|
|
} |
152
|
|
|
|
|
|
|
} |
153
|
|
|
|
|
|
|
|
154
|
|
|
|
|
|
|
sub notation_decl { |
155
|
0
|
|
|
0
|
1
|
|
my ($self,$ndecl)=@_; |
156
|
|
|
|
|
|
|
|
157
|
0
|
|
|
|
|
|
$self->SVG::Parser::Base::Notation( |
158
|
|
|
|
|
|
|
$ndecl->{Name}, |
159
|
|
|
|
|
|
|
$ndecl->{Base}, |
160
|
|
|
|
|
|
|
$ndecl->{SystemID}, |
161
|
|
|
|
|
|
|
$ndecl->{PublicID}, |
162
|
|
|
|
|
|
|
); |
163
|
|
|
|
|
|
|
} |
164
|
|
|
|
|
|
|
|
165
|
|
|
|
|
|
|
sub element_decl { |
166
|
0
|
|
|
0
|
1
|
|
my ($self,$edecl)=@_; |
167
|
|
|
|
|
|
|
|
168
|
0
|
|
|
|
|
|
$self->SVG::Parser::Base::Element( |
169
|
|
|
|
|
|
|
$edecl->{Name}, |
170
|
|
|
|
|
|
|
$edecl->{Model} |
171
|
|
|
|
|
|
|
); |
172
|
|
|
|
|
|
|
} |
173
|
|
|
|
|
|
|
|
174
|
|
|
|
|
|
|
sub attribute_decl { |
175
|
0
|
|
|
0
|
1
|
|
my ($self,$adecl)=@_; |
176
|
|
|
|
|
|
|
|
177
|
0
|
0
|
0
|
|
|
|
$self->SVG::Parser::Base::Attlist( |
|
|
0
|
|
|
|
|
|
178
|
|
|
|
|
|
|
$adecl->{eName}, |
179
|
|
|
|
|
|
|
$adecl->{aName}, |
180
|
|
|
|
|
|
|
$adecl->{Type}, |
181
|
|
|
|
|
|
|
(defined($adecl->{Value}) ? $adecl->{Value} : $adecl->{Mode}), |
182
|
|
|
|
|
|
|
((defined($adecl->{Mode}) and $adecl->{Mode} eq '#FIXED')?1:0), |
183
|
|
|
|
|
|
|
); |
184
|
|
|
|
|
|
|
} |
185
|
|
|
|
|
|
|
|
186
|
|
|
|
|
|
|
#------------------------------------------------------------------------------- |
187
|
|
|
|
|
|
|
|
188
|
|
|
|
|
|
|
=head1 NAME |
189
|
|
|
|
|
|
|
|
190
|
|
|
|
|
|
|
SVG::Parser::SAX::Handler - SAX handler class for SVG documents |
191
|
|
|
|
|
|
|
|
192
|
|
|
|
|
|
|
=head1 DESCRIPTION |
193
|
|
|
|
|
|
|
|
194
|
|
|
|
|
|
|
This module provides the handlers for constructing an SVG document object when |
195
|
|
|
|
|
|
|
using SVG::Parser::SAX. See L for more information. |
196
|
|
|
|
|
|
|
|
197
|
|
|
|
|
|
|
=head1 AUTHOR |
198
|
|
|
|
|
|
|
|
199
|
|
|
|
|
|
|
Peter Wainwright, peter.wainwright@cybrid.net |
200
|
|
|
|
|
|
|
|
201
|
|
|
|
|
|
|
=head1 SEE ALSO |
202
|
|
|
|
|
|
|
|
203
|
|
|
|
|
|
|
L, L |
204
|
|
|
|
|
|
|
|
205
|
|
|
|
|
|
|
=cut |
206
|
|
|
|
|
|
|
|
207
|
|
|
|
|
|
|
1; |