Finished changes for v0.21 - including documentation fixes and a new renderer
[p5sagit/Excel-Template.git] / lib / Excel / Template / TextObject.pm
CommitLineData
d0eafc11 1package Excel::Template::TextObject;
2
3use strict;
4
5BEGIN {
6 use vars qw(@ISA);
7 @ISA = qw(Excel::Template::Base);
8
9 use Excel::Template::Base;
d0eafc11 10}
11
12# This is a helper object. It is not instantiated by the user,
13# nor does it represent an XML object. Rather, certain elements,
14# such as <textbox>, can use this object to do text with variable
15# substitutions.
16
17sub new
18{
19 my $class = shift;
20 my $self = $class->SUPER::new(@_);
21
c11fa570 22 $self->{STACK} = []
23 unless defined $self->{STACK} &&
24 UNIVERSAL::isa($self->{STACK}, 'ARRAY');
d0eafc11 25
26 return $self;
27}
28
29sub resolve
30{
31 my $self = shift;
32 my ($context) = @_;
33
8c63e224 34 my $use_unicode = $context->use_unicode;
35
36 my $t;
37 if ($use_unicode)
38 {
39 require Unicode::String;
40 $t = Unicode::String::utf8('');
41 }
42 else
43 {
44 $t = '';
45 }
d0eafc11 46
47 for my $tok (@{$self->{STACK}})
48 {
49 my $val = $tok;
50 $val = $val->resolve($context)
37513eae 51 if Excel::Template::Factory::is_embedded( $val );
d0eafc11 52
8c63e224 53 $t .= $use_unicode
54 ? Unicode::String::utf8("$val")
55 : $val;
d0eafc11 56 }
57
58 return $t;
59}
60
611;
62__END__
63
64=head1 NAME
65
66Excel::Template::TextObject
67
68=head1 PURPOSE
69
70=head1 NODE NAME
71
72=head1 INHERITANCE
73
74=head1 ATTRIBUTES
75
76=head1 CHILDREN
77
78=head1 AFFECTS
79
80=head1 DEPENDENCIES
81
82=head1 USAGE
83
84=head1 AUTHOR
85
c09684ff 86Rob Kinyon (rob.kinyon@gmail.com)
d0eafc11 87
88=head1 SEE ALSO
89
90=cut