Initial Import
[p5sagit/Excel-Template.git] / lib / Excel / Template / TextObject.pm_
1 package Excel::Template::TextObject;
2
3 use strict;
4
5 BEGIN {
6     use vars qw(@ISA);
7     @ISA = qw(Excel::Template::Base);
8
9     use Excel::Template::Base;
10
11 UNI_YES     use Unicode::String;
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
19 sub 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
29 sub resolve
30 {
31     my $self = shift;
32     my ($context) = @_;
33
34 UNI_YES    my $t = Unicode::String::utf8('');
35 UNI_NO    my $t = '';
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
43 UNI_YES        $t .= Unicode::String::utf8("$val");
44 UNI_NO        $t .= $val;
45     }
46
47     return $t;
48 }
49
50 1;
51 __END__
52
53 =head1 NAME
54
55 Excel::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
75 Rob Kinyon (rkinyon@columbus.rr.com)
76
77 =head1 SEE ALSO
78
79 =cut