line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Excel::Template::Factory; |
2
|
|
|
|
|
|
|
|
3
|
29
|
|
|
29
|
|
120
|
use strict; |
|
29
|
|
|
|
|
38
|
|
|
29
|
|
|
|
|
11931
|
|
4
|
|
|
|
|
|
|
|
5
|
|
|
|
|
|
|
my %Manifest = ( |
6
|
|
|
|
|
|
|
|
7
|
|
|
|
|
|
|
# These are the instantiable nodes |
8
|
|
|
|
|
|
|
'IF' => 'Excel::Template::Container::Conditional', |
9
|
|
|
|
|
|
|
'LOOP' => 'Excel::Template::Container::Loop', |
10
|
|
|
|
|
|
|
'ROW' => 'Excel::Template::Container::Row', |
11
|
|
|
|
|
|
|
'SCOPE' => 'Excel::Template::Container::Scope', |
12
|
|
|
|
|
|
|
'WORKBOOK' => 'Excel::Template::Container::Workbook', |
13
|
|
|
|
|
|
|
'WORKSHEET' => 'Excel::Template::Container::Worksheet', |
14
|
|
|
|
|
|
|
|
15
|
|
|
|
|
|
|
'BACKREF' => 'Excel::Template::Element::Backref', |
16
|
|
|
|
|
|
|
'CELL' => 'Excel::Template::Element::Cell', |
17
|
|
|
|
|
|
|
'FORMULA' => 'Excel::Template::Element::Formula', |
18
|
|
|
|
|
|
|
'FREEZEPANES' => 'Excel::Template::Element::FreezePanes', |
19
|
|
|
|
|
|
|
'MERGE_RANGE' => 'Excel::Template::Element::MergeRange', |
20
|
|
|
|
|
|
|
'IMAGE' => 'Excel::Template::Element::Image', |
21
|
|
|
|
|
|
|
'RANGE' => 'Excel::Template::Element::Range', |
22
|
|
|
|
|
|
|
'VAR' => 'Excel::Template::Element::Var', |
23
|
|
|
|
|
|
|
|
24
|
|
|
|
|
|
|
'FORMAT' => 'Excel::Template::Container::Format', |
25
|
|
|
|
|
|
|
|
26
|
|
|
|
|
|
|
# These are all the Format short-cut objects |
27
|
|
|
|
|
|
|
# They are also instantiable |
28
|
|
|
|
|
|
|
'BOLD' => 'Excel::Template::Container::Bold', |
29
|
|
|
|
|
|
|
'HIDDEN' => 'Excel::Template::Container::Hidden', |
30
|
|
|
|
|
|
|
'ITALIC' => 'Excel::Template::Container::Italic', |
31
|
|
|
|
|
|
|
'LOCKED' => 'Excel::Template::Container::Locked', |
32
|
|
|
|
|
|
|
'OUTLINE' => 'Excel::Template::Container::Outline', |
33
|
|
|
|
|
|
|
'SHADOW' => 'Excel::Template::Container::Shadow', |
34
|
|
|
|
|
|
|
'STRIKEOUT' => 'Excel::Template::Container::Strikeout', |
35
|
|
|
|
|
|
|
|
36
|
|
|
|
|
|
|
'KEEP_LEADING_ZEROS' => 'Excel::Template::Container::KeepLeadingZeros', |
37
|
|
|
|
|
|
|
|
38
|
|
|
|
|
|
|
# These are the helper objects |
39
|
|
|
|
|
|
|
# They are also in here to make E::T::Factory::isa() work. |
40
|
|
|
|
|
|
|
'CONTEXT' => 'Excel::Template::Context', |
41
|
|
|
|
|
|
|
'ITERATOR' => 'Excel::Template::Iterator', |
42
|
|
|
|
|
|
|
'TEXTOBJECT' => 'Excel::Template::TextObject', |
43
|
|
|
|
|
|
|
|
44
|
|
|
|
|
|
|
'CONTAINER' => 'Excel::Template::Container', |
45
|
|
|
|
|
|
|
'ELEMENT' => 'Excel::Template::Element', |
46
|
|
|
|
|
|
|
|
47
|
|
|
|
|
|
|
'BASE' => 'Excel::Template::Base', |
48
|
|
|
|
|
|
|
); |
49
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
my %isBuildable = map { $_ => ~~1 } qw( |
51
|
|
|
|
|
|
|
WORKBOOK WORKSHEET |
52
|
|
|
|
|
|
|
FORMAT BOLD HIDDEN ITALIC LOCKED OUTLINE SHADOW STRIKEOUT |
53
|
|
|
|
|
|
|
IF ROW LOOP SCOPE KEEP_LEADING_ZEROS |
54
|
|
|
|
|
|
|
CELL FORMULA FREEZEPANES IMAGE MERGE_RANGE |
55
|
|
|
|
|
|
|
VAR BACKREF RANGE |
56
|
|
|
|
|
|
|
); |
57
|
|
|
|
|
|
|
|
58
|
|
|
|
|
|
|
{ |
59
|
|
|
|
|
|
|
my %Loaded; |
60
|
|
|
|
|
|
|
sub _load_class |
61
|
|
|
|
|
|
|
{ |
62
|
0
|
|
|
0
|
|
0
|
my $self = shift; |
63
|
0
|
|
|
|
|
0
|
my ($class) = @_; |
64
|
|
|
|
|
|
|
|
65
|
0
|
0
|
|
|
|
0
|
unless ( exists $Loaded{$class} ) |
66
|
|
|
|
|
|
|
{ |
67
|
0
|
|
|
|
|
0
|
(my $filename = $class) =~ s!::!/!g; |
68
|
0
|
|
|
|
|
0
|
eval { |
69
|
0
|
|
|
|
|
0
|
require "$filename.pm"; |
70
|
0
|
0
|
|
|
|
0
|
}; if ($@) { |
71
|
0
|
|
|
|
|
0
|
die "Cannot find or compile PM file for '$class' ($filename) because $@\n"; |
72
|
|
|
|
|
|
|
} |
73
|
|
|
|
|
|
|
|
74
|
0
|
|
|
|
|
0
|
$Loaded{$class} = ~~1; |
75
|
|
|
|
|
|
|
} |
76
|
|
|
|
|
|
|
|
77
|
0
|
|
|
|
|
0
|
return ~~1; |
78
|
|
|
|
|
|
|
} |
79
|
|
|
|
|
|
|
} |
80
|
|
|
|
|
|
|
|
81
|
|
|
|
|
|
|
{ |
82
|
|
|
|
|
|
|
my @param_names = qw(name class isa); |
83
|
|
|
|
|
|
|
sub register |
84
|
|
|
|
|
|
|
{ |
85
|
0
|
|
|
0
|
1
|
0
|
my $self = shift; |
86
|
0
|
|
|
|
|
0
|
my %params = @_; |
87
|
|
|
|
|
|
|
|
88
|
0
|
|
|
|
|
0
|
for (@param_names) |
89
|
|
|
|
|
|
|
{ |
90
|
0
|
0
|
|
|
|
0
|
unless ($params{$_}) |
91
|
|
|
|
|
|
|
{ |
92
|
0
|
0
|
|
|
|
0
|
warn "$_ was not supplied to register()\n" if $^W; |
93
|
0
|
|
|
|
|
0
|
return; |
94
|
|
|
|
|
|
|
} |
95
|
|
|
|
|
|
|
} |
96
|
|
|
|
|
|
|
|
97
|
0
|
|
|
|
|
0
|
my $name = uc $params{name}; |
98
|
0
|
0
|
|
|
|
0
|
if (exists $Manifest{$name}) |
99
|
|
|
|
|
|
|
{ |
100
|
0
|
0
|
|
|
|
0
|
warn "$params{name} already exists in the manifest.\n" if $^W; |
101
|
0
|
|
|
|
|
0
|
return; |
102
|
|
|
|
|
|
|
} |
103
|
|
|
|
|
|
|
|
104
|
0
|
|
|
|
|
0
|
my $isa = uc $params{isa}; |
105
|
0
|
0
|
|
|
|
0
|
unless (exists $Manifest{$isa}) |
106
|
|
|
|
|
|
|
{ |
107
|
0
|
0
|
|
|
|
0
|
warn "$params{isa} does not exist in the manifest.\n" if $^W; |
108
|
0
|
|
|
|
|
0
|
return; |
109
|
|
|
|
|
|
|
} |
110
|
|
|
|
|
|
|
|
111
|
|
|
|
|
|
|
{ |
112
|
29
|
|
|
29
|
|
152
|
no strict 'refs'; |
|
29
|
|
|
|
|
42
|
|
|
29
|
|
|
|
|
9739
|
|
|
0
|
|
|
|
|
0
|
|
113
|
0
|
|
|
|
|
0
|
unshift @{"$params{class}::ISA"}, $Manifest{$isa}; |
|
0
|
|
|
|
|
0
|
|
114
|
|
|
|
|
|
|
} |
115
|
|
|
|
|
|
|
|
116
|
0
|
|
|
|
|
0
|
$self->_load_class( $Manifest{$isa} ); |
117
|
0
|
|
|
|
|
0
|
$self->_load_class( $params{class} ); |
118
|
|
|
|
|
|
|
|
119
|
0
|
|
|
|
|
0
|
$Manifest{$name} = $params{class}; |
120
|
0
|
|
|
|
|
0
|
$isBuildable{$name} = ~~1; |
121
|
|
|
|
|
|
|
|
122
|
0
|
|
|
|
|
0
|
return ~~1; |
123
|
|
|
|
|
|
|
} |
124
|
|
|
|
|
|
|
} |
125
|
|
|
|
|
|
|
|
126
|
|
|
|
|
|
|
sub _create |
127
|
|
|
|
|
|
|
{ |
128
|
0
|
|
|
0
|
|
0
|
my $self = shift; |
129
|
0
|
|
|
|
|
0
|
my $name = uc shift; |
130
|
|
|
|
|
|
|
|
131
|
0
|
0
|
|
|
|
0
|
return unless exists $Manifest{$name}; |
132
|
|
|
|
|
|
|
|
133
|
0
|
|
|
|
|
0
|
$self->_load_class( $Manifest{$name} ); |
134
|
|
|
|
|
|
|
|
135
|
0
|
|
|
|
|
0
|
return $Manifest{$name}->new(@_); |
136
|
|
|
|
|
|
|
} |
137
|
|
|
|
|
|
|
|
138
|
|
|
|
|
|
|
sub _create_node |
139
|
|
|
|
|
|
|
{ |
140
|
0
|
|
|
0
|
|
0
|
my $self = shift; |
141
|
0
|
|
|
|
|
0
|
my $name = uc shift; |
142
|
|
|
|
|
|
|
|
143
|
0
|
0
|
|
|
|
0
|
return unless exists $isBuildable{$name}; |
144
|
|
|
|
|
|
|
|
145
|
0
|
|
|
|
|
0
|
return $self->_create($name, @_); |
146
|
|
|
|
|
|
|
} |
147
|
|
|
|
|
|
|
|
148
|
|
|
|
|
|
|
sub isa |
149
|
|
|
|
|
|
|
{ |
150
|
28
|
50
|
|
28
|
1
|
1660
|
return unless @_ >= 2; |
151
|
|
|
|
|
|
|
exists $Manifest{uc $_[1]} |
152
|
28
|
50
|
|
|
|
222
|
? UNIVERSAL::isa($_[0], $Manifest{uc $_[1]}) |
153
|
|
|
|
|
|
|
: UNIVERSAL::isa(@_) |
154
|
|
|
|
|
|
|
} |
155
|
|
|
|
|
|
|
|
156
|
|
|
|
|
|
|
sub is_embedded |
157
|
|
|
|
|
|
|
{ |
158
|
0
|
0
|
|
0
|
1
|
|
return unless @_ >= 1; |
159
|
|
|
|
|
|
|
|
160
|
0
|
|
0
|
|
|
|
isa( $_[0], $_ ) && return ~~1 for qw( VAR BACKREF RANGE ); |
161
|
0
|
|
|
|
|
|
return; |
162
|
|
|
|
|
|
|
} |
163
|
|
|
|
|
|
|
|
164
|
|
|
|
|
|
|
1; |
165
|
|
|
|
|
|
|
__END__ |