- Converted to use Unicode logic from PDF::Template
[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;
10
a8441e01 11UNI_YES use Unicode::String;
d0eafc11 12}
13
14# This is a helper object. It is not instantiated by the user,
15# nor does it represent an XML object. Rather, certain elements,
16# such as <textbox>, can use this object to do text with variable
17# substitutions.
18
19sub new
20{
21 my $class = shift;
22 my $self = $class->SUPER::new(@_);
23
24 $self->{STACK} = [] unless UNIVERSAL::isa($self->{STACK}, 'ARRAY');
25
26 return $self;
27}
28
29sub resolve
30{
31 my $self = shift;
32 my ($context) = @_;
33
a8441e01 34UNI_YES my $t = Unicode::String::utf8('');
35UNI_NO my $t = '';
d0eafc11 36
37 for my $tok (@{$self->{STACK}})
38 {
39 my $val = $tok;
40 $val = $val->resolve($context)
41 if Excel::Template::Factory::isa($val, 'VAR');
42
a8441e01 43UNI_YES $t .= Unicode::String::utf8("$val");
44UNI_NO $t .= $val;
d0eafc11 45 }
46
47 return $t;
48}
49
501;
51__END__
52
53=head1 NAME
54
55Excel::Template::TextObject
56
57=head1 PURPOSE
58
59=head1 NODE NAME
60
61=head1 INHERITANCE
62
63=head1 ATTRIBUTES
64
65=head1 CHILDREN
66
67=head1 AFFECTS
68
69=head1 DEPENDENCIES
70
71=head1 USAGE
72
73=head1 AUTHOR
74
75Rob Kinyon (rkinyon@columbus.rr.com)
76
77=head1 SEE ALSO
78
79=cut