1 package Excel::Template::Container;
7 @ISA = qw(Excel::Template::Base);
9 use Excel::Template::Base;
12 # Containers are objects that can contain arbitrary elements, such as
18 my $self = $class->SUPER::new(@_);
20 $self->{ELEMENTS} = []
21 unless exists $self->{ELEMENTS} &&
22 UNIVERSAL::isa($self->{ELEMENTS}, 'ARRAY');
30 my ($method, $context) = @_;
32 for my $e (@{$self->{ELEMENTS}})
34 $e->enter_scope($context);
35 $e->$method($context);
36 $e->exit_scope($context, 1);
42 sub begin_page { _do_page 'begin_page', @_ }
43 sub end_page { _do_page 'end_page', @_ }
45 sub iterate_over_children
55 $e->enter_scope($context);
57 my $rc = $e->render($context);
58 $continue = $rc if $continue;
60 $e->exit_scope($context);
66 sub render { $_[0]->iterate_over_children($_[1]) }
71 # return $self->iterate_over_children($context);
77 my ($context, $attr) = @_;
79 my $max = $context->get($self, $attr);
82 foreach my $e (@{$self->{ELEMENTS}})
84 $e->enter_scope($context);
86 my $v = $e->isa('CONTAINER')
87 ? $e->max_of($context, $attr)
88 : $e->calculate($context, $attr);
90 $max = $v if $max < $v;
92 $e->exit_scope($context, 1);
101 my ($context, $attr) = @_;
106 foreach my $e (@{$self->{ELEMENTS}})
108 $e->enter_scope($context);
110 $total += $e->isa('CONTAINER')
111 ? $e->total_of($context, $attr)
112 : $e->calculate($context, $attr);
114 $e->exit_scope($context, 1);
125 Excel::Template::Container
145 Rob Kinyon (rob.kinyon@gmail.com)