Added more tests and fixed formats to work correctly w/multiple templates.
[p5sagit/Excel-Template.git] / lib / Excel / Template / Container / Format.pm
1 package Excel::Template::Container::Format;
2
3 use strict;
4
5 BEGIN {
6     use vars qw(@ISA);
7     @ISA = qw( Excel::Template::Container );
8
9     use Excel::Template::Container;
10 }
11
12 use Excel::Template::Format;
13
14 sub render
15 {
16     my $self = shift;
17     my ($context) = @_;
18
19     my $old_format = $context->active_format;
20     my $format = $context->format_object->copy(
21         $context, $old_format,
22
23         %{$self},
24     );
25     $context->active_format($format);
26
27     my $child_success = $self->iterate_over_children($context);
28
29     $context->active_format($old_format);
30
31     return $child_success;
32 }
33
34 1;
35 __END__
36
37 =head1 NAME
38
39 Excel::Template::Container::Format - Excel::Template::Container::Format
40
41 =head1 PURPOSE
42
43 To format all children according to the parameters
44
45 =head1 NODE NAME
46
47 FORMAT
48
49 =head1 INHERITANCE
50
51 Excel::Template::Container
52
53 =head1 ATTRIBUTES
54
55 Boolean attributes should be set to 1, 0, true, or false.
56
57 Color values can be the color name or the color index. See http://search.cpan.org/~jmcnamara/Spreadsheet-WriteExcel-2.11/lib/Spreadsheet/WriteExcel.pm#COLOURS_IN_EXCEL
58
59 =over 4
60
61 =item * align
62
63 Set to either left, center, right, fill, or justify. Default is left.  See also valign.
64
65 =item * bg_color
66
67 Set to a color value. Default is none.
68
69 =item * bold
70
71 This will set bold to on or off, depending on the boolean value.
72
73 =item * border
74
75 Set the border for all for edges of a cell. Also see bottom, top, left, and right.
76 Valid values are 0 - 7. 
77
78 http://search.cpan.org/~jmcnamara/Spreadsheet-WriteExcel-2.11/lib/Spreadsheet/WriteExcel.pm#set_border()
79
80 =item * border_color
81
82 Sets the color value for the border. See also border, top_color, bottom_color, left_color
83 and right_color.
84
85 =item * bottom
86
87 See border.
88
89 =item * bottom_color
90
91 See border_color
92
93 =item * color
94
95 This will set the color of the text, depending on color value. Default is black.
96
97 =item * fg_color
98
99 Set to a color value. This color will be used in foreground of some patterns. See color
100 to change the color of text. Also see bg_color and pattern.
101
102 =item * font
103
104 This will sent the font face. Default is Arial.
105
106 =item * font_outline
107
108 This will set font_outline to on or off, depending on the boolean value. (q.v.
109 OUTLINE tag)
110
111 =item * font_shadow
112
113 This will set font_shadow to on or off, depending on the boolean value. (q.v.
114 SHADOW tag). This only applies to Excel for Macintosh.
115
116 =item * font_strikeout
117
118 This will set font_strikeout to on or off, depending on the boolean value. (q.v.
119 STRIKEOUT tag)
120
121 =item * hidden
122
123 This will set whether the cell is hidden to on or off, depending on the boolean
124 value.
125
126 =item * indent
127
128 Set the indentation level for a cell. Positive integers are allowed.
129
130 =item * italic
131
132 This will set italic to on or off, depending on the boolean value. (q.v. ITALIC
133 tag)
134
135 =item * left
136
137 See border.
138
139 =item * left_color
140
141 See border_color.
142
143 =item * num_format
144
145 Set to the index of one of Excel's built-in number formats. See http://search.cpan.org/~jmcnamara/Spreadsheet-WriteExcel-2.11/lib/Spreadsheet/WriteExcel.pm#set_num_format()
146
147 =item * pattern
148
149 Set to an integer, 0 - 18. Sets the background fill pattern of a ell. Default is 1, solid.
150
151 =item * right
152
153 See border.
154
155 =item * right_color
156
157 See border color.
158
159 =item * rotation
160
161 Set the rotation of the text in a cell. The rotation can be any angle in the range -90 to 90 degrees. 
162 The angle 270 is also supported. This indicates text where the letters run from top to bottom.
163
164 =item * shrink
165
166 A boolean value. If true, text will shrink to fit a cell.
167
168 =item * size
169
170 This will set the size of the font. Default is 10. Unless a row height is 
171 specifically set, the row will grow taller as necessary.
172
173 =item * text_justlast
174
175 A boolean value to justify the last line. Only applies to Far Eastern versions of Excel.
176
177 =item * text_wrap
178
179 A boolean value. When set to true, text will wrap in a cell instead of crossing over
180 into empty cells. If the row height is not set, the row will grow taller to accomodate
181 the wrapping text.
182
183 =item * top
184
185 See border.
186
187 =item * top_color
188
189 See border_color
190
191 =item * valign
192
193 Set to top, vcenter, bottom, or vjustify. Default is vcenter. See also align.
194
195 =back
196
197 =head1 CHILDREN
198
199 None
200
201 =head1 EFFECTS
202
203 None
204
205 =head1 DEPENDENCIES
206
207 None
208
209 =head1 USAGE
210
211   <format bold="1">
212     ... Children here
213   </format>
214
215 In the above example, the children will be displayed (if they are displaying
216 elements) in a bold format. All other formatting will remain the same and the
217 "bold"-ness will end at the end tag.
218
219 =head1 AUTHOR
220
221 Rob Kinyon (rob.kinyon@gmail.com)
222
223 =head1 SEE ALSO
224
225 BOLD, HIDDEN, ITALIC, OUTLINE, SHADOW, STRIKEOUT
226
227 =cut