Commit | Line | Data |
d0eafc11 |
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; |
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 | |
17 | sub new |
18 | { |
19 | my $class = shift; |
20 | my $self = $class->SUPER::new(@_); |
21 | |
22 | $self->{STACK} = [] unless UNIVERSAL::isa($self->{STACK}, 'ARRAY'); |
23 | |
24 | return $self; |
25 | } |
26 | |
27 | sub resolve |
28 | { |
29 | my $self = shift; |
30 | my ($context) = @_; |
31 | |
8c63e224 |
32 | my $use_unicode = $context->use_unicode; |
33 | |
34 | my $t; |
35 | if ($use_unicode) |
36 | { |
37 | require Unicode::String; |
38 | $t = Unicode::String::utf8(''); |
39 | } |
40 | else |
41 | { |
42 | $t = ''; |
43 | } |
d0eafc11 |
44 | |
45 | for my $tok (@{$self->{STACK}}) |
46 | { |
47 | my $val = $tok; |
48 | $val = $val->resolve($context) |
37513eae |
49 | if Excel::Template::Factory::is_embedded( $val ); |
d0eafc11 |
50 | |
8c63e224 |
51 | $t .= $use_unicode |
52 | ? Unicode::String::utf8("$val") |
53 | : $val; |
d0eafc11 |
54 | } |
55 | |
56 | return $t; |
57 | } |
58 | |
59 | 1; |
60 | __END__ |
61 | |
62 | =head1 NAME |
63 | |
64 | Excel::Template::TextObject |
65 | |
66 | =head1 PURPOSE |
67 | |
68 | =head1 NODE NAME |
69 | |
70 | =head1 INHERITANCE |
71 | |
72 | =head1 ATTRIBUTES |
73 | |
74 | =head1 CHILDREN |
75 | |
76 | =head1 AFFECTS |
77 | |
78 | =head1 DEPENDENCIES |
79 | |
80 | =head1 USAGE |
81 | |
82 | =head1 AUTHOR |
83 | |
c09684ff |
84 | Rob Kinyon (rob.kinyon@gmail.com) |
d0eafc11 |
85 | |
86 | =head1 SEE ALSO |
87 | |
88 | =cut |